/*
==================================================
BLOQUE TABLA
==================================================
*/

.bloque-tabla {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;

    /*
    Si la tabla necesita más ancho,
    el scroll queda DENTRO del bloque,
    nunca en toda la página.
    */
    overflow-x: auto;
    overflow-y: hidden;

    -webkit-overflow-scrolling: touch;

    box-sizing: border-box;
}


/*
==================================================
TABLA
==================================================
*/

.bloque-tabla table {
    width: 100%;
    max-width: 100%;
    min-width: 100%;

    margin-bottom: 0;

    box-sizing: border-box;
}


/*
Todas las partes de la tabla respetan
el box model.
*/

.bloque-tabla table *,
.bloque-tabla table *::before,
.bloque-tabla table *::after {
    box-sizing: border-box;
}


/*
==================================================
CELDAS
==================================================

Permitimos que textos largos puedan romper línea
en lugar de ensanchar toda la página.
==================================================
*/

.bloque-tabla th,
.bloque-tabla td {
    max-width: 100%;

    overflow-wrap: anywhere;
    word-break: normal;
}


/*
Enlaces muy largos, emails, URLs, etc.
*/

.bloque-tabla td a {
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
}


/*
==================================================
MÓVIL
==================================================

Si hay muchas columnas dejamos que la tabla tenga
un ancho mínimo cómodo, PERO el desplazamiento
queda contenido dentro de .bloque-tabla.
==================================================
*/

@media (max-width: 767.98px) {

    .bloque-tabla table {
        min-width: 600px;
    }

}


/*
==================================================
OVERLAY DETALLE
==================================================
*/

.tabla-detalle-overlay {
    position: fixed;

    inset: 0;

    z-index: 99999;

    width: 100%;
    max-width: 100%;

    overflow-x: hidden;
    overflow-y: scroll;

    box-sizing: border-box;
}


.tabla-detalle-overlay[hidden] {
    display: none !important;
}


/*
==================================================
FONDO
==================================================
*/

.tabla-detalle-fondo {
    position: fixed;

    inset: 0;

    width: 100%;
    height: 100%;

    background: rgba(0, 0, 0, .85);
}


/*
==================================================
PANEL
==================================================

IMPORTANTE:

box-sizing:border-box evita que:

width:100% + padding

supere el ancho de la ventana.
==================================================
*/

.tabla-detalle-panel {
    position: relative;

    z-index: 1;

    width: min(1400px, 100%);
    max-width: 100%;
    min-height: 100vh;

    margin: 0 auto;

    padding: clamp(
        1rem,
        3vw,
        3rem
    );

    background-color: #fff;
    background-position: center center;
    background-repeat: no-repeat;
    background-size: cover;

    box-sizing: border-box;

    overflow-x: hidden;
}


/*
==================================================
BOTÓN CERRAR
==================================================
*/

.tabla-detalle-cerrar {
    position: sticky;

    top: 1rem;

    float: right;

    z-index: 3;

    border: 0;

    background: transparent;

    font-size: 2.5rem;

    line-height: 1;
    color:#ccc;
}


/*
==================================================
CONTENIDO DEL DETALLE
==================================================
*/

.tabla-detalle-contenido {
    clear: both;

    width: 100%;
    max-width: 100%;
    min-width: 0;

    box-sizing: border-box;
}


/*
Los rows Bootstrap del contenido del detalle
no deben poder ensanchar el overlay.
*/

.tabla-detalle-contenido > .row {
    max-width: 100%;
}


/*
==================================================
OVERLAY ABIERTO
==================================================
*/

html.tabla-detalle-abierto,
body.tabla-detalle-abierto {
    overflow: hidden;
}


/*
==================================================
MÓVIL
==================================================
*/

@media (max-width: 767.98px) {

    .tabla-detalle-panel {
        width: 100%;
        max-width: 100%;

        padding: 1rem;
    }

}

/*
==================================================
SUPERFICIE DEL DETALLE
==================================================

La URL directa reutiliza la misma imagen configurada
para el fondo del lightbox.
==================================================
*/

.tabla-detalle-superficie {
    width: 100%;
    max-width: 100%;
    min-width: 0;

    background-position: center center;
    background-repeat: no-repeat;
    background-size: cover;

    box-sizing: border-box;
}


/*
Solo para la URL directa.

El fondo queda presente aunque el contenido sea
más corto que la pantalla.
*/

.tabla-detalle-superficie-directa {
    min-height: 60vh;
}


/*
Evitar que el row del detalle desborde el ancho.
*/

.tabla-detalle-superficie > .row {
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
}


/*
Evitar que el scroll del lightbox se propague
a la página que permanece por debajo.
*/

.tabla-detalle-overlay {
    overscroll-behavior: contain;
}
/*
==================================================
ANIMACIÓN SUAVE DEL LIGHTBOX DE TABLA
==================================================
Compatible con tabla-overlay-suave.js
==================================================
*/

.tabla-detalle-overlay .tabla-detalle-fondo {
    opacity: 0;
    transition:
        opacity 400ms cubic-bezier(.22, 1, .36, 1);
}

.tabla-detalle-overlay .tabla-detalle-panel {
    opacity: 0;
    transform: translateY(10px);

    transition:
        opacity 400ms cubic-bezier(.22, 1, .36, 1),
        transform 400ms cubic-bezier(.22, 1, .36, 1);

    will-change: opacity, transform;
}

.tabla-detalle-overlay.tabla-detalle-visible .tabla-detalle-fondo {
    opacity: 1;
}

.tabla-detalle-overlay.tabla-detalle-visible .tabla-detalle-panel {
    opacity: 1;
    transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {

    .tabla-detalle-overlay .tabla-detalle-fondo,
    .tabla-detalle-overlay .tabla-detalle-panel {
        transition: none !important;
        transform: none !important;
    }

}