:root {
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --secondary: #10b981;
    --danger: #ef4444;
    --dark-bg: #0f172a;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.08);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
    background-color: var(--dark-bg);
    color: var(--text-main);
    min-height: 100vh;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

canvas#backgroundCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
}

/* --- CLASES UTILITARIAS Y DE PANELES --- */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
}

.btn-primary, .btn-secondary, .btn-text, .btn-icon, .btn-sm {
    cursor: pointer;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: var(--primary);
    color: white;
    padding: 12px 20px;
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 12px 20px;
}
.btn-secondary:hover { background: rgba(255,255,255,0.05); }

.btn-text {
    background: none;
    color: var(--primary);
    padding: 8px;
}
.btn-text:hover { text-decoration: underline; }

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.full-width { width: 100%; }

input, select {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: white;
    outline: none;
}
input:focus, select:focus { border-color: var(--primary); }

/* --- AUTENTICACI�N --- */
.auth-container {
    max-width: 400px;
    width: 100%;
    padding: 40px;
    text-align: center;
    /* Margin auto handled by layout */
}

.logo-area {
    margin-bottom: 0rem;
}
.logo-area img {
    margin-bottom: 1rem;
    border-radius: 12px;
}

/* --- APP LAYOUT --- */
.app-header {
    width: 100%;
    max-width: 1000px;
    padding: 15px 25px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
}

.controls-bar {
    width: 100%;
    max-width: 1000px;
    padding: 15px;
    margin-bottom: 20px;
    display: flex;
    gap: 15px;
    align-items: center;
}

.date-selector {
    display: flex;
    gap: 10px;
    flex: 1;
}
.date-selector select { margin-bottom: 0; }

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    width: 100%;
    max-width: 1000px;
    margin-bottom: 20px;
}

.card {
    padding: 25px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 160px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 10px;
}

.card-value {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 5px;
}

.card-subtext {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.highlight-card { border-color: rgba(59, 130, 246, 0.3); }
.highlight-card .card-value { color: #60a5fa; }

.text-success { color: var(--secondary); }
.text-danger { color: var(--danger); }

.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 0.95rem;
}
.border-top {
    border-top: 1px solid var(--glass-border);
    margin-top: 8px;
    padding-top: 12px;
    font-weight: 700;
}

/* --- TABLA --- */
.transactions-container {
    width: 100%;
    max-width: 1000px;
    padding: 25px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.table-responsive { overflow-x: auto; }

.modern-table {
    width: 100%;
    border-collapse: collapse;
}

.modern-table th, .modern-table td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid var(--glass-border);
}
.modern-table th { color: var(--text-muted); font-weight: 500; }
.modern-table tr:last-child td { border-bottom: none; }

.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}
.empty-state i {
    width: 48px;
    height: 48px;
    margin-bottom: 15px;
    opacity: 0.5;
}

/* --- MODALES --- */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(5px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-card {
    background: #1e293b;
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 30px;
    width: 90%;
    max-width: 400px;
    position: relative;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
}
.close-btn:hover { color: white; }

.form-group { margin-bottom: 0px; }
.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* --- LANDING PAGE NUEVA (DOBLE COLUMNA) --- */
#landingLayout {
    display: flex;
    gap: 40px;
    max-width: 1100px;
    width: 90%;
    margin: 40px auto;
    align-items: center;
    justify-content: center;
}

#infoPanel {
    flex: 1;
    max-width: 600px;
    padding: 20px;
}

#infoPanel h2 {
    font-size: 2.8rem;
    line-height: 1.1;
    margin-bottom: 20px;
    color: var(--primary);
}

#infoPanel h3 {
    margin-top: 0px;
    margin-bottom: 15px;
    color: var(--text-muted);
    font-size: 1.3rem;
    letter-spacing: 1px;
}

/* --- RESPONSIVE --- */
@media (max-width: 850px) {
    #landingLayout {
        flex-direction: column;
        text-align: center;
    }

    #infoPanel {
        padding: 0;
    }
    
    #infoPanel h2 {
        font-size: 2.2rem;
    }

    .feature-list li {
        /* En m�vil alineamos al centro o izquierda seg�n preferencia. 
           Aqu� forzamos izquierda para mantener consistencia con los iconos */
        justify-content: flex-start;
        text-align: left;
    }

    /* Ocultar elementos de tabla en m�vil */
    .dashboard-grid { grid-template-columns: 1fr; }
    .controls-bar { flex-direction: column; gap: 10px; align-items: stretch; }
    .date-selector { display: flex; }
    .date-selector select { flex: 1; margin: 0; }
    .date-selector select:first-child { margin-right: 10px; }

    .modern-table th:nth-child(1), .modern-table th:nth-child(3) { display: none; }
    .modern-table td:nth-child(1), .modern-table td:nth-child(3) { display: none; }
    
    .btn-icon-only { padding: 4px; font-size: 14px; }
    .btn-icon-only svg { width: 18px; height: 18px; }
    .action-btn-group { gap: 4px; }
}

