/* ==========================================================================
   css/estilos.css - FPeval
   ========================================================================== */

:root {
    --bg-main: #f8fafc;
    --card-bg: #ffffff;
    --border-color: #cbd5e1;
    --border-soft: #e2e8f0;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-active: #1e40af;
    --purple: #7c3aed;
    --purple-hover: #6d28d9;
    --teal: #0f766e;
    --teal-hover: #0d9488;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --success-bg: #ecfdf5;
    --success-text: #047857;
    --danger-bg: #fff1f2;
    --danger-text: #be123c;
    --col-alumno-width: 210px;
    --max-content-width: 1400px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

html {
    scrollbar-gutter: stable;
    overflow-y: scroll;
}

html, body {
    width: 100%;
    min-height: 100%;
    background-color: var(--bg-main);
    color: var(--text-main);
}

body {
    display: flex;
    flex-direction: column;
}

/* ==========================================================================
   1. PANTALLAS DE LOGIN Y REGISTRO
   ========================================================================== */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    height: 100dvh;
    padding: 0.75rem;
    background-color: var(--bg-main);
    overflow: hidden;
}

.login-card {
    background: var(--card-bg);
    border: 1px solid var(--border-soft);
    border-radius: 1.25rem;
    padding: 1.25rem 1.15rem;
    width: 100%;
    max-width: 370px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05);
}

.login-header {
    text-align: center;
    margin-bottom: 0.9rem;
}

