/* ============================================
   III Olimpiada Nacional de Geometría
   Estilos Modernos y Responsive
   ============================================ */

:root {
    --primary: #1a3a5c;
    --primary-light: #2c5f8a;
    --primary-dark: #0f2440;
    --accent: #3498db;
    --accent-hover: #2980b9;
    --success: #27ae60;
    --warning: #f39c12;
    --danger: #e74c3c;
    --bg-light: #f8f9fa;
    --bg-white: #ffffff;
    --text-dark: #2c3e50;
    --text-muted: #7f8c8d;
    --border: #e0e6ed;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.12);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-light);
    color: var(--text-dark);
    line-height: 1.6;
    min-height: 100vh;
}

/* ===== HEADER ===== */
.header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    padding: 2rem 1rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.05) 0%, transparent 70%);
    animation: pulse 4s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.header-content {
    position: relative;
    z-index: 1;
    max-width: 800px;
    margin: 0 auto;
}

.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.logo-icon {
    width: 70px;
    height: 70px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-lg);
}

.logo-icon svg {
    width: 45px;
    height: 45px;
}

.header h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 1px;
    margin-bottom: 0.3rem;
}

.header .subtitle {
    font-size: 1rem;
    opacity: 0.9;
    font-weight: 300;
    letter-spacing: 2px;
    text-transform: uppercase;
}

/* ===== CONTENEDOR PRINCIPAL ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* ===== TARJETAS ===== */
.card {
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
    margin-bottom: 2rem;
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border);
}

.card-header h2 {
    font-size: 1.5rem;
    color: var(--primary);
    font-weight: 600;
}

.card-header .icon {
    width: 40px;
    height: 40px;
    background: var(--bg-light);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}

/* ===== FORMULARIO ===== */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-dark);
    margin-bottom: 0.5rem;
}

.form-group label .required {
    color: var(--danger);
    margin-left: 2px;
}

.form-control {
    padding: 0.85rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    transition: var(--transition);
    background: var(--bg-white);
    color: var(--text-dark);
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-control.error {
    border-color: var(--danger);
}

.form-control.success {
    border-color: var(--success);
}

select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%237f8c8d' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
}

/* ===== BOTONES ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.85rem 2rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
}

.btn-primary:hover {
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.4);
    transform: translateY(-2px);
}

.btn-success {
    background: linear-gradient(135deg, var(--success) 0%, #219a52 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(39, 174, 96, 0.3);
}

.btn-success:hover {
    box-shadow: 0 6px 20px rgba(39, 174, 96, 0.4);
    transform: translateY(-2px);
}

.btn-warning {
    background: linear-gradient(135deg, var(--warning) 0%, #e67e22 100%);
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger) 0%, #c0392b 100%);
    color: white;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--border);
    color: var(--text-dark);
}

.btn-outline:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(52, 152, 219, 0.05);
}

.btn-block {
    width: 100%;
}

.btn-group {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 1.5rem;
}

/* ===== MENSAJES FLASH ===== */
.flash-message {
    padding: 1rem 1.5rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.flash-success {
    background: #d4edda;
    color: #155724;
    border-left: 4px solid var(--success);
}

.flash-error {
    background: #f8d7da;
    color: #721c24;
    border-left: 4px solid var(--danger);
}

.flash-warning {
    background: #fff3cd;
    color: #856404;
    border-left: 4px solid var(--warning);
}

/* ===== TABLA ===== */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-sm);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.table thead {
    background: var(--primary);
    color: white;
}

.table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.table tbody tr {
    transition: var(--transition);
}

.table tbody tr:hover {
    background: var(--bg-light);
}

.badge {
    display: inline-block;
    padding: 0.3rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-success {
    background: #d4edda;
    color: #155724;
}

.badge-warning {
    background: #fff3cd;
    color: #856404;
}

.badge-danger {
    background: #f8d7da;
    color: #721c24;
}

.badge-info {
    background: #d1ecf1;
    color: #0c5460;
}

/* ===== ESTADÍSTICAS ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    width: 55px;
    height: 55px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.stat-icon.blue {
    background: rgba(52, 152, 219, 0.1);
    color: var(--accent);
}

.stat-icon.green {
    background: rgba(39, 174, 96, 0.1);
    color: var(--success);
}

.stat-icon.orange {
    background: rgba(243, 156, 18, 0.1);
    color: var(--warning);
}

.stat-icon.red {
    background: rgba(231, 76, 60, 0.1);
    color: var(--danger);
}

.stat-info h3 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-dark);
    line-height: 1;
}

.stat-info p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
}

/* ===== BARRA DE BÚSQUEDA ===== */
.search-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.search-bar .form-control {
    flex: 1;
    min-width: 200px;
}

/* ===== MODAL ===== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    backdrop-filter: blur(4px);
}

.modal-overlay.active {
    display: flex;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal {
    background: white;
    border-radius: var(--radius);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalSlide 0.3s ease;
}

@keyframes modalSlide {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 1.3rem;
    color: var(--primary);
}

.modal-close {
    width: 35px;
    height: 35px;
    border: none;
    background: var(--bg-light);
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--danger);
    color: white;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* ===== LOGIN ===== */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    padding: 1rem;
}