/* ⚠️ AJUSTES ESPECÍFICOS PARA MÓVILES MUY PEQUEÑOS (< 400px) */
@media (max-width: 400px) {
    
    /* 1. ELIMINACIÓN DE MARGEN EXTERNO (BODY) */
    /* Eliminamos todo el padding del body para maximizar el espacio horizontal */
    body {
        padding: 5px 0; /* Mínimo padding vertical, CERO horizontal */
        overflow-x: hidden; /* Medida de seguridad para ocultar barras */
    }
    
    /* 2. APLICACIÓN DE MARGEN INTERNO (CONTENEDORES PRINCIPALES) */
    /* Aplicamos el padding lateral a los contenedores internos para crear el margen visual */
    .app-header,
    .controls-bar,
    .dashboard-grid,
    .transactions-container {
        padding-left: 5px;
        padding-right: 5px;
        /* Aseguramos que usen todo el ancho y anulen cualquier max-width superior */
        max-width: 100%; 
        width: 100%; 
    }
    
    /* 3. AJUSTES FINOS DE ELEMENTOS */
    
    /* Reducción del padding interno de las tarjetas */
    .card {
        padding: 10px; 
    }
    
    /* Aseguramos que el selector de mes use el espacio disponible dentro de controls-bar */
    .date-selector-control {
        width: 100%; 
    }

    /* Ajuste de Modales */
    .modal-card {
        margin: 5px;
        padding: 20px;
        width: calc(100% - 10px); 
    }
    
    /* Hacemos el display del mes y botones más compactos */
    .month-display {
        min-width: 80px;
        font-size: 0.9rem;
    }
    
    .btn-primary, .btn-secondary, .btn-sm {
        padding: 8px 12px;
        font-size: 0.8rem;
    }
}

/* --- NOTIFICACIONES --- */

.notification-container {
    position: fixed;
    top: 20px; /* Separación de la parte superior */
    right: 20px; /* Separación de la derecha */
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    pointer-events: none; /* Permite hacer clic a través de si no hay notificación */
}

.notification {
    pointer-events: auto; /* Habilita clic en la notificación */
    min-width: 300px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: opacity 0.3s ease;
}

.notification-text {
    margin-right: 15px;
}

/* Estilo para el botón Deshacer */
.btn-undo {
    background: white;
    color: var(--primary);
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    margin-left: 10px;
    transition: background 0.2s;
}
.btn-undo:hover {
    background: #e5e7eb;
}

/* --- ESTÉTICA DE LA TABLA Y BOTONES DE ACCIÓN --- */

/* Estilo para la fila de gasto pagado */
.paid-row {
    opacity: 0.7;
    background-color: rgba(16, 185, 129, 0.05); /* Ligeramente verde/secundario */
}
.paid-row td:first-child {
    border-left: 4px solid var(--secondary);
}

/* Mejorar los botones de acción en la tabla */

.btn-icon-only {
    /* Base ya existe, mejoramos los colores */
    border: none;
    border-radius: 6px;
    padding: 8px;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

/* Editar (Azul/Primary) */
.btn-edit {
    color: var(--primary);
    background-color: rgba(59, 130, 246, 0.15); 
}
.btn-edit:hover {
    background-color: rgba(59, 130, 246, 0.3);
}

/* Eliminar (Rojo/Danger) */
.btn-delete {
    color: var(--danger);
    background-color: rgba(239, 68, 68, 0.15);
}
.btn-delete:hover {
    background-color: rgba(239, 68, 68, 0.3);
}

/* Pagar (Verde/Secondary) */
.btn-pay {
    color: var(--secondary);
    background-color: rgba(16, 185, 129, 0.15);
}
.btn-pay:hover {
    background-color: rgba(16, 185, 129, 0.3);
}

/* Pagado (Gris/Disabled) */
.btn-paid {
    color: var(--text-muted);
    background-color: rgba(148, 163, 184, 0.1);
    cursor: default;
}

/* --- CONTROL DE NAVEGACIÓN DE MES --- */
.date-selector-control {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 5px;
    margin-bottom: 10px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    margin-top: 10px;
}

.month-display {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
    min-width: 120px;
    text-align: center;
}

.date-selector-control .btn-icon-only {
    width: 30px;
    height: 30px;
    color: var(--primary);
    background: transparent;
    border-radius: 8px;
    transition: background-color 0.2s;
}

.date-selector-control .btn-icon-only:hover {
    background-color: rgba(59, 130, 246, 0.1);
}

/* === ESTILOS PARA CAJAS DE BALANCE Y AHORRO (MODIFICADO) === */
.highlight-card { 
    border-color: rgba(59, 130, 246, 0.3); /* Borde azul con 30% de opacidad */
    background: rgba(59, 130, 246, 0.1); /* Fondo azul con 10% de opacidad (muy claro) */
}
.highlight-card .card-value { color: #60a5fa; } /* Valor en color azul */

.savings-card {
    border-color: rgba(16, 185, 129, 0.3); /* Borde verde con 30% de opacidad */
    background: rgba(16, 185, 129, 0.1); /* Fondo verde con 10% de opacidad (muy claro) */
}
.savings-card .card-value {
    color: var(--secondary); /* Valor en color verde */
}