.login-header h1 {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.login-header p {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-top: 0.15rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.form-group {
    margin-bottom: 0.75rem;
}

.form-label {
    display: block;
    font-size: 0.68rem;
    font-weight: 700;
    margin-bottom: 0.2rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.form-input {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border-soft);
    font-size: 0.92rem;
    outline: none;
    transition: all 0.2s;
    background-color: #ffffff;
    color: var(--text-main);
}

.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.alert-error {
    background-color: var(--danger-bg);
    color: var(--danger-text);
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.78rem;
    margin-bottom: 0.75rem;
    text-align: center;
    border: 1px solid #fecdd3;
    font-weight: 500;
}

.alert-exito {
    background-color: var(--success-bg);
    color: var(--success-text);
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.78rem;
    margin-bottom: 0.75rem;
    text-align: center;
    border: 1px solid #a7f3d0;
    font-weight: 500;
}

.campo-oculto-trampa {
    display: none !important;
}

/* ==========================================================================
   2. NAVBAR Y BOTONES DEL MENÚ SUPERIOR (30px CON HOVER)
   ========================================================================== */
.navbar {
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--border-soft);
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    width: 100%;
}

.navbar-container {
    width: 100%;
    max-width: var(--max-content-width);
    margin: 0 auto;
    padding: 0.5rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.brand-box {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-shrink: 0;
}

.brand-icon-fp {
    width: 2.5rem !important;
    height: 2.5rem !important;
    min-width: 2.5rem !important;
    min-height: 2.5rem !important;
    flex-shrink: 0 !important;
    background: linear-gradient(135deg, #2563eb, #059669);
    border-radius: 0.65rem;
    color: #ffffff;
    font-weight: 800;
    font-size: 1.15rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.brand-text-block {
    display: flex;
    flex-direction: column;
}

.brand-title {
    font-size: 1.15rem;
    font-weight: 900;
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.brand-sub {
    font-size: 0.62rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
}

.btn-hamburger {
    display: none;
    background: transparent;
    border: 1px solid var(--border-soft);
    border-radius: 0.45rem;
    padding: 0.35rem 0.55rem;
    cursor: pointer;
    color: var(--text-main);
    font-size: 1.25rem;
    line-height: 1;
    transition: all 0.15s ease;
}

.btn-hamburger:hover {
    background: #f1f5f9;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
}

/* Reglas homogéneas para botones del menú superior */
.btn-nav-topbar {
    height: 30px !important;
    min-height: 30px !important;
    padding: 0 0.75rem !important;
    font-size: 0.78rem !important;
    font-weight: 600 !important;
    border-radius: 0.4rem !important;
    line-height: 30px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    white-space: nowrap !important;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    color: #ffffff;
}

.btn-nav-topbar:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15);
}

.btn-nav-blue {
    background: var(--primary);
}
.btn-nav-blue:hover {
    background: var(--primary-hover);
}

.btn-nav-purple {
    background: var(--purple);
}
.btn-nav-purple:hover {
    background: var(--purple-hover);
}

.btn-nav-teal {
    background: var(--teal);
}
.btn-nav-teal:hover {
    background: var(--teal-hover);
}

.btn-nav-exit {
    color: var(--text-muted) !important;
    background: #ffffff !important;
    border: 1px solid var(--border-soft) !important;
}
.btn-nav-exit:hover {
    background-color: #fee2e2 !important;
    color: #b91c1c !important;
    border-color: #fecdd3 !important;
}

.user-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 28px;
    padding: 0 0.65rem;
    font-size: 0.72rem;
    font-weight: 700;
    border-radius: 9999px;
    background: #e0e7ff;
    color: #4338ca;
    white-space: nowrap;
}

@media (max-width: 768px) {
    .btn-hamburger {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .nav-actions {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background-color: var(--card-bg);
        border-bottom: 2px solid var(--border-color);
        padding: 0.75rem 1.25rem;
        flex-direction: column;
        align-items: center;
        gap: 0.45rem;
        box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
        z-index: 60;
    }

    .nav-actions.open {
        display: flex;
    }

    .nav-actions .user-badge {
        width: auto !important;
        margin-bottom: 0.25rem;
    }

    .nav-actions .btn-nav-topbar {
        width: 100% !important;
        max-width: 220px !important;
        height: 34px !important;
        font-size: 0.8rem !important;
    }
}

/* ==========================================================================
   3. BOTONES DE ACCIÓN DE PÁGINA (38px CON HOVER ELEGANTE)
   ========================================================================== */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 1.1rem;
    height: 38px;
    background: var(--primary);
    color: #ffffff;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: all 0.15s ease;
    white-space: nowrap;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 3px 6px rgba(37, 99, 235, 0.25);
}

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

/* Botones Exportar CSV y PDF junto al selector */
.btn-export-inline {
    height: 38px !important;
    padding: 0 0.85rem !important;
    font-size: 0.82rem !important;
    font-weight: 600 !important;
    border-radius: 0.5rem !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    white-space: nowrap !important;
    cursor: pointer !important;
    border: none !important;
    transition: all 0.15s ease !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05) !important;
}

.btn-export-inline:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15) !important;
}

@media (max-width: 640px) {
    .btn-export-text {
        display: none !important;
    }
    .btn-export-inline {
        padding: 0 0.65rem !important;
        font-size: 0.95rem !important;
    }
}

.btn-group-actions-responsive {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.btn-group-actions-responsive .btn-edit,
.btn-group-actions-responsive .btn-primary {
    height: 38px !important;
    padding: 0 0.85rem !important;
    font-size: 0.82rem !important;
    border-radius: 0.5rem;
}

/* Hover para botón eliminar curso */
.card-panel .btn-primary[style*="#be123c"]:hover {
    background: #9f1239 !important;
    box-shadow: 0 3px 6px rgba(190, 18, 60, 0.3) !important;
}

/* ==========================================================================
   4. BOTONES COMPACTOS DE TABLA (28px CON HOVER)
   ========================================================================== */
.btn-edit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.65rem;
    height: 28px;
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
    border-radius: 0.375rem;
    font-size: 0.74rem;
    font-weight: 700;
    cursor: pointer;
    line-height: 1;
    transition: all 0.15s ease;
    text-decoration: none;
    white-space: nowrap;
}

.btn-edit:hover {
    background: #dbeafe;
    color: #1e40af;
    border-color: #93c5fd;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.12);
}

.btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.65rem;
    height: 28px;
    background: #fff1f2;
    color: #be123c;
    border: 1px solid #fecdd3;
    border-radius: 0.375rem;
    font-size: 0.74rem;
    font-weight: 700;
    cursor: pointer;
    line-height: 1;
    transition: all 0.15s ease;
    text-decoration: none;
    white-space: nowrap;
}

.btn-danger:hover {
    background: #ffe4e6;
    color: #9f1239;
    border-color: #fda4af;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(190, 18, 60, 0.12);
}

/* ==========================================================================
   5. CONTENEDOR PRINCIPAL, TABLAS Y CASILLAS
   ========================================================================== */
.main-wrapper {
    width: 100%;
    max-width: var(--max-content-width);
    margin: 0 auto;
    padding: 1rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.tabs-nav {
    display: flex;
    gap: 0.35rem;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-soft);
    padding-bottom: 0.4rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tab-btn {
    padding: 0.45rem 0.8rem;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 0.4rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.15s ease;
}

.tab-btn:hover {
    background: #f1f5f9;
    color: var(--text-main);
}

.tab-btn.active {
    background: #e0f2fe;
    color: #0369a1;
    border-color: #bae6fd;
}

.controls-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.65rem;
    margin-bottom: 0.85rem;
}

.info-reglas {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    font-size: 0.72rem;
}

.regla-badge {
    background: #f1f5f9;
    border: 1px solid var(--border-soft);
    padding: 0.3rem 0.55rem;
    border-radius: 0.35rem;
    color: var(--text-muted);
}

.regla-badge strong {
    color: var(--text-main);
}

.form-select {
    padding: 0 0.75rem;
    border: 1px solid var(--border-soft);
    border-radius: 0.5rem;
    background-color: #ffffff;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-main);
    width: 100%;
    outline: none;
    cursor: pointer;
    height: 38px;
    transition: border-color 0.15s ease;
}

.form-select:hover {
    border-color: var(--border-color);
}

.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.badge-guardado {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--success-text);
    background-color: var(--success-bg);
    border: 1px solid #a7f3d0;
    padding: 0.25rem 0.55rem;
    border-radius: 9999px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.card-panel {
    background: var(--card-bg);
    border: 1px solid var(--border-soft);
    border-radius: 0.75rem;
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.card-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 0.85rem;
    color: var(--text-main);
}

.table-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.6rem;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    margin-bottom: 1.25rem;
}

.table-responsive-container {
    overflow-x: auto;
    overflow-y: auto;
    max-height: calc(100vh - 210px);
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

.grade-table {
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.75rem;
    width: max-content;
}

.grade-table th, .grade-table td {
    padding: 0.35rem 0.3rem;
    border-bottom: 1px solid var(--border-soft);
    border-right: 1px solid var(--border-soft);
    text-align: center;
    vertical-align: middle;
}

.grade-table thead tr th {
    position: sticky;
    background-color: #f1f5f9;
    color: var(--text-muted);
    font-weight: 700;
    z-index: 20;
}

.grade-table thead tr:nth-child(1) th { top: 0; }
.grade-table thead tr:nth-child(2) th { top: 32px; z-index: 20; }

.sticky-col {
    position: sticky;
    left: 0;
    background-color: #ffffff;
    z-index: 10;
    text-align: left !important;
    width: var(--col-alumno-width);
    min-width: var(--col-alumno-width);
    max-width: var(--col-alumno-width);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-right: 2px solid var(--border-color) !important;
    padding-left: 0.6rem !important;
}

thead tr th.sticky-col {
    z-index: 35 !important;
    background-color: #e2e8f0 !important;
}

.col-nota-ut {
    width: 68px !important;
    min-width: 68px !important;
}

.input-nota {
    width: 100% !important;
    max-width: 64px !important;
    min-width: 58px !important;
    height: 32px;
    text-align: center;
    font-weight: 700;
    font-size: 0.9rem;
    border: 1px solid transparent;
    border-radius: 0.35rem;
    background-color: transparent;
    outline: none;
    transition: all 0.15s;
    color: var(--text-main);
    padding: 0 2px;
}

.input-nota:focus {
    background-color: #ffffff;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.celda-practica-auto {
    width: 68px !important;
    min-width: 68px !important;
    background-color: #f8fafc;
    font-weight: 700;
    font-size: 0.88rem;
    color: #334155;
    user-select: none;
}

.nota-final {
    font-weight: 800;
    font-size: 0.88rem;
    width: 82px;
    min-width: 82px;
}

.nota-aprobada {
    background-color: var(--success-bg) !important;
    color: var(--success-text) !important;
}

.nota-suspensa {
    background-color: var(--danger-bg) !important;
    color: var(--danger-text) !important;
}

/* ==========================================================================
   6. MODAL RESPONSIVE
   ========================================================================== */
.modal-overlay {
    display: none;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    background: rgba(15, 23, 42, 0.75) !important;
    backdrop-filter: blur(4px);
    z-index: 99999 !important;
    align-items: center;
    justify-content: center;
    padding: 0.65rem !important;
}

.modal-card {
    background: #ffffff;
    border-radius: 1rem;
    max-width: 580px;
    width: 100%;
    max-height: 82vh;
    max-height: 82dvh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
    overflow: hidden;
    position: relative;
    border: 1px solid var(--border-soft);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-soft);
    background: #f8fafc;
    flex-shrink: 0;
}

