/* ============================================
   SISTEMA DE EVALUACIONES - DESAFÍO ARENALINO 2026
   I.E. JEC "Antonio Álvarez de Arenales" - Huayllay
   Diseño institucional elegante y profesional
   ============================================ */

/* Fuentes premium */
@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@500;600;700&family=Inter:wght@400;500;600;700;800&family=Playfair+Display:wght@700;800;900&display=swap');

/* Variables de diseño */
:root {
    /* Paleta institucional - inspirada en el escudo (rojo, amarillo, azul marino) */
    --institutional-red: #c8102e;
    --institutional-red-dark: #9a0c23;
    --institutional-gold: #f4b41a;
    --institutional-gold-dark: #d99910;
    --institutional-navy: #1a2456;
    --institutional-navy-dark: #0f1838;
    --institutional-blue: #2563eb;
    --institutional-blue-light: #3b82f6;

    /* Colores de acento */
    --accent-gold: #f59e0b;
    --accent-gold-light: #fbbf24;
    --success-color: #059669;
    --danger-color: #dc2626;
    --warning-color: #d97706;

    /* Neutros - sofisticados */
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    --bg-white: #ffffff;
    --bg-cream: #fdfcfa;
    --bg-light: #f8fafc;
    --bg-gray: #f1f5f9;
    --border-light: #e2e8f0;
    --border-medium: #cbd5e1;

    /* Sombras refinadas */
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-sm: 0 2px 4px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08), 0 2px 4px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 12px 24px rgba(15, 23, 42, 0.1), 0 4px 8px rgba(15, 23, 42, 0.05);
    --shadow-xl: 0 20px 40px rgba(15, 23, 42, 0.12), 0 8px 16px rgba(15, 23, 42, 0.06);
    --shadow-2xl: 0 32px 64px rgba(15, 23, 42, 0.15);
    --shadow-navy: 0 20px 40px rgba(26, 36, 86, 0.25);
    --shadow-gold: 0 8px 20px rgba(244, 180, 26, 0.35);

    /* Gradientes institucionales */
    --gradient-header: linear-gradient(135deg, #1a2456 0%, #2d3a7b 50%, #1e2d65 100%);
    --gradient-navy: linear-gradient(135deg, #1a2456 0%, #0f1838 100%);
    --gradient-gold: linear-gradient(135deg, #f4b41a 0%, #d99910 100%);
    --gradient-red: linear-gradient(135deg, #c8102e 0%, #9a0c23 100%);
    --gradient-blue: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    --gradient-success: linear-gradient(135deg, #10b981 0%, #059669 100%);

    /* Fondo suave institucional */
    --gradient-bg: linear-gradient(135deg, #f8fafc 0%, #eef2f7 100%);

    /* Transiciones */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --transition-fast: all 0.15s var(--ease-out);
    --transition-base: all 0.3s var(--ease-out);
    --transition-slow: all 0.5s var(--ease-out);

    /* Radios */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;
}

/* Reset */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--gradient-bg);
    background-attachment: fixed;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    position: relative;
}

/* Textura sutil de fondo */
body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image:
        radial-gradient(circle at 20% 30%, rgba(37, 99, 235, 0.03) 0%, transparent 40%),
        radial-gradient(circle at 80% 70%, rgba(244, 180, 26, 0.03) 0%, transparent 40%);
    pointer-events: none;
    z-index: 0;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px 20px;
    position: relative;
    z-index: 1;
}

/* ============================================
   BARRA DE NAVEGACIÓN SUPERIOR
   ============================================ */
.top-nav {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-bottom: 24px;
    flex-wrap: wrap;
    animation: fadeInDown 0.5s var(--ease-out);
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: var(--bg-white);
    color: var(--institutional-navy);
    text-decoration: none;
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: 0.88rem;
    letter-spacing: 0.2px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition-base);
    border: 1px solid var(--border-light);
}

.nav-link:hover {
    background: var(--gradient-navy);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--institutional-navy);
}

.nav-link svg {
    transition: var(--transition-base);
}

.nav-link:hover svg {
    transform: scale(1.1);
}

/* ============================================
   ENCABEZADO INSTITUCIONAL ELEGANTE
   ============================================ */
