/* =====================================================================
   Sistema de Control y Gestión de Alumnado — hoja de estilos principal
   Los colores institucionales se inyectan como variables CSS.
   ===================================================================== */

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    background: #f1f4f9;
    color: #1f2937;
    font-size: .9rem;
}

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

/* ------------------------------- Sidebar ------------------------------ */
.app-sidebar {
    width: 264px;
    flex: 0 0 264px;
    background: var(--color-sidebar);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    transition: margin-left .25s ease;
    z-index: 1040;
}
.app-sidebar::-webkit-scrollbar { width: 6px; }
.app-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.18); border-radius: 3px; }

body.sidebar-collapsed .app-sidebar { margin-left: -264px; }

.sidebar-brand {
    display: flex; align-items: center; gap: .7rem;
    padding: 1rem .95rem;
    border-bottom: 1px solid rgba(255,255,255,.09);
    background: rgba(0,0,0,.16);
}
.brand-logo {
    width: 40px; height: 40px; border-radius: 9px;
    object-fit: contain; background: #fff; padding: 3px; flex: 0 0 40px;
}
.brand-logo-text {
    display: grid; place-items: center;
    background: var(--color-primario); color: #fff; font-size: 1.25rem;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-text strong { color: #fff; font-size: .82rem; }
.brand-text small { color: #94a3b8; font-size: .68rem; }

.sidebar-nav { padding: .55rem 0 2rem; flex: 1; }

.nav-link-item, .nav-group-toggle {
    display: flex; align-items: center; gap: .65rem;
    width: 100%; border: 0; background: none; text-align: left;
    padding: .58rem .95rem;
    color: #cbd5e1; text-decoration: none;
    font-size: .82rem; font-weight: 500;
    border-left: 3px solid transparent;
    transition: background .15s, color .15s;
}
.nav-link-item:hover, .nav-group-toggle:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-link-item.active, .nav-group-toggle.active {
    background: rgba(255,255,255,.11);
    color: #fff;
    border-left-color: var(--color-primario);
}
.nav-link-item i, .nav-group-toggle i { font-size: .95rem; width: 18px; text-align: center; }
.nav-group-toggle .chev { font-size: .7rem; transition: transform .2s; }
.nav-group-toggle[aria-expanded="true"] .chev { transform: rotate(180deg); }

.nav-sub { padding: .15rem 0 .35rem; background: rgba(0,0,0,.16); }
.nav-sub-link {
    display: block;
    padding: .42rem .95rem .42rem 2.5rem;
    color: #94a3b8; text-decoration: none; font-size: .78rem;
    border-left: 3px solid transparent;
}
.nav-sub-link:hover { color: #fff; background: rgba(255,255,255,.05); }
.nav-sub-link.active { color: #fff; border-left-color: var(--color-primario); font-weight: 600; }

/* ------------------------------- Header ------------------------------- */
.app-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.app-header {
    display: flex; align-items: center; gap: .85rem;
    background: var(--color-header);
    color: #fff;
    padding: .6rem 1rem;
    position: sticky; top: 0; z-index: 1030;
    box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.btn-header-toggle {
    background: rgba(255,255,255,.14); border: 0; color: #fff;
    width: 34px; height: 34px; border-radius: 8px; font-size: 1.15rem;
}
.btn-header-toggle:hover { background: rgba(255,255,255,.26); color: #fff; }
.header-title { font-size: .98rem; font-weight: 600; margin: 0; }

.header-right { margin-left: auto; display: flex; align-items: center; gap: .9rem; }
.header-institution { font-size: .76rem; opacity: .82; }

.btn-user {
    display: flex; align-items: center; gap: .55rem;
    background: rgba(255,255,255,.12); border: 0; color: #fff;
    padding: .28rem .6rem .28rem .28rem; border-radius: 30px;
}
.btn-user:hover, .btn-user:focus { background: rgba(255,255,255,.24); color: #fff; }
.user-avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--color-primario); color: #fff;
    display: grid; place-items: center; font-weight: 700; font-size: .82rem;
}
.user-meta { flex-direction: column; line-height: 1.12; text-align: left; }
.user-meta strong { font-size: .78rem; font-weight: 600; }
.user-meta small { font-size: .66rem; opacity: .8; }

/* ------------------------------ Contenido ----------------------------- */
.app-content { padding: 1.1rem 1.2rem; flex: 1; }

.app-footer {
    background: var(--color-footer); color: #cbd5e1;
    padding: .6rem 1.2rem; font-size: .72rem;
    display: flex; align-items: center;
}

/* -------------------------------- Cards ------------------------------- */
.card { border: 1px solid #e3e8ef; border-radius: 11px; box-shadow: 0 1px 3px rgba(16,24,40,.05); }
.card-header {
    background: #fff; border-bottom: 1px solid #eef1f6;
    font-weight: 600; font-size: .85rem; padding: .7rem .95rem;
    display: flex; align-items: center; gap: .5rem;
}
.card-body { padding: .95rem; }

.stat-card { border-radius: 11px; color: #fff; padding: .95rem; height: 100%; }
.stat-card .stat-icon { font-size: 1.9rem; opacity: .3; }
.stat-card .stat-valor { font-size: 1.55rem; font-weight: 700; line-height: 1.1; }
.stat-card .stat-etiqueta { font-size: .74rem; opacity: .92; text-transform: uppercase; letter-spacing: .4px; }

.bg-grad-1 { background: linear-gradient(135deg,#1f6feb,#4f9bff); }
.bg-grad-2 { background: linear-gradient(135deg,#0f9d58,#43c98a); }
.bg-grad-3 { background: linear-gradient(135deg,#e8a33d,#f4c56b); }
.bg-grad-4 { background: linear-gradient(135deg,#d9534f,#ef7b78); }
.bg-grad-5 { background: linear-gradient(135deg,#6f42c1,#9a76d8); }
.bg-grad-6 { background: linear-gradient(135deg,#0d3b66,#2f6fa8); }

/* -------------------------------- Tablas ------------------------------ */
.table { font-size: .81rem; margin-bottom: 0; }
.table > thead > tr > th {
    background: #f7f9fc; font-weight: 600; font-size: .72rem;
    text-transform: uppercase; letter-spacing: .35px; color: #5b6b7f;
    border-bottom: 1px solid #e3e8ef; white-space: nowrap;
}
.table > tbody > tr > td { vertical-align: middle; }
.table-hover > tbody > tr:hover > * { background: #f4f8ff; }

.table-acciones { white-space: nowrap; }
.table-acciones .btn { padding: .18rem .42rem; font-size: .74rem; }

/* ------------------------------- Forms -------------------------------- */
.form-label { font-size: .76rem; font-weight: 600; color: #43536b; margin-bottom: .22rem; }
.form-control, .form-select { font-size: .82rem; border-color: #d7dee9; }
.form-control:focus, .form-select:focus {
    border-color: var(--color-primario);
    box-shadow: 0 0 0 .18rem color-mix(in srgb, var(--color-primario) 18%, transparent);
}
.form-control-sm, .form-select-sm { font-size: .78rem; }
.required::after { content: " *"; color: #d9534f; }

/* ------------------------------- Botones ------------------------------ */
.btn { font-size: .8rem; border-radius: 8px; }
.btn-sm { font-size: .75rem; padding: .28rem .6rem; }
.btn-primary { background: var(--color-primario); border-color: var(--color-primario); }
.btn-primary:hover, .btn-primary:focus {
    background: color-mix(in srgb, var(--color-primario) 84%, #000);
    border-color: color-mix(in srgb, var(--color-primario) 84%, #000);
}
.btn-icon { display: inline-flex; align-items: center; gap: .35rem; }

/* ------------------------------ Secciones ----------------------------- */
.page-head {
    display: flex; align-items: center; flex-wrap: wrap; gap: .6rem;
    margin-bottom: .9rem;
}
.page-head h2 { font-size: 1.06rem; font-weight: 700; margin: 0; }
.page-head .page-sub { font-size: .76rem; color: #6b7c93; }
.page-head .ms-auto { display: flex; gap: .45rem; flex-wrap: wrap; }

.empty-state { text-align: center; padding: 2.4rem 1rem; color: #8697ab; }
.empty-state i { font-size: 2.6rem; opacity: .4; display: block; margin-bottom: .6rem; }

/* -------------------------------- Login ------------------------------- */
.login-page {
    min-height: 100vh; display: grid; place-items: center; padding: 1.5rem;
    background: linear-gradient(135deg, var(--color-header), var(--color-sidebar));
}
.login-card {
    width: 100%; max-width: 415px; background: #fff;
    border-radius: 15px; box-shadow: 0 18px 45px rgba(0,0,0,.28);
    overflow: hidden;
}
.login-head { padding: 1.6rem 1.5rem 1.1rem; text-align: center; }
.login-head img { max-height: 74px; margin-bottom: .65rem; }
.login-head h1 { font-size: 1.06rem; font-weight: 700; margin: 0; color: #12263a; }
.login-head p { font-size: .76rem; color: #75879d; margin: .2rem 0 0; }
.login-body { padding: .5rem 1.5rem 1.5rem; }
.login-foot { background: #f7f9fc; padding: .7rem; text-align: center; font-size: .7rem; color: #8697ab; }

/* ------------------------------- Utilidades --------------------------- */
.chip {
    display: inline-block; padding: .12rem .5rem; border-radius: 20px;
    font-size: .68rem; font-weight: 600; background: #eef2f8; color: #4a5a70;
}
.text-mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .78rem; }
.avatar-circle {
    width: 34px; height: 34px; border-radius: 50%; background: var(--color-primario);
    color: #fff; display: inline-grid; place-items: center; font-weight: 700; font-size: .8rem;
}
.divider-soft { height: 1px; background: #eef1f6; margin: .8rem 0; }

/* Calificaciones */
.calif-input { width: 76px; text-align: center; font-weight: 600; }
.calif-aprobada { color: #0f9d58; font-weight: 700; }
.calif-reprobada { color: #d9534f; font-weight: 700; }

/* Impresión */
@media print {
    .app-sidebar, .app-header, .app-footer, .no-print, .page-head .ms-auto { display: none !important; }
    .app-content { padding: 0; }
    body { background: #fff; }
    .card { border: 0; box-shadow: none; }
}

/* Responsivo */
@media (max-width: 991.98px) {
    .app-sidebar { position: fixed; margin-left: -264px; }
    body.sidebar-open .app-sidebar { margin-left: 0; box-shadow: 0 0 30px rgba(0,0,0,.45); }
}
