/* ==========================================================================
   VARIABLES GLOBALES (Paleta de Colores Dh No Limits)
   ========================================================================== */
:root {
    --bg-main: #0f172a;
    --bg-card: #1e293b;
    --accent: #e11d48;
    --accent-hover: #be123c;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: #334155;

    --success: #059669;
    --success-bg: rgba(5, 150, 105, 0.1);
    --warning: #d97706;
    --warning-bg: rgba(217, 119, 6, 0.1);
    --danger: #dc2626;
    --danger-bg: rgba(220, 38, 38, 0.1);
    --info: #3b82f6;
}

/* ==========================================================================
   RESETEO BASE (MOBILE FIRST)
   ========================================================================== */
body {
    font-family: 'Roboto', 'Segoe UI', Arial, sans-serif;
    background-color: var(--bg-main);
    background-image: radial-gradient(var(--border-color) 1px, transparent 1px);
    background-size: 20px 20px;
    color: var(--text-main);
    margin: 0;
    padding: 15px 10px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

* {
    box-sizing: border-box;
}

/* ==========================================================================
   CONTENEDORES Y ESTRUCTURA
   ========================================================================== */
.wrapper,
.dashboard {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

/* Tarjetas agresivas tipo Racing */
.card,
.panel {
    background: var(--bg-card);
    padding: 20px;
    border-radius: 3px;
    /* Bordes afilados */
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
    margin-bottom: 15px;
    width: 100%;
}

.panel {
    border-left: 4px solid var(--accent);
}

.panel-tabla {
    border-left: 4px solid var(--info);
}

.header {
    display: flex;
    flex-direction: column;
    gap: 15px;
    text-align: center;
    background: var(--bg-card);
    padding: 20px;
    border-radius: 3px;
    margin-bottom: 20px;
    border-left: 4px solid var(--accent);
}

.header h2,
.panel-header {
    margin: 0;
    color: white;
    text-transform: uppercase;
    font-style: italic;
    font-size: 18px;
    font-weight: 900;
}

.panel-header {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
    margin-bottom: 15px;
}

/* ==========================================================================
   GRID RESPONSIVO (Pasa de 1 columna en móvil a 2 en PC)
   ========================================================================== */
.grid-principal,
.grid-dos,
.info-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
}

/* ==========================================================================
   HEADER PÚBLICO (NAVEGACIÓN STICKY) - ESTILO DOWNHILL RACING
   ========================================================================== */
.sticky-nav {
    position: sticky;
    top: -15px;
    z-index: 1000;
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    margin-left: -10px;
    margin-right: -10px;
    padding: 15px 10px 8px 10px;
    border-bottom: 2px solid var(--accent);
    margin-bottom: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6);
}