.modal-header h3 {
    font-size: 0.98rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.2;
}

.modal-header p {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0.2rem 0.5rem;
    line-height: 1;
}

.modal-close-btn:hover {
    color: var(--danger-text);
}

.modal-body {
    padding: 0.85rem 1rem;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    flex: 1 1 auto;
    min-height: 0 !important;
    font-size: 0.8rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.65rem 1rem;
    border-top: 1px solid var(--border-soft);
    background: #f8fafc;
    flex-shrink: 0;
}

.alumno-clickable {
    cursor: pointer;
    color: var(--primary);
    text-decoration: underline;
    text-decoration-style: dotted;
}

.alumno-clickable:hover {
    color: var(--primary-hover);
}

/* ==========================================================================
   7. AJUSTES ESPECÍFICOS MÓVILES (≤ 768px)
   ========================================================================== */
@media (max-width: 768px) {
    .btn-group-actions-responsive {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 0.45rem;
    }

    .btn-group-actions-responsive .btn-edit,
    .btn-group-actions-responsive .btn-primary {
        flex: 1 1 calc(50% - 0.45rem);
        min-width: 140px;
        font-size: 0.78rem;
        height: 36px !important;
    }
}

/* ==========================================================================
   8. IMPRESIÓN LIMPIA
   ========================================================================== */
@media print {
    .navbar, .tabs-nav, .controls-row, .btn-primary, .btn-salir, .badge-guardado, .modal-footer, .btn-hamburger, .modal-close-btn, .app-footer, .cookies-floating-banner, .btn-export-inline {
        display: none !important;
    }
    body, .main-wrapper {
        background: #ffffff !important;
        padding: 0 !important;
    }
    .table-card {
        border: none !important;
        box-shadow: none !important;
    }
    .grade-table {
        font-size: 8.5pt !important;
        width: 100% !important;
    }
    .grade-table th, .grade-table td {
        border: 1px solid #94a3b8 !important;
        padding: 3px 5px !important;
    }
    .sticky-col {
        position: static !important;
        border-right: 1px solid #94a3b8 !important;
    }
    .input-nota {
        border: none !important;
        background: transparent !important;
    }
}

/* Desplazamiento ultra suave nativo para anclas */
html {
    scroll-behavior: smooth;
    scrollbar-gutter: stable;
    overflow-y: scroll;
}

/* Margen superior para que la cabecera fija no tape los títulos al hacer scroll */
section[id] {
    scroll-margin-top: 5rem;
}