/* ==========================================================================
   A-CONFIABLE — capa mobile first
   Se carga DESPUÉS de sb-admin-2.css y de los estilos de cada vista.
   Base = teléfono; los media queries min-width restauran el layout de escritorio.
   ========================================================================== */

:root {
    --ac-primary: #652d38; /* color de marca (ver .btn-primary en sb-admin-2.css) */
    --ac-topbar-h: 3.5rem;
    --ac-bottomnav-h: 3.75rem;
    --ac-radius: .6rem;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    overflow-x: hidden;
    -webkit-tap-highlight-color: rgba(101, 45, 56, .15);
}

img {
    max-width: 100%;
    height: auto;
}

/* ---------- Topbar ---------- */
.topbar {
    height: var(--ac-topbar-h);
    position: sticky;
    top: 0;
    z-index: 1030;
    background: #fff;
    margin-bottom: 1rem !important;
}

.topbar .ac-topbar-brand {
    font-weight: 800;
    color: var(--ac-primary);
    letter-spacing: .03em;
    font-size: 1rem;
    white-space: nowrap;
    text-decoration: none;
}

#sidebarToggleTop {
    width: 2.75rem;
    height: 2.75rem;
    margin-right: .5rem !important;
    font-size: 1.25rem;
}

/* ---------- Sidebar off-canvas (teléfono / tablet chica) ---------- */
@media screen and (max-width: 767.98px) {
    #wrapper #content-wrapper {
        width: 100%;
        min-width: 0;
    }

    /* El sidebar sale de la columna y se vuelve un panel deslizable */
    .sidebar,
    .sidebar.toggled {
        position: fixed !important;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 1050;
        width: 16rem !important;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        transform: translateX(-105%);
        transition: transform .25s ease;
        box-shadow: none;
    }

    body.ac-sidebar-open .sidebar {
        transform: translateX(0);
        box-shadow: 0 0 2rem rgba(0, 0, 0, .35);
    }

    /* Dentro del panel se ve como el sidebar de escritorio (texto + iconos) */
    .sidebar .nav-item .nav-link {
        width: 100% !important;
        text-align: left !important;
        padding: .9rem 1rem !important;
        font-size: .95rem !important;
    }

    .sidebar .nav-item .nav-link span {
        display: inline !important;
        font-size: .95rem !important;
    }

    .sidebar .nav-item .nav-link i {
        font-size: 1rem !important;
        margin-right: .5rem !important;
    }

    .sidebar .nav-item .nav-link[data-toggle=collapse]::after {
        display: block !important;
    }

    .sidebar .nav-item .collapse {
        position: relative !important;
        left: 0 !important;
        top: 0 !important;
        z-index: 1;
        margin: 0 .75rem !important;
        animation: none !important;
    }

    .sidebar .nav-item .collapse .collapse-inner .collapse-item {
        padding: .75rem 1rem;
        font-size: .95rem;
        white-space: normal;
    }

    .sidebar .sidebar-brand {
        height: var(--ac-topbar-h);
    }

    .sidebar .sidebar-brand .sidebar-brand-text {
        display: inline !important;
    }

    .sidebar .sidebar-heading {
        text-align: left !important;
        padding: 0 1rem !important;
    }

    .ac-sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 1040;
        background: rgba(0, 0, 0, .45);
        opacity: 0;
        visibility: hidden;
        transition: opacity .25s ease, visibility .25s;
    }

    body.ac-sidebar-open .ac-sidebar-backdrop {
        opacity: 1;
        visibility: visible;
    }

    body.ac-sidebar-open {
        overflow: hidden;
    }
}

@media (min-width: 768px) {
    .ac-sidebar-backdrop,
    .topbar .ac-topbar-brand {
        display: none !important;
    }
}

/* ---------- Barra de navegación inferior (solo teléfono) ---------- */
.ac-bottom-nav {
    display: none;
}

