/* ============================================================
   🧱 SISTEMA DE TABLAS SIGv v2 — BLINDADO
   Núcleo + variantes (operativa / compacta / premium)
   ❌ No afecta tablas legacy
   ✅ Solo actúa sobre .sigv-table
============================================================ */


/* ============================================================
   1️⃣ CONTENEDOR BASE (NEUTRO)
============================================================ */
.table-wrapper {
    width: 100%;
    overflow-x: auto;
    margin: 8px 0 16px;
    border-radius: 12px;
}


/* ============================================================
   2️⃣ TABLA BASE (OPT-IN OBLIGATORIO)
   ⚠️ Solo tablas con .sigv-table
============================================================ */
table.sigv-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
    color: #2c3e50;
    background: #ffffff;

    /* 👇 CLAVE: evita scroll fantasma en desktop */
    min-width: 100%;
    table-layout: auto;
}


/* ============================================================
   ENCABEZADOS
============================================================ */
table.sigv-table thead th {
    background: var(--color-primario);
    color: #ffffff;
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 1;
}


/* ============================================================
   CELDAS
============================================================ */
table.sigv-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #ecf0f1;
    vertical-align: middle;
    line-height: 1.35;
}


/* ============================================================
   FILAS
============================================================ */
table.sigv-table tbody tr {
    transition: background 0.15s ease;
}

table.sigv-table tbody tr:nth-child(even) {
    background: #fafafa;
}

table.sigv-table tbody tr:hover {
    background: rgba(0,0,0,0.04);
}


/* ============================================================
   3️⃣ UTILIDADES DE ALINEACIÓN
============================================================ */
.sigv-table td.text-right  { text-align: right; }
.sigv-table td.text-center { text-align: center; }
.sigv-table td.text-left   { text-align: left; }

.sigv-table .td-bold  { font-weight: 700; }
.sigv-table .td-small { font-size: 12px; opacity: 0.85; }


/* ============================================================
   4️⃣ CHIPS / ESTADOS
============================================================ */
.sigv-table .table-chip {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    color: #ffffff;
    white-space: nowrap;
}

