/* =================================================================== */
/* KONTÁ CSS - VERSIÓN FINAL CONSOLIDADA Y CORREGIDA                */
/* =================================================================== */

/* --- Variables y Estilos Base --- */
:root {
    --primary-color: #4285F4;
    --primary-color-dark: #3367D6;
    --background-color: #f5f5f5;
    --card-background: #ffffff;
    --text-color: #333333;
    --text-color-light: #5f6368;
    --input-border-color: #dfe1e5;
    --danger-color: #D93025;
    --font-family: 'Roboto', sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font-family); background-color: var(--background-color); min-width: 300px; }

/* --- Estilos de Login, Registro y Recuperación --- */
.login-container { display: flex; justify-content: center; align-items: center; min-height: 100vh; padding: 15px; }
.login-card { background-color: var(--card-background); padding: 30px 25px; border-radius: 8px; box-shadow: 0 4px 8px rgba(0,0,0,0.1); width: 100%; max-width: 400px; text-align: center; }
.login-card h1, .login-card h2 { color: var(--primary-color); font-size: 2.2rem; font-weight: 700; margin: 0 0 10px; }
.login-card .subtitle { margin: 0 0 25px; color: var(--text-color-light); line-height: 1.4; }
.input-group { margin-bottom: 20px; }
.input-group label { display: block; font-size: 0.9rem; color: var(--text-color-light); margin-bottom: 5px; text-align: left; }
.input-group input { width: 100%; padding: 12px 15px; border: 1px solid var(--input-border-color); border-radius: 4px; font-size: 1rem; }
.input-group input:focus { outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 2px rgba(66, 133, 244, 0.2); }
.btn-login { width: 100%; padding: 12px; background-color: var(--primary-color); color: white; border: none; border-radius: 4px; font-size: 1rem; font-weight: 500; cursor: pointer; transition: background-color 0.3s; }
.btn-login:hover { background-color: var(--primary-color-dark); }
.extra-links { margin-top: 20px; font-size: 0.9rem; }
.extra-links a { color: var(--primary-color); text-decoration: none; }

/* --- CABECERA PRINCIPAL (CORREGIDA) --- */
.main-header { background-color: var(--card-background); box-shadow: 0 2px 4px rgba(0,0,0,0.1); padding: 0 15px; }
.header-content { display: flex; justify-content: space-between; align-items: center; max-width: 1000px; margin: 0 auto; height: 64px; gap: 10px; }

