/* --- Global Reset & Variables (Figma Inspired Palette) --- */
:root {
    --color-bg: #121217; /* Deep Dark Blue/Black */
    --color-surface: #1E1E24; /* Slightly lighter surface */
    --color-primary: #00C897; /* Vibrant Teal/Mint Green */
    --color-secondary: #FF9800; /* Orange for contrast/income */
    --color-text-light: #E0E0E0;
    --color-text-muted: #A0A0A0;
    --color-expense: #FF5252; /* Red for expenses */
    --color-income: #4CAF50; /* Green for income */
    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --shadow-light: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 6px 18px rgba(0, 199, 151, 0.4);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-main);
    background-color: var(--color-bg);
    color: var(--color-text-light);
    line-height: 1.6;
}

/* --- Typography & Headings --- */
h1, h2, h3 {
    font-weight: 700;
    color: var(--color-text-light);
}

h1 { font-size: 2.5rem; }
h2 { font-size: 1.75rem; margin-bottom: 1rem; }
h3 { font-size: 1.25rem; }

p {
    color: var(--color-text-muted);
}

/* --- Utility Classes & Layout --- */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

header {
    background-color: var(--color-surface);
    box-shadow: var(--shadow-light);
    position: sticky;
    top: 0;
    z-index: 100;
}

nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.logo {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--color-primary);
    letter-spacing: 1px;
}

.nav-links {
    list-style: none;
    display: flex;
    gap: 25px;
}

.nav-links a {
    text-decoration: none;
    color: var(--color-text-muted);
    font-weight: 500;
    padding: 5px 10px;
    transition: color 0.3s, border-bottom 0.3s;
    border-bottom: 2px solid transparent;
}

.nav-links a:hover, .nav-links a.active {
    color: var(--color-primary);
    border-bottom: 2px solid var(--color-primary);
}

main {
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.card {
    background-color: var(--color-surface);
    border-radius: 12px;
    padding: 25px;
    box-shadow: var(--shadow-light);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
}

/* --- Dashboard Specific Styles --- */
.dashboard-container {
    display: grid;
    gap: 20px;
    grid-template-columns: 1fr;
}

.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.summary-cards .card {
    text-align: center;
    border-left: 5px solid;
    padding: 20px;
}

.total-balance { border-left-color: var(--color-primary); }
.total-income { border-left-color: var(--color-income); }
.total-expense { border-left-color: var(--color-expense); }

.summary-cards p {
    font-size: 1.8rem;
    font-weight: 700;
    margin-top: 5px;
    color: var(--color-text-light);
}

.main-content {
    display: grid;
    grid-template-columns: 1fr 2fr; /* Form on left, Chart on right */
    gap: 20px;
}

/* Form Styling */
#expense-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

label {
    margin-bottom: 5px;
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

input[type="text"], input[type="number"], select {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid #333;
    border-radius: 8px;
    background-color: var(--color-bg);
    color: var(--color-text-light);
    font-size: 1rem;
    transition: border-color 0.3s;
}

input:focus, select:focus {
    border-color: var(--color-primary);
    outline: none;
}

.btn-primary {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    background-color: var(--color-primary);
    color: var(--color-bg);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.1s;
}

.btn-primary:hover {
    background-color: #00a07e; /* Darker primary on hover */
    transform: translateY(-1px);
}

/* Chart Styling */
.chart-container {
    grid-column: span 2;
}

.filter-controls {
    margin-bottom: 15px;
    text-align: right;
}

#month-filter, #report-month-filter {
    padding: 8px 12px;
    border-radius: 6px;
    background-color: var(--color-bg);
    color: var(--color-text-light);
    border: 1px solid #333;
}

/* --- History Page Styles --- */
.history-controls {
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
}

.filter-group {
    display: flex;
    flex-direction: column;
    min-width: 150px;
}

.transaction-list {
    padding: 0;
}

#transaction-list-ul {
    list-style: none;
    width: 100%;
}

.list-header, .transaction-item {
    display: grid;
    grid-template-columns: 100px 2fr 1.5fr 1fr 150px 80px;
    padding: 15px 20px;
    border-bottom: 1px solid #2a2a30;
    align-items: center;
    transition: background-color 0.2s;
}

.list-header {
    font-weight: 600;
    color: var(--color-primary);
    border-bottom: 2px solid var(--color-primary);
    padding: 15px 20px;
}

.transaction-item:hover {
    background-color: #25252c;
}

.transaction-item span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.amount {
    font-weight: 600;
    text-align: right;
}

.amount.expense { color: var(--color-expense); }
.amount.income { color: var(--color-income); }

.delete-btn {
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    font-size: 1.1rem;
    transition: color 0.2s;
}

.delete-btn:hover {
    color: var(--color-expense);
}

