/* Gestor Escolar Pro - Versión Unida
   Arquitectura modular (Socio) + Diseño Moderno */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=DM+Mono&display=swap');

:root {
    --bg: #F7F6F2;
    --surface: #FFFFFF;
    --surface2: #F0EFE9;
    --border: #E2E0D8;
    --border2: #C8C6BC;
    --text: #1A1916;
    --text2: #5A5850;
    --text3: #9A9890;
    --blue: #2563EB; --blue-bg: #EEF3FD; --blue-t: #DBEAFE;
    --green: #16A34A; --green-bg: #F0FDF4; --green-t: #DCFCE7;
    --red: #DC2626; --red-bg: #FEF2F2; --red-t: #FEE2E2;
    --amber: #D97706; --amber-bg: #FFFBEB; --amber-t: #FEF3C7;
    --radius: 12px;
    --radius-lg: 16px;
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
    --shadow-lg: 0 20px 25px -5px rgba(0,0,0,0.1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { 
    font-family: 'DM Sans', sans-serif; 
    background: var(--bg); 
    color: var(--text); 
    font-size: 14px; 
    height: 100vh; 
    overflow: hidden; 
}

.app-container { display: flex; height: 100vh; }

/* SIDEBAR MODERNO */
.sidebar { 
    width: 240px; 
    background: var(--surface); 
    border-right: 1px solid var(--border); 
    display: flex; 
    flex-direction: column; 
}
.sidebar-header { 
    padding: 24px; 
    border-bottom: 1px solid var(--border); 
    display: flex; 
    align-items: center; 
    gap: 12px; 
}
.logo-box { 
    width: 40px; 
    height: 40px; 
    background: var(--text); 
    border-radius: 10px; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    color: white;
    font-weight: 700;
    font-size: 16px;
}
.logo-icon {
    width: 20px;
    height: 20px;
    fill: white;
}

.nav-list { 
    flex: 1; 
    padding: 16px 12px; 
    overflow-y: auto; 
}
.nav-section { 
    padding: 12px 16px 6px; 
    font-size: 10px; 
    font-weight: 700; 
    color: var(--text3); 
    text-transform: uppercase; 
    letter-spacing: 0.1em; 
}
.nav-item { 
    display: flex; 
    align-items: center; 
    gap: 12px; 
    padding: 10px 16px; 
    border-radius: 8px; 
    cursor: pointer; 
    color: var(--text2); 
    transition: all 0.2s; 
    margin-bottom: 4px; 
    font-weight: 500; 
}
.nav-item:hover { 
    background: var(--surface2); 
    color: var(--text); 
}
.nav-item.active { 
    background: var(--text); 
    color: white; 
    box-shadow: 0 4px 12px rgba(0,0,0,0.1); 
}
.nav-item svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

.sidebar-footer { 
    padding: 16px; 
    border-top: 1px solid var(--border); 
    background: #fafaf9; 
}

/* MAIN CONTENT */
.main-content { 
    flex: 1; 
    display: flex; 
    flex-direction: column; 
    overflow: hidden; 
}
.top-bar { 
    height: 64px; 
    background: var(--surface); 
    border-bottom: 1px solid var(--border); 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    padding: 0 32px; 
    flex-shrink: 0; 
}
.page-content { 
    flex: 1; 
    padding: 32px; 
    overflow-y: auto; 
    scroll-behavior: smooth; 
}

/* SYNC BAR MODERNO */
.sync-status { 
    display: flex; 
    align-items: center; 
    gap: 8px; 
    padding: 8px 32px; 
    background: #fff; 
    border-bottom: 1px solid var(--border); 
    font-size: 12px; 
    font-family: 'DM Mono', monospace; 
}
.dot { 
    width: 8px; 
    height: 8px; 
    border-radius: 50%; 
    background: #ccc; 
}
.dot.sync-loading { 
    background: var(--amber); 
    animation: pulse 1s infinite; 
}
.dot.sync-ok { background: var(--green); }
.dot.sync-error { background: var(--red); }
.dot.sync-offline { background: var(--text3); }
@keyframes pulse { 
    0% { opacity: 1; } 
    50% { opacity: 0.4; } 
    100% { opacity: 1; } 
}

/* CARDS MODERNAS */
.card { 
    background: var(--surface); 
    border-radius: var(--radius); 
    border: 1px solid var(--border); 
    padding: 24px; 
    box-shadow: var(--shadow); 
    margin-bottom: 24px; 
}
.stats-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); 
    gap: 20px; 
    margin-bottom: 24px; 
}
.stat-card { 
    background: white; 
    padding: 20px; 
    border-radius: var(--radius); 
    border: 1px solid var(--border);
    transition: transform 0.2s, box-shadow 0.2s;
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}
.stat-label {
    font-size: 11px;
    color: var(--text3);
    margin-bottom: 8px;
    font-family: 'DM Mono', monospace;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
}

