/* ============================================================
   UT LEGAL FORCE - Responsive utilities (mobile-first)
   Aplica a TODAS las vistas (publicas, auth, admin, viewers).
   Trabaja sobre Bootstrap 5.3 + custom-utlf.css.
   ============================================================ */

/* === Tablas: scroll horizontal en mobile (no recortar contenido) === */
.table-responsive,
.utlf-table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}
.table-responsive table,
.utlf-table-scroll table {
    min-width: 560px;
}

/* Auto-aplica scroll horizontal a tablas sueltas (sin .table-responsive) */
@media (max-width: 575.98px) {
    main table:not(.no-stretch),
    .card table:not(.no-stretch),
    .content table:not(.no-stretch) {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }
    main table:not(.no-stretch) th,
    main table:not(.no-stretch) td,
    .card table:not(.no-stretch) th,
    .card table:not(.no-stretch) td {
        white-space: normal;
    }
}

/* === Container fluido en mobile === */
@media (max-width: 575.98px) {
    .container,
    .container-fluid,
    main.container {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }
    .card {
        padding: 14px !important;
        border-radius: 10px !important;
    }
    .card .card-body {
        padding: 14px !important;
    }
    h1, .h1 { font-size: 1.35rem !important; line-height: 1.3 !important; }
    h2, .h2 { font-size: 1.10rem !important; line-height: 1.3 !important; }
    h3, .h3 { font-size: 1.00rem !important; }
}

/* === Botones full-width en mobile === */
@media (max-width: 575.98px) {
    .btn-block-mobile,
    .btn.btn-primary,
    .btn.btn-secondary,
    .btn.btn-outline-primary,
    .btn.btn-outline-secondary,
    .btn.btn-success,
    .btn.btn-danger {
        /* No forzar 100%: solo asegurar wrap correcto */
        white-space: normal;
    }
    /* Grupo de botones de accion principal */
    .utlf-actions {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }
    .utlf-actions .btn,
    .utlf-actions button {
        width: 100%;
        justify-content: center;
    }
}

/* === Form controls comodos en mobile (touch targets >= 44px) === */
@media (max-width: 575.98px) {
    input.form-control,
    select.form-select,
    select.form-control,
    textarea.form-control,
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="tel"],
    input[type="number"],
    input[type="search"],
    input[type="date"] {
        min-height: 44px;
        font-size: 16px !important; /* Evita zoom iOS al enfocar */
    }
    .input-group-text {
        min-width: 44px;
        min-height: 44px;
    }
}

/* === Tablas tipo "card" en mobile (opt-in con .table-stack) === */
@media (max-width: 575.98px) {
    .table-stack thead { display: none; }
    .table-stack tr {
        display: block;
        background: #fff;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        margin-bottom: 10px;
        padding: 8px 10px;
        box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    }
    .table-stack td {
        display: flex;
        justify-content: space-between;
        gap: 12px;
        padding: 6px 0;
        border: 0 !important;
        text-align: right;
    }
    .table-stack td::before {
        content: attr(data-label);
        font-weight: 600;
        text-transform: uppercase;
        font-size: 11px;
        letter-spacing: .4px;
        color: var(--brand-muted);
        text-align: left;
        flex: 1;
    }
}

/* === Modales: ancho completo en mobile === */
@media (max-width: 575.98px) {
    .modal-dialog {
        margin: 8px !important;
        max-width: calc(100vw - 16px) !important;
    }
    .modal-content {
        border-radius: 10px;
    }
    .modal-body {
        padding: 14px !important;
    }
}

/* === SweetAlert2 en mobile === */
@media (max-width: 575.98px) {
    .swal2-popup {
        width: calc(100vw - 24px) !important;
        max-width: 420px !important;
        padding: 16px !important;
    }
    .swal2-title { font-size: 1.05rem !important; }
    .swal2-html-container { font-size: 0.92rem !important; }
}

/* === Header / topbar / sidebar offcanvas === */
@media (max-width: 991.98px) {
    .vertical-menu {
        z-index: 1050;
    }
    #page-topbar {
        padding-left: 8px;
        padding-right: 8px;
    }
}

/* === Imagenes responsivas por defecto === */
img {
    max-width: 100%;
    height: auto;
}

/* === Grid simple .utlf-grid-2 que colapsa a 1 col en mobile === */
.utlf-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}
@media (max-width: 575.98px) {
    .utlf-grid-2 {
        grid-template-columns: 1fr;
        gap: 10px;
    }
}

/* === Print-friendly: certificados + actas === */
@media print {
    .vertical-menu,
    #page-topbar,
    .footer,
    .utlf-actions,
    .ayuda-ia-fab,
    .breadcrumb {
        display: none !important;
    }
    .main-content,
    .page-content {
        padding: 0 !important;
        margin: 0 !important;
    }
}