/* --- Report Page Styles --- */
.report-container {
    display: grid;
    gap: 20px;
    grid-template-columns: 1fr 2fr;
}

.summary-report {
    margin-top: 10px;
    padding: 15px;
    background-color: #25252c;
    border-radius: 8px;
}

.summary-report p {
    margin: 5px 0;
    font-size: 1.1rem;
}

.summary-report span {
    font-weight: 600;
}

.detailed-report {
    grid-column: 1 / -1;
}

#category-totals-list {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
}

.category-total-item {
    background-color: #25252c;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid var(--color-primary);
    transition: background-color 0.2s;
}

.category-total-item h4 {
    margin-bottom: 5px;
    color: var(--color-primary);
}

.category-total-item p {
    font-size: 1.1rem;
    font-weight: 600;
}

/* --- Responsive Design --- */
@media (max-width: 1024px) {
    .main-content, .report-container {
        grid-template-columns: 1fr;
    }
    .chart-container {
        grid-column: 1 / -1;
    }
    .history-controls {
        flex-direction: column;
        align-items: stretch;
    }
    .list-header, .transaction-item {
        grid-template-columns: 80px 1.5fr 1.5fr 1fr 100px;
        gap: 10px;
    }
    .list-header span:nth-child(5) { display: none; } /* Hide amount header on smaller screens */
    .transaction-item .amount-col { display: none; }
    .transaction-item .amount-header {
        display: none; /* Hide header for amount on history page */
    }
    .transaction-item span:nth-child(5) {
        display: none; /* Hide amount column */
    }
    .transaction-item span:nth-child(4) { grid-column: 4 / 5; } /* Shift type */
    .transaction-item span:nth-child(3) { grid-column: 3 / 4; } /* Shift category */
    .transaction-item span:nth-child(2) { grid-column: 1 / 3; } /* Shift description */
    .transaction-item span:nth-child(1) { grid-column: 1 / 2; } /* Shift date */
    .transaction-item .amount-header { display: none; }
    .transaction-item .amount { grid-column: 5 / 6; text-align: right; }
    .transaction-item .delete-col { grid-column: 6 / 7; }

    /* Re-adjusting for clarity on smaller screens */
    .list-header {
        grid-template-columns: 80px 1.5fr 1.5fr 1fr 100px 50px;
        gap: 10px;
    }
    .list-header span:nth-child(4) { grid-column: 4 / 5; }
    .list-header span:nth-child(5) { display: none; }
    .list-header span:last-child { grid-column: 6 / 7; }

    .transaction-item {
        grid-template-columns: 80px 1.5fr 1.5fr 1fr 100px 50px;
    }
    .transaction-item span:nth-child(1) { grid-column: 1 / 2; }
    .transaction-item span:nth-child(2) { grid-column: 2 / 4; }
    .transaction-item span:nth-child(3) { grid-column: 4 / 5; }
    .transaction-item span:nth-child(4) { grid-column: 5 / 6; }
    .transaction-item span:last-child { grid-column: 6 / 7; }
}

@media (max-width: 768px) {
    nav {
        flex-direction: column;
        gap: 10px;
        padding: 1rem 1rem;
    }
    .nav-links {
        justify-content: center;
        width: 100%;
    }
    main {
        padding: 1rem;
    }
    .summary-cards .card p {
        font-size: 1.5rem;
    }
    .list-header, .transaction-item {
        grid-template-columns: 1fr 1fr 1fr 50px; /* Date, Desc, Amount, Action */
        padding: 10px 10px;
    }
    .list-header span:nth-child(1) { grid-column: 1 / 2; } /* Date */
    .list-header span:nth-child(2) { grid-column: 2 / 3; } /* Desc */
    .list-header span:nth-child(3) { display: none; } /* Hide Category */
    .list-header span:nth-child(4) { display: none; } /* Hide Type */
    .list-header span:nth-child(5) { display: none; } /* Hide Amount */
    .list-header span:last-child { grid-column: 4 / 5; } /* Action */

    .transaction-item span:nth-child(1) { grid-column: 1 / 2; }
    .transaction-item span:nth-child(2) { grid-column: 2 / 3; }
    .transaction-item span:nth-child(3) { display: none; }
    .transaction-item span:nth-child(4) { display: none; }
    .transaction-item span:nth-child(5) { display: none; }
    .transaction-item span:last-child { grid-column: 4 / 5; }

    .report-container {
        grid-template-columns: 1fr;
    }
    .report-charts {
        order: 2;
    }
    .detailed-report {
        order: 3;
    }
    .report-controls {
        order: 1;
    }
}

/* Animation for fade in on load */
[data-animate] {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}
[data-animate].visible {
    opacity: 1;
    transform: translateY(0);
}
