/* ══════════════════════════════════════════════
   Colegio App — Soft Bubble UI
   Inspirado en macOS / iOS — bordes redondeados,
   sombras suaves, sidebar claro, mucho aire.
   ══════════════════════════════════════════════ */

/* ── Pills de riesgo por periodo (dashboard) ── */
.rb-pill {
    display: inline-block;
    min-width: 44px;
    padding: 3px 9px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
}
.rb-pill.rb-strong { font-weight: 800; }
.rb-ok   { background: #d1fae5; color: #065f46; }
.rb-warn { background: #fef3c7; color: #92400e; }
.rb-bad  { background: #fee2e2; color: #991b1b; }
.rb-none { background: #f1f5f9; color: #94a3b8; font-weight: 400; }
[data-theme="dark"] .rb-ok   { background: rgba(16, 185, 129, 0.18); color: #6ee7b7; }
[data-theme="dark"] .rb-warn { background: rgba(245, 158, 11, 0.18); color: #fcd34d; }
[data-theme="dark"] .rb-bad  { background: rgba(239, 68, 68, 0.18);  color: #fca5a5; }
[data-theme="dark"] .rb-none { background: rgba(255, 255, 255, 0.05); color: var(--text-faint); }
.risk-table th { white-space: nowrap; }
.rb-low {
    margin-top: 2px;
    font-size: 0.68rem;
    font-weight: 700;
    color: #b91c1c;
    line-height: 1;
}
[data-theme="dark"] .rb-low { color: #fca5a5; }

:root {
    --sidebar-width: 260px;
    --sidebar-bg: #1c1d20;
    --sidebar-text: #a8a9ad;
    --sidebar-text-strong: #f4f4f5;
    --sidebar-border: rgba(255, 255, 255, 0.06);
    --sidebar-hover-bg: rgba(255, 255, 255, 0.05);
    --sidebar-active-bg: rgba(255, 255, 255, 0.07);
    --sidebar-active-fg: #ffffff;
    --sidebar-heading-fg: #6b6c70;
    --topbar-height: 64px;

    --bg: #fafafa;
    --surface: #ffffff;
    --surface-muted: #f4f4f5;

    --text: #09090b;
    --text-muted: #71717a;
    --text-faint: #a1a1aa;

    --border-soft: rgba(9, 9, 11, 0.07);
    --border-strong: rgba(9, 9, 11, 0.1);

    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --accent: #6366f1;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;

    --radius-sm: 0.6rem;
    --radius-md: 1rem;
    --radius-lg: 1.25rem;
    --radius-xl: 1.5rem;

    --shadow-sm: 0 1px 2px rgba(9, 9, 11, 0.04);
    --shadow-md: 0 1px 2px rgba(9, 9, 11, 0.04),
                 0 8px 24px -8px rgba(9, 9, 11, 0.08);
    --shadow-lg: 0 4px 12px -2px rgba(9, 9, 11, 0.06),
                 0 24px 48px -16px rgba(9, 9, 11, 0.14);

    --topbar-bg: rgba(250, 250, 250, 0.8);
    --header-grad-1: #1c1d20;
    --header-grad-2: #0b0d10;
}

/* ── Dark mode ── */
[data-theme="dark"] {
    --bg: #0b0d10;
    --surface: #18191c;
    --surface-muted: #1c1d20;

    --text: #fafafa;
    --text-muted: #a1a1aa;
    --text-faint: #71717a;

    --border-soft: rgba(255, 255, 255, 0.07);
    --border-strong: rgba(255, 255, 255, 0.12);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 1px 2px rgba(0, 0, 0, 0.4),
                 0 8px 24px -8px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 4px 12px -2px rgba(0, 0, 0, 0.5),
                 0 24px 48px -16px rgba(0, 0, 0, 0.7);

    --sidebar-bg: #0e0f12;
    --topbar-bg: rgba(14, 15, 18, 0.85);
    --header-grad-1: #0b0d10;
    --header-grad-2: #050608;

    color-scheme: dark;
}

/* Bootstrap overrides for dark mode */
[data-theme="dark"] .card,
[data-theme="dark"] .modal-content {
    background: var(--surface);
    color: var(--text);
}
[data-theme="dark"] .table {
    color: var(--text);
    --bs-table-bg: transparent;
}
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
    background: var(--surface-muted);
    color: var(--text);
    border-color: var(--border-soft);
}
[data-theme="dark"] .form-control::placeholder { color: var(--text-faint); }
[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
    background: var(--surface-muted);
    color: var(--text);
}
[data-theme="dark"] .btn-outline-secondary {
    color: var(--text-muted);
    border-color: var(--border-strong);
    background: transparent;
}
[data-theme="dark"] .btn-outline-secondary:hover {
    background: var(--surface-muted);
    color: var(--text);
    border-color: var(--border-strong);
}
[data-theme="dark"] .btn-close {
    filter: invert(1) grayscale(100%) brightness(2);
}
[data-theme="dark"] hr { border-color: var(--border-soft); }
[data-theme="dark"] .text-muted { color: var(--text-muted) !important; }

/* Badges de notas e inasistencias: overrides para dark mode.
   Los templates definen los colores light hardcodeados; acá los
   reescribimos cuando el tema es oscuro para mantener legibilidad. */
[data-theme="dark"] .grade-high,
[data-theme="dark"] .abs-low {
    background: rgba(16, 185, 129, 0.18);
    color: #6ee7b7;
}
[data-theme="dark"] .grade-mid,
[data-theme="dark"] .abs-mid {
    background: rgba(245, 158, 11, 0.18);
    color: #fcd34d;
}
[data-theme="dark"] .grade-low,
[data-theme="dark"] .abs-high {
    background: rgba(239, 68, 68, 0.18);
    color: #fca5a5;
}
[data-theme="dark"] .grade-none,
[data-theme="dark"] .abs-none {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-faint);
}

/* Celdas de tabla de notas con fondos hardcodeados (student-cell,
   grade-cell, headers inline en assignment_list, etc.) */
[data-theme="dark"] .student-cell,
[data-theme="dark"] .grade-cell {
    background: var(--surface-muted) !important;
    color: var(--text) !important;
}

/* Filas de tablas con styles inline tipo background:#f8f9fa */
[data-theme="dark"] [style*="background:#f8f9fa"],
[data-theme="dark"] [style*="background: #f8f9fa"],
[data-theme="dark"] [style*="background:#f0f4ff"],
[data-theme="dark"] [style*="background: #f0f4ff"],
[data-theme="dark"] [style*="background:#fafafa"],
[data-theme="dark"] [style*="background:#f8fafc"] {
    background: var(--surface-muted) !important;
    color: var(--text) !important;
}

/* Bootstrap bg-* utilities en dark mode */
[data-theme="dark"] .bg-white,
[data-theme="dark"] .bg-light {
    background-color: var(--surface) !important;
    color: var(--text) !important;
}

/* Card transparente del card-header (queda translúcido pero coherente) */
[data-theme="dark"] .card-header.bg-transparent { color: var(--text); }

/* Bootstrap utilities que asumen fondo claro */
[data-theme="dark"] .text-dark { color: var(--text) !important; }
[data-theme="dark"] .table-light,
[data-theme="dark"] .table-light > th,
[data-theme="dark"] .table-light > td,
[data-theme="dark"] thead.table-light {
    background-color: var(--surface-muted) !important;
    color: var(--text) !important;
    border-color: var(--border-soft) !important;
}

/* Borders inline hardcodeados que se pierden en dark */
[data-theme="dark"] [style*="border-bottom:1px solid #dee2e6"],
[data-theme="dark"] [style*="border-bottom: 1px solid #dee2e6"],
[data-theme="dark"] [style*="border-top: 2px solid #ced4da"],
[data-theme="dark"] [style*="border-top:2px solid #ced4da"] {
    border-color: var(--border-soft) !important;
}

/* Bootstrap accordion: respeta el tema */
[data-theme="dark"] .accordion-item {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border-soft);
}
[data-theme="dark"] .accordion-button {
    background: var(--surface);
    color: var(--text);
}
[data-theme="dark"] .accordion-button:not(.collapsed) {
    background: var(--surface-muted);
    color: var(--text);
    box-shadow: inset 0 -1px 0 var(--border-soft);
}
[data-theme="dark"] .accordion-button::after {
    filter: invert(1) grayscale(100%) brightness(1.5);
}
[data-theme="dark"] .accordion-body { background: var(--surface); }

/* Badges Bootstrap con combinaciones light en dark */
[data-theme="dark"] .badge.bg-light.text-dark,
[data-theme="dark"] .badge.bg-info.text-dark {
    background: var(--surface-muted) !important;
    color: var(--text) !important;
    border-color: var(--border-soft) !important;
}
[data-theme="dark"] .badge.bg-secondary {
    background: rgba(255, 255, 255, 0.12) !important;
    color: var(--text) !important;
}

/* Botones outline-secondary y -primary en hover/normal */
[data-theme="dark"] .btn-outline-primary {
    color: #93c5fd;
    border-color: rgba(147, 197, 253, 0.4);
}
[data-theme="dark"] .btn-outline-primary:hover {
    background: rgba(147, 197, 253, 0.12);
    color: #dbeafe;
    border-color: rgba(147, 197, 253, 0.6);
}

/* Override de variables Bootstrap para que TODOS los componentes
   nativos (tables, accordions, dropdowns, modals, list-groups)
   respeten el tema sin necesidad de envolverlos en .table-card. */
[data-theme="dark"] {
    --bs-body-bg: var(--bg);
    --bs-body-color: var(--text);
    --bs-border-color: var(--border-soft);
    --bs-border-color-translucent: var(--border-soft);

    --bs-table-bg: transparent;
    --bs-table-color: var(--text);
    --bs-table-border-color: var(--border-soft);
    --bs-table-striped-bg: rgba(255, 255, 255, 0.02);
    --bs-table-hover-bg: rgba(255, 255, 255, 0.04);
    --bs-table-hover-color: var(--text);

    --bs-accordion-bg: var(--surface);
    --bs-accordion-color: var(--text);
    --bs-accordion-border-color: var(--border-soft);
    --bs-accordion-active-bg: var(--surface-muted);
    --bs-accordion-active-color: var(--text);
    --bs-accordion-btn-bg: var(--surface);
    --bs-accordion-btn-color: var(--text);

    --bs-card-bg: var(--surface);
    --bs-card-color: var(--text);
    --bs-card-border-color: var(--border-soft);
    --bs-card-cap-bg: transparent;

    --bs-list-group-bg: var(--surface);
    --bs-list-group-color: var(--text);
    --bs-list-group-border-color: var(--border-soft);

    --bs-dropdown-bg: var(--surface);
    --bs-dropdown-color: var(--text);
    --bs-dropdown-border-color: var(--border-soft);
    --bs-dropdown-link-color: var(--text);
    --bs-dropdown-link-hover-bg: var(--surface-muted);
    --bs-dropdown-link-hover-color: var(--text);

    --bs-modal-bg: var(--surface);
    --bs-modal-color: var(--text);
    --bs-modal-border-color: var(--border-soft);

    --bs-input-bg: var(--surface-muted);
    --bs-input-color: var(--text);
    --bs-input-border-color: var(--border-soft);

    --bs-emphasis-color: var(--text);
    --bs-secondary-color: var(--text-muted);
    --bs-tertiary-color: var(--text-faint);
    --bs-link-color: #93c5fd;
    --bs-link-hover-color: #bfdbfe;
}

/* Asegura que los <td> y <th> sueltos (sin .table-card) usen el color
   del texto del tema, no el gris por defecto del navegador. */
[data-theme="dark"] .table {
    color: var(--text);
}
[data-theme="dark"] .table > :not(caption) > * > * {
    background-color: transparent;
    color: var(--text);
    border-color: var(--border-soft);
}
[data-theme="dark"] .table-hover > tbody > tr:hover > * {
    background-color: rgba(255, 255, 255, 0.04);
    color: var(--text);
}

/* Texto secundario un poco más claro para no quedar invisible */
[data-theme="dark"] {
    --text-muted: #b4b4ba;
}

/* Alerts en dark con tinte translúcido */
[data-theme="dark"] .alert-info {
    background: rgba(59, 130, 246, 0.12);
    color: #93c5fd;
}
[data-theme="dark"] .alert-warning {
    background: rgba(245, 158, 11, 0.12);
    color: #fcd34d;
}
[data-theme="dark"] .alert-danger {
    background: rgba(239, 68, 68, 0.12);
    color: #fca5a5;
}
[data-theme="dark"] .alert-success {
    background: rgba(16, 185, 129, 0.12);
    color: #6ee7b7;
}

/* ── Layout ── */
* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--bg);
    color: var(--text);
    letter-spacing: -0.01em;
}

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

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-width);
    background:
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.06), transparent 40%),
        var(--sidebar-bg);
    color: var(--sidebar-text);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1040;
    overflow-y: auto;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0.75rem;
    border-right: 1px solid rgba(255, 255, 255, 0.04);
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 10px;
}

