/* Application adaptations, after Hyper. Keep desktop grids and vendor files intact. */
html { -webkit-text-size-adjust: 100%; }
body, #app, .app-shell { min-width: 0; }
.app-shell { width: 100%; max-width: 100%; }
.app-shell :where(main, section, form, .card, .card-body, .row > *, .d-flex > *) { min-width: 0; }
.app-shell :where(h1, h2, h3, h4, p, .alert, .badge, .validation-message, .form-text, small, label) { overflow-wrap: anywhere; }
.app-shell :where(img, video, canvas) { max-width: 100%; }
.app-shell :where(input, select, textarea) { max-width: 100%; }
.app-shell .btn { white-space: normal; }
.app-shell .badge { white-space: normal; text-align: start; }
.app-shell .table-responsive { max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; }
.app-table-scroll:focus-visible { outline: 2px solid var(--ct-primary, #727cf5); outline-offset: 2px; }
.app-table-scroll td { overflow-wrap: anywhere; }
.app-filter-bar { align-items: end; }
.app-pagination { display: flex; gap: .5rem; flex-wrap: wrap; }
.app-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.app-shell .nav-tabs { flex-wrap: nowrap; max-width: 100%; overflow-x: auto; overflow-y: hidden; }
.app-shell .nav-tabs .nav-link { flex: 0 0 auto; white-space: nowrap; }
.app-shell .modal :where(.modal-title, .modal-body) { overflow-wrap: anywhere; }

@media (max-width: 767.98px) {
    /* 16px avoids iOS zoom when focusing inputs; do not disable pinch zoom. */
    .app-shell :where(.form-control, .form-select, input, select, textarea) { font-size: 1rem; }
    .app-shell :where(.btn, .nav-link) { min-height: 44px; }
    .app-shell .btn-close { min-width: 44px; min-height: 44px; box-sizing: border-box; }
    .app-shell .form-check { min-height: 44px; padding-top: .35rem; padding-bottom: .35rem; }
    .app-shell :where(.form-check-input, .form-check-label) { cursor: pointer; }
    .app-shell .app-table-scroll table { min-width: 40rem; }
    .app-shell #registro-formulario .card-body { padding: 1rem; }
    .app-shell #registro-formulario .seccion-header { padding: 1rem; }
    .app-shell #registro-formulario input[type="file"] { min-width: 0; width: 100%; }
    .app-shell .authentication-bg { align-items: flex-start !important; min-height: 100svh !important; }
}

@media (max-width: 575.98px) {
    .app-shell .nav-tabs { overflow: visible; }
    .app-shell .nav-tabs .nav-link { flex: 1 1 0; min-width: 0; white-space: normal; }
    /* Keep real table semantics/headers; present each row as a labelled card. */
    .app-shell .app-table-scroll .app-table-mobile { display: block; min-width: 0; width: 100%; }
    .app-table-mobile thead { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
    .app-table-mobile tbody { display: grid; gap: .75rem; }
    .app-table-mobile tbody tr { display: block; min-width: 0; padding: .75rem; border: 1px solid var(--ct-border-color, #dee2e6); border-radius: .25rem; }
    .app-table-mobile tbody td { display: grid; grid-template-columns: 6rem minmax(0, 1fr); gap: .5rem; align-items: start; padding: .375rem 0; border: 0; text-align: start; box-shadow: none; background: transparent; }
    .app-table-mobile td[data-label]::before { content: attr(data-label); font-weight: 600; color: var(--ct-body-color, #6c757d); }
    .app-table-mobile tbody td[colspan] { display: block; }
    .app-table-mobile td .btn { width: 100%; }
    .app-table-mobile td .badge { justify-self: start; max-width: 100%; }
    .app-table-mobile caption { display: block; white-space: normal; overflow-wrap: anywhere; }
    .app-shell > main.container, .app-shell > main.container-fluid { padding-inline: .75rem; }
    .app-shell .card-body { padding: 1rem; }
    .app-shell .app-page-header { align-items: stretch !important; }
    .app-shell .app-page-header > *, .app-shell .app-page-header .app-actions { width: 100%; }
    .app-shell .app-actions > .btn { flex: 1 1 100%; margin-inline: 0 !important; }
    .app-filter-bar > div { flex: 1 1 100%; width: 100%; }
    .app-filter-bar > .btn { width: 100%; }
    .app-pagination > .btn { flex: 1 1 0; }
    .app-shell .authentication-bg .card-body.p-4 { padding: 1.25rem !important; }
    .app-shell #modal_terminos .modal-content { max-height: 100dvh; }
    .app-shell #modal_terminos .modal-footer { gap: .5rem; padding-bottom: max(1rem, env(safe-area-inset-bottom)); }
    .app-shell #modal_terminos .modal-footer .btn { flex: 1 1 0; margin: 0; }
}

@media (max-height: 500px) and (orientation: landscape) {
    .app-shell .authentication-bg { align-items: flex-start !important; }
}
