@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@400;600;700;800&family=Barlow:wght@400;500;600&display=swap');

:root {
    --azul:       #0E4b9c;
    --azul-dark:  #0a3a7a;
    --azul-light: #e8effc;
    --verde:      #28a745;
    --gris:       #6c757d;
    --texto:      #1a1a2e;
    --borde:      #d0ddf5;
    --fondo:      #f4f7ff;
    --desc-bg:    #f2f2f2;
    --desc-color: #7a7a7a;
    --desc-borde: #c8c8c8;
    --desc-brown: #856404;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Barlow', sans-serif;
    background: var(--fondo);
    color: var(--texto);
    min-height: 100vh;
}

/* ── NAVBAR ── */
.navbar {
    width: 100%;
    background: var(--azul);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 18px 8px 14px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 12px rgba(14,75,156,0.4);
}
.nav-left img { height: 42px; }
.nav-right {
    display: flex;
    align-items: center;
    gap: 14px;
}
.nav-label {
    font-family: sans-serif;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 5px;
    border-bottom: 1px solid rgba(255,255,255,0.35);
    padding-bottom: 2px;
}
.nav-right .material-symbols-outlined { font-size: 20px; }
.cerrar {
    font-size: 20px;
    cursor: pointer;
    width: 34px; height: 34px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    transition: background 0.2s, transform 0.4s;
    -webkit-tap-highlight-color: transparent;
}
.cerrar:hover, .cerrar:active {
    background: rgba(255,255,255,0.15);
    transform: rotate(180deg);
}

/* ── TÍTULO ── */
h1 {
    font-family: Arial, sans-serif;
    font-weight: 700;
    text-align: center;
    color: var(--azul);
    font-size: clamp(20px, 6vw, 34px);
    letter-spacing: 0.02em;
    padding: 18px 15px 4px;
}
.subtitulo {
    text-align: center;
    color: grey;
    font-size: 17px;
    margin-bottom: 16px;
    letter-spacing: 0.03em;
    font-family: Arial, sans-serif;
}

/* ── CONTENEDOR ── */
.contenedor {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 12px 50px;
}

/* ── FILTRO ── */
.marco {
    border: 1.5px solid var(--azul);
    border-radius: 14px;
    padding: 12px 14px 10px;
    background: white;
    max-width: 560px;
    margin: 0 auto 4px;
    box-shadow: 0 2px 10px rgba(14,75,156,0.08);
}
legend {
    padding: 0 8px;
    color: var(--azul);
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 700;
    font-size: 15px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
label {
    display: block;
    margin-bottom: 4px;
    color: var(--texto);
    font-weight: 600;
    font-size: 12px;
    margin-left: 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
select {
    width: 100%;
    padding: 10px 34px 10px 12px;
    border-radius: 8px;
    border: 1.5px solid var(--borde);
    font-size: 15px;
    font-family: 'Barlow', sans-serif;
    background: var(--fondo);
    color: var(--texto);
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%230E4b9c' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    cursor: pointer;
    transition: border-color 0.2s;
}
select:focus { outline: none; border-color: var(--azul); }

/* ── BOTONES ── */
.boton-centro {
    text-align: center;
    margin-top: 14px;
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}
.btn-registrar, .btn-limpiar {
    padding: 12px 24px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 15px;
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: none;
    transition: transform 0.12s, box-shadow 0.12s;
    -webkit-tap-highlight-color: transparent;
    min-width: 130px;
    justify-content: center;
    touch-action: manipulation;
}
.btn-registrar {
    background: var(--verde);
    color: white;
    box-shadow: 0 3px 10px rgba(40,167,69,0.3);
}
.btn-registrar:active { transform: scale(0.96); box-shadow: none; }
.btn-limpiar {
    background: white;
    color: var(--gris);
    border: 1.5px solid var(--borde);
}
.btn-limpiar:active { transform: scale(0.96); }

/* ── CONTADOR ── */
.contador {
    text-align: right;
    font-size: 12px;
    color: var(--gris);
    margin: 12px 2px 2px;
    font-style: italic;
}

/* ══════════════════════════════════════
   CABECERA DE DIVISIÓN
   ══════════════════════════════════════ */
.bloque-division { margin-top: 18px; }

.div-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 10px 10px 0 0;
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 17px;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--azul);
    background: var(--azul-light);
    border: 1.5px solid var(--borde);
    border-bottom: none;
}
.div-header .material-symbols-outlined { font-size: 22px; }