/* FILTERS Y FORMULARIOS */
.filters { 
    display: flex; 
    gap: 12px; 
    margin-bottom: 20px; 
    align-items: center; 
    flex-wrap: wrap; 
}
.form-control { 
    padding: 10px 14px; 
    border: 1px solid var(--border); 
    border-radius: 8px; 
    font-family: inherit; 
    font-size: 14px; 
    outline: none; 
    transition: all 0.2s; 
    background: white;
}
.form-control:focus { 
    border-color: var(--text); 
    box-shadow: 0 0 0 3px rgba(0,0,0,0.05);
}
.form-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text2);
    margin-bottom: 6px;
    display: block;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* BOTONES MODERNOS */
.btn { 
    padding: 10px 18px; 
    border-radius: 8px; 
    border: 1px solid var(--border); 
    cursor: pointer; 
    font-weight: 600; 
    font-family: inherit; 
    font-size: 13px; 
    display: inline-flex; 
    align-items: center; 
    gap: 8px; 
    transition: all 0.2s;
    background: white;
    color: var(--text);
}
.btn:hover {
    background: var(--surface2);
    border-color: var(--border2);
    transform: translateY(-1px);
}
.btn-primary { 
    background: var(--text); 
    color: #fff; 
    border-color: var(--text); 
}
.btn-primary:hover { 
    background: #333;
    border-color: #333;
}
.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}
.btn-danger {
    background: var(--red-bg);
    color: var(--red);
    border-color: var(--red-t);
}
.btn-danger:hover {
    background: var(--red-t);
}
.btn-blue {
    background: var(--blue-bg);
    color: var(--blue);
    border-color: var(--blue-t);
}
.btn-green {
    background: var(--green-bg);
    color: var(--green);
    border-color: var(--green-t);
}

/* TABLAS MODERNAS */
table { 
    width: 100%; 
    border-collapse: collapse;
    font-size: 14px;
}
th { 
    text-align: left; 
    padding: 12px 16px; 
    border-bottom: 1px solid var(--border); 
    background: #fafaf9; 
    font-size: 11px; 
    font-weight: 600;
    text-transform: uppercase; 
    color: var(--text3);
    letter-spacing: 0.05em;
}
td { 
    padding: 14px 16px; 
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
tr:hover td { 
    background: var(--surface2); 
}
tr:last-child td {
    border-bottom: none;
}

/* BADGES MODERNOS */
.badge { 
    padding: 4px 10px; 
    border-radius: 6px; 
    font-size: 11px; 
    font-weight: 600; 
    font-family: 'DM Mono', monospace;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.badge-blue { 
    background: var(--blue-bg); 
    color: var(--blue); 
}
.badge-green {
    background: var(--green-bg);
    color: var(--green);
}
.badge-red {
    background: var(--red-bg);
    color: var(--red);
}
.badge-amber {
    background: var(--amber-bg);
    color: var(--amber);
}
.badge-gray {
    background: var(--surface2);
    color: var(--text2);
}

/* CALENDARIO MODERNO */
.cal-grid-wrap { 
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); 
    gap: 20px; 
}
.cal-card { 
    background: white; 
    border-radius: var(--radius); 
    border: 1px solid var(--border); 
    padding: 20px;
    transition: transform 0.2s, box-shadow 0.2s;
}
.cal-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}
.cal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.cal-title {
    font-weight: 600;
    font-size: 14px;
}
.cal-pct {
    font-size: 12px;
    font-weight: 700;
    font-family: 'DM Mono', monospace;
}
.cal-grid { 
    display: grid; 
    grid-template-columns: repeat(7, 1fr); 
    gap: 4px; 
}
.cal-head { 
    text-align: center; 
    font-size: 10px; 
    font-weight: 700; 
    color: var(--text3); 
    padding-bottom: 8px;
    font-family: 'DM Mono', monospace;
}
.cal-day { 
    aspect-ratio: 1; 
    border-radius: 6px; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    font-size: 12px; 
    cursor: pointer; 
    border: 1px solid #f0f0f0; 
    background: #fff;
    font-weight: 600;
    transition: all 0.15s;
}
.cal-day:hover:not(:disabled) { 
    background: var(--surface2);
    border-color: var(--border2);
    transform: scale(1.05);
}
.cal-day.P { 
    background: var(--green); 
    color: white; 
    border-color: var(--green); 
}
.cal-day.A { 
    background: var(--red); 
    color: white; 
    border-color: var(--red); 
}
.cal-day.T { 
    background: var(--amber); 
    color: white; 
    border-color: var(--amber); 
}
.cal-day.vacio { 
    border: none; 
    cursor: default;
    background: transparent;
}
.cal-day:disabled { 
    opacity: 0.3; 
    cursor: not-allowed;
    background: var(--surface2);
}

