/* =============================================
   JD Mobile — Responsive Styles
   Autor: Juan David Zapata
   ============================================= */

/* ── Sidebar Overlay (capa oscura al abrir sidebar en mobile) ── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    z-index: 1009;   /* justo debajo del sidebar (1010) pero encima del header (999) */
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}
.sidebar-overlay.show { display: block; }

/* ── Hamburger button (solo visible en mobile) ── */
.sidebar-hamburger {
    display: none;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: #fff;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: var(--jd-radius-sm, 8px);
    flex-shrink: 0;
    transition: all 0.3s ease;
    line-height: 1;
}
.sidebar-hamburger:hover {
    color: var(--jd-crimson, #ff4d6d);
    background: rgba(255, 77, 109, 0.1);
}

/* ── Sidebar close button (solo visible en mobile) ── */
.sidebar-close-btn {
    display: none;
    position: absolute;
    top: 14px;
    right: 14px;
    background: rgba(255, 77, 109, 0.1);
    border: 1px solid rgba(255, 77, 109, 0.3);
    color: var(--jd-crimson, #ff4d6d);
    width: 30px;
    height: 30px;
    border-radius: var(--jd-radius-sm, 8px);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    z-index: 1;
}
.sidebar-close-btn:hover {
    background: var(--jd-crimson, #ff4d6d);
    color: #fff;
    border-color: transparent;
}

/* ── FAB Nueva Orden (mobile only) ── */
.fab-nueva-ot {
    display: none;
    position: fixed;
    bottom: 24px;
    right: 20px;
    z-index: 990;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ff5577 0%, #b81848 100%);
    color: #fff;
    border: none;
    font-size: 1.5rem;
    box-shadow: 0 4px 16px rgba(255, 77, 109, 0.5);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    text-decoration: none;
}
.fab-nueva-ot:hover, .fab-nueva-ot:focus {
    background: linear-gradient(135deg, #ff7a94 0%, #cc2050 100%);
    transform: translateY(-3px) scale(1.06);
    color: #fff;
    box-shadow: 0 8px 24px rgba(255, 77, 109, 0.6);
}

/* ============================================
   TABLET / MOBILE (max-width: 768px)
   ============================================ */
@media (max-width: 768px) {

    /* ── Elementos que aparecen solo en mobile ── */
    .sidebar-hamburger { display: flex; }
    .sidebar-close-btn { display: flex; }
    .fab-nueva-ot { display: flex; }

    /* ── Filtros flex-nowrap: wrap en 2 columnas ── */
    .jd-filter-row {
        flex-wrap: wrap !important;
        gap: 8px !important;
    }
    .jd-filter-row > .col-auto {
        flex: 1 1 calc(50% - 8px) !important;
        max-width: calc(50% - 4px) !important;
        min-width: 120px;
    }
    .jd-filter-row .form-control,
    .jd-filter-row .form-select {
        max-width: 100% !important;
        width: 100% !important;
        min-width: 0 !important;
    }
    .jd-filter-row .d-flex.gap-2 {
        flex-wrap: wrap;
        gap: 6px !important;
    }

    /* ── Card-component (crear_ot, login) ── */
    .card-component {
        padding: 20px 14px !important;
        margin: 12px auto !important;
        border-radius: 12px !important;
    }

    /* ── Formularios con col-md-1 (switches) ── */
    .col-md-1.d-flex,
    [class*="col-md-1"] .form-check {
        justify-content: flex-start !important;
    }

    /* ── Sidebar override para mobile ── */
    .admin-sidebar {
        height: 100vh !important;
        height: 100dvh !important;
        border-radius: 0 var(--jd-radius-xl, 16px) var(--jd-radius-xl, 16px) 0 !important;
        margin: 0 !important;
        z-index: 1010 !important;
    }
    /* El hover de scale está restringido a ≥769px en sidebar-admin.css */
    /* Aquí solo aseguramos el estado show */
    .admin-sidebar.show {
        transform: translateX(0) !important;
    }

    /* ── Header search ── */
    .buscador-header {
        flex: 1 !important;
        min-width: 0;
        margin-left: 6px !important;
        margin-right: 6px !important;
    }
    .buscador-global {
        width: 100% !important;
        min-width: 0 !important;
    }

    /* ── Ocultar nombre de usuario en header, conservar ícono ── */
    .jd-header-username { display: none !important; }

    /* ── Admin hero compacto ── */
    .admin-hero {
        flex-wrap: wrap !important;
        gap: 10px !important;
        margin-bottom: 1rem !important;
    }
    .admin-hero .admin-title { font-size: 1.3rem !important; }
    .admin-hero .stat-icon {
        width: 42px !important;
        height: 42px !important;
        font-size: 1.2rem !important;
        min-width: 42px !important;
        margin-bottom: 0 !important;
    }
    .admin-hero .ms-auto {
        margin-left: 0 !important;
        width: 100%;
        flex-wrap: wrap;
        gap: 8px;
    }

    /* ── Container padding ── */
    .container.py-4 {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }
    .container-fluid.px-4 {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }

    /* ── Stats ── */
    .stat-number { font-size: 1.8rem !important; }
    .stat-card { margin-bottom: 12px; }

    /* ── Kanban: columnas full-width ── */
    .kanban-column {
        flex: 1 1 100% !important;
        width: 100% !important;
        max-width: 100% !important;
        max-height: 65vh !important;
    }
    .kanban-board { gap: 12px !important; }

    /* ── Kanban filter: scroll horizontal ── */
    .kanban-filter-area {
        overflow-x: auto !important;
        flex-wrap: nowrap !important;
        justify-content: flex-start !important;
        padding-bottom: 6px !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 8px !important;
    }
    .kanban-filter-area::-webkit-scrollbar { display: none; }
    .kanban-filter-area .btn {
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* ── Etiquetas filtro: scroll horizontal ── */
    .etiquetas-filter-wrap {
        overflow-x: auto !important;
        flex-wrap: nowrap !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 4px;
    }
    .etiquetas-filter-wrap::-webkit-scrollbar { display: none; }

    /* ── Tables: touch scroll ── */
    .table-responsive { -webkit-overflow-scrolling: touch; }

    /* ── Side panels full-width ── */
    #notif-panel, #chat-panel, #tareas-panel {
        width: 100vw !important;
        right: -100vw !important;
    }
    #notif-panel.open, #chat-panel.open, #tareas-panel.open {
        right: 0 !important;
    }

    /* ── Touch targets más grandes ── */
    .btn { min-height: 40px; }
    .btn-sm { min-height: 34px; }
    .form-control, .form-select { min-height: 42px; font-size: 1rem !important; }
    .form-control-sm, .form-select-sm { min-height: 36px; }

    /* ── Modals ── */
    .modal-dialog { margin: 0.5rem; }
    .modal-dialog-scrollable .modal-body { max-height: 65vh; }

    /* ── Tabs ── */
    .nav-tabs .nav-link { padding: 0.45rem 0.7rem; font-size: 0.9rem; }

    /* ── Pagination ── */
    .pagination .page-link { padding: 0.45rem 0.65rem; font-size: 0.85rem; }

    /* ── Ocultar texto de botones, mantener íconos ── */
    .btn-mobile-icon-only .btn-text { display: none; }

    /* ── Charts: contenedor responsivo ── */
    canvas { max-width: 100%; }
    .chart-container, [class*="chart-wrap"] { overflow: hidden; }

    /* ── Admin ver servicio: botones de acción en hero ── */
    .admin-hero .ms-auto.d-flex {
        flex-wrap: wrap !important;
        justify-content: flex-start !important;
    }

    /* ── Cuadre / analytics: stats compactos ── */
    .stat-card .card-body { padding: 1rem !important; }
    .jd-card { padding: var(--jd-spacing-md) !important; }

    /* ── WMS y páginas con layout de 2 paneles ── */
    .wms-grid, [class*="wms-"] { overflow-x: auto; }

    /* ── Dropdowns en mobile ── */
    .dropdown-menu { min-width: auto !important; }

    /* ── Accordion sidebar (Bootstrap) ── */
    .accordion-button { font-size: 0.9rem; padding: 0.6rem 1rem; }
}

/* ============================================
   SMALL MOBILE (max-width: 480px)
   ============================================ */
@media (max-width: 480px) {
    body { padding-top: 64px !important; }

    header.admin-header-top { padding: 0.3rem 0.5rem !important; }

    .admin-title { font-size: 1.1rem !important; }
    .admin-subtitle { font-size: 0.8rem !important; }

    .stat-number { font-size: 1.5rem !important; }

    .kanban-card { padding: 10px; }
    .kanban-card-title { font-size: 0.88rem; }
    .kanban-column { max-height: 60vh !important; }

    /* Modals casi full screen */
    .modal-dialog {
        margin: 0;
        max-width: 100vw;
    }
    .modal-content {
        border-radius: var(--jd-radius-lg, 12px) var(--jd-radius-lg, 12px) 0 0;
        min-height: 50vh;
    }

    /* Header: ocultar botones menos esenciales */
    .header-icon-hide-xs { display: none !important; }

    /* FAB más compacto */
    .fab-nueva-ot { width: 50px; height: 50px; font-size: 1.3rem; bottom: 20px; right: 16px; }
}
