﻿/* ===== Base table reset ===== */

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    font-weight: 600;
    color: #475569;
}

td {
    vertical-align: middle;
}

/* ===========================
   Fix para los btn-link
   =========================== */

table .btn-link {
    margin: 0;
}

/* ===========================
   MAIN TABLE
   =========================== */
.main-table {
    background-color: #ffffff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.main-table td > *,
.sub-table td > * {
    min-width: 0;
}

.main-table th {
    padding: 12px 14px;
}

.main-table td {
    padding: 14px 18px;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.main-table > thead {
    background-color: #f1f5f9;
}

.main-table > tbody > tr {
    transition: background-color 0.15s ease;
}

/* Hover SOLO para filas principales */
.main-table > tbody > tr:hover {
    background-color: #f8fafc;
}

/* ===========================
   SUB TABLE
   =========================== */

.sub-table {
    width: 100%;
    margin-top: 10px;
    background-color: #f8fafc;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: inset 0 0 0 1px #e2e8f0;
}

.sub-table th {
    padding: 14px 18px;
    color: #64748b;
}

.sub-table td {
    padding: 14px 18px;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.sub-table thead {
    background-color: #e2e8f0;
}

/* Hover propio, mucho más sutil */
.sub-table tbody tr {
    transition: background-color 0.15s ease;
}

.sub-table tbody tr:hover {
    background-color: #eef2f7;
}

/* ===========================
   OBS ACTIONS
   =========================== */

.obs-actions {
    margin-top: 4px;
    display: inline-flex;
    gap: 10px;
}

/* ===========================
   TD STATES / HIGHLIGHTS
   =========================== */

/* ✔ OK / Positivo */
.td-ok {
    font-weight: 600;
    color: #16a34a; /* verde */
}

/* ✖ NO OK / Negativo */
.td-bad {
    font-weight: 600;
    color: #dc2626; /* rojo */
}

/* ⚠ Importante / Atención */
.td-important {
    font-weight: 600;
    /* color: #b45309; ámbar */
}


@media (max-width: 1024px) {

    /* El TD que contiene la sub-tabla debe ocupar TODO el ancho */
    .main-table .sub-table-row > td {
        display: block; /* rompe el grid */
        grid-column: 1 / -1; /* ocupa ambas columnas */
        width: 100%;
        padding: 0; /* opcional */
    }

    /* ===========================
       TABLE WRAPPER
       =========================== */

    .main-table,
    .sub-table {
        display: block;
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
        box-shadow: none;
    }

    /* ===========================
       HIDE HEADERS
       =========================== */

    .main-table thead,
    .sub-table thead {
        display: none;
    }

    /* ===========================
       ROW AS FULL-WIDTH CARD
       =========================== */

    .main-table tbody,
    .sub-table tbody {
        display: block;
        width: 100%;
    }

    .main-table tbody tr,
    .sub-table tbody tr {
        display: block;
        width: 100%;
        background: #fff;
        border-radius: 8px;
        margin-bottom: 12px;
        padding: 12px 16px;
        box-shadow: 0 1px 2px rgba(0,0,0,0.04);
        box-sizing: border-box;
    }

    /* ===========================
       CELL → GRID ROW
       =========================== */

    .main-table td,
    .sub-table td {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 15px;
        align-items: start;
        padding: 6px 0;
        width: 100%;
        box-sizing: border-box;
    }

    /* ===========================
       LABEL
       =========================== */

    .main-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #64748b;
        text-align: left;
    }

    .sub-table td::before {
        content: attr(data-label);
        font-weight: 600;
        text-align: left;
    }

    .sub-table tbody tr {
        background-color: #eef2f7;
    }

    /* ===========================
       VALUE
       =========================== */

    .main-table td > *,
    .sub-table td > * {
        justify-self: start;
        text-align: left;
    }

    /* ===========================
       LINKS / BUTTONS
       =========================== */

    .btn-link,
    .btn-primary {
        padding-left: 0;
        justify-content: flex-start;
    }

    .obs-actions {
        margin-top: 8px;
        width: 100%;
        justify-content: flex-start;
        gap: 8px;
        flex-wrap: wrap;
    }

    /* ===========================
       STATES VISIBILITY
       =========================== */

    .td-ok,
    .td-bad,
    .td-important {
        font-size: 14px;
    }


    /* Tabla detalle (Etiqueta / Valor) */
    .table-detail {
        border: none;
    }

    .table-detail tbody {
        display: block;
    }

    .table-detail tr {
        display: grid;
        grid-template-columns: 1fr auto;
        gap: 12px;
        padding: 8px 0;
        border-bottom: 1px solid #eee;
    }

    .table-detail th {
        padding: 0;
        font-weight: 600;
        color: #555;
        text-align: left;
        background: none;
    }

    .table-detail td {
        padding: 0;
        text-align: right;
        font-weight: 500;
        background: none;
        white-space: nowrap;
    }
}