.header-global {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.brand-logo {
    font-size: 16px;
    font-weight: 900;
    color: white;
    font-style: italic;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.header-actions {
    display: flex;
    gap: 6px;
}

.btn-outline {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 4px 8px;
    border-radius: 3px;
    text-decoration: none;
    font-size: 10px;
    font-weight: 900;
    text-transform: uppercase;
    font-style: italic;
    transition: 0.2s;
}

.btn-outline:hover {
    background: var(--border-color);
    color: white;
}

.btn-outline-accent {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-outline-accent:hover {
    background: var(--accent);
    color: white;
}

.menu-carreras {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.menu-carreras::-webkit-scrollbar {
    display: none;
}

.tab-carrera {
    padding: 5px 12px;
    background: #111827;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    text-decoration: none;
    font-size: 11px;
    font-weight: 900;
    white-space: nowrap;
    text-transform: uppercase;
    font-style: italic;
    transition: all 0.2s ease;
}

.tab-carrera:hover {
    border-color: var(--text-muted);
    color: white;
}

.tab-carrera.tab-activa {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    box-shadow: 0 0 10px rgba(225, 29, 72, 0.4);
}

@media (min-width: 768px) {
    .sticky-nav {
        margin-left: 0;
        margin-right: 0;
        padding-left: 0;
        padding-right: 0;
        border-radius: 0 0 3px 3px;
        top: 0;
    }
}

input[type="text"], input[type="password"], input[type="date"], input[type="number"], select {
    width: 100%;
    padding: 14px 12px;
    background: #111827;
    border: 1px solid var(--border-color);
    color: white;
    border-radius: 3px; /* Afilados */
    font-size: 16px !important;
}

/* ==========================================================================
   NAVEGACIÓN (Menú superior deslizable en móvil)
   ========================================================================== */
.nav-admin {
    background: var(--bg-card);
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    gap: 8px;
    border: 1px solid var(--border-color);
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
}

.nav-admin::-webkit-scrollbar {
    display: none;
}

/* Ocultar barra scroll */

.nav-admin a {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: bold;
    font-size: 12px;
    padding: 12px 16px;
    border-radius: 4px;
    text-transform: uppercase;
}

.nav-admin a:hover,
.nav-admin a.activo {
    background: var(--accent);
    color: white;
}

/* ==========================================================================
   BOTONES (Altos y cómodos para tocar en el celular)
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 16px;
    /* Más altos para pantallas táctiles */
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 900;
    text-transform: uppercase;
    font-style: italic;
    cursor: pointer;
    text-decoration: none;
    transition: 0.2s;
    width: 100%;
    /* Botones 100% ancho en celular */
}

.btn-icon-only {
    width: auto;
    padding: 12px 15px;
}

.btn-accent {
    background: var(--accent);
    color: white;
}

.btn-accent:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
}

.btn-blue {
    background: var(--info);
    color: white;
}

.btn-green {
    background: var(--success);
    color: white;
}

.btn-orange {
    background: var(--warning);
    color: white;
}

.btn-red {
    background: var(--danger);
    color: white;
}

.btn-gray {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
}

.btn-gray:hover {
    background: var(--border-color);
    color: white;
}

/* ==========================================================================
   FORMULARIOS Y BUSCADOR
   ========================================================================== */
.form-group {
    margin-bottom: 15px;
}

label {
    display: block;
    font-weight: bold;
    margin-bottom: 6px;
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
}

input[type="text"],
input[type="date"],
input[type="number"],
select {
    width: 100%;
    padding: 14px 12px;
    background: #111827;
    border: 1px solid var(--border-color);
    color: white;
    border-radius: 6px;
    font-size: 16px !important;
    /* Previene zoom automático en iOS */
}

input:focus,
select:focus {
    border-color: var(--accent);
    outline: none;
}

.search-box {
    display: flex;
    flex-direction: column;
    /* Apilado en móvil */
    gap: 10px;
    width: 100%;
}

.search-input-wrapper {
    position: relative;
    flex: 1;
}

.search-input-wrapper i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-input-wrapper input {
    padding-left: 45px;
}

/* ==========================================================================
   TABLAS MODO "TARJETA" PARA CELULAR
   ========================================================================== */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

/* Diseño móvil (Tarjetas) por defecto */
thead {
    display: none;
}

tr {
    display: block;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-bottom: 15px;
    background: #111827;
    padding: 10px;
}

td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 13px;
    text-align: right;
}

td:last-child {
    border-bottom: none;
}

td::before {
    content: attr(data-label);
    font-weight: bold;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 10px;
}

/* ==========================================================================
   VARIANTE: TABLAS COMPACTAS (Ideal para listas largas de 100+ items)
   ========================================================================== */
.table-compact tr {
    display: grid;
    grid-template-columns: 1fr auto;
    /* Columna 1 expansible, Columna 2 ajustada al contenido */
    gap: 2px 10px;
    padding: 12px 10px;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0;
    border-radius: 0;
}

.table-compact tr:last-child {
    border-bottom: none;
}

.table-compact td {
    display: block;
    padding: 0;
    border: none;
    text-align: left;
}

.table-compact td::before {
    display: none;
    /* Ocultamos las etiquetas de texto para ahorrar espacio */
}

/* Posicionamiento en el Grid Móvil */
.table-compact td:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
}

/* Fila 1: Piloto */
.table-compact td:nth-child(2) {
    grid-column: 1;
    grid-row: 2;
}

