/* ==============================================
   ECO MERCADO - ESTILOS PREMIUM
   Modo oscuro/claro con diseño elegante
   ============================================== */

:root {
    /* Tema claro: paleta verde (temas.css) */
    --bg-primary: #f0f7f2;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-gradient: linear-gradient(135deg, #A0D0AD 0%, #6aab7a 100%);
    --text-primary: #3B3C43;
    --text-secondary: #5f6068;
    --text-muted: #8a8b92;
    --border: #d6ead9;
    --border-light: #e8f5eb;
    --header-bg: linear-gradient(135deg, #b9dfc4 0%, #A0D0AD 100%);
    --card-shadow: 0 1px 4px rgba(59, 60, 67, 0.08), 0 4px 16px rgba(59, 60, 67, 0.06);
    --card-shadow-hover: 0 8px 32px rgba(59, 60, 67, 0.16);
    --btn-primary: #3B7A4E;
    --btn-primary-hover: #2f6340;
    --btn-success: #10b981;
    --btn-success-hover: #059669;
    --btn-danger: #ef4444;
    --btn-danger-hover: #dc2626;
    --btn-warning: #f59e0b;
    --btn-warning-hover: #d97706;
    --btn-info: #2d6fa8;
    --btn-info-hover: #245a8a;
    --badge-time-bg: #e8f5eb;
    --badge-time-text: #3B7A4E;
    --input-bg: #fafdf9;
    --input-border: #d6ead9;
    --focus-ring: rgba(59, 122, 78, 0.25);
    --accent-1: #6aab7a;
    --accent-2: #3B7A4E;
}

body.dark-mode {
    --accent-1: #667eea;
    --accent-2: #764ba2;
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-card: #16213e;
    --bg-gradient: linear-gradient(135deg, #1e1b4b 0%, #2d2b55 100%);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: rgba(255, 255, 255, 0.08);
    --border-light: rgba(255, 255, 255, 0.05);
    --header-bg: rgba(26, 26, 46, 0.95);
    --card-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    --card-shadow-hover: 0 20px 50px rgba(0, 0, 0, 0.4);
    --btn-primary: #818cf8;
    --btn-primary-hover: #6366f1;
    --btn-success: #34d399;
    --btn-success-hover: #10b981;
    --btn-danger: #f87171;
    --btn-danger-hover: #ef4444;
    --btn-warning: #fbbf24;
    --btn-warning-hover: #f59e0b;
    --btn-info: #60a5fa;
    --btn-info-hover: #3b82f6;
    --badge-time-bg: #312e81;
    --badge-time-text: #a5b4fc;
    --input-bg: #1e1e3a;
    --input-border: #2d2d5e;
    --focus-ring: rgba(129, 140, 248, 0.3);
}

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

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ========== CONTENEDOR ========== */
.container {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 2rem;
}

/* ========== TARJETAS ========== */
.card {
    background-color: var(--bg-card);
    border-radius: 20px;
    padding: 1.8rem;
    margin-bottom: 1.8rem;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border-light);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

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

.card-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 1.2rem;
    padding-bottom: 0.8rem;
    border-bottom: 2px solid transparent;
    border-image: linear-gradient(90deg, var(--accent-1), var(--accent-2));
    border-image-slice: 1;
    display: inline-block;
    letter-spacing: -0.3px;
}

body.dark-mode .card-title {
    border-image: linear-gradient(90deg, #818cf8 0%, #c084fc 100%);
    border-image-slice: 1;
}

/* ========== TABLAS ========== */
.table-responsive {
    overflow-x: auto;
    border-radius: 16px;
}

table {
    width: 100%;
    border-collapse: collapse;
    background-color: transparent;
}

th, td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
}

th {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

tr:hover td {
    background-color: rgba(99, 102, 241, 0.05);
}

/* ========== FORMULARIOS ========== */
.form-group {
    margin-bottom: 1.2rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

input, select, textarea {
    width: 100%;
    padding: 0.8rem 1rem;
    border: 2px solid var(--input-border);
    border-radius: 12px;
    background-color: var(--input-bg);
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: all 0.2s;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--btn-primary);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ========== BOTONES ========== */
.btn {
    padding: 0.7rem 1.5rem;
    border: none;
    border-radius: 40px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    letter-spacing: 0.3px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--btn-primary) 0%, var(--btn-primary-hover) 100%);
    color: white;
    box-shadow: 0 2px 8px var(--focus-ring);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 16px var(--focus-ring); }

.btn-info {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}
.btn-info:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4); }

.btn-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}
.btn-warning:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(245, 158, 11, 0.4); }

.btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}
.btn-danger:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(239, 68, 68, 0.4); }