@media screen and (max-width: 767.98px) {
    .ac-bottom-nav {
        display: flex;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1035;
        height: calc(var(--ac-bottomnav-h) + env(safe-area-inset-bottom, 0px));
        padding-bottom: env(safe-area-inset-bottom, 0px);
        background: #fff;
        border-top: 1px solid #e3e6f0;
        box-shadow: 0 -.25rem 1rem rgba(0, 0, 0, .06);
    }

    .ac-bottom-nav a {
        flex: 1 1 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: .2rem;
        color: #858796;
        font-size: .68rem;
        line-height: 1.1;
        text-decoration: none;
        text-align: center;
        padding: 0 .15rem;
    }

    .ac-bottom-nav a i {
        font-size: 1.2rem;
    }

    .ac-bottom-nav a.active,
    .ac-bottom-nav a:active {
        color: var(--ac-primary);
        font-weight: 700;
    }

    body.ac-has-bottom-nav #content {
        padding-bottom: calc(var(--ac-bottomnav-h) + env(safe-area-inset-bottom, 0px) + 1rem);
    }

    body.ac-has-bottom-nav .scroll-to-top {
        bottom: calc(var(--ac-bottomnav-h) + 1rem) !important;
    }
}

/* ---------- Contenedores y tipografía ---------- */
@media screen and (max-width: 767.98px) {
    #content .container,
    #content .container-fluid,
    #content .container-fluid2 {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    #content h1, #content .h1 { font-size: 1.5rem; }
    #content h2, #content .h2 { font-size: 1.3rem; }
    #content h3, #content .h3 { font-size: 1.2rem; }
    #content h4, #content .h4 { font-size: 1.1rem; }
    #content h5, #content .h5 { font-size: 1rem; }

    /* Columnas fijas (col-6, col-4...) usadas en formularios: una por fila */
    #content .form-group[class*="col-"]:not([class*="col-sm"]):not([class*="col-md"]):not([class*="col-lg"]):not([class*="col-xl"]),
    .modal .form-group[class*="col-"]:not([class*="col-sm"]):not([class*="col-md"]):not([class*="col-lg"]):not([class*="col-xl"]) {
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* col-md-14 / col-md-20 no existen en Bootstrap: que ocupen todo */
    #content .col-md-14,
    #content .col-md-20 {
        width: 100%;
    }
}

/* ---------- Formularios táctiles ---------- */
@media screen and (max-width: 767.98px) {
    /* 16px evita el zoom automático de iOS al enfocar un campo */
    .form-control,
    .custom-select,
    select.form-control,
    input[type="text"],
    input[type="number"],
    input[type="date"],
    input[type="email"],
    input[type="search"],
    input[type="tel"],
    input[type="password"],
    textarea {
        font-size: 16px !important;
    }

    .form-control,
    .custom-select {
        min-height: 2.75rem;
    }

    textarea.form-control {
        min-height: 5rem;
    }

    label {
        margin-bottom: .3rem;
        font-weight: 600;
        font-size: .9rem;
    }

    .btn {
        min-height: 2.75rem;
        padding: .5rem .9rem;
    }

    .btn-sm {
        min-height: 2.25rem;
    }

    /* Botones sueltos dentro de una columna de formulario: ancho completo */
    .row > [class*="col-"] > .btn:only-child,
    .row > [class*="col-"] > .form-group > .btn:only-child {
        width: 100%;
    }

    .input-group {
        flex-wrap: nowrap;
    }

    .input-group > .form-outline {
        flex: 1 1 auto;
        min-width: 0;
    }

    .input-group > .form-outline .form-control {
        margin-right: 0 !important;
        border-top-right-radius: 0;
        border-bottom-right-radius: 0;
    }

    .input-group > .btn {
        flex: 0 0 auto;
    }

    input[type="file"] {
        max-width: 100%;
    }

    /* Grupos de botones que se salen de la pantalla */
    .btn-group,
    .btn-toolbar {
        flex-wrap: wrap;
    }
}

/* ---------- Tarjetas de lista (ruta de cobros, mora, créditos...) ---------- */
@media screen and (max-width: 575.98px) {
    /* Las vistas definen .card { width: 18rem|20rem|25rem; display:inline-flex } */
    #content [ng-repeat].card,
    #content .card[ng-repeat] {
        width: 100% !important;
        display: flex !important;
        margin: 0 0 .75rem 0 !important;
    }
}

@media screen and (min-width: 576px) and (max-width: 991.98px) {
    #content .card[ng-repeat] {
        width: calc(50% - 10px) !important;
        vertical-align: top;
    }
}

@media screen and (max-width: 767.98px) {
    #content .card {
        border-radius: var(--ac-radius);
    }

    #content .card-body {
        padding: .9rem;
    }

    #content .card-body p {
        margin-bottom: .35rem;
    }

    #content .card-footer {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: .5rem;
    }

    #content .card-footer > a,
    #content .card-footer > button {
        flex: 1 1 auto;
    }

    #content .card-footer .btn {
        width: 100%;
    }
}