/* Fila 2: Equipo */
.table-compact td:nth-child(3) {
    grid-column: 2;
    grid-row: 1 / span 2;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

/* Derecha: Categoría/Badge */

/* ==========================================================================
   ALERTAS, BADGES Y ETIQUETAS
   ========================================================================== */
/* ... (Mantén tus estilos de badges intactos aquí) ... */
.alerta,
.alert-box,
.success-box {
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 15px;
    font-size: 13px;
    text-align: center;
}

.alerta-exito,
.success-box {
    background: var(--success-bg);
    color: #34d399;
    border: 1px solid var(--success);
}

.alerta-error,
.alert-box {
    background: var(--danger-bg);
    color: #f87171;
    border: 1px solid var(--danger);
}

.badge,
.badge-cat {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: bold;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.badge-green {
    background: var(--success-bg);
    color: #34d399;
}

.badge-orange {
    background: var(--warning-bg);
    color: #fbbf24;
    border: 1px solid var(--warning);
}

.badge-red {
    background: var(--danger-bg);
    color: #ef4444;
    border: 1px solid var(--danger);
}

.badge-blue {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
    border: 1px solid var(--info);
}

.badge-gray {
    background: rgba(156, 163, 175, 0.1);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}

.badge-cat {
    background: rgba(37, 99, 235, 0.2);
    color: #60a5fa;
}

.monto-tag {
    display: inline-block;
    background: #065f46;
    color: #a7f3d0;
    padding: 3px 6px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: bold;
    margin-right: 5px;
}

.monto-box {
    font-size: 30px;
    font-weight: 900;
    color: var(--success);
    margin: 15px 0;
    background: #111827;
    padding: 15px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    font-family: monospace;
    text-align: center;
}

.qr-container {
    background: white;
    padding: 15px;
    border-radius: 6px;
    display: inline-block;
    margin: 10px auto;
    width: 100%;
    max-width: 250px;
}

.qr-image {
    width: 100%;
    height: auto;
    display: block;
}

.tx-code {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 15px;
    font-family: monospace;
    text-align: center;
}

.empty-state {
    text-align: center;
    padding: 25px;
    color: var(--text-muted);
    font-size: 14px;
    font-style: italic;
}

/* ==========================================================================
   ADAPTACIÓN A ESCRITORIO (PC) - MOBILE FIRST OVERRIDES
   ========================================================================== */
@media (min-width: 768px) {
    .header {
        flex-direction: row;
        justify-content: space-between;
        text-align: left;
    }

    .header .btn {
        width: auto;
    }

    .search-box {
        flex-direction: row;
    }

    .search-box .btn {
        width: auto;
    }

    .grid-principal,
    .grid-dos,
    .info-grid {
        grid-template-columns: 1fr 1fr;
    }

    .info-item.full {
        grid-column: 1 / -1;
    }

    .btn {
        width: auto;
        display: inline-flex;
    }

    .btn-block {
        width: 100%;
    }

    /* TABLAS EN PC: Vuelven a su formato tradicional */
    thead {
        display: table-header-group;
    }

    tr,
    .table-compact tr {
        display: table-row;
        border: none;
        background: transparent;
        padding: 0;
    }

    tr:hover,
    .table-compact tr:hover {
        background: rgba(255, 255, 255, 0.02);
    }

    th {
        background: #111827;
        color: var(--text-muted);
        padding: 15px;
        text-align: left;
        font-size: 11px;
        text-transform: uppercase;
        border-bottom: 2px solid var(--border-color);
    }

    td,
    .table-compact td {
        display: table-cell;
        text-align: left;
        padding: 12px 15px;
        border-bottom: 1px solid var(--border-color);
    }

    td::before {
        display: none;
    }
}

/* ==========================================================================
   COMPROBANTES Y PAGOS (QR, Montos)
   ========================================================================== */
.monto-box {
    font-size: 30px;
    font-weight: 900;
    color: var(--success);
    margin: 15px 0;
    background: #111827;
    padding: 15px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    font-family: monospace;
    text-align: center;
}

.qr-container {
    background: white;
    padding: 15px;
    border-radius: 6px;
    display: inline-block;
    margin: 10px auto;
    width: 100%;
    max-width: 250px;
}

.qr-image {
    width: 100%;
    height: auto;
    display: block;
}

.tx-code {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 15px;
    font-family: monospace;
    text-align: center;
}

.empty-state {
    text-align: center;
    padding: 25px;
    color: var(--text-muted);
    font-size: 14px;
    font-style: italic;
}

/* ==========================================================================
   ADAPTACIÓN A ESCRITORIO (PC) - MOBILE FIRST OVERRIDES
   ========================================================================== */
@media (min-width: 768px) {

    /* El Header se pone en línea */
    .header {
        flex-direction: row;
        justify-content: space-between;
        text-align: left;
    }

    .header .btn {
        width: auto;
    }

    /* Buscador horizontal */
    .search-box {
        flex-direction: row;
    }

    .search-box .btn {
        width: auto;
    }

    /* Grillas a dos columnas */
    .grid-principal,
    .grid-dos,
    .info-grid {
        grid-template-columns: 1fr 1fr;
    }

    .info-item.full {
        grid-column: 1 / -1;
    }

    /* El botón vuelve a su tamaño normal */
    .btn {
        width: auto;
        display: inline-flex;
    }

    .btn-block {
        width: 100%;
    }

    /* Si queremos forzar que un boton ocupe todo, usamos .btn-block */

    /* TABLAS EN PC: Vuelven a su formato tradicional */
    thead {
        display: table-header-group;
    }

    tr {
        display: table-row;
        border: none;
        background: transparent;
        padding: 0;
    }

    tr:hover {
        background: rgba(255, 255, 255, 0.02);
    }

    th {
        background: #111827;
        color: var(--text-muted);
        padding: 15px;
        text-align: left;
        font-size: 11px;
        text-transform: uppercase;
        border-bottom: 2px solid var(--border-color);
    }

    td {
        display: table-cell;
        text-align: left;
        padding: 15px;
        border-bottom: 1px solid var(--border-color);
    }

    td::before {
        display: none;
    }

    /* Ocultamos la etiqueta falsa de móvil */
    .val-celda {
        text-align: left;
    }
}

/* ==========================================================================
   HEADER PÚBLICO (NAVEGACIÓN STICKY) - ESTILO DOWNHILL RACING
   ========================================================================== */
.sticky-nav {
    position: sticky;
    top: -15px;
    /* Compensa el padding del body en celulares */
    z-index: 1000;

    /* Fondo semitransparente con efecto cristal (blur) */
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);

    margin-left: -10px;
    margin-right: -10px;
    padding: 15px 10px 8px 10px;
    /* Padding inferior reducido al mínimo */

    border-bottom: 2px solid var(--accent);
    /* Línea roja gruesa tipo carrera */
    margin-bottom: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6);
}

