﻿/* ============================================================
   ESTILOS CENTRALIZADOS - GestionVentanas
   Corrección de maquetado: labels + checkboxes alineados
   ============================================================ */

/* ── Variables globales ── */
:root {
    --color-primary:    #000000;
    --color-accent:     #f6e70f;
    --color-danger:     #dc3545;
    --color-border:     #dee2e6;
    --color-bg-odd:     #f2f2f2;
    --color-bg-even:    #ffffff;
    --color-bg-hover:   #fffbe6;
    --radius:           4px;
    --font-size-base:   14px;
}

/* ============================================================
   LAYOUT PRINCIPAL: cabecera fija, contenido scrollable
   ============================================================ */

/* La sección principal ocupa la altura disponible sin overflow en el body */
html, body {
    height:   100%;
    overflow: hidden; /* el scroll ocurre DENTRO de los paneles, no en la página */
}

/* Contenedor principal del artículo */
.section-main {
    display:        flex;
    flex-direction: column;
    height:         100vh;          /* ocupa toda la ventana */
    overflow:       hidden;
}

/* Bloque sticky superior: filtros + nombre cliente
   Engloba los dos .form-filtro de cabecera */
.cabecera-sticky {
    position:         sticky;
    top:              0;
    z-index:          50;
    background-color: #fff;
    padding:          6px 0 4px;
    border-bottom:    2px solid var(--color-border);
    flex-shrink:      0;            /* nunca se encoge */
}

/* Área de trabajo central (foto + panel de medidas): ocupa el resto */
.area-trabajo {
    flex:       1 1 auto;
    overflow:   hidden;             /* los paneles internos gestionan su propio scroll */
    display:    flex;
    position:   relative;
}

/* ============================================================
   CABECERA STICKY  (filtros superiores que no deben desaparecer)
   Envuelve los dos .form-filtro de arriba (Solicitud + Cliente)
   en un contenedor con esta clase para que quede anclado.
   ============================================================ */
.filtros-sticky {
    position:         sticky;
    top:              0;
    z-index:          200;
    background-color: #ffffff;
    border-bottom:    2px solid var(--color-border);
    padding:          6px 12px;
    box-shadow:       0 2px 6px rgba(0,0,0,0.08);
}

