/* ══════════════════════════════════════════════════════════════
 *  responsive_tables.css — Tablas responsive para QMSPM
 *  Incluir en cada app: <link rel="stylesheet" href="css/responsive_tables.css">
 *  MAS CONSULTA SAS | 2026
 * ══════════════════════════════════════════════════════════════ */

/* ── Wrapper: scroll horizontal en mobile ── */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
}

.table-responsive table {
    min-width: 600px;
}

/* ── Hint de scroll en mobile ── */
.table-responsive::after {
    content: '';
    display: none;
}

@media (max-width: 768px) {
    .table-responsive {
        border: 1px solid #dee2e6;
        border-radius: 6px;
    }

    .table-responsive::after {
        content: '\2190 Desliza \2192';
        display: block;
        text-align: center;
        font-size: 0.75rem;
        color: #999;
        padding: 4px;
        background: #f8f9fa;
    }
}

/* ── Card-mode: tablas se convierten en tarjetas en mobile ── */
@media (max-width: 640px) {
    table.card-table thead {
        display: none;
    }

    table.card-table tbody tr {
        display: block;
        margin-bottom: 0.75rem;
        border: 1px solid #dee2e6;
        border-radius: 8px;
        padding: 0.5rem;
        background: #fff;
        box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    }

    table.card-table tbody td {
        display: flex;
        justify-content: space-between;
        padding: 0.35rem 0.5rem;
        border: none;
        border-bottom: 1px solid #f0f0f0;
        font-size: 0.9rem;
    }

    table.card-table tbody td:last-child {
        border-bottom: none;
    }

    table.card-table tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #2F5496;
        flex: 0 0 40%;
        font-size: 0.8rem;
    }

    /* Acciones: centrar botones */
    table.card-table tbody td.td-actions {
        justify-content: center;
        gap: 0.5rem;
        flex-wrap: wrap;
        padding-top: 0.5rem;
    }

    table.card-table tbody td.td-actions::before {
        display: none;
    }
}

/* ── Formularios responsivos ── */
@media (max-width: 768px) {
    .form-grid {
        grid-template-columns: 1fr !important;
    }

    .form-row {
        flex-direction: column;
    }

    .form-row > * {
        width: 100% !important;
        min-width: 0;
    }

    /* Modales: full width en mobile */
    .modal-content,
    [class*="modal"] > div {
        width: 95vw !important;
        max-width: 95vw !important;
        margin: 1rem auto;
        max-height: 90vh;
        overflow-y: auto;
    }
}

@media (max-width: 480px) {
    /* Botones: stack en móvil */
    .btn-group,
    .action-bar {
        flex-direction: column;
        gap: 0.5rem;
    }

    .btn-group > button,
    .action-bar > button {
        width: 100%;
    }

    /* Tabs: scroll horizontal */
    .tabs,
    .tab-bar,
    [class*="tabs"] {
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }
}

/* ── Print: ocultar controles ── */
@media print {
    .table-responsive::after,
    .btn-group,
    .action-bar,
    .sidebar,
    .top-bar,
    button {
        display: none !important;
    }

    table {
        font-size: 9pt;
    }

    table.card-table thead {
        display: table-header-group !important;
    }

    table.card-table tbody tr {
        display: table-row !important;
    }

    table.card-table tbody td {
        display: table-cell !important;
    }

    table.card-table tbody td::before {
        display: none !important;
    }
}
