/* ==========================================================
   WMS — RESPONSIVE CSS UNIVERSAL
   ========================================================== */

/* --- VIEWPORT META GUARD: ensure no horizontal scroll --- */
html { overflow-x: hidden; }

.btn-voltar-home {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: #111827;
    color: #ffffff;
    padding: 12px 14px;
    border-radius: 11px;
    text-decoration: none;
    font-weight: 700;
    border: none;
    margin: 0;
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 10000;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.35);
    transition: filter 0.2s ease, transform 0.2s ease, background-color 0.2s ease;
}

.btn-voltar-home:hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
}

#btn-voltar-home.mobile-home-btn {
    display: inline-flex !important;
}

#btn-voltar-home.mobile-home-btn span,
#btn-voltar-home.mobile-back-btn span {
    display: none;
}

.mobile-user-badge {
    display: none;
}

body.mobile-no-sidebar .sidebar {
    display: none !important;
}

body.mobile-no-sidebar #mobile-menu-btn,
body.mobile-no-sidebar #sidebar-overlay {
    display: none !important;
}

/* --- MEDIUM SCREENS (up to 1100px) --- */
@media (max-width: 1100px) {
    .main-content { padding: 20px; }
    .sidebar h3 { font-size: 1.2rem; margin-bottom: 20px; }
}

/* --- TABLETS (769px – 1024px) --- */
@media (max-width: 1024px) {
    :root { --sidebar-width: 70px; }

    #mobile-menu-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        position: fixed;
        top: 15px;
        left: 15px;
        width: 44px;
        height: 44px;
        z-index: 10000;
        background: var(--primary);
        color: white;
        border-radius: 11px;
        border: none;
        box-shadow: 0 4px 12px rgba(79,70,229,0.35);
        cursor: pointer;
        font-size: 1rem;
        transition: transform 0.22s ease, background-color 0.22s ease;
    }

    #mobile-menu-btn i {
        transition: transform 0.2s ease;
    }

    #mobile-menu-btn.is-active {
        transform: rotate(90deg);
        background: #0b1220;
    }

    .mobile-user-badge {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        background: #0f172a;
        color: #e2e8f0;
        border: 1px solid #334155;
        border-radius: 10px;
        padding: 8px 12px;
        margin: 10px 10px 12px;
        font-size: 0.78rem;
        font-weight: 700;
    }

    .mobile-user-badge i {
        color: #38bdf8;
    }

    .sidebar { width: var(--sidebar-width); padding: 20px 8px; }
    .sidebar span,
    .sidebar h3,
    .sidebar-header .brand-name,
    .sidebar-header .theme-label { display: none !important; }
    .sidebar nav a { justify-content: center; padding: 13px 0; }
    .sidebar nav a i { font-size: 1.3rem; margin: 0; }

    .main-content { margin-left: var(--sidebar-width); }

    /* Tablets: admin dashboard KPI columns 2x2 */
    .dash-hero-kpis { flex-wrap: wrap; }
    .dash-hero-kpi { flex: 1 0 120px; }
}

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

    /* Layout reset */
    .dashboard-wrapper { flex-direction: column; }
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        padding: 0 !important;
    }

    /* Sidebar: off-canvas drawer */
    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        width: 280px !important;
        height: 100vh;
        z-index: 9999;
        transition: left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: none;
    }

    .sidebar.mobile-open {
        left: 0;
        box-shadow: 20px 0 60px rgba(0,0,0,0.55);
    }

    .sidebar span,
    .sidebar h3,
    .sidebar .theme-label { display: block !important; }

    /* Hamburger button */
    #mobile-menu-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        position: fixed;
        top: 15px;
        left: 15px;
        width: 44px;
        height: 44px;
        z-index: 10000;
        background: var(--primary);
        color: white;
        border-radius: 11px;
        border: none;
        box-shadow: 0 4px 12px rgba(79,70,229,0.35);
        cursor: pointer;
        font-size: 1rem;
        transition: transform 0.22s ease, background-color 0.22s ease;
    }

    #mobile-menu-btn i {
        transition: transform 0.2s ease;
    }

    #mobile-menu-btn.is-active {
        transform: rotate(90deg);
        background: #0b1220;
    }

    #btn-voltar-home.mobile-home-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        position: fixed;
        top: 15px;
        left: 15px;
        z-index: 10000;
        padding: 12px 14px;
        margin: 0;
        background: var(--primary);
        color: #ffffff;
        border: none;
        box-shadow: 0 4px 12px rgba(15, 118, 110, 0.35);
        border-radius: 11px;
    }

    #btn-voltar-home.mobile-home-btn span {
        display: none;
    }

    /* Theme/floating btn: move away from hamburger */
    .theme-floating-btn {
        top: 15px;
        right: 15px;
    }

    /* KPI/stat grids */
    .grid-stats {
        grid-template-columns: 1fr 1fr !important;
        gap: 10px;
    }

    .dashboard-grid-main {
        grid-template-columns: 1fr !important;
        gap: 14px;
    }

    /* Tables: horizontal scroll */
    .table-container {
        padding: 12px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table { min-width: 580px; }

    /* Tabs: scrollable on mobile */
    .dash-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 4px;
        scrollbar-width: none;
    }
    .dash-tabs::-webkit-scrollbar { display: none; }
    .dash-tab { flex-shrink: 0; }

    /* Resume grid */
    .resumo-vendas {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Kanban: stack columns */
    .kanban-wrap {
        grid-template-columns: 1fr;
    }

    /* Worker screen: full bleed */
    #area-operador .worker-screen {
        padding-top: 0;
    }

    /* Forms: full width */
    input, select, textarea {
        max-width: 100%;
    }

    /* Section headers: stack */
    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }

    /* Modal full-screen bottom sheet */
    .modal-overlay {
        align-items: flex-end;
        padding: 0;
    }

    .modal-box {
        border-radius: 20px 20px 0 0;
        max-height: 88vh;
        max-width: 100%;
        padding: 22px 18px;
    }
}

@media (max-width: 1024px) {
    #btn-voltar-home.mobile-home-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        position: fixed;
        top: 15px;
        left: 15px;
        z-index: 10000;
        padding: 12px 14px;
        margin: 0;
        background: var(--primary);
        color: #ffffff;
        border: none;
        box-shadow: 0 4px 12px rgba(15, 118, 110, 0.35);
        border-radius: 11px;
    }

    #btn-voltar-home.mobile-home-btn span {
        display: none;
    }

    #btn-voltar-home.mobile-back-btn span {
        display: none;
    }
}

/* --- SMALL MOBILE (≤ 480px) --- */
@media (max-width: 480px) {
    h1 { font-size: 1.3rem; }
    .card-stat .value { font-size: 1.4rem; }

    .grid-stats { grid-template-columns: 1fr !important; }

    .dash-hero { padding: 18px 16px; }
    .dash-hero-kpis { gap: 8px; }
    .dash-hero-kpi { padding: 10px 12px; }
    .dash-hero-kpi .hk-val { font-size: 1.3rem; }

    .worker-tiles { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .worker-greeting .greet-name { font-size: 1.2rem; }
    .worker-quick-stats { gap: 6px; }
    .wqs-card .wqs-value { font-size: 1.2rem; }
}
