/* ============================================================
   Xscholar — Design System (admin moderno / soft UI)
   Paleta de marca (logo): morado #5B2A86 · vino #8B1E3F ·
   negro #1A1A1A · blanco #FFFFFF
   ============================================================ */
:root {
    --primary: #5B2A86;       /* morado del logo */
    --primary-hover: #47206A; /* morado más oscuro (hover) */
    --primary-rgb: 91,42,134;
    --accent: #8B1E3F;        /* vino del logo */
    --accent-hover: #6E1731;
    --accent-rgb: 139,30,63;
    /* Degradado de marca morado → vino: elementos destacados */
    --gradient-brand: linear-gradient(135deg, #5B2A86 0%, #8B1E3F 100%);
    --secondary: #6B7280;     /* gris neutro */
    --success: #10B981;       /* estados: activo */
    --danger: #C0392B;        /* estados: eliminar/baja */
    --warning: #E0A106;       /* estados: aviso */
    --info: #7C4DAB;          /* morado claro (cohesivo con la marca) */
    --bg: #F5F3F8;            /* lila muy claro */
    --surface: #FFFFFF;       /* tarjetas */
    --text: #1A1A1A;          /* negro del logo */
    --muted: #6B7280;
    --radius: 14px;
    --shadow: 0 10px 30px rgba(26,26,26,.06);
    --shadow-lg: 0 20px 60px rgba(26,26,26,.12);
    /* Menú lateral: morado grisáceo → carbón (más claro para que lea el texto) */
    --sidebar-bg: linear-gradient(185deg, #3B2A55 0%, #2A2532 62%);
    --sidebar-width: 264px;
    --topbar-height: 68px;

    /* Overrides de Bootstrap */
    --bs-primary: var(--primary);
    --bs-body-bg: var(--bg);
    --bs-body-color: var(--text);
    --bs-border-radius: var(--radius);
    --bs-font-sans-serif: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden; /* nunca scroll horizontal */
}

a { text-decoration: none; }

/* ===================== LAYOUT ===================== */
.app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: #CBD5E1;
    display: flex;
    flex-direction: column;
    transform: translateX(0);
    transition: transform .28s ease;
    z-index: 1045;
}

.app-main {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left .28s ease;
}

.app-content {
    padding: 24px;
    flex: 1 1 auto;
}

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(2,8,23,.5);
    z-index: 1044;
    opacity: 0;
    visibility: hidden;
    transition: opacity .28s ease;
}
.sidebar-backdrop.show { opacity: 1; visibility: visible; }

/* Móvil / tablet: sidebar oculta y deslizable */
@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    .app-sidebar.show { transform: translateX(0); }
    .app-main { margin-left: 0; }
}

/* ===================== SIDEBAR ===================== */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    height: var(--topbar-height);
    padding: 0 22px;
    color: #fff;
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: .2px;
    flex: 0 0 auto;
}
.sidebar-brand .brand-logo {
    width: 38px; height: 38px;
    border-radius: 10px;
    display: grid; place-items: center;
    color: #fff; font-size: 1.1rem;
}
/* Cuando la marca es una imagen (logo Xscholar): sin fondo, imagen contenida. */
.sidebar-brand img.brand-logo {
    background: none;
    object-fit: contain;
}

.sidebar-nav {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 12px 24px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.18) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.28); }