/* ---------- Tablas ---------- */
.table-responsive {
    -webkit-overflow-scrolling: touch;
}

@media screen and (max-width: 767.98px) {
    #content .table {
        font-size: .85rem;
    }

    #content .table td,
    #content .table th {
        padding: .5rem;
    }

    /* tbody con text-nowrap fuerza tablas enormes: dejar que el texto baje */
    #content .table tbody.text-nowrap {
        white-space: normal !important;
    }

    /* ----- Tabla convertida en tarjetas (clase .table-cards) ----- */
    #content table.table-cards,
    #content table.table-cards tbody,
    #content table.table-cards tr,
    #content table.table-cards td {
        display: block;
        width: 100%;
    }

    #content table.table-cards thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }

    #content table.table-cards {
        border: 0 !important;
        background: transparent;
        font-size: .9rem;
    }

    #content table.table-cards tr {
        margin-bottom: .75rem;
        background: #fff !important;
        border: 1px solid #e3e6f0;
        border-radius: var(--ac-radius);
        box-shadow: 0 .125rem .5rem rgba(58, 59, 69, .08);
        overflow: hidden;
    }

    #content table.table-cards tr:nth-of-type(odd) {
        background: #fff !important;
    }

    /* Etiqueta fija a la izquierda; el contenido (texto, badges, botones) se apila a la derecha */
    #content table.table-cards td {
        position: relative;
        text-align: right !important;
        border: 0 !important;
        border-bottom: 1px solid #f1f2f6 !important;
        padding: .5rem .85rem .5rem calc(40% + 1rem) !important;
        min-height: 2.4rem;
        word-break: break-word;
        line-height: 1.35;
    }

    #content table.table-cards td:last-child {
        border-bottom: 0 !important;
    }

    #content table.table-cards td::before {
        content: attr(data-label);
        position: absolute;
        left: .85rem;
        top: .6rem;
        width: 40%;
        text-align: left;
        font-weight: 700;
        color: #5a5c69;
        font-size: .72rem;
        line-height: 1.3;
        text-transform: uppercase;
        letter-spacing: .02em;
    }

    #content table.table-cards td[data-label=""]::before,
    #content table.table-cards td:not([data-label])::before {
        display: none;
    }

    #content table.table-cards td:not([data-label]),
    #content table.table-cards td[data-label=""] {
        padding-left: .85rem !important;
    }

    /* Columnas que sobran en teléfono */
    #content table.table-cards .ac-hide-mobile {
        display: none !important;
    }

    /* Primera celda = encabezado de la tarjeta */
    #content table.table-cards td:first-child {
        background: #f8f9fc;
        font-weight: 700;
        color: #3a3b45;
    }

    #content table.table-cards td .btn {
        margin: 0 !important;
    }

    /* Barra de acciones: las celdas que solo tienen botones se ponen lado a lado */
    #content table.table-cards tr {
        display: flex;
        flex-wrap: wrap;
    }

    #content table.table-cards td {
        flex: 0 0 100%;
    }

    #content table.table-cards td.ac-btn-cell {
        flex: 1 1 22%;
        min-width: 22%;
        width: auto;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-end;
        gap: .25rem;
        padding: .5rem .3rem !important;
        text-align: center !important;
        border-bottom: 0 !important;
        border-top: 1px solid #f1f2f6 !important;
        background: #fcfcfd;
    }

    #content table.table-cards td.ac-btn-cell::before {
        position: static;
        width: auto;
        text-align: center;
        font-size: .6rem;
        font-weight: 600;
        color: #858796;
    }

    #content table.table-cards td.ac-btn-cell .btn {
        width: 100%;
        margin-top: 0 !important;
    }

    #content table.table-cards td > div {
        text-align: right;
    }

    /* Filas de totales / tfoot */
    #content table.table-cards tfoot {
        display: block;
    }

    #content table.table-cards tfoot tr {
        background: #eaecf4 !important;
    }

    /* DataTables */
    .dataTables_wrapper .row {
        margin: 0;
    }

    .dataTables_wrapper .row > [class*="col-"] {
        padding: 0;
    }

    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate,
    .dataTables_wrapper .dt-buttons {
        text-align: center !important;
        float: none !important;
        margin-bottom: .5rem;
    }

    .dataTables_wrapper .dataTables_filter input {
        width: 100% !important;
        margin-left: 0 !important;
    }

    .dataTables_wrapper .dataTables_filter label {
        width: 100%;
    }

    .dataTables_wrapper .dataTables_paginate .pagination {
        justify-content: center !important;
        flex-wrap: wrap;
    }

    .dataTables_wrapper .dt-buttons {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: .35rem;
    }

    .dataTables_wrapper .dt-buttons .btn {
        flex: 1 1 auto;
    }
}