/* GRID DE TARJETAS */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}
.card-item {
    background: white;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 24px;
    transition: all 0.2s;
}
.card-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--border2);
}
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}
.card-title {
    font-weight: 700;
    font-size: 16px;
    color: var(--text);
}
.card-subtitle {
    font-size: 13px;
    color: var(--text3);
    margin-top: 4px;
}
.card-body {
    font-size: 13px;
    color: var(--text2);
    line-height: 1.6;
}
.card-footer {
    display: flex;
    gap: 8px;
    margin-top: 20px;
    flex-wrap: wrap;
}

/* MODALES MODERNOS */
.modal-overlay { 
    position: fixed; 
    inset: 0; 
    background: rgba(0,0,0,0.4); 
    backdrop-filter: blur(4px); 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    z-index: 1000;
    padding: 20px;
}
.modal { 
    background: white; 
    padding: 32px; 
    border-radius: var(--radius-lg); 
    width: 520px; 
    max-width: 90vw; 
    max-height: 85vh; 
    overflow-y: auto; 
    box-shadow: var(--shadow-lg);
}
.modal-header { 
    margin-bottom: 24px; 
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
.modal-title { 
    font-size: 20px; 
    font-weight: 700;
    margin-bottom: 4px;
}
.modal-subtitle {
    font-size: 13px;
    color: var(--text3);
}
.modal-footer { 
    margin-top: 24px; 
    display: flex; 
    justify-content: flex-end; 
    gap: 12px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

/* FORMULARIOS EN MODALES */
.form-group {
    margin-bottom: 20px;
}
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.form-control-full {
    width: 100%;
}

/* LOGIN SCREEN */
.login-screen { 
    background: var(--bg) !important;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}
.login-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 400px;
    max-width: 90vw;
    box-shadow: var(--shadow-lg);
    text-align: center;
}
.login-logo {
    width: 56px;
    height: 56px;
    background: var(--text);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    color: white;
    font-weight: 700;
    font-size: 20px;
}
.login-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
}
.login-subtitle {
    color: var(--text3);
    font-size: 14px;
    margin-bottom: 32px;
}
.login-error {
    background: var(--red-bg);
    color: var(--red);
    border: 1px solid var(--red-t);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 20px;
    font-size: 13px;
}

/* UTILIDADES */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text3); }
.font-mono { font-family: 'DM Mono', monospace; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-5 { margin-bottom: 20px; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }

.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }

.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* ROL BADGES */
.role-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    font-family: 'DM Mono', monospace;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.role-admin {
    background: var(--text);
    color: white;
}
.role-docente {
    background: var(--green-bg);
    color: var(--green);
}
.role-lectura {
    background: var(--amber-bg);
    color: var(--amber);
}

/* NOTAS BADGES */
.nota-badge {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    font-family: 'DM Mono', monospace;
    min-width: 36px;
    text-align: center;
    display: inline-block;
}
.nota-b {
    background: var(--green-bg);
    color: var(--green);
}
.nota-m {
    background: var(--amber-bg);
    color: var(--amber);
}
.nota-r {
    background: var(--red-bg);
    color: var(--red);
}
.nota-empty {
    background: var(--surface2);
    color: var(--text3);
}

/* ANIMACIONES */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-fade-in {
    animation: fadeIn 0.3s ease-out;
}

/* SCROLLBAR MODERNO */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--surface2);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--border2);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text3);
}

/* OCULTAR ELEMENTOS */
[x-cloak] { 
    display: none !important; 
}