.header-logo { flex-shrink: 0; }
.logo-link { text-decoration: none; }
.logo { font-family: 'Quicksand', sans-serif; font-weight: 700; font-size: 1.8rem; margin: 0; background: linear-gradient(45deg, #4285F4, #34A853); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; text-fill-color: transparent; }

.header-user { flex-grow: 1; text-align: center; }
.profile-link { font-size: 0.9rem; color: var(--text-color); text-decoration: none; font-weight: 500; padding: 8px; border-radius: 4px; transition: background-color 0.2s; }
.profile-link:hover { background-color: #f1f1f1; }

.header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 5px; flex-shrink: 0; }
.btn-icon, .btn-logout { background-color: transparent; color: var(--text-color-light); border: none; border-radius: 50%; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; cursor: pointer; text-decoration: none; transition: background-color 0.2s, color 0.2s; }
.btn-icon:hover { background-color: #f1f1f1; color: var(--primary-color); }
.btn-logout:hover { background-color: #f1f1f1; color: var(--danger-color); }

/* --- Contenedor Principal y Tarjetas --- */
.container { padding: 15px; }
.summary-container { display: grid; grid-template-columns: 1fr; gap: 15px; margin-bottom: 20px; }
.summary-card { background-color: var(--card-background); padding: 15px; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.12); display: flex; align-items: center; }
.summary-icon { font-size: 2rem; margin-right: 15px; }
.summary-text { display: flex; flex-direction: column; }
.summary-value { font-size: 1.3rem; font-weight: 700; color: var(--primary-color); }
.summary-label { font-size: 0.9rem; color: var(--text-color-light); }

/* --- Sección Colapsable y Filtros --- */
.collapsible-trigger { display: flex; align-items: center; width: 100%; background-color: var(--card-background); border: none; padding: 15px 20px; border-radius: 8px; font-size: 1.1rem; font-weight: 500; font-family: var(--font-family); cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,0.12); margin-bottom: 20px; transition: box-shadow 0.2s, border-radius 0.3s; }
.collapsible-trigger .material-icons { margin-right: 10px; transition: transform 0.3s ease; }
.collapsible-trigger.active { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.collapsible-trigger.active .material-icons { transform: rotate(135deg); }
.collapsible-content { background: var(--card-background); padding: 0 20px; max-height: 0; overflow: hidden; transition: max-height 0.3s ease-out, padding 0.3s ease-out; border-bottom-left-radius: 8px; border-bottom-right-radius: 8px; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1); }
.filter-container { background-color: var(--card-background); padding: 15px; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.12); margin-bottom: 20px; }
.filter-container form { display: flex; flex-direction: column; gap: 15px; }
.search-bar { display: flex; align-items: center; border: 1px solid var(--input-border-color); border-radius: 4px; padding: 0 10px; }
.search-bar .material-icons { color: var(--text-color-light); }
.search-bar input[type="search"] { width: 100%; border: none; padding: 10px 5px; font-size: 1rem; }
.search-bar input[type="search"]:focus { outline: none; }
.date-filters { display: flex; gap: 10px; }
.date-filters select { width: 100%; padding: 10px; border: 1px solid var(--input-border-color); border-radius: 4px; font-size: 1rem; background-color: white; }

/* --- Lista de Facturas (Acordeón) --- */
.invoice-accordion { display: flex; flex-direction: column; gap: 10px; }
.invoice-card { background: var(--card-background); border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.08); transition: box-shadow 0.3s ease; }
.invoice-card.active { box-shadow: 0 4px 8px rgba(0,0,0,0.12); }
.invoice-card-header { display: flex; justify-content: space-between; align-items: center; padding: 15px; cursor: pointer; }
.invoice-card-provider { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.invoice-card-amount { display: flex; align-items: center; gap: 8px; font-weight: bold; color: var(--primary-color); }
.expand-icon { transition: transform 0.3s ease; }
.invoice-card-details { max-height: 0; overflow: hidden; padding: 0 15px; transition: max-height 0.3s ease-out, padding 0.3s ease-out; }
.invoice-card.active .invoice-card-details { border-top: 1px solid #f0f0f0; }
.detail-row { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; }
.actions-row { padding-top: 10px; }
.actions-cell { display: flex; gap: 20px; justify-content: flex-end; }
.icon-link .material-icons { transition: transform 0.2s; }
.icon-link:hover .material-icons { transform: scale(1.2); }
.icon-link.danger .material-icons { color: var(--danger-color); }

/* --- Página de Análisis --- */
.analysis-container { display: grid; grid-template-columns: 1fr; gap: 20px; }
.chart-card { background-color: var(--card-background); padding: 20px; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.chart-card h3 { margin-top: 0; text-align: center; color: var(--text-color-light); }
.chart-wrapper { position: relative; height: 300px; }

/* --- Menú Fijo Inferior --- */
.content-wrapper { padding-bottom: 75px; }
.bottom-nav { position: fixed; bottom: 0; left: 0; width: 100%; height: 60px; background: var(--card-background); box-shadow: 0 -2px 5px rgba(0,0,0,0.1); display: flex; justify-content: space-around; align-items: center; z-index: 1000; }
.nav-link { display: flex; flex-direction: column; align-items: center; justify-content: center; flex-grow: 1; color: var(--text-color-light); text-decoration: none; padding: 5px 0; transition: color 0.2s; }
.nav-link .material-icons { margin-bottom: 2px; }
.nav-text { font-size: 0.7rem; }
.nav-link.active { color: var(--primary-color); }
.nav-link:hover { color: var(--primary-color); }

/* --- Mensajes de Feedback y Botones Secundarios --- */
.message { padding: 15px; margin-bottom: 20px; border-radius: 8px; font-weight: 500; border: 1px solid transparent; animation: fadeIn 0.5s ease; }
.message.fade-out { animation: fadeOut 0.5s ease forwards; }
.message.success { background-color: #d4edda; color: #155724; border-color: #c3e6cb; }
.message.error { background-color: #f8d7da; color: #721c24; border-color: #f5c6cb; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }
.btn-secondary { display: block; width: 100%; padding: 12px; background-color: #f1f1f1; color: var(--text-color-light); border: 1px solid var(--input-border-color); border-radius: 4px; font-size: 1rem; font-weight: 500; cursor: pointer; text-align: center; text-decoration: none; transition: background-color 0.3s; margin-top: 10px; }
.btn-secondary:hover { background-color: #e0e0e0; }

/* =================================================================== */
/* --- MEDIA QUERIES (RESPONSIVE) --- */
/* =================================================================== */

@media (max-width: 767px) {
    /* Oculta solo el botón de "Análisis" en el header móvil */
    .desktop-only {
        display: none;
    }

    /* Ajusta el contenedor del nombre para que sea visible y se alinee */
    .header-user {
        display: block; /* Asegura que el contenedor sea visible */
        flex-grow: 1;   /* Permite que ocupe el espacio central */
        text-align: center; /* Centra el nombre del usuario */
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        padding: 0 5px; /* Añade un pequeño espacio a los lados */
    }

    .profile-link {
        font-size: 0.8rem; /* Hacemos el texto un poco más pequeño para que quepa */
    }
}

@media (min-width: 768px) {
    .container { max-width: 1000px; margin: 20px auto; padding: 0 20px; }
    .summary-container { grid-template-columns: repeat(3, 1fr); }
    .filter-container form { flex-direction: row; align-items: center; }
    .search-bar { flex-grow: 1; margin-right: 20px; }
    .date-filters { flex-grow: 0; }
    .date-filters select { width: auto; min-width: 120px; }
    .bottom-nav { display: none; }
    .content-wrapper { padding-bottom: 0; }
}

@media (min-width: 992px) {
    .analysis-container { grid-template-columns: 2fr 1fr; }
    .chart-wrapper { height: 400px; }
}