/* Material Design 3 CSS Variables */
:root {
    /* Primary Colors */
    --md-sys-color-primary: #6750A4;
    --md-sys-color-on-primary: #FFFFFF;
    --md-sys-color-primary-container: #EADDFF;
    --md-sys-color-on-primary-container: #21005D;

    /* Secondary Colors */
    --md-sys-color-secondary: #625B71;
    --md-sys-color-on-secondary: #FFFFFF;
    --md-sys-color-secondary-container: #E8DEF8;
    --md-sys-color-on-secondary-container: #1D192B;

    /* Tertiary Colors */
    --md-sys-color-tertiary: #7D5260;
    --md-sys-color-on-tertiary: #FFFFFF;
    --md-sys-color-tertiary-container: #FFD8E4;
    --md-sys-color-on-tertiary-container: #31111D;

    /* Error Colors */
    --md-sys-color-error: #BA1A1A;
    --md-sys-color-on-error: #FFFFFF;
    --md-sys-color-error-container: #FFDAD6;
    --md-sys-color-on-error-container: #410002;

    /* Surface Colors */
    --md-sys-color-surface: #FEF7FF;
    --md-sys-color-on-surface: #1C1B1F;
    --md-sys-color-surface-variant: #E7E0EC;
    --md-sys-color-on-surface-variant: #49454F;
    --md-sys-color-surface-container-lowest: #FFFFFF;
    --md-sys-color-surface-container-low: #F7F2FA;
    --md-sys-color-surface-container: #F3EDF7;
    --md-sys-color-surface-container-high: #ECE6F0;
    --md-sys-color-surface-container-highest: #E6E0E9;

    /* Outline Colors */
    --md-sys-color-outline: #79747E;
    --md-sys-color-outline-variant: #CAC4D0;

    /* Typography */
    --md-sys-typescale-display-large-font-family: 'Roboto Flex', system-ui, sans-serif;
    --md-sys-typescale-display-large-font-size: 57px;
    --md-sys-typescale-display-large-line-height: 64px;
    --md-sys-typescale-display-large-font-weight: 400;

    --md-sys-typescale-headline-large-font-family: 'Roboto Flex', system-ui, sans-serif;
    --md-sys-typescale-headline-large-font-size: 32px;
    --md-sys-typescale-headline-large-line-height: 40px;
    --md-sys-typescale-headline-large-font-weight: 400;

    --md-sys-typescale-title-large-font-family: 'Roboto Flex', system-ui, sans-serif;
    --md-sys-typescale-title-large-font-size: 22px;
    --md-sys-typescale-title-large-line-height: 28px;
    --md-sys-typescale-title-large-font-weight: 400;

    --md-sys-typescale-body-large-font-family: 'Roboto Flex', system-ui, sans-serif;
    --md-sys-typescale-body-large-font-size: 16px;
    --md-sys-typescale-body-large-line-height: 24px;
    --md-sys-typescale-body-large-font-weight: 400;

    --md-sys-typescale-label-large-font-family: 'Roboto Flex', system-ui, sans-serif;
    --md-sys-typescale-label-large-font-size: 14px;
    --md-sys-typescale-label-large-line-height: 20px;
    --md-sys-typescale-label-large-font-weight: 500;

    /* Elevation */
    --md-sys-elevation-level0: 0px 0px 0px 0px rgba(0, 0, 0, 0.00), 0px 0px 0px 0px rgba(0, 0, 0, 0.00);
    --md-sys-elevation-level1: 0px 1px 2px 0px rgba(0, 0, 0, 0.30), 0px 1px 3px 1px rgba(0, 0, 0, 0.15);
    --md-sys-elevation-level2: 0px 1px 2px 0px rgba(0, 0, 0, 0.30), 0px 2px 6px 2px rgba(0, 0, 0, 0.15);
    --md-sys-elevation-level3: 0px 1px 3px 0px rgba(0, 0, 0, 0.30), 0px 4px 8px 3px rgba(0, 0, 0, 0.15);
    --md-sys-elevation-level4: 0px 2px 3px 0px rgba(0, 0, 0, 0.30), 0px 6px 10px 4px rgba(0, 0, 0, 0.15);
    --md-sys-elevation-level5: 0px 4px 4px 0px rgba(0, 0, 0, 0.30), 0px 8px 12px 6px rgba(0, 0, 0, 0.15);

    /* Shape */
    --md-sys-shape-corner-extra-small: 4px;
    --md-sys-shape-corner-small: 8px;
    --md-sys-shape-corner-medium: 12px;
    --md-sys-shape-corner-large: 16px;
    --md-sys-shape-corner-extra-large: 28px;
}

/* Dark Theme Variables */
[data-theme="dark"] {
    /* Primary Colors */
    --md-sys-color-primary: #D0BCFF;
    --md-sys-color-on-primary: #381E72;
    --md-sys-color-primary-container: #4F378B;
    --md-sys-color-on-primary-container: #EADDFF;

    /* Secondary Colors */
    --md-sys-color-secondary: #CCC2DC;
    --md-sys-color-on-secondary: #332D41;
    --md-sys-color-secondary-container: #4A4458;
    --md-sys-color-on-secondary-container: #E8DEF8;

    /* Tertiary Colors */
    --md-sys-color-tertiary: #EFB8C8;
    --md-sys-color-on-tertiary: #492532;
    --md-sys-color-tertiary-container: #633B48;
    --md-sys-color-on-tertiary-container: #FFD8E4;

    /* Error Colors */
    --md-sys-color-error: #FFB4AB;
    --md-sys-color-on-error: #690005;
    --md-sys-color-error-container: #93000A;
    --md-sys-color-on-error-container: #FFDAD6;

    /* Surface Colors */
    --md-sys-color-surface: #10081C;
    --md-sys-color-on-surface: #E6E0E9;
    --md-sys-color-surface-variant: #49454F;
    --md-sys-color-on-surface-variant: #CAC4D0;
    --md-sys-color-surface-container-lowest: #0B0017;
    --md-sys-color-surface-container-low: #1D1B20;
    --md-sys-color-surface-container: #211F26;
    --md-sys-color-surface-container-high: #2B2930;
    --md-sys-color-surface-container-highest: #36343B;

    /* Outline Colors */
    --md-sys-color-outline: #938F99;
    --md-sys-color-outline-variant: #49454F;
}

