/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    background-color: #f5f5f5;
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* Dashboard Layout */
.dashboard-section {
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    height: 40px;
}

.section-header h2 {
    font-size: 1.5rem;
    color: #1a1a1a;
}

/* Cards */
.card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.overview-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.overview-cards .card {
    position: relative;
}

.overview-cards .card h3 {
    font-size: 1rem;
    color: #666;
    margin-bottom: 0.5rem;
}

.amount {
    font-size: 2rem;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0.5rem 0;
}

.negative {
    color: #e53e3e;
}

.subtitle {
    font-size: 0.875rem;
    color: #666;
}

/* Forms */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    align-items: end;
}

.form-group {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    margin-bottom: 0.6rem;
    color: #666;
    font-size: 0.875rem;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.85rem 0.75rem;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #000;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
}

/* Buttons */
.primary-button {
    background-color: #000;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.primary-button:hover {
    background-color: #333;
}

.secondary-button {
    background-color: transparent;
    color: #666;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

.secondary-button:hover {
    background-color: #f5f5f5;
    border-color: #666;
    color: #333;
}

.danger-button {
    background-color: transparent;
    color: #e53e3e;
    border: 1px solid #e53e3e;
    border-radius: 8px;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

.danger-button:hover {
    background-color: #e53e3e;
    color: white;
}

.button-group {
    display: flex;
    gap: 0.5rem;
}

.icon-button {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 0.25rem;
    position: absolute;
    right: 1rem;
    top: 1rem;
}

.icon-button:hover {
    color: #333;
}

/* Success and error states for buttons */
.success-button {
    background-color: #4caf50 !important;
    color: white !important;
    border-color: #4caf50 !important;
}

.error-button {
    background-color: #f44336 !important;
    color: white !important;
    border-color: #f44336 !important;
}

/* Expense List */
#expense-list {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.expense-item {
    display: flex;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s;
}

.expense-item:last-child {
    border-bottom: none;
}

.expense-item:hover {
    background-color: #f9f9f9;
}

.expense-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
    color: white; /* White icon color for all categories */
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Add category-specific font icons */
.expense-icon::before {
    content: '\f07a'; /* Default icon */
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    font-size: 16px;
}

.expense-icon.groceries::before { content: '\f290'; } /* Shopping cart */
.expense-icon.utilities::before { content: '\f0eb'; } /* Lightbulb */
.expense-icon.rent::before { content: '\f015'; } /* Home */
.expense-icon.transportation::before { content: '\f1b9'; } /* Car */
.expense-icon.entertainment::before { content: '\f008'; } /* Film */
.expense-icon.savings::before { content: '\f19c'; } /* Bank/Institution */
.expense-icon.other::before { content: '\f0c0'; } /* Users */

.expense-details {
    flex: 1;
}

.expense-details h4 {
    margin: 0;
    font-size: 1rem;
}

.expense-details .date {
    margin: 0;
    font-size: 0.875rem;
    color: #666;
}

.expense-amount-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.expense-actions {
    display: flex;
    gap: 0.5rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.expense-item:hover .expense-actions {
    opacity: 1;
}

.expense-actions .icon-button {
    position: static;
    background-color: #f0f0f0;
    color: #666;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.2s ease;
    font-size: 0.8rem;
}

.expense-actions .edit-expense {
    color: #2196F3;
}

.expense-actions .edit-expense:hover {
    background-color: #e3f2fd;
    color: #0d47a1;
}

.expense-actions .delete-expense {
    color: #F44336;
}

.expense-actions .delete-expense:hover {
    background-color: #ffebee;
    color: #b71c1c;
}

/* Budget Rule Cards */
.budget-rule-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.rule-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background-color: #f0f0f0;
    border-radius: 3px;
    margin: 0.5rem 0;
    overflow: hidden;
}

.progress {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

/* Category-specific styles */
.needs-card .progress { background-color: #2196f3; }
.wants-card .progress { background-color: #9c27b0; }
.savings-card .progress { background-color: #4caf50; }
.needs-card .amount { color: #2196f3; }
.wants-card .amount { color: #9c27b0; }
.savings-card .amount { color: #4caf50; }

/* Category Icons - Update colors to match the chart colors */
.expense-icon.groceries { background-color: #4CAF50; }
.expense-icon.utilities { background-color: #2196F3; }
.expense-icon.rent { background-color: #9C27B0; }
.expense-icon.transportation { background-color: #FF9800; }
.expense-icon.entertainment { background-color: #E91E63; }
.expense-icon.savings { background-color: #009688; } /* Teal color for savings */
.expense-icon.other { background-color: #607D8B; }

/* Charts */
.charts-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.chart-card {
    padding: 15px;
}

.chart-card h3 {
    font-size: 1.1rem;
    color: #333;
    margin-bottom: 1.25rem;
    text-align: center;
    font-weight: 600;
}

/* Time control buttons styling - updated to match primary/secondary button style */
.chart-controls {
    display: flex;
    gap: 10px;
}

.time-button {
    background-color: transparent;
    color: #666;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

.time-button:hover {
    background-color: #f5f5f5;
    border-color: #666;
    color: #333;
}

.time-button.active {
    background-color: #000;
    color: white;
    border-color: #000;
}

/* For backwards compatibility, keep tab-button styles but make them match time-button */
.tab-button {
    background-color: transparent;
    color: #666;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-button:hover {
    background-color: #f5f5f5;
    border-color: #666;
    color: #333;
}

.tab-button.active {
    background-color: #000;
    color: white;
    border-color: #000;
}

/* Two-column layout */
.dashboard-flex-section {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1rem;
}

.half-width {
    flex: 1; 
    height: 500px;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* Expense section heights */
#add-expense-section, #expense-history-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 500px;
}

#add-expense-section .card, #expense-history-section .card {
    flex: 1;
    height: calc(100% - 40px);
    margin-bottom: 0;
}

/* Form layouts */
.form-groups {
    display: flex;
    flex-direction: column;
    gap: 1.45rem;
    flex-grow: 1;
    padding-bottom: 1.25rem;
}

.form-submit {
    margin-top: auto;
    padding-top: 1.5rem;
    padding-bottom: 0.5rem;
    display: flex;
    justify-content: flex-end;
    border-top: 1px solid #f0f0f0;
}

#expense-form {
    display: flex;
    flex-direction: column;
    height: 100%;
    justify-content: space-between;
    padding: 1.5rem;
}

.expense-list-card {
    height: 100% !important;
    overflow-y: auto;
    padding: 1.5rem;
}

/* Empty state */
.empty-state {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    flex-grow: 1;
    text-align: center;
    color: #999;
    font-size: 0.95rem;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background-color: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 500px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

/* Tooltip */
.tooltip {
    position: relative;
    display: inline-flex;
    color: #666;
}

.tooltip:hover .tooltip-text {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.tooltip-text {
    position: absolute;
    bottom: 100%;
    right: 0;
    background-color: #333;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-size: 0.75rem;
    width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.2s ease;
    z-index: 1;
}

.tooltip-text::after {
    content: '';
    position: absolute;
    top: 100%;
    right: 5px;
    border-width: 5px;
    border-style: solid;
    border-color: #333 transparent transparent transparent;
}

/* Input with prefix */
.input-with-prefix {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.input-with-prefix .prefix {
    position: absolute;
    left: 0.75rem;
    color: #666;
    font-size: 1rem;
}

.input-with-prefix input {
    padding-left: 1.75rem !important;
    width: 100%;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

header h1 {
    font-size: 1.75rem;
    color: #1a1a1a;
    margin: 0;
}

#logout-btn {
    padding: 0.5rem 1rem;
    background-color: transparent;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.875rem;
    color: #666;
    transition: all 0.2s;
}

#logout-btn:hover {
    background-color: #f5f5f5;
    border-color: #666;
    color: #333;
}

/* Utility Classes */
.hidden {
    display: none;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    .overview-cards,
    .charts-container,
    .budget-rule-cards {
        grid-template-columns: 1fr;
    }

    .dashboard-flex-section {
        flex-direction: column;
    }

    .half-width {
        width: 100%;
        height: auto;
    }

    #add-expense-section, 
    #expense-history-section {
        height: auto;
        min-height: 400px;
    }

    .charts-container {
        grid-template-columns: 1fr;
    }
    
    #spending-insights {
        grid-template-columns: 1fr;
    }
}

/* New analytics container styles */
.analytics-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Insights card styles */
.insights-card {
    padding: 20px;
}

#spending-insights {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-top: 15px;
}

.insight-item {
    text-align: center;
    padding: 10px;
    border-radius: 8px;
    background-color: #f5f5f5;
}

.insight-item h4 {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: #555;
}

.insight-item p {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
} 