header {
    position: relative;
    margin-bottom: 36px;
    padding: 48px 40px;
    background: var(--gradient-header);
    color: white;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-navy);
    overflow: hidden;
    isolation: isolate;
}

/* Patrón decorativo de fondo */
header::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle at 15% 50%, rgba(244, 180, 26, 0.15) 0%, transparent 35%),
        radial-gradient(circle at 85% 50%, rgba(37, 99, 235, 0.2) 0%, transparent 40%);
    pointer-events: none;
    z-index: -1;
}

/* Línea dorada decorativa superior */
header::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg,
        var(--institutional-red) 0%,
        var(--institutional-gold) 50%,
        var(--institutional-red) 100%);
}

/* Estructura del header */
.header-content {
    display: flex;
    align-items: center;
    gap: 32px;
    justify-content: center;
    text-align: left;
    position: relative;
}

.header-logo-wrapper {
    flex-shrink: 0;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 120px;
    height: 120px;
    background: radial-gradient(circle at center, rgba(255,255,255,0.12) 0%, transparent 70%);
    border-radius: 50%;
}

.header-logo-wrapper::before {
    content: '';
    position: absolute;
    inset: -6px;
    background: conic-gradient(from 0deg,
        rgba(244, 180, 26, 0.4) 0deg,
        transparent 90deg,
        rgba(244, 180, 26, 0.4) 180deg,
        transparent 270deg,
        rgba(244, 180, 26, 0.4) 360deg);
    border-radius: 50%;
    animation: rotate-glow 8s linear infinite;
    opacity: 0.7;
    z-index: 0;
    filter: blur(6px);
}

@keyframes rotate-glow {
    to { transform: rotate(360deg); }
}

.header-logo {
    position: relative;
    z-index: 1;
    width: 100px;
    height: 100px;
    object-fit: contain;
    filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.5));
    animation: fadeInLogo 0.8s var(--ease-out);
    transition: var(--transition-slow);
}

.header-logo:hover {
    transform: scale(1.08) rotate(-3deg);
}

@keyframes fadeInLogo {
    from { opacity: 0; transform: scale(0.8) rotate(-10deg); }
    to { opacity: 1; transform: scale(1) rotate(0); }
}

.header-text {
    flex: 1;
    min-width: 0;
}

/* Pretítulo */
.header-pretitle {
    display: inline-block;
    padding: 4px 14px;
    background: rgba(244, 180, 26, 0.15);
    border: 1px solid rgba(244, 180, 26, 0.4);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    color: var(--institutional-gold);
    margin-bottom: 12px;
    animation: slideIn 0.6s var(--ease-out) 0.2s backwards;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Título principal - tipografía elegante */
header h1 {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: clamp(1.8rem, 4.5vw, 3.2rem);
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -1px;
    margin-bottom: 8px;
    text-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.6s var(--ease-out) 0.3s backwards;
}

header h1 .year-badge {
    display: inline-block;
    background: var(--gradient-gold);
    color: var(--institutional-navy-dark);
    padding: 2px 16px;
    border-radius: var(--radius-md);
    font-size: 0.7em;
    font-weight: 900;
    margin-left: 8px;
    vertical-align: middle;
    text-shadow: none;
    box-shadow: var(--shadow-gold);
    letter-spacing: 1px;
}

/* Subtítulo institucional */
header h2 {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: clamp(1rem, 2.5vw, 1.4rem);
    font-weight: 600;
    margin-bottom: 6px;
    opacity: 0.95;
    font-style: italic;
    letter-spacing: 0.3px;
    animation: slideIn 0.6s var(--ease-out) 0.4s backwards;
}

/* Tercer nivel */
header h3 {
    font-size: clamp(0.85rem, 2vw, 1rem);
    font-weight: 400;
    opacity: 0.85;
    letter-spacing: 0.5px;
    animation: slideIn 0.6s var(--ease-out) 0.5s backwards;
}

/* Divisor dorado decorativo */
.header-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 14px 0 8px;
    animation: slideIn 0.6s var(--ease-out) 0.4s backwards;
}

.header-divider::before,
.header-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--institutional-gold), transparent);
    max-width: 80px;
}