/* ---- Grupo colapsable (acordeón) ---- */
.nav-group { margin-bottom: 2px; }
.nav-group-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: transparent;
    border: 0;
    cursor: pointer;
    color: #B7BECD;
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .9px;
    padding: 14px 14px 8px;
    transition: color .15s;
}
.nav-group-toggle:hover { color: #fff; }
.nav-group-caret {
    font-size: .62rem;
    transition: transform .25s ease;
    opacity: .7;
}
.nav-group.open > .nav-group-toggle .nav-group-caret { transform: rotate(180deg); }

/* Contenido del grupo: oculto por defecto, animado al abrir */
.nav-group-items { display: none; }
.nav-group.open > .nav-group-items { display: block; animation: navGroupIn .22s ease; }
@keyframes navGroupIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---- Enlaces ---- */
.sidebar-nav .nav-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    color: #E4E7EE;
    padding: 10px 14px;
    border-radius: 10px;
    font-weight: 500;
    font-size: .9rem;
    margin-bottom: 2px;
    transition: background .18s, color .18s, padding-left .18s;
}
.sidebar-nav .nav-link i {
    width: 20px;
    text-align: center;
    font-size: .95rem;
    color: #A6ADBE;
    transition: color .18s, transform .18s;
}
.sidebar-nav .nav-link span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-nav .nav-link:hover {
    background: rgba(255,255,255,.10);
    color: #fff;
    padding-left: 18px;
}
.sidebar-nav .nav-link:hover i { color: #fff; }
.sidebar-nav .nav-link.active {
    background: var(--gradient-brand);
    color: #fff;
    box-shadow: 0 8px 20px rgba(var(--primary-rgb),.4);
}
.sidebar-nav .nav-link.active i { color: #fff; }
/* Barra de acento a la izquierda del enlace activo */
.sidebar-nav .nav-link.active::before {
    content: "";
    position: absolute;
    left: -12px;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 22px;
    border-radius: 0 4px 4px 0;
    background: #fff;
}

/* ===================== TOPBAR ===================== */
.app-topbar {
    height: var(--topbar-height);
    background: var(--surface);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1030;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
}
.topbar-toggle {
    border: none;
    background: transparent;
    font-size: 1.25rem;
    color: var(--text);
    width: 42px; height: 42px;
    border-radius: 10px;
}
.topbar-toggle:hover { background: var(--bg); }

.topbar-spacer { flex: 1 1 auto; }

.topbar-select {
    min-width: 140px;
    max-width: 220px;
    border-radius: 10px;
}

.topbar-avatar {
    width: 42px; height: 42px;
    border-radius: 50%;
    background: var(--gradient-brand);
    color: #fff;
    display: grid; place-items: center;
    font-weight: 600;
}

/* ===================== CARDS ===================== */
.card {
    background: var(--surface);
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card .card-header {
    background: transparent;
    border-bottom: 1px solid #EEF2F7;
    padding: 18px 22px;
    font-weight: 600;
    border-radius: var(--radius) var(--radius) 0 0;
}
.card .card-body { padding: 22px; }

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 22px;
}
.page-header h1 { font-size: 1.5rem; font-weight: 700; margin: 0; }

/* Stat cards (dashboard) */
.stat-card { display: flex; align-items: center; gap: 16px; }
.stat-icon {
    width: 56px; height: 56px;
    border-radius: 14px;
    display: grid; place-items: center;
    font-size: 1.4rem; color: #fff;
    flex: 0 0 auto;
}
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: .85rem; }

/* ===================== BOTONES ===================== */
.btn { border-radius: 10px; font-weight: 600; padding: .55rem 1.1rem; display: inline-flex; align-items: center; }
.btn-primary { background: var(--gradient-brand); border-color: var(--primary); }
.btn-primary:hover, .btn-primary:focus, .btn-primary:active {
    background: linear-gradient(135deg, var(--primary-hover) 0%, var(--accent-hover) 100%);
    border-color: var(--primary-hover);
}
.btn-sm { padding: .35rem .7rem; border-radius: 8px; }
.btn-icon { width: 38px; height: 38px; padding: 0; justify-content: center; }

/* ===================== FORMULARIOS ===================== */
.form-label { font-weight: 600; font-size: .85rem; margin-bottom: 6px; color: #334155; }
.form-control, .form-select {
    border-radius: 10px;
    border: 1px solid #E2E8F0;
    padding: .6rem .85rem;
    font-size: .92rem;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb),.18);
}
.input-group-text { border-radius: 10px 0 0 10px; background: var(--bg); border-color: #E2E8F0; }

/* ===================== TABLAS ===================== */
.table { --bs-table-color: var(--text); margin-bottom: 0; }
.table > thead th {
    text-transform: uppercase;
    font-size: .72rem;
    letter-spacing: .5px;
    color: var(--muted);
    border-bottom: 1px solid #EEF2F7;
    font-weight: 700;
    white-space: nowrap;
}
.table > tbody td { vertical-align: middle; border-color: #F1F5F9; padding: .8rem .75rem; }
.table-hover > tbody > tr:hover > * { background: #F8FAFC; }

.badge { font-weight: 600; padding: .4em .7em; border-radius: 8px; }

/* ===================== LOADING OVERLAY ===================== */
#loadingOverlay {
    position: fixed;
    inset: 0;
    background: rgba(241,245,249,.7);
    backdrop-filter: blur(2px);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
}
#loadingOverlay.show { display: flex; }
.spinner-ring {
    width: 54px; height: 54px;
    border: 5px solid #E2E8F0;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===================== TOASTS / ANIM ===================== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ===================== INTEGRACIONES (DataTables / Select2) ===================== */
div.dataTables_wrapper div.dataTables_filter input,
div.dataTables_wrapper div.dataTables_length select {
    border-radius: 10px;
    border: 1px solid #E2E8F0;
    padding: .4rem .7rem;
}
table.dataTable thead th { border-bottom: 1px solid #EEF2F7 !important; }
.page-link { border-radius: 8px !important; margin: 0 2px; border: none; color: var(--primary); }
.page-item.active .page-link { background: var(--primary); }

.select2-container--bootstrap-5 .select2-selection {
    border-radius: 10px !important;
    border-color: #E2E8F0 !important;
    min-height: 42px;
}

/* ===================== UTILIDADES ===================== */
.text-muted-2 { color: var(--muted) !important; }
.cursor-pointer { cursor: pointer; }
img { max-width: 100%; }

/* ===================== FOOTER (QA 2026-09-07) ===================== */
.app-footer {
    margin-top: 32px;
    padding: 22px 4px 8px;
    border-top: 1px solid var(--bs-border-color, #E2E8F0);
}
.app-footer-inner {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 20px;
    align-items: center;
    justify-content: space-between;
}
.app-footer-copy {
    margin: 0;
    color: var(--muted);
    font-size: .88rem;
}
.app-footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    align-items: center;
}
.app-footer-links a {
    color: var(--muted);
    text-decoration: none;
    font-size: .88rem;
    transition: color .2s;
}
.app-footer-links a:hover {
    color: var(--primary);
    text-decoration: underline;
}
.app-footer-sub {
    margin-top: 12px;
    text-align: center;
    color: var(--muted);
    opacity: .8;
}
/* Móvil: apila y centra */
@media (max-width: 575.98px) {
    .app-footer-inner {
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }
    .app-footer-links {
        justify-content: center;
    }
}