.sigv-table .table-chip.ok    { background: #27ae60; }
.sigv-table .table-chip.warn  { background: #f39c12; }
.sigv-table .table-chip.error { background: #c0392b; }
.sigv-table .table-chip.info  { background: var(--color-primario); }
.sigv-table .table-chip.gray  { background: #7f8c8d; }


/* ============================================================
   5️⃣ VARIANTE OPERATIVA (ADMIN / GESTIÓN)
============================================================ */
.sigv-table.table-operativa {
    font-size: 0.9rem;
}

.sigv-table.table-operativa td {
    padding: 8px 10px;
}

.sigv-table.table-operativa .btn {
    padding: 6px 12px;
    font-size: 13px;
}


/* ============================================================
   5️⃣ BIS — VARIANTE COMPACTA (ADMIN INTENSIVO)
   ✔️ Soluciona filas “altas”
============================================================ */
.sigv-table.table-compacta {
    font-size: 0.85rem;
}

.sigv-table.table-compacta td {
    padding: 6px 8px;
    line-height: 1.25;
}

.sigv-table.table-compacta th {
    padding: 8px 10px;
    font-size: 0.85rem;
}

/* Formularios embebidos */
.sigv-table.table-compacta form {
    margin: 0;
}

.sigv-table.table-compacta select {
    padding: 4px 6px;
    font-size: 12px;
}

.sigv-table.table-compacta .btn {
    padding: 4px 10px;
    font-size: 12px;
    line-height: 1.1;
}

/* Chips más delgados */
.sigv-table.table-compacta .table-chip {
    padding: 3px 8px;
    font-size: 11px;
}

/* Acciones en una sola línea */
.sigv-table.table-compacta td[data-label="Acciones"] {
    white-space: nowrap;
}


/* ============================================================
   6️⃣ VARIANTE PREMIUM (INFORMES / DOCUMENTOS)
============================================================ */
.sigv-table.table-premium {
    border-collapse: separate;
    border-spacing: 0 10px;
}

.sigv-table.table-premium thead th {
    border-radius: 8px;
}

.sigv-table.table-premium tbody tr {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
    transition: transform .12s ease, box-shadow .15s ease;
}

.sigv-table.table-premium tbody tr:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.10);
}

.sigv-table.table-premium td:first-child {
    border-radius: 12px 0 0 12px;
}

.sigv-table.table-premium td:last-child {
    border-radius: 0 12px 12px 0;
}


/* ============================================================
   7️⃣ MONTOS
============================================================ */
.sigv-table .monto-positive {
    color: #1e8f5b;
    font-weight: 600;
}

.sigv-table .monto-negative {
    color: #c0392b;
    font-weight: 600;
}


/* ============================================================
   8️⃣ SIN RESULTADOS
============================================================ */
.sigv-table .table-empty {
    text-align: center;
    padding: 20px;
    font-size: 15px;
    color: #7f8c8d;
}


/* ============================================================
   9️⃣ RESPONSIVE — SOLO MÓVIL
   ❗ No afecta desktop ni tesorería
============================================================ */
@media (max-width: 768px) {

    table.sigv-table {
        min-width: 100%;
    }

    .sigv-table thead {
        display: none;
    }

    .sigv-table,
    .sigv-table tbody,
    .sigv-table tr,
    .sigv-table td {
        display: block;
        width: 100%;
    }

    .sigv-table tr {
        margin-bottom: 14px;
        padding: 10px;
        border-radius: 14px;
        background: #ffffff;
        box-shadow: var(--shadow-card, 0 3px 8px rgba(0,0,0,0.12));
        animation: cardFloatIn 0.35s ease-out;
    }

    .sigv-table td {
        display: flex;
        justify-content: space-between;
        gap: 10px;
        padding: 6px 4px;
        border: none;
    }

    .sigv-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--color-primario);
        flex-basis: 40%;
    }

    @keyframes cardFloatIn {
        from { transform: translateY(10px); opacity: 0; }
        to   { transform: translateY(0);  opacity: 1; }
    }


@media (max-width: 768px) {

    .sigv-main {
        flex-wrap: wrap;         /* 🔑 permite salto */
       /* gap: 10px 14px;*/
    }

    .sigv-celda {
        flex: 0 0 auto;
    }

   .sigv-celda.acciones {
        width: 100%;
        justify-content: flex-end;
        margin-top: 6px;
    }
}


/* ============================================================
   🔹 SIGv LISTA OPERATIVA
   Sustituto visual de tablas complejas:
   - Históricos (Casa → registros)
   - Acciones inline
   - Mobile-first real
   ❌ No usa <table>
   ✅ Convive con .sigv-table
============================================================ */


/* ============================================================
   1️⃣ CONTENEDOR PRINCIPAL
============================================================ */
.sigv-lista {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 12px 0 20px;
}


/* ============================================================
   2️⃣ ITEM (EQUIVALENTE A UNA FILA LÓGICA)
============================================================ */
.sigv-item {
    background: #ffffff;
    border-radius: 14px;
    box-shadow: var(--shadow-card, 0 3px 8px rgba(0,0,0,0.12));
    overflow: hidden;
}


/* ============================================================
   3️⃣ FILA PRINCIPAL (RESUMEN)
============================================================ */
.sigv-main {
    display: grid;
    grid-template-columns:
        auto      /* toggle */
        90px      /* casa */
        120px     /* aportación */
        120px     /* fecha */
        120px     /* adeudo */
        1fr;      /* acciones */

    align-items: center;
    gap: 8px;
    padding: 10px 12px;
}


/* ============================================================
   4️⃣ CELDAS SEMÁNTICAS
============================================================ */
.sigv-celda {
    font-size: 0.9rem;
    white-space: nowrap;
}

.sigv-celda.casa {
    font-weight: 700;
}

.sigv-celda.monto {
    font-weight: 600;
}

.sigv-celda.fecha {
    font-size: 0.85rem;
    opacity: 0.85;
}


/* ============================================================
   5️⃣ ACCIONES
============================================================ */
.sigv-celda.acciones {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
}

.sigv-celda.acciones .btn {
    padding: 6px 12px;
    font-size: 13px;
    border-radius: 999px;
}


/* ============================================================
   6️⃣ BOTÓN TOGGLE HISTORIAL
============================================================ */
.sigv-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-weight: 600;
    color: var(--color-primario);
    padding: 0;
}