.header-divider-symbol {
    color: var(--institutional-gold);
    font-size: 1rem;
    letter-spacing: 4px;
}

/* ============================================
   FORMULARIO DE BÚSQUEDA
   ============================================ */
.search-container {
    background-color: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 40px;
    box-shadow: var(--shadow-lg);
    margin-bottom: 28px;
    border: 1px solid var(--border-light);
    animation: fadeInUp 0.6s var(--ease-out);
    position: relative;
    overflow: hidden;
}

.search-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg,
        var(--institutional-red) 0%,
        var(--institutional-gold) 50%,
        var(--institutional-blue) 100%);
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.search-container h2 {
    font-family: 'Playfair Display', serif;
    color: var(--institutional-navy);
    font-size: 1.6rem;
    margin-bottom: 24px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-container h2 .icon-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--gradient-navy);
    color: white;
    border-radius: var(--radius-md);
    font-size: 1.1rem;
    box-shadow: var(--shadow-sm);
}

.form-group {
    margin-bottom: 22px;
}

.form-group label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
    letter-spacing: 0.3px;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="file"],
select {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid var(--border-light);
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-family: inherit;
    background-color: var(--bg-white);
    color: var(--text-primary);
    transition: var(--transition-base);
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="file"]:focus,
select:focus {
    outline: none;
    border-color: var(--institutional-blue);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

input[type="text"]:hover,
input[type="password"]:hover,
input[type="email"]:hover,
select:hover {
    border-color: var(--border-medium);
}

/* ============================================
   BOTONES REFINADOS
   ============================================ */
.button-group {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

.btn-primary, .btn-secondary, .btn-download, .btn-success {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex: 1;
    border: none;
    border-radius: var(--radius-md);
    padding: 14px 22px;
    font-size: 0.98rem;
    font-weight: 600;
    font-family: inherit;
    letter-spacing: 0.3px;
    cursor: pointer;
    transition: var(--transition-base);
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

.btn-primary::before, .btn-download::before, .btn-success::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    transform: translate(-50%, -50%);
    transition: width 0.5s, height 0.5s;
}

.btn-primary:hover::before, .btn-download:hover::before, .btn-success:hover::before {
    width: 400px;
    height: 400px;
}

.btn-primary {
    background: var(--gradient-navy);
    color: white;
    box-shadow: 0 4px 14px rgba(26, 36, 86, 0.35);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(26, 36, 86, 0.5);
}

.btn-secondary {
    background: var(--bg-white);
    color: var(--text-secondary);
    border: 2px solid var(--border-light);
}

.btn-secondary:hover {
    background: var(--bg-gray);
    border-color: var(--institutional-navy);
    color: var(--institutional-navy);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-download {
    background: var(--gradient-gold);
    color: var(--institutional-navy-dark);
    box-shadow: var(--shadow-gold);
    width: auto;
    padding: 13px 28px;
    font-weight: 700;
}

.btn-download:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(244, 180, 26, 0.5);
}

.btn-success {
    background: var(--gradient-success);
    color: white;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(16, 185, 129, 0.4);
}

.btn-primary:active, .btn-secondary:active, .btn-download:active, .btn-success:active {
    transform: translateY(0);
}

.btn-download svg, .btn-primary svg, .btn-secondary svg, .btn-success svg {
    width: 18px;
    height: 18px;
    stroke-width: 2.2;
}

/* ============================================
   CONTENEDOR DE RESULTADOS
   ============================================ */
.results-container {
    background-color: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 36px;
    box-shadow: var(--shadow-lg);
    min-height: 120px;
    border: 1px solid var(--border-light);
    animation: fadeInUp 0.6s var(--ease-out) 0.1s backwards;
}

.results-container:empty {
    display: none;
}

.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
    font-style: italic;
    font-size: 1.05rem;
}

.loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    margin-left: 12px;
    border: 3px solid var(--border-light);
    border-top-color: var(--institutional-navy);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.error {
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    color: #991b1b;
    padding: 18px 22px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    border-left: 4px solid var(--danger-color);
    font-weight: 500;
    box-shadow: var(--shadow-xs);
}

.success-message {
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    color: #166534;
    padding: 18px 22px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    border-left: 4px solid var(--success-color);
    font-weight: 500;
    box-shadow: var(--shadow-xs);
}

/* ============================================
   TARJETA DE ESTUDIANTE
   ============================================ */
.student-card {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow-md);
    margin-bottom: 28px;
    border-left: 6px solid var(--institutional-navy);
    position: relative;
    overflow: hidden;
    animation: slideInFromLeft 0.5s var(--ease-out);
}