/* Theme Toggle Switch */
.theme-toggle {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 1000;
    background: none;
    border: none;
    cursor: pointer;
    padding: 12px;
    border-radius: var(--md-sys-shape-corner-extra-large);
    background-color: var(--md-sys-color-surface-container-high);
    color: var(--md-sys-color-on-surface);
    box-shadow: var(--md-sys-elevation-level2);
    transition: all 0.3s cubic-bezier(0.2, 0.0, 0.0, 1.0);
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    box-shadow: var(--md-sys-elevation-level3);
    transform: scale(1.05);
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
}

.theme-toggle:focus-visible {
    outline: 2px solid var(--md-sys-color-primary);
    outline-offset: 2px;
}

.theme-icon {
    font-size: 24px;
    transition: transform 0.5s cubic-bezier(0.4, 0.0, 0.2, 1);
    display: block;
}

.theme-toggle:active .theme-icon {
    transform: rotate(360deg) scale(0.9);
}

/* Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

@import url('https://fonts.googleapis.com/css2?family=Roboto+Flex:opsz,wght@8..144,100..1000&display=swap');

body {
    font-family: var(--md-sys-typescale-body-large-font-family);
    font-size: var(--md-sys-typescale-body-large-font-size);
    line-height: var(--md-sys-typescale-body-large-line-height);
    font-weight: var(--md-sys-typescale-body-large-font-weight);
    background-color: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
    min-height: 100vh;
    padding: 8px;
    margin: 0;
}

/* Layout Components */
.container {
    max-width: 1200px;
    margin: 0 auto;
    background-color: var(--md-sys-color-surface-container-lowest);
    border-radius: var(--md-sys-shape-corner-extra-large);
    box-shadow: var(--md-sys-elevation-level2);
    overflow: hidden;
}

.header {
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    padding: 24px;
    text-align: center;
}

.header h1 {
    margin: 0;
    font-family: var(--md-sys-typescale-headline-large-font-family);
    font-size: var(--md-sys-typescale-headline-large-font-size);
    line-height: var(--md-sys-typescale-headline-large-line-height);
    font-weight: var(--md-sys-typescale-headline-large-font-weight);
}

.header p {
    margin-top: 8px;
    font-family: var(--md-sys-typescale-body-large-font-family);
    font-size: var(--md-sys-typescale-body-large-font-size);
    opacity: 0.8;
}

.install-banner {
    background-color: var(--md-sys-color-tertiary-container);
    color: var(--md-sys-color-on-tertiary-container);
    padding: 16px;
    text-align: center;
    cursor: pointer;
    display: none;
    font-weight: var(--md-sys-typescale-label-large-font-weight);
}

.install-banner:hover {
    background-color: var(--md-sys-color-tertiary);
    color: var(--md-sys-color-on-tertiary);
}

.content {
    padding: 24px;
}

/* Form Styles */
.form-section {
    background-color: var(--md-sys-color-surface-container);
    padding: 24px;
    border-radius: var(--md-sys-shape-corner-large);
    margin-bottom: 24px;
    box-shadow: var(--md-sys-elevation-level1);
}

.form-section h2 {
    font-family: var(--md-sys-typescale-title-large-font-family);
    font-size: var(--md-sys-typescale-title-large-font-size);
    line-height: var(--md-sys-typescale-title-large-line-height);
    font-weight: var(--md-sys-typescale-title-large-font-weight);
    color: var(--md-sys-color-on-surface);
    margin-bottom: 16px;
}

.form-row {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.form-group {
    flex: 1;
    min-width: 240px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-family: var(--md-sys-typescale-label-large-font-family);
    font-size: var(--md-sys-typescale-label-large-font-size);
    line-height: var(--md-sys-typescale-label-large-line-height);
    font-weight: var(--md-sys-typescale-label-large-font-weight);
    color: var(--md-sys-color-on-surface);
}

input,
select,
textarea {
    width: 100%;
    padding: 16px;
    border: 1px solid var(--md-sys-color-outline);
    border-radius: var(--md-sys-shape-corner-extra-small);
    font-family: var(--md-sys-typescale-body-large-font-family);
    font-size: var(--md-sys-typescale-body-large-font-size);
    background-color: var(--md-sys-color-surface-container-highest);
    color: var(--md-sys-color-on-surface);
    transition: all 0.2s cubic-bezier(0.2, 0.0, 0.0, 1.0);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--md-sys-color-primary);
    border-width: 2px;
    box-shadow: 0 0 0 1px var(--md-sys-color-primary);
}