/* ============================================================
   7️⃣ CONTENEDOR DE DETALLE / HISTORIAL
============================================================ */
.sigv-detalle {
    display: none;
    padding: 10px 14px 14px;
    border-top: 1px solid #ecf0f1;
    background: #fafafa;
}


/* ============================================================
   8️⃣ VARIANTE COMPACTA
============================================================ */
.sigv-lista.compacta .sigv-main {
    grid-template-columns:
        auto 70px 100px 100px 100px 1fr;
    padding: 8px 10px;
    font-size: 0.85rem;
}


/* ============================================================
   9️⃣ RESPONSIVE — MÓVIL
============================================================ */
@media (max-width: 768px) {

    .sigv-main {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .sigv-celda {
        display: flex;
        justify-content: space-between;
        gap: 8px;
    }

    .sigv-celda::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--color-primario);
    }

    .sigv-celda.acciones {
        justify-content: flex-start;
        flex-wrap: wrap;
    }
}

/* ============================================================
   SIGv LISTA – ESPACIADO LEGIBLE
============================================================ */

.sigv-main {
    display: flex;
    align-items: center;
    gap: 14px;              /* 🔑 separa columnas */
    padding: 12px 14px;     /* 🔑 aire vertical */
    line-height: 1.45;      /* 🔑 evita texto aplastado */
}


/* ============================================================
   🧠 AJUSTES ESPECÍFICOS — master_casas
============================================================ */

/* Control de anchos por columna */
.sigv-table th[data-col="casa"],
.sigv-table td[data-col="casa"] {
    width: 60px;
    white-space: nowrap;
}

.sigv-table th[data-col="telefono"],
.sigv-table td[data-col="telefono"] {
    width: 120px;
}

.sigv-table th[data-col="personas"],
.sigv-table td[data-col="personas"] {
    width: 80px;
    text-align: center;
}

.sigv-table th[data-col="activo"],
.sigv-table td[data-col="activo"] {
    width: 70px;
    text-align: center;
}

.sigv-table th[data-col="acciones"],
.sigv-table td[data-col="acciones"] {
    width: 120px;
    white-space: nowrap;
}

/* 🔑 Las importantes */
.sigv-table th[data-col="observaciones"],
.sigv-table td[data-col="observaciones"],
.sigv-table th[data-col="notas"],
.sigv-table td[data-col="notas"] {
    min-width: 260px;
    width: 30%;
}

/* Textareas bien portados */
.sigv-table textarea {
    width: 100%;
    min-height: 48px;
    resize: vertical;
    white-space: normal;
    word-break: break-word;
    line-height: 1.35;
}

/* ============================================================
   🧠 FIX LIMPIO — master_casas (mínimo y definitivo)
============================================================ */

/* Columnas cortas */
.sigv-table th[data-col="telefono"],
.sigv-table td[data-col="telefono"] {
    width: 90px;
    white-space: nowrap;
}

.sigv-table th[data-col="personas"],
.sigv-table td[data-col="personas"] {
    width: 60px;
    text-align: center;
    white-space: nowrap;
}

/* Columnas largas */
.sigv-table th[data-col="observaciones"],
.sigv-table td[data-col="observaciones"],
.sigv-table th[data-col="notas"],
.sigv-table td[data-col="notas"] {
    min-width: 320px;
    max-width: 420px;
    vertical-align: top;          /* 🔑 CLAVE */
}

/* Textareas sanos */
.sigv-table textarea {
    width: 100%;
    min-height: 88px;
    height: auto;
    resize: vertical;
    text-align: left;
    white-space: normal;
    word-break: break-word;
    line-height: 1.4;
}

/* Blindaje contra table-compacta */
.sigv-table.table-compacta td[data-col="observaciones"],
.sigv-table.table-compacta td[data-col="notas"] {
    vertical-align: top !important;
    padding-top: 8px;
    padding-bottom: 8px;
}