.student-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 180px;
    height: 180px;
    background: radial-gradient(circle, rgba(26, 36, 86, 0.06) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

.student-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 60px;
    height: 6px;
    background: var(--gradient-gold);
}

.student-info {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
    flex-wrap: wrap;
    position: relative;
    z-index: 1;
}

.student-personal {
    flex: 1;
    min-width: 250px;
}

.student-academic {
    text-align: right;
    min-width: 200px;
}

.student-name {
    font-family: 'Playfair Display', serif;
    font-size: clamp(1.4rem, 3vw, 2rem);
    color: var(--institutional-navy);
    margin-bottom: 10px;
    font-weight: 800;
    letter-spacing: -0.5px;
    line-height: 1.15;
}

.dni-number {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-bottom: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dni-number::before {
    content: '';
    display: inline-block;
    width: 22px;
    height: 22px;
    background-color: var(--institutional-navy);
    -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2'><rect x='3' y='5' width='18' height='14' rx='2'/><circle cx='9' cy='12' r='2'/><line x1='14' y1='10' x2='18' y2='10'/><line x1='14' y1='14' x2='18' y2='14'/></svg>") no-repeat center;
    mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2'><rect x='3' y='5' width='18' height='14' rx='2'/><circle cx='9' cy='12' r='2'/><line x1='14' y1='10' x2='18' y2='10'/><line x1='14' y1='14' x2='18' y2='14'/></svg>") no-repeat center;
}

.grade-section {
    display: inline-block;
    background: var(--gradient-navy);
    color: white;
    padding: 7px 18px;
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: 0.92rem;
    letter-spacing: 0.3px;
    box-shadow: 0 4px 12px rgba(26, 36, 86, 0.3);
    margin-top: 8px;
}

.bimester-info {
    display: inline-block;
    background: var(--gradient-gold);
    color: var(--institutional-navy-dark);
    padding: 7px 18px;
    border-radius: var(--radius-full);
    font-weight: 700;
    font-size: 0.92rem;
    letter-spacing: 0.3px;
    box-shadow: var(--shadow-gold);
    margin-bottom: 10px;
}

.total-score {
    font-family: 'Playfair Display', serif;
    font-size: clamp(2rem, 4.5vw, 2.8rem);
    color: var(--institutional-navy);
    font-weight: 900;
    margin-top: 14px;
    letter-spacing: -1.5px;
    line-height: 1;
}

.student-academic p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 8px 0;
    font-weight: 500;
}

/* ============================================
   TABLA DE RESULTADOS
   ============================================ */
.results-table {
    width: 100%;
    border-collapse: collapse;
    margin: 28px 0;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    background: var(--bg-white);
    animation: fadeInUp 0.6s var(--ease-out) 0.2s backwards;
}

.results-table thead {
    background: var(--gradient-navy);
}

.results-table th {
    padding: 16px 20px;
    text-align: left;
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
    letter-spacing: 0.8px;
    text-transform: uppercase;
}

.results-table td {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-light);
    transition: var(--transition-fast);
}

.results-table tbody tr {
    transition: var(--transition-fast);
}

.results-table tbody tr:hover {
    background-color: #f0f5ff;
}

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

.score-value {
    font-weight: 700;
    text-align: center;
    color: var(--institutional-navy);
    font-size: 1.05rem;
}

/* ============================================
   GRÁFICOS
   ============================================ */
.chart-container {
    margin-top: 32px;
    padding: 32px;
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
    animation: fadeInUp 0.6s var(--ease-out) 0.3s backwards;
}

.chart-title {
    font-family: 'Playfair Display', serif;
    text-align: center;
    margin-bottom: 24px;
    color: var(--institutional-navy);
    font-size: 1.4rem;
    font-weight: 700;
}