.login-card {
    background: white;
    border-radius: var(--radius);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}

.login-card .logo-container {
    margin-bottom: 2rem;
}

/* ===== CREDENCIAL / FOTOSHEK ===== */
.credential {
    width: 800px;
    height: 500px;
    background: linear-gradient(135deg, #ffffff 0%, #f0f4f8 100%);
    border: 3px solid var(--primary);
    border-radius: 15px;
    padding: 2rem;
    position: relative;
    overflow: hidden;
    font-family: 'Segoe UI', sans-serif;
}

.credential::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 80px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
}

.credential-header {
    position: relative;
    z-index: 1;
    text-align: center;
    color: white;
    padding-top: 1rem;
}

.credential-header h2 {
    font-size: 1.3rem;
    margin-bottom: 0.2rem;
}

.credential-header p {
    font-size: 0.85rem;
    opacity: 0.9;
    letter-spacing: 2px;
}

.credential-body {
    display: flex;
    gap: 2rem;
    margin-top: 2rem;
    position: relative;
    z-index: 1;
}

.credential-photo {
    width: 150px;
    height: 180px;
    background: var(--border);
    border: 3px solid var(--primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.credential-info {
    flex: 1;
}

.credential-info .info-row {
    margin-bottom: 0.8rem;
}

.credential-info .info-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    font-weight: 600;
}

.credential-info .info-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-dark);
    border-bottom: 2px solid var(--accent);
    padding-bottom: 0.2rem;
}