.btn-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}
.btn-success:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4); }

/* Botón secundario (Volver, Cancelar, Cerrar): antes no tenía estilo global y se veía como texto plano */
.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 2px solid var(--btn-primary);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}
.btn-secondary:hover {
    background: var(--btn-primary);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px var(--focus-ring);
}

/* Enlaces de texto sin clase dentro de tarjetas y modales: visibles y reconocibles como enlace */
.card a:not([class]),
.modal a:not([class]) {
    color: var(--btn-primary);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.card a:not([class]):hover,
.modal a:not([class]):hover {
    color: var(--btn-primary-hover);
    text-decoration-thickness: 2px;
}

.card .btn { margin-top: 1rem; }

/* ========== MODALES ========== */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--bg-card);
    margin: 5% auto;
    padding: 2rem;
    border-radius: 24px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    border: 1px solid var(--border-light);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from { transform: translateY(-30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.close {
    float: right;
    font-size: 1.8rem;
    font-weight: bold;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
}
.close:hover { color: var(--btn-danger); transform: scale(1.1); }

/* ========== ALERTAS ========== */
.alert {
    padding: 1rem 1.2rem;
    border-radius: 16px;
    margin-bottom: 1.2rem;
    font-weight: 500;
    border-left: 4px solid;
}
.alert-success { background: linear-gradient(135deg, rgba(16,185,129,0.1) 0%, rgba(5,150,105,0.05) 100%); color: #10b981; border-left-color: #10b981; }
body.dark-mode .alert-success { background: linear-gradient(135deg, rgba(52,211,153,0.15) 0%, rgba(16,185,129,0.08) 100%); }
.alert-error { background: linear-gradient(135deg, rgba(239,68,68,0.1) 0%, rgba(220,38,38,0.05) 100%); color: #ef4444; border-left-color: #ef4444; }
.alert-info { background: linear-gradient(135deg, rgba(59,130,246,0.1) 0%, rgba(37,99,235,0.05) 100%); color: #3b82f6; border-left-color: #3b82f6; }
.alert-warning { background: linear-gradient(135deg, rgba(245,158,11,0.1) 0%, rgba(217,119,6,0.05) 100%); color: #f59e0b; border-left-color: #f59e0b; }

/* ========== UTILIDADES ========== */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1.8rem; }
.text-center { text-align: center; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1.5rem; }

/* ========== SCROLLBAR ========== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--border-light); border-radius: 10px; }
::-webkit-scrollbar-thumb { background: var(--btn-primary); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--btn-primary-hover); }

/* ========== SECCIÓN DE BIENVENIDA MEJORADA ========== */
.welcome-section {
    margin-bottom: 3rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-light);
    position: relative;
}

.welcome-title {
    font-size: 1.8rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--btn-primary) 0%, #3541ee 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    display: inline-flex;
    align-items: center;
    gap: 0.8rem;
    animation: fadeInUp 0.6s cubic-bezier(0.2, 0.9, 0.4, 1.1);
    margin-bottom: 0.5rem;
}

.welcome-wave {
    display: inline-block;
    animation: wave 1.5s ease-in-out infinite;
    transform-origin: 70% 70%;
    font-size: 2rem;
}

.welcome-subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    animation: fadeInUp 0.6s cubic-bezier(0.2, 0.9, 0.4, 1.1) 0.1s backwards;
}

/* Animaciones */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes wave {
    0%, 100% {
        transform: rotate(0deg);
    }
    25% {
        transform: rotate(15deg);
    }
    75% {
        transform: rotate(-10deg);
    }
}

/* Efecto de línea decorativa debajo de la bienvenida */
.welcome-section::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 80px;
    height: 3px;
    background: linear-gradient(90deg, var(--btn-primary), #99134b, transparent);
    border-radius: 3px;
    animation: lineGrow 0.8s ease-out 0.3s backwards;
}

@keyframes lineGrow {
    from {
        width: 0;
        opacity: 0;
    }
    to {
        width: 80px;
        opacity: 1;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .welcome-section {
        margin-bottom: 2rem;
    }
    
    .welcome-title {
        font-size: 1.4rem;
    }
    
    .welcome-wave {
        font-size: 1.6rem;
    }
    
    .welcome-subtitle {
        font-size: 0.85rem;
    }
    
    .welcome-section::after {
        width: 50px;
    }
}

/* ========== AJUSTE COLOR BIENVENIDA MODO CLARO ========== */
:root {
    --welcome-text: #1e293b;
}

body.dark-mode {
    --welcome-text: #f1f5f9;
}

.welcome-title {
    color: var(--welcome-text);
    background: none;
    -webkit-background-clip: unset;
    background-clip: unset;
}

/* Mantener el gradiente solo en la animación (opcional) */
.welcome-title {
    background: linear-gradient(135deg, var(--welcome-text) 0%, var(--welcome-text) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* FORZAR QUE LA MANITO SEA VISIBLE SIEMPRE */
.welcome-wave {
    background: none !important;
    -webkit-background-clip: unset !important;
    background-clip: unset !important;
    color: var(--text-primary) !important;
    display: inline-block !important;
    animation: wave 1.5s ease-in-out infinite !important;
}

/* ========================================== */
/* FOOTER - ANCHO COMPLETO CON FONDO GRIS */
/* ========================================== */

.footer {
    background: var(--bg-secondary);
    border-top: 2px solid var(--border);
    padding: 2.5rem 0;
    margin-top: 3rem;
    width: 100%;
}

/* MODO CLARO: fondo gris más marcado */
body:not(.dark-mode) .footer {
    background: #d6ead9;
    border-top-color: #A0D0AD;
}

/* MODO OSCURO: fondo oscuro */
body.dark-mode .footer {
    background: #1a1a2e;
}

.footer-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 2rem;
}

.footer-left,
.footer-right {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
}

.footer-center {
    flex: 1;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.8;
}

.footer-center p {
    margin: 0.1rem 0;
}

.footer-center .derechos {
    font-size: 0.75rem;
    opacity: 0.7;
}

.footer-logo {
    width: auto;
    object-fit: contain;
}

.footer-logo.municipalidad {
    height: 120px;
    max-width: 400px;
}

.footer-logo.fosis {
    height: 85px;
    max-width: 260px;
}

/* Responsive */
@media (max-width: 992px) {
    .footer-logo.municipalidad {
        height: 100px;
        max-width: 320px;
    }

    .footer-logo.fosis {
        height: 70px;
        max-width: 220px;
    }
}

@media (max-width: 768px) {
    .footer-container {
        flex-direction: column;
        justify-content: center;
        gap: 1.5rem;
        text-align: center;
    }

    .footer-left,
    .footer-right {
        flex: 0 0 auto;
    }

    .footer-center {
        width: 100%;
    }

    .footer-logo.municipalidad {
        height: 85px;
        max-width: 280px;
    }

    .footer-logo.fosis {
        height: 60px;
        max-width: 190px;
    }
}

@media (max-width: 480px) {
    .footer-logo.municipalidad {
        height: 70px;
        max-width: 220px;
    }

    .footer-logo.fosis {
        height: 50px;
        max-width: 160px;
    }

    .footer-center {
        font-size: 0.75rem;
    }
}

/* ========================================== */
/* GRÁFICOS                                   */
/* ========================================== */

.graficos-section {
    margin-top: 2rem;
}

.graficos-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.grafico-card {
    padding: 1.5rem;
}

.grafico-card h3 {
    text-align: center;
    margin-bottom: 1rem;
    font-size: 1rem;
}

.grafico-container {
    position: relative;
    height: 250px;
    max-width: 100%;
}

.grafico-instruccion {
    text-align: center;
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.loading-spinner {
    text-align: center;
    padding: 3rem;
    font-size: 1.5rem;
    color: var(--text-secondary);
}

.btn-volver {
    display: inline-block;
    margin-bottom: 1.5rem;
}

/* Responsive */
@media (max-width: 768px) {
    .graficos-grid {
        grid-template-columns: 1fr;
    }
}

/* Modo oscuro - ajustes para gráficos */
body.dark-mode .grafico-card {
    background: var(--bg-card);
}

body.dark-mode .grafico-instruccion {
    color: var(--text-secondary);
}

/* ========== TEMA CLARO VERDE: ajustes del header y menú ========== */
body:not(.dark-mode) .user-role,
body:not(.dark-mode) .badge-notificacion-header {
    background: linear-gradient(135deg, #3B7A4E 0%, #2f6340 100%) !important;
    color: #ffffff !important;
}
body:not(.dark-mode) .nav-menu {
    background-color: #f7fbf8;
    border-color: #d6ead9;
}
body:not(.dark-mode) .nav-menu a::after {
    background: linear-gradient(90deg, #6aab7a 0%, #3B7A4E 100%);
}
body:not(.dark-mode) .nav-menu a:hover {
    color: #3B7A4E;
}


/* ===== Firma SRM en el pie de página (morado en claro, dorado en oscuro) ===== */
.footer-firma { display: flex; justify-content: center; margin-bottom: 0.3rem; }
.srm-firma { height: 64px; width: auto; display: block; }
.srm-firma-oscuro { display: none; }
body.dark-mode .srm-firma-claro { display: none; }
body.dark-mode .srm-firma-oscuro { display: block; }