input:hover,
select:hover,
textarea:hover {
    border-color: var(--md-sys-color-on-surface);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

/* Material Design 3 Buttons */
.btn {
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    border: none;
    padding: 10px 24px;
    border-radius: var(--md-sys-shape-corner-extra-large);
    cursor: pointer;
    font-family: var(--md-sys-typescale-label-large-font-family);
    font-size: var(--md-sys-typescale-label-large-font-size);
    line-height: var(--md-sys-typescale-label-large-line-height);
    font-weight: var(--md-sys-typescale-label-large-font-weight);
    transition: all 0.2s cubic-bezier(0.2, 0.0, 0.0, 1.0);
    margin: 8px;
    min-height: 40px;
    box-shadow: var(--md-sys-elevation-level1);
    position: relative;
    overflow: hidden;
}

.btn:hover {
    background-color: var(--md-sys-color-primary);
    box-shadow: var(--md-sys-elevation-level2);
}

.btn:active {
    box-shadow: var(--md-sys-elevation-level1);
}

.btn-success {
    background-color: var(--md-sys-color-secondary);
    color: var(--md-sys-color-on-secondary);
}

.btn-success:hover {
    background-color: var(--md-sys-color-secondary);
    box-shadow: var(--md-sys-elevation-level2);
}

.btn-warning {
    background-color: var(--md-sys-color-tertiary);
    color: var(--md-sys-color-on-tertiary);
}

.btn-warning:hover {
    background-color: var(--md-sys-color-tertiary);
    box-shadow: var(--md-sys-elevation-level2);
}

.btn-danger {
    background-color: var(--md-sys-color-error);
    color: var(--md-sys-color-on-error);
}

.btn-danger:hover {
    background-color: var(--md-sys-color-error);
    box-shadow: var(--md-sys-elevation-level2);
}

/* Actions Section */
.actions {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

/* Expense List Styles */
.expense-list {
    background-color: var(--md-sys-color-surface-container);
    border-radius: var(--md-sys-shape-corner-large);
    overflow: hidden;
    box-shadow: var(--md-sys-elevation-level1);
}

.expense-list h2 {
    font-family: var(--md-sys-typescale-title-large-font-family);
    font-size: var(--md-sys-typescale-title-large-font-size);
    line-height: var(--md-sys-typescale-title-large-line-height);
    font-weight: var(--md-sys-typescale-title-large-font-weight);
    color: var(--md-sys-color-on-surface);
}

.expense-item {
    background-color: var(--md-sys-color-surface-container-highest);
    margin: 12px;
    padding: 16px;
    border-radius: var(--md-sys-shape-corner-medium);
    border-left: 4px solid var(--md-sys-color-primary);
    box-shadow: var(--md-sys-elevation-level1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    transition: all 0.2s cubic-bezier(0.2, 0.0, 0.0, 1.0);
}

.expense-item:hover {
    box-shadow: var(--md-sys-elevation-level2);
}

.expense-info {
    flex: 1;
}

.expense-amount {
    font-family: var(--md-sys-typescale-title-large-font-family);
    font-size: var(--md-sys-typescale-title-large-font-size);
    font-weight: var(--md-sys-typescale-title-large-font-weight);
    color: var(--md-sys-color-error);
}

.expense-category {
    background-color: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
    padding: 4px 12px;
    border-radius: var(--md-sys-shape-corner-extra-large);
    font-family: var(--md-sys-typescale-label-large-font-family);
    font-size: var(--md-sys-typescale-label-large-font-size);
    font-weight: var(--md-sys-typescale-label-large-font-weight);
    display: inline-block;
    margin: 8px 0;
}

.expense-date {
    color: var(--md-sys-color-on-surface-variant);
    font-family: var(--md-sys-typescale-body-large-font-family);
    font-size: 14px;
}

.expense-note {
    color: var(--md-sys-color-on-surface-variant);
    font-style: italic;
    margin-top: 8px;
    font-family: var(--md-sys-typescale-body-large-font-family);
    font-size: 14px;
}

.delete-btn {
    background-color: var(--md-sys-color-error-container);
    color: var(--md-sys-color-on-error-container);
    border: none;
    padding: 8px 16px;
    border-radius: var(--md-sys-shape-corner-large);
    cursor: pointer;
    font-family: var(--md-sys-typescale-label-large-font-family);
    font-size: var(--md-sys-typescale-label-large-font-size);
    font-weight: var(--md-sys-typescale-label-large-font-weight);
    transition: all 0.2s cubic-bezier(0.2, 0.0, 0.0, 1.0);
    min-height: 44px;
    min-width: 44px;
}

.delete-btn:hover {
    background-color: var(--md-sys-color-error);
    color: var(--md-sys-color-on-error);
}

/* Total Section */
.total-section {
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    padding: 24px;
    margin: 24px 0;
    border-radius: var(--md-sys-shape-corner-large);
    text-align: center;
    box-shadow: var(--md-sys-elevation-level2);
}

.total-section h3 {
    font-family: var(--md-sys-typescale-title-large-font-family);
    font-size: var(--md-sys-typescale-title-large-font-size);
    line-height: var(--md-sys-typescale-title-large-line-height);
    font-weight: var(--md-sys-typescale-title-large-font-weight);
    margin-bottom: 8px;
}

.total-amount {
    font-family: var(--md-sys-typescale-display-large-font-family);
    font-size: 48px;
    line-height: 56px;
    font-weight: 400;
    margin: 8px 0;
}

/* Status Messages */
.status {
    padding: 16px;
    margin: 16px 0;
    border-radius: var(--md-sys-shape-corner-medium);
    text-align: center;
    font-family: var(--md-sys-typescale-body-large-font-family);
    font-size: var(--md-sys-typescale-body-large-font-size);
    font-weight: var(--md-sys-typescale-body-large-font-weight);
}

.status.success {
    background-color: var(--md-sys-color-tertiary-container);
    color: var(--md-sys-color-on-tertiary-container);
}

.status.error {
    background-color: var(--md-sys-color-error-container);
    color: var(--md-sys-color-on-error-container);
}

/* Utility Classes */
.hidden {
    display: none;
}

#fileInput {
    display: none;
}

/* Charts Section */
.charts-section {
    background-color: var(--md-sys-color-surface-container-lowest);
    border-radius: var(--md-sys-shape-corner-large);
    padding: 24px;
    margin: 24px 0;
    box-shadow: var(--md-sys-elevation-level1);
}

.charts-section h2 {
    color: var(--md-sys-color-on-surface);
    font-family: var(--md-sys-typescale-headline-small-font-family);
    font-size: var(--md-sys-typescale-headline-small-font-size);
    font-weight: var(--md-sys-typescale-headline-small-font-weight);
    margin: 0 0 24px 0;
}

.chart-filters {
    background-color: var(--md-sys-color-surface-container);
    border-radius: var(--md-sys-shape-corner-medium);
    padding: 16px;
    margin-bottom: 24px;
}

.chart-filters .form-row {
    align-items: end;
    gap: 16px;
}

.chart-filters .form-group {
    flex: 1;
}

.chart-filters .form-group:last-child {
    flex: none;
    display: flex;
    gap: 8px;
}

.btn-secondary {
    background-color: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
}

.btn-secondary:hover {
    background-color: var(--md-sys-color-secondary);
    color: var(--md-sys-color-on-secondary);
}

.charts-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 24px;
}

.chart-card {
    background-color: var(--md-sys-color-surface-container);
    border-radius: var(--md-sys-shape-corner-large);
    padding: 20px;
    box-shadow: var(--md-sys-elevation-level1);
    border: 1px solid var(--md-sys-color-outline-variant);
}

.chart-card h3 {
    color: var(--md-sys-color-on-surface);
    font-family: var(--md-sys-typescale-title-medium-font-family);
    font-size: var(--md-sys-typescale-title-medium-font-size);
    font-weight: var(--md-sys-typescale-title-medium-font-weight);
    margin: 0 0 16px 0;
    text-align: center;
}

.chart-card canvas {
    max-height: 300px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .charts-container {
        grid-template-columns: 1fr;
    }

    .chart-filters .form-row {
        flex-direction: column;
        align-items: stretch;
    }

    .chart-filters .form-group:last-child {
        flex-direction: column;
    }

    .chart-card canvas {
        max-height: 250px;
    }

    /* Ajustes específicos para las transformaciones en móviles */
    .menu-toggle.active .hamburger:nth-child(1),
    #menuToggle.active .hamburger:nth-child(1) {
        transform: rotate(45deg) translate(0, 5px);
    }

    .menu-toggle.active .hamburger:nth-child(3),
    #menuToggle.active .hamburger:nth-child(3) {
        transform: rotate(-45deg) translate(0, -5px);
    }
}