.sidebar-brand {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 0.75rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--sidebar-text-strong);
    text-decoration: none;
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
}

.sidebar-brand:hover {
    color: var(--sidebar-text-strong);
}

.sidebar-brand i {
    font-size: 1.1rem;
    margin-right: 0.65rem;
    color: var(--sidebar-text-strong);
    background: linear-gradient(135deg, #6366f1, #2563eb);
    width: 32px;
    height: 32px;
    border-radius: 0.55rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px -2px rgba(99, 102, 241, 0.5);
}

/* Logo del colegio en el sidebar (imagen subida) */
.sidebar-brand {
    gap: 0.7rem;
}
.sidebar-brand-img {
    width: 44px;
    height: 44px;
    border-radius: 0.7rem;
    object-fit: contain;
    background: #fff;
    padding: 3px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px -2px rgba(0, 0, 0, 0.25);
}
.sidebar-brand-fallback { display: none; }
.sidebar-brand-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.15;
}

/* Logo del colegio en el login — caja blanca con padding generoso
   alrededor del PNG para que no se vea como un "parche" sobre el card. */
.login-card .login-icon {
    width: 130px;
    height: 130px;
    background: #fff !important;
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.6) inset,
        0 8px 24px -4px rgba(0, 0, 0, 0.12),
        0 2px 6px -2px rgba(0, 0, 0, 0.08) !important;
    border-radius: 1.5rem;
    margin: 0 auto 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px;
}
.login-logo-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.login-logo-fallback { display: none; }