.chart-wrapper {
    position: relative;
    height: 400px;
    margin: 0 auto;
    max-width: 700px;
}

.chart-info {
    text-align: center;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border-light);
}

.chart-total-info {
    font-size: 1.1rem;
    color: var(--text-primary);
}

.chart-total-info strong {
    font-family: 'Playfair Display', serif;
    color: var(--institutional-navy);
    font-size: 1.5rem;
    font-weight: 800;
    margin: 0 4px;
}

/* ============================================
   MENSAJE DE NO RESULTADOS
   ============================================ */
.no-results {
    text-align: center;
    padding: 50px 20px;
    color: var(--text-secondary);
}

.no-results::before {
    content: '🔍';
    display: block;
    font-size: 3.5rem;
    margin-bottom: 16px;
    opacity: 0.6;
}

.no-results h3 {
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: var(--institutional-navy);
    font-weight: 700;
}

.no-results p {
    font-size: 1rem;
    max-width: 500px;
    margin: 0 auto;
}

/* ============================================
   BOTÓN DE DESCARGA
   ============================================ */
.download-container {
    text-align: center;
    margin-top: 24px;
    display: none;
    animation: fadeInUp 0.5s var(--ease-out);
}

/* ============================================
   FOOTER INSTITUCIONAL
   ============================================ */
footer {
    text-align: center;
    margin-top: 60px;
    padding: 32px 20px 20px;
    color: var(--text-muted);
    font-size: 0.88rem;
    border-top: 1px solid var(--border-light);
    position: relative;
}

footer::before {
    content: '';
    position: absolute;
    top: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 3px;
    background: var(--gradient-gold);
    border-radius: var(--radius-full);
}

footer p {
    margin: 6px 0;
    line-height: 1.7;
}

footer strong {
    color: var(--institutional-navy);
}

/* ============================================
   DASHBOARD
   ============================================ */
.dashboard-container {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 22px;
    margin-bottom: 30px;
}

.filter-card {
    grid-column: span 12;
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
    position: relative;
    overflow: hidden;
}

.filter-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-gold);
}

.filter-card h2 {
    font-family: 'Playfair Display', serif;
    color: var(--institutional-navy);
    font-size: 1.3rem;
    margin-bottom: 20px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    align-items: flex-end;
}

.filter-group {
    flex: 1;
    min-width: 160px;
}

.filter-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.form-control {
    width: 100%;
    padding: 11px 16px;
    border: 2px solid var(--border-light);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-family: inherit;
    background-color: var(--bg-white);
    transition: var(--transition-base);
}

.form-control:focus {
    outline: none;
    border-color: var(--institutional-blue);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.filter-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.filter-buttons .btn-primary,
.filter-buttons .btn-secondary {
    flex: 0 0 auto;
    padding: 11px 22px;
    font-size: 0.92rem;
}

/* Tarjetas de estadísticas */
.stats-card {
    grid-column: span 3;
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 26px 22px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
    text-align: center;
    position: relative;
    overflow: hidden;
    transition: var(--transition-base);
}

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

.stats-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--gradient-navy);
}

.stats-card:nth-of-type(3)::before {
    background: var(--gradient-gold);
}

.stats-card:nth-of-type(4)::before {
    background: var(--gradient-success);
}

.stats-card:nth-of-type(5)::before {
    background: var(--gradient-red);
}

.stats-number {
    font-family: 'Playfair Display', serif;
    display: block;
    font-size: clamp(2rem, 4.5vw, 2.8rem);
    font-weight: 800;
    color: var(--institutional-navy);
    margin-bottom: 6px;
    letter-spacing: -1.5px;
    line-height: 1;
}

.stats-label {
    display: block;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Tarjetas de gráficos */
.chart-card {
    grid-column: span 6;
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
}

.card-title {
    font-family: 'Playfair Display', serif;
    color: var(--institutional-navy);
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 2px solid var(--border-light);
    position: relative;
}

.card-title::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 60px;
    height: 2px;
    background: var(--gradient-gold);
}