/* Mobile Landscape */
@media (max-width: 768px) {
    body {
        padding: 4px;
    }

    .container {
        margin: 4px;
        border-radius: var(--md-sys-shape-corner-medium);
    }

    .content {
        padding: 12px;
    }

    .header {
        padding: 16px 12px;
    }

    .header h1 {
        font-size: 24px;
        line-height: 32px;
    }

    .form-row {
        flex-direction: column;
        gap: 12px;
    }

    .form-group {
        min-width: auto;
    }

    .actions {
        flex-direction: column;
        gap: 8px;
    }

    .actions .btn {
        width: 100%;
        padding: 12px 16px;
    }

    .expense-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        padding: 12px;
    }

    .expense-info {
        width: 100%;
    }

    .delete-btn {
        align-self: flex-end;
        margin-top: 8px;
    }

    .total-amount {
        font-size: 32px;
        line-height: 40px;
    }

    .total-section {
        padding: 16px 12px;
        text-align: center;
    }

    .charts-section {
        padding: 16px 12px;
        margin: 16px 0;
    }

    .charts-container {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .chart-card {
        padding: 16px 12px;
    }

    .chart-card canvas {
        max-height: 220px;
    }

    .chart-filters {
        padding: 12px;
    }

    .chart-filters .form-group:last-child {
        margin-top: 12px;
    }

    .chart-filters .form-group:last-child .btn {
        width: 100%;
        margin-bottom: 8px;
    }

    /* Theme toggle adjustments */
    .theme-toggle {
        top: 12px;
        right: 12px;
        width: 44px;
        height: 44px;
        padding: 8px;
    }

    .theme-icon {
        font-size: 18px;
    }
}

/* Mobile Portrait */
@media (max-width: 480px) {
    body {
        padding: 2px;
    }

    .container {
        margin: 2px;
        border-radius: var(--md-sys-shape-corner-small);
    }

    .content {
        padding: 8px;
    }

    .header {
        padding: 12px 8px;
    }

    .header h1 {
        font-size: 20px;
        line-height: 28px;
    }

    .header p {
        font-size: 14px;
    }

    .form-section h2,
    .charts-section h2 {
        font-size: 18px;
        line-height: 24px;
        margin-bottom: 12px;
    }

    .form-section {
        padding: 12px 8px;
    }

    .btn {
        padding: 10px 12px;
        font-size: 14px;
    }

    .actions {
        padding: 12px 8px;
        gap: 6px;
    }

    .expense-item {
        padding: 10px 8px;
        gap: 6px;
    }

    .expense-amount {
        font-size: 18px;
        line-height: 24px;
    }

    .expense-category,
    .expense-date {
        font-size: 12px;
    }

    .expense-note {
        font-size: 12px;
    }

    .total-amount {
        font-size: 28px;
        line-height: 36px;
    }

    .total-section {
        padding: 12px 8px;
    }

    .charts-section {
        padding: 12px 8px;
        margin: 12px 0;
    }

    .chart-card {
        padding: 12px 8px;
    }

    .chart-card h3 {
        font-size: 16px;
        line-height: 20px;
        margin-bottom: 12px;
    }

    .chart-card canvas {
        max-height: 200px;
    }

    .chart-filters {
        padding: 8px;
    }

    .chart-filters .form-group:last-child .btn {
        padding: 8px 12px;
        font-size: 12px;
    }

    /* Theme toggle for small screens */
    .theme-toggle {
        top: 8px;
        right: 8px;
        width: 40px;
        height: 40px;
        padding: 6px;
    }

    .theme-icon {
        font-size: 16px;
    }

    /* Install banner adjustments */
    .install-banner {
        padding: 8px;
        font-size: 12px;
        margin: 4px;
        border-radius: var(--md-sys-shape-corner-small);
    }

    /* Status messages */
    .status {
        padding: 8px 12px;
        font-size: 14px;
        margin: 8px;
        border-radius: var(--md-sys-shape-corner-small);
    }

    /* Form inputs */
    input,
    select,
    textarea {
        padding: 8px 12px;
        font-size: 14px;
    }

    label {
        font-size: 12px;
        margin-bottom: 4px;
    }
}

/* === TOUCH & MOBILE IMPROVEMENTS === */

/* Aumentar área táctil para botones pequeños */
.delete-btn {
    min-height: 44px;
    min-width: 44px;
}

.theme-toggle {
    min-height: 44px;
    min-width: 44px;
}

/* Mejorar la experiencia táctil */
@media (hover: none) and (pointer: coarse) {
    .btn:hover {
        background-color: var(--md-sys-color-primary);
        transform: none;
    }

    .theme-toggle:hover {
        background-color: var(--md-sys-color-secondary-container);
        transform: none;
    }

    .delete-btn:hover {
        background-color: var(--md-sys-color-error);
        transform: none;
    }
}

/* Prevenir zoom en inputs en Safari iOS */
@media screen and (-webkit-min-device-pixel-ratio: 2) {

    input[type="date"],
    input[type="number"],
    input[type="text"],
    select,
    textarea {
        font-size: 16px !important;
    }
}

/* Mejorar scrolling en dispositivos táctiles */
.expense-list,
.charts-container {
    -webkit-overflow-scrolling: touch;
}

/* Ocultar scrollbars en dispositivos móviles */
.expense-list::-webkit-scrollbar,
.charts-container::-webkit-scrollbar {
    display: none;
}

/* === FIN TOUCH & MOBILE IMPROVEMENTS === */

/* Material Design 3 Focus Rings */
.btn:focus-visible {
    outline: 2px solid var(--md-sys-color-primary);
    outline-offset: 2px;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--md-sys-color-primary);
    outline-offset: 2px;
}

/* === iOS SAFARI SPECIFIC FIXES === */

