@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    /* Paleta exacta de Tailwind CSS */
    --slate-50: #f8fafc;
    --slate-100: #f1f5f9;
    --slate-200: #e2e8f0;
    --slate-300: #cbd5e1;
    --slate-500: #64748b;
    --slate-700: #334155;
    --slate-800: #1e293b;
    --slate-900: #0f172a;
    
    --indigo-50: #eef2ff;
    --indigo-500: #6366f1;
    --indigo-600: #4f46e5;
    --indigo-700: #4338ca;

    --emerald-100: #d1fae5;
    --emerald-600: #059669;
    
    --red-100: #fee2e2;
    --red-600: #dc2626;

    --amber-100: #fef3c7;
    --amber-600: #d97706;

    --bg-main: var(--slate-50);
    --text-main: var(--slate-800);
    --text-muted: var(--slate-500);
    
    /* Sombras Tailwind */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

/* =========================================
   RESET Y TIPOGRAFÍA GLOBALES
========================================= */
* { box-sizing: border-box; }

/* =========================================
   RESET Y TIPOGRAFÍA GLOBALES
========================================= */
* { box-sizing: border-box; }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    margin: 0;
    padding: 0;
    
    /* 1. Tu fondo original intacto */
    background-image: url('../img/fondo.png');
    background-repeat: repeat;
    background-attachment: fixed;
    background-color: var(--slate-100); /* Color base por si la imagen tarda en cargar */
    
    color: var(--text-main);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 { color: var(--slate-900); font-weight: 700; margin-top: 0; }

/* =========================================
   FORMULARIOS Y BOTONES (Estilo Tailwind)
========================================= */
input, select, textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    background-color: white;
    border: 1px solid var(--slate-300);
    border-radius: 0.5rem; /* rounded-lg */
    font-size: 0.95rem;
    font-family: 'Inter', sans-serif;
    color: var(--slate-800);
    transition: all 0.2s ease-in-out;
    box-shadow: var(--shadow-sm);
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--indigo-500);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2); /* ring-indigo-500/20 */
}

input:disabled, .readonly-field {
    background-color: var(--slate-100) !important;
    color: var(--slate-500);
    cursor: not-allowed;
    border-color: var(--slate-200) !important;
    box-shadow: none;
}

.btn-primary {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    padding: 0.875rem 1.5rem;
    background-color: var(--indigo-600);
    color: white;
    border: none;
    border-radius: 0.5rem; /* rounded-lg */
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}
.btn-primary:hover { background-color: var(--indigo-700); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

label {
    display: block;
    font-size: 0.875rem; /* text-sm */
    font-weight: 600; /* font-semibold */
    color: var(--slate-700);
    margin-bottom: 0.5rem;
}

/* =========================================
   MÓDULO DE AUTENTICACIÓN (LOGIN)
========================================= */
.auth-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 1rem;
}

.login-container, .password-container {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 3rem 2.5rem;
    border-radius: 1.5rem; /* rounded-3xl */
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 420px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.logo-login {
    width: 100%;
    max-width: 200px;
    height: auto;
    margin-bottom: 2rem;
}

.auth-form-group { text-align: left; margin-bottom: 1.5rem; }

/* =========================================
   DASHBOARD Y LAYOUT PRINCIPAL
========================================= */
.main-wrapper { display: flex; min-height: 100vh; }

/* Sidebar Premium */
.sidebar {
    width: 280px;
    background-color: var(--slate-900);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    border-right: 1px solid var(--slate-800);
}

.sidebar-header {
    padding: 1.5rem;
    font-size: 1.25rem;
    font-weight: 800;
    text-align: center;
    border-bottom: 1px solid var(--slate-800);
    color: white;
    letter-spacing: 0.05em;
}

.sidebar nav ul { list-style: none; padding: 1rem; margin: 0; display: flex; flex-direction: column; gap: 0.25rem; }
.sidebar nav ul li a {
    color: var(--slate-300);
    text-decoration: none;
    padding: 0.875rem 1rem;
    display: block;
    border-radius: 0.5rem;
    font-weight: 500;
    transition: all 0.2s;
}
.sidebar nav ul li a:hover {
    background-color: var(--slate-800);
    color: white;
}
.sidebar nav ul li a.active {
    background-color: var(--indigo-600);
    color: white;
    box-shadow: var(--shadow-md);
}

.content-area {
    flex-grow: 1;
    margin-left: 280px;
    display: flex;
    flex-direction: column;
}

/* Barra de Navegación Superior */
.top-nav {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--slate-200);
    position: sticky;
    top: 0;
    z-index: 40;
}

.header-left { display: flex; align-items: center; gap: 1rem; }
.logo-nav { height: 40px; width: auto; }
.breadcrumb { color: var(--slate-500); font-size: 0.875rem; font-weight: 500; }
.breadcrumb strong { color: var(--slate-800); }

.user-pill { display: flex; align-items: center; gap: 1rem; font-size: 0.875rem; }
.logout-btn {
    background: var(--red-100);
    color: var(--red-600);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    font-weight: 600;
    font-size: 0.875rem;
    transition: 0.2s;
}
.logout-btn:hover { background: #fecaca; }

.main-content { padding: 2rem; max-width: 1400px; margin: 0 auto; width: 100%; box-sizing: border-box; }

/* =========================================
   TARJETAS Y COMPONENTES (Estilo Tailwind)
========================================= */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.5rem; margin-bottom: 2rem;}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: 1rem; /* rounded-2xl */
    border: 1px solid var(--slate-200);
    box-shadow: var(--shadow-md);
    transition: transform 0.2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.stat-card h4 { font-size: 0.875rem; color: var(--slate-500); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.5rem;}