.header-global {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    /* Margen súper reducido */
}

.brand-logo {
    font-size: 16px;
    /* Más pequeño para ahorrar altura */
    font-weight: 900;
    color: white;
    font-style: italic;
    /* Aspecto de velocidad */
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.header-actions {
    display: flex;
    gap: 6px;
}

/* Botones del Header (Login y Registro) - Estilo Técnico */
.btn-outline {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 4px 8px;
    /* Compactos */
    border-radius: 3px;
    /* Bordes afilados */
    text-decoration: none;
    font-size: 10px;
    font-weight: 900;
    text-transform: uppercase;
    font-style: italic;
    transition: 0.2s;
}

.btn-outline:hover {
    background: var(--border-color);
    color: white;
}

.btn-outline-accent {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-outline-accent:hover {
    background: var(--accent);
    color: white;
}

/* Pestañas (Tabs) de Carreras */
.menu-carreras {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.menu-carreras::-webkit-scrollbar {
    display: none;
}

.tab-carrera {
    padding: 5px 12px;
    /* Delgadas pero legibles */
    background: #111827;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    /* Bordes cuadrados y agresivos */
    text-decoration: none;
    font-size: 11px;
    font-weight: 900;
    white-space: nowrap;
    text-transform: uppercase;
    font-style: italic;
    transition: all 0.2s ease;
}

.tab-carrera:hover {
    border-color: var(--text-muted);
    color: white;
}

.tab-carrera.tab-activa {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    box-shadow: 0 0 10px rgba(225, 29, 72, 0.4);
    /* Resplandor neón en la pestaña activa */
}

/* Ajuste para pantallas más grandes (PC) */
@media (min-width: 768px) {
    .sticky-nav {
        margin-left: 0;
        margin-right: 0;
        padding-left: 0;
        padding-right: 0;
        border-radius: 0 0 8px 8px;
        top: 0;
        /* En PC no hay padding negativo que compensar */
    }
}