.sidebar-nav {
    padding: 0;
}

.sidebar-heading {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--sidebar-heading-fg);
    padding: 1.1rem 0.75rem 0.4rem;
    font-weight: 600;
}

.sidebar-link {
    display: flex;
    align-items: center;
    padding: 0.4rem 0.6rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.86rem;
    font-weight: 500;
    transition: all 0.2s ease;
    border-radius: 0.7rem;
    margin-bottom: 2px;
    letter-spacing: -0.005em;
    position: relative;
}

.sidebar-link:hover {
    color: var(--sidebar-text-strong);
}

/* ── Liquid glass icon pill (all items) ── */
.sidebar-link i {
    width: 30px;
    height: 30px;
    margin-right: 0.65rem;
    font-size: 0.88rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.55rem;
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.06) 0%,
        rgba(255, 255, 255, 0.02) 100%
    );
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.08),
        inset 0 -1px 0 rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: all 0.2s ease;
    opacity: 0.9;
}

.sidebar-link:hover i {
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.12) 0%,
        rgba(255, 255, 255, 0.04) 100%
    );
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.14),
        inset 0 -1px 0 rgba(0, 0, 0, 0.2);
    opacity: 1;
}

/* ── Active item: full liquid glass bubble ── */
.sidebar-link.active {
    color: var(--sidebar-active-fg);
    font-weight: 600;
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.1) 0%,
        rgba(255, 255, 255, 0.04) 100%
    );
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.14),
        inset 0 -1px 0 rgba(0, 0, 0, 0.25),
        0 4px 16px -4px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.sidebar-link.active i {
    background: linear-gradient(
        135deg,
        rgba(99, 102, 241, 0.4) 0%,
        rgba(37, 99, 235, 0.25) 100%
    );
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.25),
        inset 0 -1px 0 rgba(0, 0, 0, 0.2),
        0 2px 8px -2px rgba(99, 102, 241, 0.4);
    opacity: 1;
    color: #fff;
}