/* Fix para inputs de fecha en iOS Safari */
@supports (-webkit-touch-callout: none) {
    input[type="date"] {
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
        background-color: var(--md-sys-color-surface-container);
        border: 1px solid var(--md-sys-color-outline);
        border-radius: var(--md-sys-shape-corner-small);
        padding: 12px 16px;
        font-size: 16px !important;
        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
        color: var(--md-sys-color-on-surface);
        min-height: 44px;
        box-sizing: border-box;
        width: 100%;

        /* Añadir icono de calendario */
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='%23666'%3E%3Cpath d='M19 3h-1V1h-2v2H8V1H6v2H5c-1.11 0-1.99.9-1.99 2L3 19c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V8h14v11zM7 10h5v5H7z'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 12px center;
        background-size: 20px;
        padding-right: 44px;
    }

    input[type="date"]:focus {
        outline: 2px solid var(--md-sys-color-primary);
        outline-offset: 2px;
        border-color: var(--md-sys-color-primary);
    }

    /* Estilo para el valor del input de fecha */
    input[type="date"]::-webkit-datetime-edit {
        color: var(--md-sys-color-on-surface);
        padding: 0;
    }

    input[type="date"]::-webkit-datetime-edit-fields-wrapper {
        padding: 0;
    }

    input[type="date"]::-webkit-datetime-edit-text {
        color: var(--md-sys-color-on-surface-variant);
        padding: 0 2px;
    }

    input[type="date"]::-webkit-datetime-edit-month-field,
    input[type="date"]::-webkit-datetime-edit-day-field,
    input[type="date"]::-webkit-datetime-edit-year-field {
        color: var(--md-sys-color-on-surface);
        padding: 0 2px;
    }

    input[type="date"]::-webkit-calendar-picker-indicator {
        opacity: 0;
        width: 20px;
        height: 20px;
        cursor: pointer;
    }
}

/* Fix específico para iPhone/iPad */
@media screen and (-webkit-min-device-pixel-ratio: 2) and (max-width: 768px) {
    input[type="date"] {
        font-size: 16px !important;
        min-height: 48px;
        line-height: 1.5;
        transform: translateZ(0);
        -webkit-transform: translateZ(0);
    }

    /* Mejorar el contrast en modo oscuro para iOS */
    [data-theme="dark"] input[type="date"] {
        background-color: var(--md-sys-color-surface-container-high);
        border-color: var(--md-sys-color-outline-variant);
        color: var(--md-sys-color-on-surface);
    }
}

/* === FIN iOS SAFARI FIXES === */

/* === MEJORAS ADICIONALES PARA iOS === */

/* Prevenir zoom automático en todos los inputs de iOS */
@media screen and (max-device-width: 768px) {

    input,
    select,
    textarea {
        font-size: 16px !important;
        -webkit-text-size-adjust: 100%;
        -webkit-appearance: none;
        appearance: none;
        border-radius: 8px;
    }

    /* Mejorar el renderizado en Retina displays */
    input[type="date"],
    input[type="number"],
    select {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* Estilos específicos para iPhone en orientación portrait */
@media screen and (max-width: 428px) and (orientation: portrait) {
    .chart-filters .form-row {
        flex-direction: column;
        gap: 12px;
    }

    .chart-filters .form-group {
        width: 100%;
    }

    .chart-filters label {
        font-size: 14px;
        font-weight: 500;
        margin-bottom: 6px;
        display: block;
    }

    input[type="date"] {
        width: 100%;
        min-height: 48px;
        padding: 12px 44px 12px 16px;
        font-size: 16px !important;
        line-height: 1.4;
    }
}

/* Mejoras para el tema oscuro en iOS */
@media screen and (-webkit-min-device-pixel-ratio: 2) {
    [data-theme="dark"] input[type="date"] {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='%23D0BCFF'%3E%3Cpath d='M19 3h-1V1h-2v2H8V1H6v2H5c-1.11 0-1.99.9-1.99 2L3 19c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V8h14v11zM7 10h5v5H7z'/%3E%3C/svg%3E");
    }
}

/* === FIN MEJORAS iOS === */

/* === ESTILOS ESPECÍFICOS CUANDO SE DETECTA iOS === */

.ios-device input[type="date"] {
    /* Estilos más agresivos para iOS */
    -webkit-appearance: none !important;
    appearance: none !important;
    background-color: var(--md-sys-color-surface-container) !important;
    border: 2px solid var(--md-sys-color-outline) !important;
    border-radius: 12px !important;
    padding: 14px 48px 14px 16px !important;
    font-size: 16px !important;
    min-height: 48px !important;
    line-height: 1.4 !important;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Helvetica Neue', sans-serif !important;

    /* Forzar el icono de calendario */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='%236750A4'%3E%3Cpath d='M19 3h-1V1h-2v2H8V1H6v2H5c-1.11 0-1.99.9-1.99 2L3 19c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V8h14v11zM7 10h5v5H7z'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 12px center !important;
    background-size: 24px !important;
}

.ios-device input[type="date"]:focus {
    border-color: var(--md-sys-color-primary) !important;
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(103, 80, 164, 0.2) !important;
}

.ios-device input[type="date"]::-webkit-date-and-time-value {
    text-align: left;
    font-size: 16px !important;
}

/* Para tema oscuro en iOS */
.ios-device[data-theme="dark"] input[type="date"],
[data-theme="dark"] .ios-device input[type="date"] {
    background-color: var(--md-sys-color-surface-container-high) !important;
    border-color: var(--md-sys-color-outline-variant) !important;
    color: var(--md-sys-color-on-surface) !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='%23D0BCFF'%3E%3Cpath d='M19 3h-1V1h-2v2H8V1H6v2H5c-1.11 0-1.99.9-1.99 2L3 19c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V8h14v11zM7 10h5v5H7z'/%3E%3C/svg%3E") !important;
}

/* Mejorar la sección de filtros en iOS */
.ios-device .chart-filters {
    padding: 16px !important;
    background-color: var(--md-sys-color-surface-container-low) !important;
    border-radius: 16px !important;
}

.ios-device .chart-filters .form-group {
    margin-bottom: 16px !important;
}

.ios-device .chart-filters label {
    font-size: 14px !important;
    font-weight: 600 !important;
    color: var(--md-sys-color-on-surface) !important;
    margin-bottom: 8px !important;
}

/* === FIN ESTILOS iOS ESPECÍFICOS === */

/* === MEJORAS DE CONTRASTE PARA GRÁFICAS === */

/* Asegurar contraste en tooltips de Chart.js */
.chartjs-tooltip {
    background-color: var(--md-sys-color-inverse-surface) !important;
    color: var(--md-sys-color-inverse-on-surface) !important;
    border: 1px solid var(--md-sys-color-outline) !important;
    border-radius: var(--md-sys-shape-corner-small) !important;
    box-shadow: var(--md-sys-elevation-level2) !important;
}

.chartjs-tooltip-key {
    background-color: var(--md-sys-color-primary) !important;
}

/* Mejorar contraste en leyendas */
.chartjs-legend {
    color: var(--md-sys-color-on-surface) !important;
}

.chartjs-legend-item {
    color: var(--md-sys-color-on-surface) !important;
}

/* Asegurar que todos los textos de las gráficas tengan buen contraste */
canvas {
    background-color: var(--md-sys-color-surface) !important;
}

/* Forzar colores de texto en modo oscuro */
[data-theme="dark"] .chart-card {
    color: var(--md-sys-color-on-surface) !important;
}

[data-theme="dark"] .chart-card h3 {
    color: var(--md-sys-color-on-surface) !important;
}

/* Asegurar contraste en elementos de Chart.js */
[data-theme="dark"] .chartjs-render-monitor {
    filter: brightness(1.1) contrast(1.1);
}

/* Mejorar visibilidad de textos pequeños */
.chart-card canvas+div {
    color: var(--md-sys-color-on-surface) !important;
}

/* === FIN MEJORAS DE CONTRASTE === */

/* === CONFIGURACIÓN ESPECÍFICA PARA CHART.JS === */

/* Personalizar tooltips de Chart.js */
.chartjs-tooltip {
    opacity: 1 !important;
    background: var(--md-sys-color-inverse-surface) !important;
    color: var(--md-sys-color-inverse-on-surface) !important;
    border: none !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2) !important;
    padding: 12px !important;
    font-size: 14px !important;
    font-family: var(--md-sys-typescale-body-medium-font-family) !important;
}

/* Personalizar el fondo del canvas para mejor contraste */
.chart-card canvas {
    background-color: var(--md-sys-color-surface) !important;
    border-radius: var(--md-sys-shape-corner-medium);
}

[data-theme="dark"] .chart-card canvas {
    background-color: var(--md-sys-color-surface-container-low) !important;
}

/* Mejorar la visibilidad de las leyendas */
.chart-card .chartjs-legend-item {
    margin: 4px 8px !important;
}

.chart-card .chartjs-legend-item span {
    border-radius: 3px !important;
}

/* === FIN CONFIGURACIÓN CHART.JS === */

/* === NAVBAR Y MENÚ HAMBURGUESA === */

.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background-color: var(--md-sys-color-surface-container);
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    box-shadow: var(--md-sys-elevation-level2);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.navbar-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.navbar-brand h1 {
    font-family: var(--md-sys-typescale-title-large-font-family);
    font-size: var(--md-sys-typescale-title-large-font-size);
    font-weight: var(--md-sys-typescale-title-large-font-weight);
    color: var(--md-sys-color-on-surface);
    margin: 0;
}

.navbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Theme toggle en navbar */
.navbar .theme-toggle {
    position: relative;
    top: auto;
    right: auto;
    width: 44px;
    height: 44px;
    padding: 8px;
    background-color: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--md-sys-elevation-level1);
    transition: all 0.3s ease;
}