.chart-card .chart-container {
    margin: 0;
    padding: 0;
    box-shadow: none;
    border: none;
    height: 350px;
    position: relative;
    animation: none;
}

/* Tabla de ranking */
.ranking-card {
    grid-column: span 12;
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-md);
}

.ranking-table {
    width: 100%;
    border-collapse: collapse;
}

.ranking-table thead {
    background: var(--gradient-navy);
}

.ranking-table th {
    padding: 16px 18px;
    text-align: left;
    color: white;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    white-space: nowrap;
}

.ranking-table td {
    padding: 15px 18px;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.95rem;
}

.ranking-table tbody tr {
    transition: var(--transition-fast);
}

.ranking-table tbody tr:hover {
    background-color: #f0f5ff;
}

.ranking-table tbody tr:nth-child(1) td:first-child,
.ranking-table tbody tr:nth-child(2) td:first-child,
.ranking-table tbody tr:nth-child(3) td:first-child {
    font-weight: 800;
    font-size: 1.15rem;
    font-family: 'Playfair Display', serif;
}

.ranking-table tbody tr:nth-child(1) td:first-child::before { content: '🥇 '; }
.ranking-table tbody tr:nth-child(2) td:first-child::before { content: '🥈 '; }
.ranking-table tbody tr:nth-child(3) td:first-child::before { content: '🥉 '; }

.badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: var(--radius-full);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.badge-primary {
    background: linear-gradient(135deg, #dbeafe, #bfdbfe);
    color: var(--institutional-navy);
}

.ranking-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
    margin-bottom: 18px;
    padding-bottom: 18px;
    border-bottom: 2px solid var(--border-light);
    position: relative;
}

.ranking-header::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 80px;
    height: 2px;
    background: var(--gradient-gold);
}

.ranking-header h3 {
    font-family: 'Playfair Display', serif;
    color: var(--institutional-navy);
    font-size: 1.3rem;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ============================================
   INSTRUCCIONES (SUBIR RESULTADOS)
   ============================================ */
.instructions {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border-left: 4px solid var(--institutional-blue);
    padding: 26px;
    margin: 24px 0;
    border-radius: var(--radius-md);
    position: relative;
}

.instructions h3 {
    font-family: 'Playfair Display', serif;
    margin-top: 0;
    color: var(--institutional-navy);
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 14px;
}

.instructions h4 {
    margin-top: 18px;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 10px;
}

.instructions ul {
    padding-left: 22px;
    margin: 10px 0;
}

.instructions li {
    margin-bottom: 8px;
    color: var(--text-secondary);
    line-height: 1.7;
}

.instructions strong {
    color: var(--text-primary);
    font-weight: 600;
}

.areas-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

.areas-list span {
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-full);
    padding: 6px 14px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: var(--transition-fast);
}

.areas-list span:hover {
    background: var(--institutional-navy);
    color: white;
    border-color: var(--institutional-navy);
    transform: translateY(-2px);
}

.template-link {
    margin-top: 22px;
    text-align: center;
}

.template-link a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--institutional-navy);
    text-decoration: none;
    font-weight: 600;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    transition: var(--transition-base);
    border: 2px dashed var(--institutional-blue);
}