/* ── Main content ── */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ── Topbar ── */
.topbar {
    height: var(--topbar-height);
    background: var(--topbar-bg);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.75rem;
    position: sticky;
    top: 0;
    z-index: 1030;
    border-bottom: 1px solid var(--border-soft);
}

/* ── Theme toggle button ── */
.theme-toggle {
    width: 36px;
    height: 36px;
    border-radius: 999px;
    border: 1px solid var(--border-soft);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    transition: all 0.15s ease;
}
.theme-toggle:hover {
    color: var(--text);
    border-color: var(--border-strong);
    box-shadow: var(--shadow-sm);
}
.theme-toggle .theme-icon-light { display: none; }
.theme-toggle .theme-icon-dark { display: inline; }
[data-theme="dark"] .theme-toggle .theme-icon-light { display: inline; }
[data-theme="dark"] .theme-toggle .theme-icon-dark { display: none; }

.topbar .btn-toggle-sidebar {
    display: none;
    border: none;
    background: none;
    font-size: 1.3rem;
    color: var(--text-muted);
    cursor: pointer;
}

/* ── Content area ── */
.content-area {
    padding: 1.75rem;
    flex: 1;
}

/* ── Cards / Surfaces ── */
.card {
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    background: var(--surface);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-soft);
    padding: 1rem 1.25rem;
    font-weight: 600;
}