.stat-card .value { font-size: 2.25rem; font-weight: 800; color: var(--slate-900); margin: 0.5rem 0; }
.stat-card p { font-size: 0.875rem; color: var(--slate-500); margin: 0;}

/* Tarjetas de Formularios (Novedades) */
.form-card {
    background: white;
    padding: 2.5rem;
    border-radius: 1rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--slate-200);
    margin-bottom: 2rem;
}

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.5rem; margin-bottom: 1.5rem; }

/* Acordeón de la Matriz Semanal */
.day-accordion {
    margin-bottom: 1.5rem;
    border: 1px solid var(--slate-200);
    border-radius: 0.75rem;
    background: white;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.day-header {
    background: var(--slate-50);
    padding: 1.25rem 1.5rem;
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--slate-800);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: 0.2s;
    border-bottom: 1px solid transparent;
}
.day-header:hover { background: var(--slate-100); }
.day-header.active { background: var(--slate-800); color: white; border-bottom: 1px solid var(--slate-900); }
.day-body { padding: 2rem; display: none; background: white; }
.day-body.active { display: block; }

/* Tarjeta Interna de Modalidad */
.modalidad-card {
    border: 1px solid var(--slate-200);
    border-radius: 0.75rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.mod-head, .modalidad-header {
    background: var(--slate-50);
    padding: 1rem 1.5rem;
    font-weight: 700;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--slate-200);
    color: var(--slate-800);
}
.badge-cupo {
    background: var(--indigo-100);
    color: var(--indigo-700);
    padding: 0.25rem 0.75rem;
    border-radius: 9999px; /* full rounded */
    font-size: 0.875rem;
    font-weight: 700;
}
.mod-content, .modalidad-body { padding: 1.5rem; }

/* Desglose Amarillo Tailwind */
.desglose-panel {
    background: var(--amber-50);
    border: 1px solid var(--amber-200);
    padding: 1.5rem;
    border-radius: 0.75rem;
    margin-top: 1.5rem;
    display: none;
}
.grados-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 1.5rem; margin-top: 1rem; }
.grado-box { display: flex; flex-direction: column; height: 100%; }
.grado-box label { font-size: 0.75rem; display: block; color: #92400e; margin-bottom: 5px; font-weight: bold; line-height: 1.2; }
.grado-box input { margin-top: auto; border: 1px solid #fcd34d; padding: 8px; text-align: center; width: 100%; border-radius: 5px; box-sizing: border-box; }

/* Alertas */
.alert { padding: 1rem; border-radius: 0.5rem; margin-bottom: 1.5rem; font-size: 0.875rem; font-weight: 500; }
.alert-error { background-color: var(--red-100); color: var(--red-700); border: 1px solid #fecaca; }
.alert-success { background-color: var(--emerald-100); color: var(--emerald-700); border: 1px solid #a7f3d0; }

/* =========================================
   MOBILE RESPONSIVE (SILICON VALLEY STANDARD)
========================================= */

/* Botón Hamburguesa (Oculto en PC) */
.menu-toggle { display: none; background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--slate-800); margin-right: 10px;}
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(15, 23, 42, 0.5); backdrop-filter: blur(2px); z-index: 40; }

@media (max-width: 1024px) {
    /* 1. Ocultar el Sidebar deslizado a la izquierda */
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 50;
    }
    
    /* Clase que se activa con JS para mostrarlo */
    .sidebar.active { transform: translateX(0); box-shadow: var(--shadow-xl); }
    
    /* 2. El contenido principal debe tomar el 100% de la pantalla */
    .content-area { margin-left: 0; width: 100%; }
    
    /* 3. Mostrar el botón hamburguesa */
    .menu-toggle { display: block; }
    
    /* 4. Apilar las columnas en Formularios y Dashboard */
    .grid-2 { grid-template-columns: 1fr !important; gap: 1rem; }
    .stats-grid { grid-template-columns: 1fr; }
    .grid-dashboard { grid-template-columns: 1fr; }
    .profile-grid { grid-template-columns: 1fr; }
    
    /* 5. Ajustes del menú superior para que no se amontone */
    .top-nav { padding: 1rem; flex-wrap: wrap; gap: 1rem; justify-content: space-between; }
    .header-left { width: 100%; justify-content: flex-start; border-bottom: 1px solid var(--slate-200); padding-bottom: 10px; }
    .logo-nav { height: 30px; }
    .breadcrumb { font-size: 0.75rem; }
    .user-pill { width: 100%; justify-content: space-between; }
    
    /* 6. Fondo oscuro al abrir el menú */
    .sidebar-overlay.active { display: block; }
}

/* Responsividad extra para tablas móviles */
@media (max-width: 768px) {
    table, thead, tbody, th, td, tr { display: block; }
    thead tr { position: absolute; top: -9999px; left: -9999px; }
    tr { margin-bottom: 1rem; border: 1px solid var(--slate-200); border-radius: 0.5rem; background: white; }
    td { border: none; border-bottom: 1px solid var(--slate-100); position: relative; padding-left: 50%; text-align: right; }
    td:before { position: absolute; top: 1rem; left: 1rem; width: 45%; padding-right: 10px; white-space: nowrap; font-weight: bold; text-align: left; color: var(--slate-500); font-size: 0.75rem; text-transform: uppercase; }
    
    /* Etiquetas falsas para la tabla de Usuarios */
    td:nth-of-type(1):before { content: "Usuario"; }
    td:nth-of-type(2):before { content: "Rol"; }
    td:nth-of-type(3):before { content: "Zona"; }
    td:nth-of-type(4):before { content: "Estado"; }
}