/* =====================================================================
   LEYDY STORE - PANEL ADMINISTRATIVO EN CELULAR Y TABLET
   Se carga después de ferre-premium.css y solo actúa en pantallas
   de menos de 992 px. En computadora no cambia nada.
   ===================================================================== */

@media (max-width: 991.98px) {

    /* "clip" evita el desplazamiento lateral sin bloquear el scroll vertical */
    html, body {
        overflow-x: clip !important;
    }

    /* ---------- Contenido a todo el ancho ---------- */
    body .content-wrapper,
    body:not(.sidebar-collapse) .content-wrapper,
    body.sidebar-collapse .content-wrapper {
        margin-left: 0 !important;
        width: 100% !important;
        min-width: 0 !important;
        margin-top: 64px !important;
    }

    .content-header .container-fluid,
    .content .container-fluid {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }


    /* ---------- Títulos ---------- */
    .content-header h1,
    .content-wrapper h1,
    .content-wrapper .ferre-title,
    .content-wrapper .page-title {
        font-size: 24px !important;
        line-height: 1.2 !important;
        word-break: break-word;
    }

    .content-header {
        padding: 12px 0 6px !important;
    }

    /* ---------- Tablas (DataTables) ---------- */
    .dataTables_wrapper {
        width: 100% !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dt-buttons,
    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate {
        float: none !important;
        width: 100% !important;
        text-align: center !important;
        margin: 6px 0 !important;
    }

    .dataTables_wrapper .dataTables_filter label {
        display: flex !important;
        align-items: center;
        gap: 6px;
        width: 100% !important;
        margin: 0 !important;
        white-space: nowrap;
    }

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

    .dataTables_wrapper .dt-buttons {
        display: flex !important;
        flex-wrap: wrap;
        justify-content: center;
        gap: 6px;
    }

    .dataTables_wrapper .dataTables_paginate .paginate_button {
        padding: 4px 9px !important;
        margin: 2px !important;
    }

    .table-responsive,
    .content-wrapper .card-body > table:not(.dataTable) {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* ---------- Pestañas: se deslizan de lado si no caben ---------- */
    .content-wrapper .nav-tabs,
    .content-wrapper .nav-pills {
        flex-wrap: nowrap !important;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .content-wrapper .nav-tabs .nav-link,
    .content-wrapper .nav-pills .nav-link {
        white-space: nowrap;
    }

    /* ---------- Tarjetas y bloques ---------- */
    .content-wrapper .card {
        max-width: 100% !important;
        min-width: 0 !important;
    }

    .content-wrapper .card-body {
        padding: 14px !important;
    }

    .content-wrapper .row > [class*="col"] {
        min-width: 0;
    }

    /* Botones de acciones: bajan de línea en vez de salirse */
    .content-wrapper .btn-group,
    .content-wrapper .card-tools,
    .content-wrapper .d-flex.justify-content-between,
    .content-wrapper .d-flex.justify-content-end {
        flex-wrap: wrap !important;
        gap: 6px;
    }

    /* ---------- Formularios ---------- */
    .content-wrapper .form-control,
    .content-wrapper .custom-select,
    .content-wrapper .select2-container {
        max-width: 100% !important;
    }

    .content-wrapper input,
    .content-wrapper select,
    .content-wrapper textarea {
        font-size: 16px; /* evita que el iPhone acerque la pantalla al escribir */
    }

    /* ---------- Ventanas emergentes ---------- */
    .modal-dialog,
    .modal-dialog.modal-lg,
    .modal-dialog.modal-xl {
        max-width: calc(100vw - 16px) !important;
        width: auto !important;
        margin: 8px auto !important;
    }

    .modal-body {
        padding: 12px !important;
    }

    .modal-footer {
        flex-wrap: wrap;
        gap: 6px;
    }

    .modal-footer > .btn {
        flex: 1 1 auto;
    }

    .swal2-popup {
        width: calc(100vw - 32px) !important;
        max-width: 420px !important;
    }


    /* ---------- Encabezado de cada pantalla ---------- */
    .content-wrapper > .content-header {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    /* ---------- Tablero principal ---------- */
    .dashboard-premium {
        padding: 12px !important;
    }

    .dashboard-layout {
        display: flex !important;
        flex-direction: column !important;
        gap: 16px !important;
        grid-template-columns: none !important;
    }

    .dashboard-left,
    .dashboard-right {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
    }

    .dashboard-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 10px !important;
    }

    .dashboard-card {
        min-width: 0 !important;
        width: auto !important;
        padding: 14px !important;
    }

    .dashboard-card * {
        overflow-wrap: anywhere;
    }

    .canvasjs-chart-container,
    .canvasjs-chart-container canvas {
        max-width: 100% !important;
    }

    /* ---------- Venta POS ---------- */
    .w-carrito-pos {
        width: 100% !important;
        max-width: 100vw !important;
    }

    .mdlVentaPos {
        max-width: 100vw !important;
        margin: 0 !important;
    }

    /* ---------- Menú lateral: se oculta y se abre con ☰ ---------- */
    body .main-sidebar,
    body.sidebar-collapse .main-sidebar {
        position: fixed !important;
        top: 0 !important;
        bottom: 0 !important;
        left: 0 !important;
        width: 280px !important;
        max-width: 85vw !important;
        margin-left: 0 !important;
        transform: translateX(-105%) !important;
        transition: transform .25s ease !important;
        z-index: 1100 !important;
        overflow-y: auto !important;
        box-shadow: none;
    }

    body.ls-menu-abierto .main-sidebar {
        transform: translateX(0) !important;
        box-shadow: 0 0 40px rgba(0, 0, 0, .35);
    }

    /* En celular el menú siempre muestra los textos completos */
    body.sidebar-collapse .main-sidebar .nav-link p,
    body.sidebar-collapse .main-sidebar .brand-text,
    body.sidebar-collapse .main-sidebar .nav-sidebar .nav-link p {
        display: inline-block !important;
        width: auto !important;
        opacity: 1 !important;
        visibility: visible !important;
        margin-left: 0 !important;
    }

    .ls-menu-fondo {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, .45);
        z-index: 1090;
    }

    body.ls-menu-abierto .ls-menu-fondo {
        display: block;
    }

    body.ls-menu-abierto {
        overflow: hidden !important;
    }

    /* ---------- Barra superior ---------- */
    body .ferre-topbar,
    body.sidebar-collapse .ferre-topbar {
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        height: 64px !important;
        padding: 0 10px !important;
        gap: 6px !important;
        z-index: 1050 !important;
    }

    .ferre-top-left {
        gap: 8px !important;
        min-width: 0 !important;
        flex: 1 1 auto !important;
        width: auto !important;
    }

    .ferre-top-left h2 {
        font-size: 17px !important;
        margin: 0 !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .ferre-toggle {
        flex: 0 0 auto !important;
    }

    /* El buscador general se oculta en celular (ocupa todo el ancho) */
    .ferre-top-center {
        display: none !important;
    }

    .ferre-top-right {
        gap: 6px !important;
        flex: 0 0 auto !important;
        width: auto !important;
        min-width: 0 !important;
    }

    /* Sucursal y usuario: solo íconos / foto */
    .ferre-branch {
        width: auto !important;
        min-width: 0 !important;
    }

    .ferre-branch-card {
        padding: 6px !important;
        min-width: 0 !important;
        width: auto !important;
    }

    .ferre-branch-card > *:not(.ferre-branch-left),
    .ferre-branch-left > *:not(.ferre-branch-icon) {
        display: none !important;
    }

    .ferre-user-top {
        width: auto !important;
        min-width: 0 !important;
        padding: 0 !important;
        gap: 0 !important;
    }

    .ferre-user-top .ferre-user-info,
    .ferre-user-top > svg,
    .ferre-user-top > i {
        display: none !important;
    }

    .ferre-user-top img {
        width: 38px !important;
        height: 38px !important;
    }

    /* Menús desplegables de la barra superior dentro de la pantalla */
    .ferre-topbar .dropdown-menu,
    .ferre-topbar [class*="dropdown"],
    .ferre-topbar [class*="-menu"]:not(.ferre-toggle) {
        max-width: calc(100vw - 20px) !important;
    }
}

/* Teléfonos pequeños */
@media (max-width: 400px) {
    .ferre-top-left h2 {
        font-size: 15px !important;
    }
    .ferre-icon,
    .ferre-notification {
        width: 34px !important;
        height: 34px !important;
    }
}