.stat-card {
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    background: var(--surface);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg,
        transparent,
        rgba(255, 255, 255, 0.8),
        transparent
    );
    opacity: 0;
    transition: opacity 0.25s ease;
}

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

.stat-card:hover::before {
    opacity: 1;
}

.stat-card .stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    position: relative;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.stat-card:hover .stat-icon {
    transform: scale(1.05);
    transition: transform 0.25s ease;
}

.stat-card .stat-value {
    font-size: 1.95rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.03em;
    line-height: 1.1;
}

.stat-card .stat-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    margin-top: 0.25rem;
}

/* ── Page header ── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.page-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    margin: 0;
    letter-spacing: -0.025em;
}

/* ── Tables ── */
.table-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.table-card .table {
    margin-bottom: 0;
}

.table-card .table thead {
    position: sticky;
    top: 0;
    z-index: 2;
}

.table-card .table thead th {
    background: var(--surface-muted);
    border-bottom: 1px solid var(--border-soft);
    border-top: none;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    font-weight: 600;
    padding: 0.95rem 1.15rem;
    white-space: nowrap;
}

.table-card .table tbody td {
    padding: 0.95rem 1.15rem;
    vertical-align: middle;
    font-size: 0.9rem;
    color: var(--text);
    border-bottom: 1px solid var(--border-soft);
    position: relative;
}

.table-card .table tbody tr:last-child td {
    border-bottom: none;
}

.table-card .table tbody tr {
    transition: background 0.15s ease;
}

.table-card .table tbody tr:hover {
    background: linear-gradient(
        90deg,
        rgba(99, 102, 241, 0.03),
        rgba(59, 130, 246, 0.05) 50%,
        transparent
    );
}

.table-card .table tbody tr:hover td:first-child::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    background: linear-gradient(180deg, var(--accent), var(--primary));
    border-radius: 0 3px 3px 0;
}

/* ── Buttons ── */
.btn {
    border-radius: 0.7rem;
    font-weight: 500;
    padding: 0.45rem 1rem;
    transition: all 0.15s ease;
    letter-spacing: -0.005em;
}

.btn-sm {
    border-radius: 0.55rem;
    padding: 0.3rem 0.7rem;
    font-size: 0.825rem;
}

.btn-primary {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    border-color: transparent;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.2),
        0 1px 2px rgba(37, 99, 235, 0.2),
        0 4px 12px -2px rgba(37, 99, 235, 0.25);
    position: relative;
    overflow: hidden;
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent
    );
    transition: left 0.6s ease;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    border-color: transparent;
    transform: translateY(-1px);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.25),
        0 4px 16px -2px rgba(37, 99, 235, 0.4);
}