.navbar .theme-toggle:hover {
    background-color: var(--md-sys-color-secondary);
    color: var(--md-sys-color-on-secondary);
    transform: scale(1.05);
}

.navbar .theme-icon {
    font-size: 20px;
    line-height: 1;
    transition: all 0.3s ease;
}

/* Menú hamburguesa */
.menu-toggle,
#menuToggle {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    border-radius: var(--md-sys-shape-corner-small);
    transition: background-color 0.3s ease;
    display: flex;
    flex-direction: column;
    width: 44px;
    height: 44px;
    justify-content: center;
    align-items: center;
    gap: 0;
    position: relative;
}

.menu-toggle:hover,
#menuToggle:hover {
    background-color: var(--md-sys-color-surface-container-high);
}

.hamburger {
    width: 20px;
    height: 2px;
    background-color: var(--md-sys-color-on-surface);
    border-radius: 1px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: center center;
    position: relative;
    margin: 2px 0;
}

/* Cuando el menú está activo (forma X) */
.menu-toggle.active .hamburger:nth-child(1),
#menuToggle.active .hamburger:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.menu-toggle.active .hamburger:nth-child(2),
#menuToggle.active .hamburger:nth-child(2) {
    opacity: 0;
    transform: scale(0);
}

.menu-toggle.active .hamburger:nth-child(3),
#menuToggle.active .hamburger:nth-child(3) {
    transform: rotate(-45deg) translate(2px, -2px);
}

/* Ajustes específicos para las transformaciones en móviles */
@media (max-width: 768px) {

    .menu-toggle.active .hamburger:nth-child(1),
    #menuToggle.active .hamburger:nth-child(1) {
        transform: rotate(45deg) translate(0, 5px);
    }

    .menu-toggle.active .hamburger:nth-child(3),
    #menuToggle.active .hamburger:nth-child(3) {
        transform: rotate(-45deg) translate(0, -5px);
    }
}

@media (max-width: 480px) {

    .menu-toggle.active .hamburger:nth-child(1),
    #menuToggle.active .hamburger:nth-child(1) {
        transform: rotate(45deg) translate(4px, 4px);
    }

    .menu-toggle.active .hamburger:nth-child(3),
    #menuToggle.active .hamburger:nth-child(3) {
        transform: rotate(-45deg) translate(2px, -2px);
    }
}

/* Dropdown menu */
.dropdown-menu,
#dropdownMenu {
    position: absolute;
    top: 100%;
    right: 20px;
    background-color: var(--md-sys-color-surface-container-high);
    border-radius: var(--md-sys-shape-corner-large);
    box-shadow: var(--md-sys-elevation-level3);
    border: 1px solid var(--md-sys-color-outline-variant);
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    overflow: hidden;
    z-index: 1001;
}

.dropdown-menu.show,
#dropdownMenu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    color: var(--md-sys-color-on-surface);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.menu-item:hover {
    background-color: var(--md-sys-color-surface-container-highest);
}

.menu-item-danger {
    color: var(--md-sys-color-error);
}

.menu-item-danger:hover {
    background-color: var(--md-sys-color-error-container);
    color: var(--md-sys-color-on-error-container);
}