.template-link a:hover {
    background: var(--institutional-navy);
    color: white;
    border-style: solid;
    transform: translateY(-2px);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1024px) {
    .stats-card {
        grid-column: span 6;
    }

    .chart-card {
        grid-column: span 12;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 16px 14px;
    }

    header {
        padding: 32px 24px;
        margin-bottom: 24px;
    }

    .header-content {
        flex-direction: column;
        text-align: center;
        gap: 16px;
    }

    .header-logo-wrapper {
        width: 90px;
        height: 90px;
    }

    .header-logo {
        width: 75px;
        height: 75px;
    }

    .header-divider {
        justify-content: center;
    }

    .header-pretitle {
        display: inline-block;
    }

    .search-container,
    .results-container,
    .filter-card,
    .chart-card,
    .ranking-card {
        padding: 22px;
    }

    .student-info {
        flex-direction: column;
    }

    .student-academic {
        text-align: left;
        margin-top: 16px;
    }

    .chart-wrapper {
        height: 300px;
    }

    .button-group {
        flex-direction: column;
    }

    .btn-primary, .btn-secondary, .btn-download, .btn-success {
        width: 100%;
    }

    .stats-card {
        grid-column: span 6;
    }

    .filter-form {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-group {
        width: 100%;
    }

    .ranking-table th,
    .ranking-table td {
        padding: 10px 10px;
        font-size: 0.85rem;
    }

    .results-table th,
    .results-table td {
        padding: 11px 14px;
        font-size: 0.9rem;
    }

    .top-nav {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .stats-card {
        grid-column: span 12;
    }

    header h1 {
        font-size: 1.6rem;
    }

    header h1 .year-badge {
        display: inline-block;
        margin-top: 8px;
        margin-left: 0;
        font-size: 0.85rem;
    }

    .chart-wrapper {
        height: 260px;
    }

    .header-logo-wrapper {
        width: 80px;
        height: 80px;
    }

    .header-logo {
        width: 65px;
        height: 65px;
    }
}

/* ============================================
   ANIMACIONES
   ============================================ */
@keyframes slideInFromLeft {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Accesibilidad - focus visible */
:focus-visible {
    outline: 3px solid var(--institutional-gold);
    outline-offset: 2px;
}

/* Scrollbar personalizado */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-gray);
}

::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: var(--radius-full);
}

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

/* Print styles */
@media print {
    body {
        background: white;
    }

    body::before {
        display: none;
    }

    .top-nav,
    .download-container,
    .button-group,
    .filter-card {
        display: none;
    }

    header {
        box-shadow: none;
        border: 1px solid var(--border-light);
    }

    .search-container,
    .results-container,
    .chart-container {
        box-shadow: none;
        border: 1px solid var(--border-light);
    }
}

/* ============================================
   PÁGINA DE LOGIN
   ============================================ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: var(--gradient-header);
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle at 20% 30%, rgba(244, 180, 26, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 80% 70%, rgba(200, 16, 46, 0.15) 0%, transparent 40%);
    pointer-events: none;
}

/* Patrón geométrico decorativo */
.login-page::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(30deg, transparent 48%, rgba(255,255,255,0.02) 48%, rgba(255,255,255,0.02) 52%, transparent 52%),
        linear-gradient(150deg, transparent 48%, rgba(255,255,255,0.02) 48%, rgba(255,255,255,0.02) 52%, transparent 52%);
    background-size: 60px 60px;
    pointer-events: none;
}

.login-card {
    background: var(--bg-white);
    border-radius: var(--radius-xl);
    padding: 32px 36px;
    max-width: 420px;
    width: 100%;
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.35);
    position: relative;
    z-index: 1;
    animation: loginFadeIn 0.6s var(--ease-out);
    border-top: 4px solid var(--institutional-gold);
}

@keyframes loginFadeIn {
    from { opacity: 0; transform: translateY(30px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.login-header {
    text-align: center;
    margin-bottom: 20px;
}

.login-logo {
    width: 75px;
    height: 75px;
    margin: 0 auto 10px;
    display: block;
    object-fit: contain;
    filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.15));
    animation: fadeInLogo 0.8s var(--ease-out);
}

.login-institution {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--institutional-navy);
    margin-bottom: 4px;
    opacity: 0.7;
}

.login-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
    color: var(--institutional-navy);
    margin-bottom: 4px;
    font-weight: 800;
    letter-spacing: -0.5px;
    line-height: 1.1;
}

.login-title .year-badge {
    display: inline-block;
    background: var(--gradient-gold);
    color: var(--institutional-navy-dark);
    padding: 2px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.7em;
    font-weight: 900;
    margin-left: 6px;
    vertical-align: middle;
    box-shadow: var(--shadow-gold);
    letter-spacing: 1px;
}

.login-subtitle {
    color: var(--text-muted);
    font-size: 0.82rem;
    margin-top: 4px;
}

/* Tabs de login (estudiante / admin) */
.login-tabs {
    display: flex;
    background: var(--bg-gray);
    border-radius: var(--radius-md);
    padding: 4px;
    margin-bottom: 18px;
    position: relative;
}

.login-tab {
    flex: 1;
    padding: 9px 14px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-base);
    font-family: inherit;
    position: relative;
    z-index: 1;
}