.btn-primary:hover::before {
    left: 100%;
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-outline-secondary {
    border-color: var(--border-soft);
    color: var(--text-muted);
    background: var(--surface);
}

.btn-outline-secondary:hover {
    background: var(--surface-muted);
    color: var(--text);
    border-color: var(--border-soft);
}

/* ── Badges ── */
.badge {
    border-radius: 999px;
    padding: 0.3em 0.7em;
    font-weight: 600;
    font-size: 0.72rem;
    letter-spacing: 0.01em;
}

.badge-active {
    background-color: rgba(16, 185, 129, 0.12);
    color: #047857;
}

.badge-inactive {
    background-color: rgba(239, 68, 68, 0.1);
    color: #b91c1c;
}

.badge-closed {
    background-color: rgba(15, 23, 42, 0.08);
    color: var(--text-muted);
}

.badge-graduated {
    background-color: rgba(59, 130, 246, 0.12);
    color: #1d4ed8;
}

.badge-promoted {
    background-color: rgba(245, 158, 11, 0.14);
    color: #b45309;
}

/* ── Login ── */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background:
        radial-gradient(circle at 18% 22%, rgba(99, 102, 241, 0.35), transparent 45%),
        radial-gradient(circle at 82% 78%, rgba(236, 72, 153, 0.22), transparent 45%),
        radial-gradient(circle at 50% 100%, rgba(59, 130, 246, 0.28), transparent 55%),
        linear-gradient(135deg, #0b0d10 0%, #1c1d20 100%);
    position: relative;
    overflow: hidden;
}

.login-wrapper::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.04) 1px, transparent 0);
    background-size: 32px 32px;
    pointer-events: none;
}

.login-card {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(40px) saturate(180%);
    -webkit-backdrop-filter: blur(40px) saturate(180%);
    border-radius: var(--radius-xl);
    padding: 2.75rem 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.6),
        0 20px 60px -10px rgba(0, 0, 0, 0.5),
        0 8px 24px -8px rgba(99, 102, 241, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.4);
    position: relative;
    z-index: 1;
}

.login-card h3 {
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.03em;
    font-size: 1.5rem;
}

.login-card .login-icon {
    width: 72px;
    height: 72px;
    background:
        radial-gradient(circle at 30% 30%, #818cf8, #4f46e5 60%);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 2rem;
    margin: 0 auto 1.25rem;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.4),
        inset 0 -2px 4px rgba(0, 0, 0, 0.15),
        0 12px 28px -4px rgba(79, 70, 229, 0.5),
        0 4px 12px -2px rgba(99, 102, 241, 0.4);
    position: relative;
}

.login-card .login-icon::after {
    content: '';
    position: absolute;
    inset: 4px;
    border-radius: calc(var(--radius-lg) - 4px);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.25), transparent 50%);
    pointer-events: none;
}

/* ── Form controls ── */
.form-control,
.form-select {
    border-radius: 0.7rem;
    border-color: var(--border-soft);
    padding: 0.5rem 0.85rem;
    font-size: 0.9rem;
    transition: all 0.15s ease;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.form-label {
    font-weight: 500;
    color: var(--text-muted);
    font-size: 0.825rem;
}

/* ── Grades input ── */
.grade-input {
    width: 80px;
    text-align: center;
    font-weight: 600;
    border-radius: 0.6rem;
}

.grade-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

/* ── Action buttons (icon-only) ── */
.btn-action {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.6rem;
    font-size: 0.85rem;
}

/* ── Empty state ── */
.empty-state {
    text-align: center;
    padding: 3.5rem 1rem;
    color: var(--text-faint);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    display: block;
    color: var(--text-faint);
}

/* ── Alerts ── */
.alert {
    border-radius: var(--radius-md);
    border: none;
    padding: 0.85rem 1.1rem;
    font-size: 0.9rem;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    color: #065f46;
}

.alert-danger,
.alert-error {
    background: rgba(239, 68, 68, 0.1);
    color: #991b1b;
}

.alert-warning {
    background: rgba(245, 158, 11, 0.12);
    color: #92400e;
}

.alert-info {
    background: rgba(59, 130, 246, 0.1);
    color: #1d4ed8;
}

/* ── Modal ── */
.modal-content {
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.modal-confirm .modal-header {
    border-bottom: 0;
    padding-bottom: 0;
}

.modal-confirm .modal-footer {
    border-top: 0;
}

/* ── Responsive ── */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .topbar .btn-toggle-sidebar {
        display: block;
    }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.4);
        backdrop-filter: blur(4px);
        z-index: 1035;
        display: none;
    }

    .sidebar-overlay.show {
        display: block;
    }
}