.menu-icon {
    margin-right: 12px;
    font-size: 18px;
    min-width: 24px;
    text-align: center;
}

.menu-text {
    font-family: var(--md-sys-typescale-body-large-font-family);
    font-size: var(--md-sys-typescale-body-large-font-size);
    font-weight: var(--md-sys-typescale-body-large-font-weight);
}

.menu-separator {
    height: 1px;
    background-color: var(--md-sys-color-outline-variant);
    margin: 8px 0;
}

/* Ajustar el contenido principal para la navbar fija */
body {
    padding-top: 80px;
}

.container {
    margin-top: 0;
}

/* === RESPONSIVE PARA NAVBAR === */

@media (max-width: 768px) {
    .navbar-content {
        padding: 8px 16px;
    }

    .navbar-brand h1 {
        font-size: 18px;
    }

    .navbar .theme-toggle {
        width: 40px;
        height: 40px;
        padding: 6px;
    }

    .navbar .theme-icon {
        font-size: 18px;
    }

    .menu-toggle {
        width: 40px;
        height: 40px;
    }

    .hamburger {
        /* width: 18px; */
        width: 100%;
        margin: 1.5px 0;
    }

    .dropdown-menu {
        right: 16px;
        min-width: 180px;
    }

    .menu-item {
        padding: 14px 16px;
    }

    body {
        padding-top: 64px;
    }
}

@media (max-width: 480px) {
    .navbar-content {
        padding: 6px 12px;
    }

    .navbar-brand h1 {
        font-size: 16px;
    }

    .navbar .theme-toggle {
        width: 36px;
        height: 36px;
        padding: 4px;
    }

    .navbar .theme-icon {
        font-size: 16px;
    }

    .menu-toggle {
        width: 36px;
        height: 36px;
        gap: 0;
    }

    .hamburger {
        /* width: 16px; */
        width: 100%;
        height: 1.5px;
        margin: 1.5px 0;
    }

    .dropdown-menu {
        right: 12px;
        min-width: 160px;
    }

    .menu-item {
        padding: 12px 14px;
    }

    .menu-icon {
        font-size: 16px;
        margin-right: 10px;
    }

    .menu-text {
        font-size: 14px;
    }

    body {
        padding-top: 56px;
    }
}

/* === FIN NAVBAR Y MENÚ === */

/* === SISTEMA DE PESTAÑAS === */

.tabs-nav {
    display: flex;
    background-color: var(--md-sys-color-surface-container);
    border-radius: var(--md-sys-shape-corner-large) var(--md-sys-shape-corner-large) 0 0;
    margin: 0 -20px 0 -20px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.tabs-nav::-webkit-scrollbar {
    display: none;
}

.tab-btn {
    flex: 1;
    min-width: 100px;
    background: none;
    border: none;
    padding: 16px 12px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    transition: all 0.3s ease;
    color: var(--md-sys-color-on-surface-variant);
    position: relative;
    font-family: var(--md-sys-typescale-label-medium-font-family);
    font-size: var(--md-sys-typescale-label-medium-font-size);
    font-weight: var(--md-sys-typescale-label-medium-font-weight);
}

.tab-btn:hover {
    background-color: var(--md-sys-color-surface-container-high);
    color: var(--md-sys-color-on-surface);
}

.tab-btn.active {
    color: var(--md-sys-color-primary);
    background-color: var(--md-sys-color-surface-container-highest);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background-color: var(--md-sys-color-primary);
    border-radius: 3px 3px 0 0;
}

.tab-icon {
    font-size: 20px;
    line-height: 1;
}

.tab-text {
    font-size: 12px;
    font-weight: 500;
    text-align: center;
    white-space: nowrap;
}

/* Tab Content */
.tab-content {
    display: none;
    padding: 20px;
    margin: 0 -20px;
    min-height: calc(100vh - 200px);
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Ajustes específicos para cada pestaña */
#gastos-tab {
    background-color: var(--md-sys-color-surface);
}

#analisis-tab {
    background-color: var(--md-sys-color-surface);
}

#historial-tab {
    background-color: var(--md-sys-color-surface);
}

/* Responsive para pestañas */
@media (max-width: 768px) {
    .tabs-nav {
        margin: 0 -16px 0 -16px;
    }

    .tab-content {
        padding: 16px;
        margin: 0 -16px;
    }

    .tab-btn {
        padding: 12px 8px;
        min-width: 80px;
    }

    .tab-icon {
        font-size: 18px;
    }

    .tab-text {
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    .tab-btn {
        padding: 10px 6px;
        min-width: 70px;
    }

    .tab-icon {
        font-size: 16px;
    }

    .tab-text {
        font-size: 10px;
    }

    .tab-content {
        padding: 12px;
        margin: 0 -12px;
    }
}

/* === FIN SISTEMA DE PESTAÑAS === */

/* === CONTROLES DE ORDENACIÓN === */

.expense-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    margin: 0;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    background-color: var(--md-sys-color-surface-container);
}

.expense-list-header h2 {
    margin: 0;
    font-family: var(--md-sys-typescale-headline-small-font-family);
    font-size: var(--md-sys-typescale-headline-small-font-size);
    font-weight: var(--md-sys-typescale-headline-small-font-weight);
    color: var(--md-sys-color-on-surface);
}

.sort-controls {
    display: flex;
    gap: 8px;
}

.sort-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background-color: var(--md-sys-color-surface);
    border: 1px solid var(--md-sys-color-outline);
    border-radius: var(--md-sys-shape-corner-medium);
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: var(--md-sys-typescale-label-large-font-family);
    font-size: var(--md-sys-typescale-label-large-font-size);
    font-weight: var(--md-sys-typescale-label-large-font-weight);
    color: var(--md-sys-color-on-surface);
    min-width: 80px;
}

.sort-btn:hover {
    background-color: var(--md-sys-color-surface-container-high);
    border-color: var(--md-sys-color-outline-variant);
    transform: translateY(-1px);
    box-shadow: var(--md-sys-elevation-level1);
}

.sort-btn.active {
    background-color: var(--md-sys-color-primary-container);
    border-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary-container);
}

.sort-btn.active:hover {
    background-color: var(--md-sys-color-primary-container);
    transform: translateY(-1px);
    box-shadow: var(--md-sys-elevation-level2);
}

.sort-icon {
    font-size: 16px;
    line-height: 1;
}