.login-tab.active {
    background: var(--bg-white);
    color: var(--institutional-navy);
    box-shadow: var(--shadow-sm);
}

.login-form {
    display: none;
    animation: fadeInUp 0.4s var(--ease-out);
}

.login-form.active {
    display: block;
}

/* Form groups más compactos dentro del login */
.login-form .form-group {
    margin-bottom: 14px;
}

.login-form .form-group label {
    margin-bottom: 6px;
    font-size: 0.85rem;
}

.login-form input[type="text"],
.login-form input[type="password"] {
    padding: 11px 16px;
    font-size: 0.95rem;
}

.login-form .input-with-icon input {
    padding-left: 44px;
}

.login-form .input-with-icon:has(.toggle-password) input {
    padding-right: 44px;
}

/* Input con icono */
.input-with-icon {
    position: relative;
    display: block;
    width: 100%;
}

.input-with-icon .input-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    z-index: 2;
    display: flex;
    align-items: center;
}

.input-with-icon input {
    padding-left: 48px;
    width: 100%;
    box-sizing: border-box;
}

/* Cuando hay botón toggle, más padding a la derecha */
.input-with-icon:has(.toggle-password) input {
    padding-right: 48px;
}

.input-with-icon .toggle-password {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.input-with-icon .toggle-password:hover {
    color: var(--institutional-navy);
    background: var(--bg-gray);
}

/* Mensajes de alerta en login */
.login-alert {
    padding: 10px 14px;
    border-radius: var(--radius-md);
    margin-bottom: 14px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: fadeInUp 0.3s var(--ease-out);
    line-height: 1.4;
}

.login-alert-error {
    background: #fef2f2;
    color: #991b1b;
    border-left: 3px solid var(--danger-color);
}

.login-alert-info {
    background: #eff6ff;
    color: #1e40af;
    border-left: 3px solid var(--institutional-blue);
}

.login-alert-success {
    background: #f0fdf4;
    color: #166534;
    border-left: 3px solid var(--success-color);
}

/* Ayuda bajo el formulario */
.login-help {
    margin-top: 14px;
    padding: 10px 14px;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-radius: var(--radius-md);
    border-left: 3px solid var(--institutional-gold);
    font-size: 0.8rem;
    color: #78350f;
    line-height: 1.4;
}

.login-help strong {
    color: #92400e;
}

.login-help-icon {
    display: inline-block;
    margin-right: 4px;
}

/* Footer del login */
.login-footer {
    text-align: center;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border-light);
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.login-footer a {
    color: var(--institutional-navy);
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition-fast);
}

.login-footer a:hover {
    color: var(--institutional-blue);
}

/* Botón principal de login con loading */
.btn-login {
    width: 100%;
    padding: 12px 20px;
    background: var(--gradient-navy);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-base);
    box-shadow: 0 4px 14px rgba(26, 36, 86, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    position: relative;
    overflow: hidden;
    font-family: inherit;
    letter-spacing: 0.3px;
    margin-top: 8px;
}

.btn-login::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    transform: translate(-50%, -50%);
    transition: width 0.5s, height 0.5s;
}

.btn-login:hover::before {
    width: 400px;
    height: 400px;
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(26, 36, 86, 0.5);
}

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

.btn-login:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-login.loading .btn-text {
    opacity: 0;
}

.btn-login.loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Responsive login */
@media (max-width: 480px) {
    .login-card {
        padding: 32px 24px;
    }

    .login-title {
        font-size: 1.4rem;
    }

    .login-logo {
        width: 70px;
        height: 70px;
    }
}

/* ============================================
   BARRA DE USUARIO (cuando está logueado)
   ============================================ */
.user-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: var(--bg-white);
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--gradient-navy);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    letter-spacing: 0.5px;
}

.user-details {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.user-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
}

.user-role {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.btn-logout {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    background: transparent;
    color: var(--danger-color);
    border: 1.5px solid var(--danger-color);
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-base);
    font-family: inherit;
    text-decoration: none;
}

.btn-logout:hover {
    background: var(--danger-color);
    color: white;
    transform: translateY(-1px);
}
