/* Utilidades y componentes base compartidos.
   Diseñado para trabajar junto a tokens.css (cargar primero tokens.css). */

/* El body legado usa display:flex; sin esto app-root se encoge al ancho
   de su contenido y las páginas de ancho completo se ven recortadas. */
app-root {
    display: block;
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    min-height: 100vh;
}

/* Foco visible accesible (Fase D1) */
:focus-visible {
    outline: 3px solid var(--mt-color-accent);
    outline-offset: 2px;
}

.logo_titulo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    min-width: 180px;
    max-width: min(100%, 360px);
    padding: .45rem 1.25rem;
    margin-right: 1rem;
    background-color: var(--mt-color-primary, #000);
    color: #fff !important;
    font-weight: bold;
    line-height: 1.2;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-radius: var(--mt-radius-lg, 25px);
}

.botonXModal {
    color: #fff !important;
    font-size: 25px;
    cursor: pointer;
}

/* Separar el título del botón de cerrar en la cabecera de los modales */
.modal-header {
    justify-content: space-between;
}
.modal-header .botonXModal {
    margin-left: auto;
}

.CabezaModal {
    color: #fff !important;
    background: var(--mt-color-primary, #000) !important;
}

/* ---- Estado de carga en botones (Fase B2) ---- */
button.is-loading,
.btn.is-loading {
    pointer-events: none;
    opacity: .7;
    position: relative;
}
button.is-loading > .btn-spinner {
    display: inline-flex;
}
.btn-spinner {
    display: none;
    width: 1em;
    height: 1em;
    margin-right: .4em;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    vertical-align: middle;
    animation: mt-spin .6s linear infinite;
}

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

/* ---- Estados vacío / error en listados (Fase B4) ---- */
.estado-vacio,
.estado-error {
    padding: var(--mt-space-6, 32px) var(--mt-space-4, 16px);
    text-align: center;
    color: var(--mt-color-muted, #6c757d);
}
.estado-vacio .icono,
.estado-error .icono {
    font-size: 40px;
    display: block;
    margin-bottom: var(--mt-space-2, 8px);
}
.estado-error .icono { color: var(--mt-color-danger, #d9202b); }

/* ---- Tablas accesibles (Fase B4/D) ---- */
.tabla-mt thead th {
    background: var(--mt-color-primary, #0d0d0d);
    color: #fff;
    border: 0;
    white-space: nowrap;
}
.tabla-mt tbody tr { cursor: pointer; }
.tabla-mt tbody tr:hover { background: rgba(217, 32, 43, .06); }
.tabla-mt tbody tr.is-seleccionada {
    background: rgba(217, 32, 43, .12);
    box-shadow: inset 3px 0 0 var(--mt-color-accent, #d9202b);
}

/* ---- Mensajes de validación inline (Fase B5) ---- */
.msg-validacion {
    color: var(--mt-color-danger, #d9202b);
    font-size: .85rem;
    margin-top: .25rem;
}
.ng-invalid.ng-touched:not(form) {
    border-color: var(--mt-color-danger, #d9202b);
}

/* ==========================================================================
   Fase D — Accesibilidad, contraste y responsive (aditivo)
   ========================================================================== */

/* Respeta la preferencia de reducir movimiento */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
    }
}

/* Contraste en acciones y texto deshabilitado/de apoyo */
.dropdown-item:hover,
.dropdown-item:focus {
    background: rgba(217, 32, 43, .1);
    color: var(--mt-color-text, #212529);
}
.btn-outline-danger:hover,
.btn-outline-danger:focus {
    background-color: var(--mt-color-accent, #d9202b);
    color: #fff;
}

/* Controles con área táctil mínima y texto legible */
button,
.btn,
input,
select,
textarea,
.nav-link,
.dropdown-item {
    font-size: .95rem;
}
.btn:disabled,
button:disabled {
    cursor: not-allowed;
}

/* ==========================================================================
   Responsive global
   ========================================================================== */
@media (max-width: 992px) {
    .container-fluid { padding-left: .5rem; padding-right: .5rem; }
    .modal-dialog { margin: .5rem auto; }
    .table { font-size: .88rem; }
    .modal-body { max-height: 72vh; overflow: auto; }
}

@media (max-width: 768px) {
    /* Sidebar compacta */
    .row.flex-nowrap > .col-auto { width: 84px !important; min-width: 84px; }
    .BotonMenuVertical {
        font-size: .72rem;
        padding: .35rem .25rem;
        height: auto;
        white-space: normal;
        line-height: 1.1;
    }
    .IconBotonMenuVertical {
        margin-right: 3px !important;
        font-size: 130% !important;
    }
    /* Navbar flexible */
    .navbar .container-fluid { flex-wrap: wrap; gap: .5rem; }
    .navbar-brand.logo_titulo { font-size: 1rem; }
    .form-control, .form-select { font-size: .9rem; }
    h5 { font-size: 1.05rem; }
}

@media (max-width: 576px) {
    /* Ocultar sidebar para dar espacio al contenido */
    .row.flex-nowrap > .col-auto { display: none; }
    .container-fluid { padding-left: .35rem; padding-right: .35rem; }
    .btn { font-size: .85rem; }
}

/* ==========================================================================
   Menú móvil (off-canvas)
   ========================================================================== */
#mtMenuBtn {
    display: none;
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 2100;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: none;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #fff;
    background: #0d0d0f;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .3);
    cursor: pointer;
}
@media (max-width: 768px) {
    #mtMenuBtn { display: inline-flex; width: 40px; height: 40px; top: 8px; left: 8px; border-radius: 10px; font-size: 17px; }
    /* Reservar espacio para que no choque con el título de la página */
    .navbar > .container-fluid { padding-left: 58px; }
    /* Espacio superior para el botón de menú en todas las vistas de panel */
    .container-fluid > .row.flex-nowrap > .col { padding-top: 56px !important; }

    /* En móvil, quitar alturas fijas (%) que provocan solapamiento de botones sobre tablas */
    .navbar { height: auto !important; }
    .navbar .container-fluid { flex-wrap: wrap; gap: .5rem; }
    [style*="height: 100vh"], [style*="height:100vh"],
    [style*="height: 90vh"], [style*="height:90vh"],
    [style*="height: 88%"], [style*="height:88%"],
    [style*="height: 85%"], [style*="height:85%"],
    [style*="height: 80%"], [style*="height:80%"],
    [style*="height: 78%"], [style*="height:78%"],
    [style*="height: 15%"], [style*="height:15%"],
    [style*="height: 12%"], [style*="height:12%"],
    [style*="height: 10%"], [style*="height:10%"],
    [style*="height: 5%"],  [style*="height:5%"],
    [style*="height: 500px"], [style*="height:500px"] {
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
    }
}

/* Fondo oscuro al abrir el menú */
#menuOverlay { display: none; }
@media (max-width: 768px) {
    body.menu-abierto #menuOverlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, .5);
        z-index: 2040;
    }
    body.menu-abierto .row.flex-nowrap > .col-auto {
        display: block !important;
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 250px !important;
        min-width: 250px;
        max-width: 80vw;
        overflow-y: auto;
        z-index: 2050;
        background: #0d0d0f;
        box-shadow: 4px 0 20px rgba(0, 0, 0, .4);
    }
}

/* Navegación vertical: evitar desbordes en pantallas angostas */
@media (max-width: 992px) {
    [ng-include] {
        min-width: 150px;
    }
    .nav .BotonMenuVertical {
        white-space: normal;
        height: auto;
    }
}
@media (max-width: 576px) {
    [ng-include] {
        display: none;
    }
}

/* ==========================================================================
   Tiempos de juego (configuración del marcador)
   ========================================================================== */
.tiempo-seccion-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: .35rem .5rem;
    background: rgba(13, 13, 13, .04);
    border-radius: var(--mt-radius-sm, 8px);
}
.tiempos-lista {
    width: 100%;
}
.tiempo-row {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .55rem .1rem;
    border-bottom: 1px solid var(--mt-color-border, #e9ecef);
    width: 100%;
}
.tiempo-row:last-child {
    border-bottom: 0;
}
.tiempo-idx {
    flex: 0 0 auto;
    width: 1.7rem;
    color: var(--mt-color-muted, #6c757d);
    font-weight: 600;
    text-align: right;
}
.tiempo-fields {
    flex: 1 1 auto;
    display: flex;
    justify-content: stretch;
    gap: .6rem;
}
.tiempo-field {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: .15rem;
}
.tiempo-unit {
    align-self: center;
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .3px;
    color: var(--mt-color-muted, #6c757d);
}
.tiempo-field input {
    width: 100%;
    text-align: center;
}
.tiempo-del {
    flex: 0 0 auto;
    color: var(--mt-color-danger, #d9202b);
    padding: 0 .25rem;
    font-size: 1rem;
    text-decoration: none;
}
.tiempo-del:hover {
    color: var(--mt-color-accent-hover, #b8151f);
    text-decoration: none;
}
.tiempos-vacio {
    padding: 1rem;
    text-align: center;
    color: var(--mt-color-muted, #6c757d);
    background: rgba(13, 13, 13, .03);
    border-radius: var(--mt-radius-sm, 8px);
}
.tiempos-footer {
    display: flex;
    align-items: center;
}