/* Cuando el sticky está activo (hay scroll) añade sombra más fuerte */
.filtros-sticky.is-stuck {
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* ============================================================
   FORM-FILTRO
   Fila flexible usada en el formulario principal y en modales.
   Por defecto: wrap para que no se desborde en pantallas pequeñas.
   ============================================================ */
.form-filtro {
    display:     flex;
    align-items: center;
    flex-wrap:   wrap;          /* evita que los elementos se salgan */
    gap:         8px 12px;      /* gap vertical / horizontal */
    margin:      8px 0;
}

/* ── Label estándar dentro de form-filtro ── */
.form-filtro .label-inline,
.form-filtro > label {
    font-weight:  bold;
    white-space:  nowrap;       /* el texto del label nunca se parte */
    margin:       0;            /* reset de márgenes heredados */
    align-self:   center;       /* alinea verticalmente con el control */
    /* SIN width fijo: cada label ocupa lo que necesita */
}

/* ── Checkbox dentro de form-filtro ──
   Se coloca justo después de su label, centrado verticalmente. */
.form-filtro input[type="checkbox"] {
    width:        18px;
    height:       18px;
    margin:       0;
    flex-shrink:  0;
    align-self:   center;
    cursor:       pointer;
}

/* ── Separadores de grupos de opciones dentro de una misma fila ──
   Si se quiere un pequeño espacio antes de un nuevo par label+check
   se puede añadir la clase .group-start al label. */
.form-filtro .group-start {
    margin-left: 20px;
}

/* ============================================================
   CABECERA (fila de campo de formulario con label + control)
   ============================================================ */
.cabecera {
    display:     flex;
    align-items: center;
    flex-wrap:   nowrap;
    gap:         8px;
    margin-bottom: 8px;
}

.cabecera > label,
.cabecera .label-inline {
    font-weight:  bold;
    white-space:  nowrap;
    margin:       0;
    align-self:   center;
    text-align:   right;
    min-width:    110px;   /* mínimo para que queden alineados */
}

/* ── Input / Select / TextBox dentro de cabecera ── */
.cabecera .form-control,
.cabecera select,
.cabecera input[type="text"],
.cabecera input[type="number"] {
    flex:      1 1 auto;
    min-width: 80px;
}

/* ============================================================
   CHECKCABECERA  (bloque de checkbox agrupados: Agujero, Zapata…)
   ============================================================ */
.checkcabecera {
    font-size:      var(--font-size-base);
    display:        flex;
    flex-direction: column;
    gap:            6px;
    margin:         6px 0;
}

/* Cada fila de checkboxes */
.checkbox-row {
    display:     flex;
    align-items: center;
    flex-wrap:   wrap;
    gap:         8px 14px;
}

/* Etiqueta de grupo ("Agujero colocación:", "Zapata:") */
.checkbox-row .label-bold {
    font-weight:  bold;
    white-space:  nowrap;
    margin-right: 4px;
}

/* Par individual: texto + checkbox */
.checkbox-pair {
    display:     inline-flex;
    align-items: center;
    gap:         5px;
    white-space: nowrap;
    cursor:      pointer;
}

.checkbox-pair span {
    font-size: var(--font-size-base);
    line-height: 1;
}

.checkbox-pair input[type="checkbox"] {
    width:  16px;
    height: 16px;
    margin: 0;
    cursor: pointer;
}

/* ============================================================
   LABEL-INLINE (uso general fuera de form-filtro)
   ============================================================ */
.label-inline {
    font-weight: bold;
    /* Sin width fijo: se adapta al contenido */
}

/* ============================================================
   SEPARADOR HORIZONTAL
   ============================================================ */
.separador-horizontal {
    display:         flex;
    align-items:     center;
    justify-content: center;
    width:           100%;
    margin:          8px 0;
    position:        relative;
}

.separador-horizontal::before,
.separador-horizontal::after {
    content:          "";
    height:           1px;
    background-color: #999;
    flex-grow:        1;
}

.separador-horizontal::before { margin-right: 10px; }
.separador-horizontal::after  { margin-left:  10px; }

.texto-separador {
    font-weight:      bold;
    color:            #333;
    white-space:      nowrap;
    z-index:          1;
    background-color: #fff;
    padding:          0 10px;
    font-size:        12px;
    text-transform:   uppercase;
    letter-spacing:   0.5px;
}

/* ============================================================
   TABLA   (#OrdenaryFiltrar)
   ============================================================ */
.form-filtro-tabla {
    display:     flex;
    align-items: center;
    gap:         10px;
    margin:      20px 0;
}

.form-filtro-tabla .label-inline {
    margin-right: 10px;
    font-weight:  bold;
    width:        20%;
}

#tabla {
    width:      100%;
    overflow-x: auto;
    overflow-y: auto;
    position:   relative;
    border:     1px solid var(--color-border);
    border-radius: var(--radius);
    max-height: 80%;
}

#OrdenaryFiltrar {
    border-collapse: separate;
    border-spacing:  0;
    width:           max-content;
    min-width:       100%;
    margin-bottom:   0;
}

/* Cabecera sticky */
#OrdenaryFiltrar thead {
    position: sticky;
    top:      0;
    z-index:  10;
}

#OrdenaryFiltrar thead tr th {
    background-color: var(--color-primary) !important;
    color:            var(--color-accent)  !important;
    text-align:       center;
    text-transform:   uppercase;
    padding:          8px 12px;
    border-right:     1px solid #333;
    border-bottom:    1px solid #333;
    white-space:      nowrap;
    cursor:           pointer;
}

#OrdenaryFiltrar thead tr:hover th {
    background-color: var(--color-primary) !important;
    color:            var(--color-accent)  !important;
}

/* Cuerpo */
#OrdenaryFiltrar tbody tr:nth-child(odd)  td { background-color: var(--color-bg-odd);  }
#OrdenaryFiltrar tbody tr:nth-child(even) td { background-color: var(--color-bg-even); }
#OrdenaryFiltrar tbody tr:hover           td { background-color: var(--color-bg-hover) !important; }

#OrdenaryFiltrar tbody td {
    padding:       7px 10px;
    height:        auto;
    white-space:   nowrap;
    overflow:      hidden;
    text-overflow: ellipsis;
    max-width:     200px;
    border-bottom: 1px solid var(--color-border);
    border-right:  1px solid var(--color-border);
    vertical-align: middle;
    max-height:    134px;
}