.credential-footer {
    position: absolute;
    bottom: 1rem;
    left: 2rem;
    right: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.credential-id {
    background: var(--primary);
    color: white;
    padding: 0.3rem 0.8rem;
    border-radius: 5px;
    font-weight: 600;
}

/* ===== NAVBAR ===== */
.navbar {
    background: white;
    box-shadow: var(--shadow);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-brand {
    font-weight: 700;
    color: var(--primary);
    font-size: 1.1rem;
    text-decoration: none;
}

.navbar-links {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.navbar-links a {
    text-decoration: none;
    color: var(--text-dark);
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.navbar-links a:hover {
    background: var(--bg-light);
    color: var(--accent);
}

/* ===== FOOTER ===== */
.footer {
    background: var(--primary-dark);
    color: white;
    text-align: center;
    padding: 1.5rem;
    margin-top: 3rem;
    font-size: 0.9rem;
}

.footer a {
    color: var(--accent);
    text-decoration: none;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .header h1 {
        font-size: 1.4rem;
    }
    
    .header .subtitle {
        font-size: 0.8rem;
    }
    
    .logo-icon {
        width: 55px;
        height: 55px;
    }
    
    .logo-icon svg {
        width: 35px;
        height: 35px;
    }
    
    .container {
        padding: 1rem 0.75rem;
    }
    
    .card {
        padding: 1.5rem;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .btn-group {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
    
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 1rem;
    }
    
    .stat-card {
        padding: 1rem;
    }
    
    .stat-icon {
        width: 45px;
        height: 45px;
        font-size: 1.2rem;
    }
    
    .stat-info h3 {
        font-size: 1.4rem;
    }
    
    .navbar {
        padding: 0.75rem 1rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .navbar-links {
        width: 100%;
        justify-content: center;
    }
    
    .table th, .table td {
        padding: 0.75rem 0.5rem;
        font-size: 0.85rem;
    }
    
    .search-bar {
        flex-direction: column;
    }
    
    .credential {
        width: 100%;
        height: auto;
        min-height: 400px;
    }
    
    .credential-body {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 1.5rem 1rem;
    }
    
    .header h1 {
        font-size: 1.2rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .card-header h2 {
        font-size: 1.2rem;
    }
}

/* ===== ANIMACIONES ===== */
.fade-in {
    animation: fadeIn 0.5s ease;
}

.slide-up {
    animation: slideUp 0.5s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== LOADING ===== */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== PRINT ===== */
@media print {
    .navbar, .footer, .btn, .search-bar {
        display: none !important;
    }
    
    .credential {
        box-shadow: none;
        border: 2px solid #000;
    }
}
/* Tabla con scroll horizontal */
.table-container {
    overflow-x: auto;
    width: 100%;
}

.table {
    min-width: 1200px; /* Ancho mínimo para que no se comprima */
    width: 100%;
}

/* Ajuste de columnas específicas */
.table th:nth-child(1), /* ID */
.table td:nth-child(1) {
    width: 100px;
    min-width: 100px;
}

.table th:nth-child(2), /* APELLIDOS Y NOMBRES */
.table td:nth-child(2) {
    width: 280px; /* Ampliado de ~200px a 280px */
    min-width: 280px;
}

.table th:nth-child(3), /* DNI */
.table td:nth-child(3) {
    width: 120px;
    min-width: 120px;
}

.table th:nth-child(4), /* INSTITUCIÓN */
.table td:nth-child(4) {
    width: 200px;
    min-width: 200px;
}

.table th:nth-child(5), /* CIUDAD */
.table td:nth-child(5) {
    width: 150px;
    min-width: 150px;
}

.table th:nth-child(6), /* NIVEL */
.table td:nth-child(6) {
    width: 90px;
    min-width: 90px;
    text-align: center;
}

/* Badge de nivel optimizado */
.nivel-badge,
.table td:nth-child(6) {
    display: inline-block;
    padding: 4px 10px;
    font-size: 0.85rem;
    white-space: nowrap; /* Evita que se rompa en dos líneas */
}

/* Acciones */
.table th:nth-child(7), /* FECHA */
.table td:nth-child(7) {
    width: 140px;
    min-width: 140px;
}

.table th:nth-child(8), /* ACCIONES */
.table td:nth-child(8) {
    width: 120px;
    min-width: 120px;
    text-align: center;
}
/* ===== FOOTER SIEMPRE ABAJO ===== */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* El contenedor principal debe expandirse */
.container {
    flex: 1;
}

/* El footer se queda abajo automáticamente */
.footer {
    margin-top: auto;
    width: 100%;
}
/* ===== BARRA SUPERIOR COMPACTA (Header + Navbar combinados) ===== */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #1a3a5c 0%, #2c5282 100%);
    padding: 12px 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.top-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 45px;
    height: 45px;
    background: rgba(255,255,255,0.15);
    border-radius: 50%;
    flex-shrink: 0;
}

.top-title h1 {
    font-size: 1.15rem;
    color: #ffffff;
    font-weight: 700;
    margin: 0;
    line-height: 1.2;
}

.top-title p {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.7);
    margin: 0;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.top-bar-right {
    display: flex;
    gap: 8px;
}

.top-link {
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    padding: 8px 18px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.top-link:hover {
    background: rgba(255,255,255,0.15);
    color: #ffffff;
}

.top-link.active {
    background: rgba(255,255,255,0.2);
    color: #ffffff;
    font-weight: 600;
}

/* Responsive para móviles */
@media (max-width: 768px) {
    .top-bar {
        flex-direction: column;
        gap: 10px;
        padding: 12px 15px;
    }
    .top-bar-left {
        width: 100%;
        justify-content: center;
    }
    .top-title h1 {
        font-size: 0.95rem;
    }
    .top-bar-right {
        width: 100%;
        justify-content: center;
    }
}
/* ===== FORZAR HEADER Y NAVBAR ORIGINALES ===== */
.header {
    background: linear-gradient(135deg, #2c5282 0%, #1a3a5c 100%) !important;
    padding: 40px 20px !important;
    text-align: center !important;
    color: white !important;
}

.header-content {
    max-width: 800px;
    margin: 0 auto;
}

.logo-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px !important;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
}

.logo-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.header h1 {
    font-size: 1.8rem !important;
    margin: 15px 0 5px 0 !important;
    color: white !important;
}

.subtitle {
    font-size: 0.85rem !important;
    opacity: 0.8 !important;
    letter-spacing: 2px !important;
}

.navbar {
    background: white !important;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1) !important;
    padding: 15px 30px !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
}

.navbar-brand {
    font-weight: 600 !important;
    color: #1a3a5c !important;
    text-decoration: none !important;
}

.navbar-links a {
    color: #4a5568 !important;
    text-decoration: none !important;
    padding: 8px 15px !important;
}

.navbar-links a.active {
    color: #2c5282 !important;
    font-weight: 600 !important;
}

/* Ocultar la barra top-bar si existe */
.top-bar {
    display: none !important;
}