/* ── Avatar (utility class) ── */
.avatar {
    width: 36px;
    height: 36px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 600;
    font-size: 0.82rem;
    letter-spacing: 0.01em;
    background: linear-gradient(135deg, #6366f1, #2563eb);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.25),
        0 2px 8px -2px rgba(99, 102, 241, 0.4);
    flex-shrink: 0;
    user-select: none;
}

.avatar-sm {
    width: 28px;
    height: 28px;
    font-size: 0.72rem;
}

.avatar-lg {
    width: 48px;
    height: 48px;
    font-size: 1rem;
}

/* Color variants — for visual variety in lists */
.avatar-1 { background: linear-gradient(135deg, #6366f1, #2563eb); }
.avatar-2 { background: linear-gradient(135deg, #10b981, #059669); }
.avatar-3 { background: linear-gradient(135deg, #f59e0b, #d97706); }
.avatar-4 { background: linear-gradient(135deg, #ec4899, #be185d); }
.avatar-5 { background: linear-gradient(135deg, #8b5cf6, #6d28d9); }
.avatar-6 { background: linear-gradient(135deg, #06b6d4, #0e7490); }
.avatar-7 { background: linear-gradient(135deg, #ef4444, #b91c1c); }
.avatar-8 { background: linear-gradient(135deg, #84cc16, #4d7c0f); }

/* ── Topbar enrichment ── */
.topbar-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.topbar-breadcrumb .breadcrumb-sep {
    color: var(--text-faint);
    font-size: 0.75rem;
    opacity: 0.6;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.3rem 0.85rem 0.3rem 0.3rem;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--border-soft);
    transition: all 0.15s ease;
}

.topbar-user:hover {
    box-shadow: var(--shadow-sm);
    border-color: var(--border-strong);
}

.topbar-user .topbar-user-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.1;
}

.topbar-user .topbar-user-role {
    font-size: 0.7rem;
    color: var(--text-muted);
    line-height: 1.1;
}

/* ── Utility ── */
.min-width-0 { min-width: 0; }

/* ══════════════════════════════════════════════
   Responsive — mobile / tablet
   ══════════════════════════════════════════════ */

/* Tablas largas: scroll horizontal con pista visual del borde derecho */
.table-card {
    position: relative;
}
@media (max-width: 768px) {
    .table-card {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .table-card .table {
        min-width: 540px;
    }
    .table-card::after {
        content: '';
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        width: 24px;
        background: linear-gradient(to left, rgba(15, 23, 42, 0.06), transparent);
        pointer-events: none;
        opacity: 0.8;
    }
}

/* Pills de periodo: una columna o min-width chico en mobile */
@media (max-width: 576px) {
    .period-tab {
        flex: 1 0 calc(50% - 0.5rem);
        min-width: 0;
        padding: 0.6rem 0.8rem;
    }
    .period-tab .period-tab-name { font-size: 0.88rem; }
}

/* Hamburguesa: más visible y con target táctil mínimo */
@media (max-width: 991.98px) {
    .topbar .btn-toggle-sidebar {
        width: 40px;
        height: 40px;
        border-radius: 0.6rem;
        background: var(--surface);
        border: 1px solid var(--border-soft);
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-size: 1.2rem;
    }
    .topbar .btn-toggle-sidebar:hover {
        background: var(--surface-muted);
    }
}

/* Page header colapsa a 1 columna en mobile */
@media (max-width: 575.98px) {
    .page-header {
        flex-direction: column;
        align-items: stretch !important;
        gap: 0.7rem;
    }
    .page-header > * { width: 100%; }
    .page-header h2 { font-size: 1.25rem; }
}

/* Topbar: en mobile esconder textos secundarios para no aplastar */
@media (max-width: 575.98px) {
    .topbar {
        padding: 0 0.85rem;
    }
    .topbar-breadcrumb { display: none; }
    .topbar-user {
        padding: 0.25rem;
        border: none;
        background: transparent;
    }
    .topbar-user .topbar-user-name,
    .topbar-user .topbar-user-role { display: none; }
    .theme-toggle { width: 38px; height: 38px; }
}

/* Stat cards: 1 columna real bajo 480px */
@media (max-width: 479.98px) {
    .row > .col-sm-6,
    .row > .col-md-4,
    .row > .col-lg-4 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* Inputs y botones con target táctil mínimo de 40px en mobile */
@media (max-width: 768px) {
    .btn-action {
        width: 38px;
        height: 38px;
    }
}

/* Login: padding más chico en pantalla angosta */
@media (max-width: 479.98px) {
    .login-card {
        padding: 1.75rem 1.4rem;
    }
}