/* ══════════════════════════════════════
   TARJETAS — mobile first
   ══════════════════════════════════════ */
.cards-wrapper {
    display: flex;
    flex-direction: column;
    border: 1.5px solid var(--borde);
    border-radius: 0 0 10px 10px;
    overflow: hidden;
    background: white;
    box-shadow: 0 3px 10px rgba(14,75,156,0.07);
}

.card-partido {
    display: grid;
    grid-template-columns: 72px 1fr;
    border-bottom: 1px solid var(--borde);
    -webkit-tap-highlight-color: transparent;
    transition: background 0.12s;
}
.card-partido:last-child { border-bottom: none; }
.card-partido:active { background: #dce9fc; }

.card-meta {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 10px 6px;
    background: var(--azul);
    color: white;
    text-align: center;
}
.card-hora {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 400;
    font-size: 22px;
    line-height: 1;
    letter-spacing: 0.02em;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}
.card-hora .material-symbols-outlined {
    font-size: 20px;
    opacity: 0.85;
}
.card-pista {
    font-size: 19px;
    font-weight: 700;
    opacity: 1;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    display: flex;
    align-items: center;
    gap: 2px;
}
.card-pista .material-symbols-outlined { font-size: 12px; }
.card-pista-label { display: none; }

.card-enfrentamiento {
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
}
.card-pareja {
    font-weight: 600;
    font-size: 14px;
    color: #0E4b9c;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.card-vs {
    display: inline-block;
    background: transparent;
    border: 1px solid #d8dde6;
    color: #9aa3b0;
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.06em;
    padding: 1px 6px;
    border-radius: 4px;
    width: fit-content;
    margin: 1px 0;
}

/* ── DESCANSO — tarjeta móvil ── */
.card-partido.card-descanso {
    grid-template-columns: 72px 1fr;
}
.card-partido.card-descanso .card-meta {
    background: #9a9a9a;
}
.card-partido.card-descanso:active { background: #e8e8e8; }

/* ── Badge DESCANSO ── */
.desc-badge-hora {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffc107;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    padding: 2px 6px 2px 4px;
    border-radius: 4px;
    white-space: nowrap;
}
.desc-badge-hora .material-symbols-outlined {
    font-size: 13px;
    line-height: 1;
    font-variation-settings: 'wght' 400;
}

/* ── Separador entre parejas en descanso ── */
.desc-sep {
    color: #aaa;
    font-size: 1rem;
    margin: 0 6px;
    vertical-align: middle;
}

/* ── Icono coffee centrado ── */
.desc-coffee {
    text-align: center !important;
    justify-content: center !important;
    color: #856404 !important;
}
.desc-coffee .material-symbols-outlined {
    font-size: 20px;
    vertical-align: middle;
}

/* Parejas en descanso — marrón (móvil) */
.card-pareja.desc-pareja {
    color: var(--desc-brown) !important;
    font-style: normal !important;
    font-weight: 400 !important;
}

/* ══════════════════════════════════════
   TABLA — sólo en escritorio (≥ 640px)
   ══════════════════════════════════════ */
.tabla-cruces { display: none; }

@media (min-width: 640px) {
    .cards-wrapper  { display: none !important; }
    .tabla-cruces   { display: table; }

    .tabla-cruces {
        width: 100%;
        border-collapse: collapse;
        border: 1.5px solid var(--borde);
        border-top: none;
        border-radius: 0 0 10px 10px;
        overflow: hidden;
        background: white;
        box-shadow: 0 3px 10px rgba(14,75,156,0.07);
    }
    .tabla-cruces thead tr {
        background: var(--azul-dark);
        color: white;
    }
    .tabla-cruces thead th {
        padding: 10px 14px;
        font-family: 'Barlow Condensed', sans-serif;
        font-size: 13px;
        font-weight: 700;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        text-align: left;
    }
    .fila-partido td {
        padding: 10px 14px;
        border-bottom: none;
        vertical-align: middle;
        font-size: 15px;
    }

    .fila-par  td { background: white; }
    .fila-impar td { background: #f8faff; }
    .fila-par td, .fila-impar td { border-top: 1px solid var(--borde); }
    .fila-partido:hover td { background: #dce9fc; transition: background 0.15s; }

    /* ── Celda de hora combinada (rowspan) ── */
    td.celda-hora-merged {
        background: var(--azul-light) !important;
        text-align: center;
        vertical-align: middle !important;
        border-right: 1px solid var(--borde);
        border-top: 1px solid var(--azul) !important;
        border-bottom: none;
    }
    .fila-partido:hover td.celda-hora-merged { background: var(--azul-light) !important; }

    /* Bordes de grupo de hora */
    /* El separador entre grupos es el border-top del primer registro de cada grupo nuevo.
       Así no dependemos de :has() ni de border-bottom en fila-hora-end.            */
    .fila-hora-start td                    { border-top: 1.5px solid var(--azul) !important; }
    .tabla-cruces tbody tr:first-child td  { border-top: none !important; }  /* primer grupo: sin borde arriba */
    .fila-hora-end td                      { border-bottom: none !important; }

    /* ── DESCANSO — fila escritorio ── */
    .fila-descanso td { background: var(--desc-bg) !important; border-top: none !important; border-bottom: none !important; overflow: hidden; }
    .fila-descanso:hover td { background: #e4e4e4 !important; transition: background 0.15s; }
    .fila-descanso .celda-hora { color: var(--desc-color); }
    .fila-descanso .celda-pista { color: var(--desc-color); }
    .celda-descanso-badge {
        text-align: center;
    }

    .desc-icono { color: var(--desc-color) !important; }

    .desc-badge {
        display: inline-flex;
        align-items: center;
        gap: 4px;
        background: white;
        border: 1.5px solid var(--desc-borde);
        color: var(--desc-color);
        font-family: 'Barlow Condensed', sans-serif;
        font-size: 11px;
        font-weight: 700;
        letter-spacing: 0.06em;
        text-transform: uppercase;
        padding: 2px 8px;
        border-radius: 4px;
    }
    .desc-badge .material-symbols-outlined { font-size: 14px; }

    /* Parejas en descanso — marrón (escritorio) */
    .pareja-desc {
        font-weight: 400 !important;
        color: var(--desc-brown) !important;
        font-style: normal !important;
    }

    .celda-hora {
        white-space: nowrap;
        font-family: 'Barlow Condensed', sans-serif;
        font-weight: 700;
        font-size: 17px !important;
        color: var(--azul);
        width: 100px;
        text-align: center;
    }
    .celda-pista {
        white-space: nowrap;
        width: 120px;
        color: var(--azul);
        font-family: 'Barlow Condensed', sans-serif;
        font-weight: 700;
        font-size: 16px !important;
    }
    .celda-partido {
        display: flex !important;
        align-items: center;
        gap: 10px;
        flex-wrap: wrap;
    }
    .pareja { font-weight: 600; color: #0E4b9c; }
    .vs-badge {
        background: #eef0f3;
        color: #8a939f;
        font-family: 'Barlow Condensed', sans-serif;
        font-size: 11px;
        font-weight: 600;
        padding: 2px 7px;
        border-radius: 4px;
        letter-spacing: 0.04em;
    }
    .icono-mini {
        font-size: 17px;
        vertical-align: middle;
        color: var(--azul);
        margin-right: 3px;
        font-variation-settings: 'wght' 700;
    }
}

/* ── MENSAJES ── */
.aviso-error, .aviso-vacio {
    margin-top: 20px;
    padding: 14px 16px;
    border-radius: 10px;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.aviso-error { background: #ffe5e5; color: #c0392b; border: 1px solid #f5c6cb; }
.aviso-vacio { background: #fff3cd; color: #856404; border: 1px solid #ffc107; }

/* ── NAVBAR en móvil pequeño ── */
@media (max-width: 480px) {
    .nav-label { display: none; }
    h1 { font-size: 19px; padding: 14px 12px 4px; }
}