/* ---------- Modales: pantalla completa en teléfono ---------- */
@media screen and (max-width: 575.98px) {
    .modal-dialog,
    .modal-dialog.modal-lg,
    .modal-dialog.modal-xl,
    .modal-dialog.modal-sm {
        margin: 0;
        max-width: 100%;
        width: 100%;
        min-height: 100%;
        align-items: stretch;
    }

    .modal-dialog-centered::before {
        display: none;
    }

    .modal-content {
        min-height: 100vh;
        min-height: 100dvh;
        border: 0;
        border-radius: 0;
        padding: 0 !important;
    }

    .modal-header {
        position: sticky;
        top: 0;
        z-index: 2;
        background: #fff;
        align-items: center;
    }

    .modal-header .close {
        font-size: 2rem;
        padding: .5rem 1rem;
        margin: -.5rem -1rem -.5rem auto;
    }

    .modal-body {
        flex: 1 1 auto;
    }

    .modal-footer {
        position: sticky;
        bottom: 0;
        z-index: 2;
        background: #fff;
        flex-direction: column-reverse;
        align-items: stretch;
        padding-bottom: calc(.75rem + env(safe-area-inset-bottom, 0px));
        box-shadow: 0 -.25rem .75rem rgba(0, 0, 0, .05);
    }

    .modal-footer > * {
        margin: .25rem 0 !important;
        width: 100%;
    }

    .modal-footer > a > .btn,
    .modal-footer > .btn {
        width: 100%;
    }
}

/* ---------- SweetAlert2 ---------- */
@media screen and (max-width: 575.98px) {
    .swal2-popup {
        width: calc(100% - 1.5rem) !important;
        padding: 1rem !important;
    }

    .swal2-actions {
        flex-wrap: wrap;
        width: 100%;
    }

    .swal2-actions button {
        flex: 1 1 100%;
        margin: .3rem 0 !important;
        min-height: 2.75rem;
    }

    .swal2-input,
    .swal2-select,
    .swal2-textarea {
        font-size: 16px !important;
        width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
}

/* ---------- Dropdowns ---------- */
@media screen and (max-width: 575.98px) {
    .topbar .dropdown-menu {
        position: fixed !important;
        top: var(--ac-topbar-h) !important;
        left: .5rem !important;
        right: .5rem !important;
        width: auto !important;
        transform: none !important;
    }

    .dropdown-item {
        padding: .75rem 1.25rem;
    }
}

/* ---------- Formularios por pasos (solicitud de crédito) ---------- */
@media screen and (max-width: 767.98px) {
    #progressbar {
        padding: 0;
        margin-bottom: 1rem;
    }

    #progressbar li {
        font-size: .62rem !important;
        line-height: 1.2;
        padding: 0 2px;
    }

    #progressbar li:before {
        width: 38px !important;
        height: 38px !important;
        line-height: 34px !important;
        font-size: 16px !important;
    }

    #progressbar li:after {
        top: 19px !important;
    }

    /* La solicitud de crédito mete padding extra en fila + columna */
    #grad1 > .row > [class*="col-"] {
        padding: 0 !important;
    }

    #grad1 .row[style*="padding"] {
        padding: 0 !important;
        margin: 0;
    }

    #msform .form-card {
        padding: 0 .25rem;
    }

    fieldset .action-button,
    fieldset .action-button-previous,
    fieldset .next,
    fieldset .previous {
        width: 100% !important;
        margin: .35rem 0 !important;
        min-height: 2.75rem;
    }
}

/* ---------- reCAPTCHA (304px fijo) en pantallas muy angostas ---------- */
@media screen and (max-width: 359.98px) {
    .g-recaptcha {
        transform: scale(.88);
        transform-origin: center top;
    }
}

/* ---------- Impresión: nunca mostrar elementos móviles ---------- */
@media print {
    .ac-bottom-nav,
    .ac-sidebar-backdrop,
    .ac-topbar-brand {
        display: none !important;
    }

    body.ac-has-bottom-nav #content {
        padding-bottom: 0 !important;
    }
}
