/* ============================================================
   MUNDOCOMPETICION - Hoja de estilos BASE
   Estructura y componentes. Los COLORES se definen únicamente
   con variables CSS en publico/css/temas/*.css
   ============================================================ */

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

html { font-size: 16px; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
    background: var(--fondo);
    color: var(--texto);
    min-height: 100vh;
    transition: background .3s, color .3s;
}

/* ---------- Estructura general ---------- */
.contenedor {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

.cabecera {
    background: var(--superficie);
    border-bottom: 3px solid var(--primario);
    padding: .6rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;            /* móviles estrechos: no se corta */
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px var(--sombra);
}

.cabecera .logo {
    font-weight: 800;
    font-size: 1.2rem;
    color: var(--primario);
    text-decoration: none;
    letter-spacing: .5px;
}

.principal { display: flex; min-height: calc(100vh - 60px); }

/* ---------- Menú lateral ---------- */
.menu-lateral {
    width: 230px;
    flex-shrink: 0;
    background: var(--superficie);
    border-right: 1px solid var(--borde);
    padding: 1rem .5rem;
}

.menu-lateral a {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .6rem .8rem;
    margin-bottom: .2rem;
    border-radius: 8px;
    color: var(--texto);
    text-decoration: none;
    font-size: .95rem;
    transition: background .15s, color .15s;
}

.menu-lateral a:hover { background: var(--primario-suave); color: var(--primario); }
.menu-lateral a.activo { background: var(--primario); color: var(--texto-sobre-primario); font-weight: 600; }

.contenido { flex: 1; padding: 1.5rem; min-width: 0; }

/* ---------- Tarjetas ---------- */
.tarjeta {
    background: var(--superficie);
    border: 1px solid var(--borde);
    border-radius: 12px;
    padding: 1.2rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 10px var(--sombra);
}

.tarjeta h1, .tarjeta h2 { color: var(--primario); margin-bottom: .8rem; }

/* ---------- Formularios ---------- */
.campo { margin-bottom: 1rem; }

.campo label {
    display: block;
    font-size: .85rem;
    font-weight: 600;
    margin-bottom: .3rem;
    color: var(--texto-suave);
}

.campo input, .campo select, .campo textarea {
    width: 100%;
    padding: .65rem .8rem;
    border: 1.5px solid var(--borde);
    border-radius: 8px;
    background: var(--fondo);
    color: var(--texto);
    font-size: 1rem;
    transition: border-color .15s, box-shadow .15s;
}

.campo input:focus, .campo select:focus, .campo textarea:focus {
    outline: none;
    border-color: var(--primario);
    box-shadow: 0 0 0 3px var(--primario-suave);
}

/* ---------- Botones ---------- */
.boton {
    display: inline-block;
    padding: .65rem 1.4rem;
    border: none;
    border-radius: 8px;
    background: var(--primario);
    color: var(--texto-sobre-primario);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: filter .15s, transform .05s;
}

.boton:hover { filter: brightness(1.1); }
.boton:active { transform: scale(.98); }
.boton.secundario { background: var(--secundario); }
.boton.peligro { background: var(--peligro); }
.boton.bloque { display: block; width: 100%; }

/* ---------- Tablas ---------- */
.tabla { width: 100%; border-collapse: collapse; }

.tabla th {
    background: var(--primario);
    color: var(--texto-sobre-primario);
    padding: .6rem .8rem;
    text-align: left;
    font-size: .85rem;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.tabla td { padding: .55rem .8rem; border-bottom: 1px solid var(--borde); }
.tabla tr:hover td { background: var(--primario-suave); }

/* ---------- Avisos ---------- */
.aviso {
    padding: .8rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: .95rem;
    border-left: 4px solid;
}

.aviso.error { background: var(--peligro-suave); border-color: var(--peligro); color: var(--peligro); }
.aviso.exito { background: var(--exito-suave); border-color: var(--exito); color: var(--exito); }

/* ---------- Página de login ---------- */
.login-centro {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: linear-gradient(135deg, var(--fondo) 0%, var(--primario-suave) 100%);
}

.login-caja { width: 100%; max-width: 420px; }

.login-caja .tarjeta { padding: 2rem; }

.login-logo { text-align: center; font-size: 1.6rem; font-weight: 800; color: var(--primario); margin-bottom: 1.5rem; }

.login-pestanas { display: flex; gap: .5rem; margin-bottom: 1.5rem; }

.login-pestanas a {
    flex: 1;
    text-align: center;
    padding: .6rem;
    border-radius: 8px;
    background: var(--fondo);
    border: 1.5px solid var(--borde);
    color: var(--texto);
    text-decoration: none;
    font-weight: 600;
}

.login-pestanas a.activa { background: var(--primario); border-color: var(--primario); color: var(--texto-sobre-primario); }

/* ---------- Selector de tema ---------- */
.selector-tema { display: flex; align-items: center; gap: .5rem; }

.selector-tema select {
    padding: .35rem .5rem;
    border-radius: 6px;
    border: 1px solid var(--borde);
    background: var(--fondo);
    color: var(--texto);
}

/* ---------- Llaves de eliminatoria ---------- */
.llaves {
    display: flex;
    gap: 1.2rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: .8rem;
}

.llaves-columna {
    min-width: 190px;
    display: flex;
    flex-direction: column;
    justify-content: space-around;   /* aproxima la forma de la llave */
    gap: .8rem;
}

.llaves-columna.perdedores { border-left: 2px dashed var(--borde); padding-left: 1.2rem; }

.llaves-titulo {
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--texto-suave);
    text-transform: uppercase;
}

.llaves-cruce {
    border: 1.5px solid var(--borde);
    border-radius: 8px;
    overflow: hidden;
    background: var(--fondo);
}

.llaves-cruce.enjuego { border-color: var(--exito); }

.llaves-equipo {
    display: flex;
    justify-content: space-between;
    gap: .5rem;
    padding: .35rem .55rem;
    font-size: .85rem;
}

.llaves-equipo + .llaves-equipo { border-top: 1px solid var(--borde); }
.llaves-equipo.ganador { background: var(--primario-suave); font-weight: 700; }
.llaves-equipo .nombre { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 140px; }
.llaves-equipo .puntos { font-variant-numeric: tabular-nums; font-weight: 700; }

/* ---------- Responsive ---------- */
@media (max-width: 800px) {
    .principal { flex-direction: column; }
    .menu-lateral { width: 100%; border-right: none; border-bottom: 1px solid var(--borde); display: flex; overflow-x: auto; padding: .5rem; }
    .menu-lateral a { white-space: nowrap; }
    .contenido { padding: 1rem; }

    /* Tablas anchas: scroll horizontal en lugar de romper el diseño */
    .tabla {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .tabla th, .tabla td { white-space: nowrap; }
}

@media (max-width: 600px) {
    html { font-size: 15px; }
    .cabecera { padding: .5rem .7rem; }
    .tarjeta { padding: .9rem; }

    /* Filtros y formularios en línea: apilados a ancho completo */
    .tarjeta form[style*="flex"] { flex-direction: column !important; align-items: stretch !important; }
    .tarjeta form[style*="flex"] .campo { min-width: 100% !important; }

    /* Botones de acción en filas de tabla: tamaño táctil */
    .tabla td .boton { display: block; width: 100%; margin: 0 0 .3rem; text-align: center; }
    .tabla td form { width: 100%; }
}