.sort-text {
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.sort-arrow {
    font-size: 14px;
    line-height: 1;
    transition: transform 0.3s ease;
}

.sort-btn::after {
    content: "↓";
    font-size: 12px;
    opacity: 0.6;
    margin-left: 4px;
    transition: transform 0.3s ease;
}

.sort-btn.ascending::after {
    transform: rotate(180deg);
    content: "↑";
}

.sort-btn.ascending .sort-arrow {
    transform: rotate(180deg);
}

/* Responsive para controles de ordenación */
@media (max-width: 768px) {
    .expense-list-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        padding: 16px;
    }

    .sort-controls {
        width: 100%;
        justify-content: center;
    }

    .sort-btn {
        flex: 1;
        justify-content: center;
        padding: 10px 8px;
        min-width: 70px;
    }

    .sort-text {
        font-size: 11px;
    }

    .sort-icon {
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .expense-list-header h2 {
        font-size: 18px;
        align-self: center;
    }

    .sort-btn {
        padding: 8px 6px;
        gap: 4px;
        min-width: 60px;
    }

    .sort-text {
        font-size: 10px;
    }

    .sort-icon {
        font-size: 12px;
    }

    .sort-arrow {
        font-size: 12px;
    }
}

/* === FIN CONTROLES DE ORDENACIÓN === */

/* === GESTIÓN DE CATEGORÍAS === */

/* Gestión de Categorías */
.categories-management {
    padding: 0;
}

.categories-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding: 0 16px;
    flex-wrap: wrap;
    gap: 16px;
}

.categories-header h2 {
    margin: 0;
    color: var(--md-sys-color-on-surface);
    font-family: var(--md-sys-typescale-headline-small-font);
    font-size: var(--md-sys-typescale-headline-small-size);
    font-weight: var(--md-sys-typescale-headline-small-weight);
    line-height: var(--md-sys-typescale-headline-small-line-height);
}

/* Formulario de categoría */
.category-form-container {
    background: var(--md-sys-color-surface-variant);
    border-radius: var(--md-sys-shape-corner-medium);
    margin: 0 16px 24px;
    overflow: hidden;
    animation: slideDown 0.3s ease-out;
}

.category-form {
    padding: 24px;
}

.category-form h3 {
    margin: 0 0 16px 0;
    color: var(--md-sys-color-on-surface-variant);
    font-family: var(--md-sys-typescale-title-medium-font);
    font-size: var(--md-sys-typescale-title-medium-size);
    font-weight: var(--md-sys-typescale-title-medium-weight);
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 20px;
}

.form-actions .btn {
    min-width: 80px;
}

/* Lista de categorías */
.categories-list {
    padding: 0 16px;
}

.categories-section {
    margin-bottom: 32px;
}

.categories-section h3 {
    margin: 0 0 16px 0;
    color: var(--md-sys-color-on-surface);
    font-family: var(--md-sys-typescale-title-medium-font);
    font-size: var(--md-sys-typescale-title-medium-size);
    font-weight: var(--md-sys-typescale-title-medium-weight);
    padding-bottom: 8px;
    border-bottom: 2px solid var(--md-sys-color-outline-variant);
}

.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

/* Tarjeta de categoría */
.category-card {
    background: var(--md-sys-color-surface);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-corner-medium);
    padding: 16px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    box-shadow: var(--md-sys-elevation-level1);
}

.category-card:hover {
    box-shadow: var(--md-sys-elevation-level2);
    transform: translateY(-2px);
    border-color: var(--md-sys-color-primary);
}

.category-card.default {
    border-left: 4px solid var(--md-sys-color-tertiary);
}

.category-card.custom {
    border-left: 4px solid var(--md-sys-color-primary);
}

.category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.category-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.category-icon {
    font-size: 24px;
    width: 40px;
    height: 40px;
    border-radius: var(--md-sys-shape-corner-small);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--md-sys-color-surface-variant);
}

.category-details h4 {
    margin: 0;
    font-family: var(--md-sys-typescale-title-small-font);
    font-size: var(--md-sys-typescale-title-small-size);
    font-weight: var(--md-sys-typescale-title-small-weight);
    color: var(--md-sys-color-on-surface);
}

.category-details p {
    margin: 4px 0 0 0;
    font-family: var(--md-sys-typescale-body-small-font);
    font-size: var(--md-sys-typescale-body-small-size);
    color: var(--md-sys-color-on-surface-variant);
    line-height: 1.2;
}

.category-actions {
    display: flex;
    gap: 8px;
}

.category-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: var(--md-sys-shape-corner-small);
    background: transparent;
    color: var(--md-sys-color-on-surface-variant);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 14px;
}

.category-btn:hover {
    background: var(--md-sys-color-surface-variant);
}

.category-btn.edit:hover {
    background: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
}

.category-btn.delete:hover {
    background: var(--md-sys-color-error-container);
    color: var(--md-sys-color-on-error-container);
}

.category-stats {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--md-sys-color-outline-variant);
    font-family: var(--md-sys-typescale-body-small-font);
    font-size: var(--md-sys-typescale-body-small-size);
    color: var(--md-sys-color-on-surface-variant);
}

.usage-count {
    display: flex;
    align-items: center;
    gap: 4px;
}

.usage-count .count {
    font-weight: 600;
    color: var(--md-sys-color-primary);
}

/* Estado vacío */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--md-sys-color-on-surface-variant);
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.6;
}

.empty-state h4 {
    margin: 0 0 8px 0;
    font-family: var(--md-sys-typescale-title-medium-font);
    font-size: var(--md-sys-typescale-title-medium-size);
    color: var(--md-sys-color-on-surface);
}

.empty-state p {
    margin: 0;
    font-family: var(--md-sys-typescale-body-medium-font);
    font-size: var(--md-sys-typescale-body-medium-size);
    max-width: 300px;
    margin: 0 auto;
}

/* Animaciones */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive para gestión de categorías */
@media (max-width: 768px) {
    .categories-header {
        flex-direction: column;
        align-items: stretch;
    }

    .categories-grid {
        grid-template-columns: 1fr;
    }

    .form-actions {
        flex-direction: column-reverse;
    }

    .form-actions .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .category-form {
        padding: 16px;
    }

    .categories-list {
        padding: 0 8px;
    }

    .categories-header {
        padding: 0 8px;
    }
}

/* === FIN GESTIÓN DE CATEGORÍAS === */