#OrdenaryFiltrar tbody td:last-child      { border-right:  none; }
#OrdenaryFiltrar tbody tr:last-child td   { border-bottom: none; }

th {
    width:      auto;
    white-space: nowrap;
}



/* ============================================================
   SCROLLABLE PANELS  (.jamba / .puerta)
   ============================================================ */
/* .puerta {
    overflow-y: auto;
    height:     320px;
}

.jamba {
    overflow-y: auto;
    height:     350px;
} */

@media (min-height: 810px) {
    .puerta { height: 400px; }
    .jamba  { height: 450px; }
}

/* ── Flechas de scroll ── */
.scroll-arrow {
    position:         absolute;
    right:            2px;
    font-size:        20px;
    color:            rgba(0,0,0,0.6);
    z-index:          1000;
    pointer-events:   none;
    background:       rgba(255,255,255,0.7);
    border-radius:    50%;
    width:            24px;
    height:           24px;
    text-align:       center;
    line-height:      24px;
}
.scroll-arrow.up   { top:    4px;   }
.scroll-arrow.down { bottom: 154px; }

/* ============================================================
   BOTONES  (.btn-danger, .btn-success, .btn-primary)
   ============================================================ */
.btn {
    white-space: nowrap;
    cursor:      pointer;
}

/* ============================================================
   POPUP / MODAL
   ============================================================ */
.popup {
    position:   fixed;
    top:        0;
    left:       0;
    width:      100%;
    height:     100%;
    background: rgba(0, 0, 0, 0.5);
    display:    flex;
    justify-content: center;
    align-items:     center;
    z-index:    1000;
}

.popup-contenido {
    background:    white;
    padding:       20px;
    border-radius: 10px;
    width:         60%;
    box-shadow:    0px 0px 10px rgba(0,0,0,0.5);
    text-align:    left;
}

/* form-filtro dentro de popup: misma lógica que el global */
.popup-contenido .form-filtro,
.popup-contenido .form-group.cabecera {
    gap:         8px 12px;
    margin-bottom: 10px;
}

/* Botones de acción en popup */
.form-buttons {
    display:         flex;
    justify-content: space-between;
    margin-top:      20px;
    gap:             10px;
}

/* ============================================================
   BLOQUE INFERIOR DE BOTONES  (.footer-buttons / .botones-cambio)
   ============================================================ */
.footer-buttons {
    bottom:     0;
    width:      100%;
    display:    flex;
    flex-direction: row !important;
    justify-content: space-between;
    padding:    10px 20px;
    box-sizing: border-box;
    background-color: #fff;
    height:     max-content !important;
}

.footer-buttons .btn { margin: 5px; }

.botones-cambio {
    position: fixed;
    bottom: 47px;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    background-color: white;
    z-index: 100;
    box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.1);
}

.botones-cambio .btn {
    height:     max-content;
    flex-grow:  1;
    flex-shrink: 1;
    margin:     0 5px;
}

/* ============================================================
   FOTO / CONTENEDOR IMAGEN IZQUIERDA
   ============================================================ */
.foto {
    width:           35%;
    border:          1px solid #ccc;
    height:          84%;
    display:         flex;
    flex-direction:  column;
    align-items:     center;
    justify-content: center;
}

/* ============================================================
   INPUT .input-line
   ============================================================ */
.input-line {
    width: 70%;
}

/* ============================================================
   CHK-LINE  (checkbox grande independiente)
   ============================================================ */
.chk-line {
    transform:     scale(1.2);
    text-align:    left;
    margin-bottom: 15px;
}


.section-main {
    max-height:      calc(100vh - 50px);
    overflow-y:      auto;
    scroll-behavior: smooth;
}

/* Cabecera de filtros pegada arriba al hacer scroll */
.filtros-sticky {
    position:         sticky;
    top:              0;
    z-index:          200;
    background-color: #ffffff;
    border-bottom:    2px solid var(--color-border);
    padding:          6px 12px 4px;
    transition:       box-shadow 0.2s ease;
}

/* Sombra cuando hay scroll activo (la clase la añade el JS) */
.filtros-sticky.is-stuck {
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}