/* ================================================================
   MOBILE-ONLY STYLES FOR MANUFACTURE PAGE (< 768px)
   ================================================================ */

@media (max-width: 768px) {
    /* ===== HEADER COMPACT ===== */
    header {
        padding: 0 !important;
        min-height: 48px;
    }

    header .container {
        padding-top: 0.25rem !important;
        padding-bottom: 0.25rem !important;
    }

    header h1 {
        font-size: 0.95rem !important;
    }

    header .w-10.h-10 {
        width: 1.6rem !important;
        height: 1.6rem !important;
    }

    header .w-10.h-10 i {
        font-size: 0.7rem !important;
    }

    /* ===== MAIN CONTENT SPACING ===== */
    main {
        padding: 0.5rem 0.25rem !important;
    }

    /* ===== FILTER BAR - STACKED ===== */
    .filter-bar {
        flex-direction: column !important;
        align-items: stretch !important;
        padding: 0.75rem !important;
        gap: 0.6rem !important;
        margin-bottom: 0.5rem !important;
    }

    .filter-section {
        width: 100% !important;
    }

    .filter-options-container {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 0.35rem !important;
        justify-content: center !important;
    }

    .filter-option {
        font-size: 0.72rem !important;
        padding: 0.35rem 0.65rem !important;
        border-radius: 1rem !important;
    }

    .search-section {
        width: 100% !important;
        max-width: 100% !important;
    }

    .search-wrapper {
        width: 100% !important;
    }

    .filter-bar .search-bar {
        width: 100% !important;
        padding: 0.55rem 0.75rem 0.55rem 2.2rem !important;
        font-size: 16px !important;
        border-radius: 0.5rem !important;
    }

    .search-icon {
        left: 0.75rem !important;
        font-size: 0.75rem !important;
    }

    /* Autocomplete list */
    .autocomplete-list {
        max-height: 200px !important;
        border-radius: 0.5rem !important;
    }

    .autocomplete-item {
        padding: 0.5rem 0.65rem !important;
        font-size: 0.85rem !important;
    }

    .autocomplete-item img {
        width: 24px !important;
        height: 24px !important;
    }

    /* Dropdown */
    .dropdown-wrapper {
        width: 100% !important;
        margin-left: 0 !important;
    }

    #dropdownSelected {
        width: 100% !important;
        padding: 0.55rem 0.75rem !important;
        font-size: 0.85rem !important;
        border-radius: 0.5rem !important;
    }

    .dropdown-list {
        width: 100% !important;
        max-height: 200px !important;
        border-radius: 0.5rem !important;
    }

    .dropdown-item {
        padding: 0.5rem 0.65rem !important;
        font-size: 0.85rem !important;
    }

    /* Settings toggle */
    .settings-toggle {
        width: 32px !important;
        height: 32px !important;
    }

    .settings-dropdown {
        right: 0 !important;
        min-width: 160px !important;
        border-radius: 0.5rem !important;
    }

    .settings-option {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.85rem !important;
    }

    /* History toggle */
    .history-toggle {
        font-size: 0.75rem !important;
        padding: 0.35rem 0.65rem !important;
    }

    /* ===== HISTORY BAR ===== */
    .history-bar {
        padding: 0.5rem 0.65rem !important;
        margin-bottom: 0.5rem !important;
        gap: 0.4rem !important;
    }

    .history-bar-title {
        font-size: 0.75rem !important;
    }

    .history-item {
        padding: 0.3rem 0.5rem !important;
        font-size: 0.75rem !important;
    }

    .history-item img {
        width: 16px !important;
        height: 16px !important;
    }

    .history-nav-btn,
    .history-clear-btn {
        padding: 0.3rem 0.5rem !important;
        font-size: 0.75rem !important;
    }

    /* ===== SELECTED ITEM HEADER ===== */
    .selected-item-header {
        flex-direction: column !important;
        gap: 0.75rem !important;
        padding: 0.75rem 1rem !important;
        margin-bottom: 0.75rem !important;
        text-align: center !important;
    }

    .selected-item-header .item-info {
        flex-direction: column !important;
        gap: 0.5rem !important;
    }

    .selected-item-header .item-image {
        width: 40px !important;
        height: 40px !important;
    }

    .selected-item-header .item-name {
        font-size: 1rem !important;
    }

    .selected-item-header .item-type-badge {
        font-size: 0.65rem !important;
    }

    .selected-item-header .quantity-controls {
        width: 100% !important;
        justify-content: center !important;
        gap: 0.5rem !important;
    }

    .quantity-label {
        font-size: 0.75rem !important;
    }

    .quantity-input {
        width: 60px !important;
        padding: 0.4rem 0.5rem !important;
        font-size: 0.85rem !important;
    }

    .quantity-btn {
        padding: 0.4rem 0.75rem !important;
        font-size: 0.75rem !important;
    }

    /* ===== PROCESS CHECKLIST CARD ===== */
    .dashboard-card.process-checklist-card {
        padding: 0.75rem 0.5rem !important;
        min-height: auto !important;
        border-radius: 0.75rem !important;
    }

    .dashboard-card h2 {
        font-size: 1.1rem !important;
    }

    .tree-controls {
        gap: 0.35rem !important;
    }

    .tree-controls button {
        font-size: 0.72rem !important;
        padding: 0.35rem 0.65rem !important;
        border-radius: 0.4rem !important;
    }

    /* Legend */
    .mb-4.p-3.bg-wlDarker {
        padding: 0.5rem 0.65rem !important;
        gap: 0.5rem !important;
        margin-bottom: 0.5rem !important;
    }

    .legend-item {
        font-size: 0.65rem !important;
        gap: 0.3rem !important;
    }

    .legend-item i {
        font-size: 0.7rem !important;
        width: 1rem !important;
    }

    /* Process tree */
    #processTree {
        font-size: 0.85rem !important;
        padding-left: 0 !important;
    }

    .process-step {
        margin-left: 0.25rem !important;
        padding-left: 0.5rem !important;
        border-radius: 0.5rem !important;
        margin-bottom: 0.25rem !important;
    }

    .process-step.root {
        padding-left: 0.1rem !important;
    }

    .process-step label {
        padding: 0.4rem 0.1rem 0.4rem 0 !important;
        gap: 0.3rem !important;
        font-size: 0.82rem !important;
    }

    .process-step .fa-cube,
    .process-step .fa-tools,
    .process-step .fa-clock,
    .process-step .fa-cogs,
    .process-step .fa-leaf,
    .process-step .fa-info-circle {
        font-size: 0.75rem !important;
    }

    .process-step img {
        width: 1.25rem !important;
        height: 1.25rem !important;
    }

    .process-step .text-xs {
        font-size: 0.65rem !important;
    }

    .tree-toggle {
        padding: 0.2rem !important;
    }

    /* Progress bar */
    .mt-8.mb-4 {
        margin-top: 0.75rem !important;
        margin-bottom: 0.5rem !important;
    }

    .progress-bar-bg,
    .progress-bar-fill {
        height: 0.6rem !important;
        border-radius: 0.3rem !important;
    }

    #progressPercent {
        font-size: 0.75rem !important;
    }

    #progressCount {
        font-size: 0.65rem !important;
    }

    /* Summary box */
    .summary-box {
        padding: 0.75rem !important;
        border-radius: 0.75rem !important;
        margin-top: 0.75rem !important;
    }

    .summary-box h3 {
        font-size: 0.95rem !important;
    }

    #summaryRaw,
    #summaryTime {
        font-size: 0.75rem !important;
    }

    #summaryRaw li,
    #summaryTime div {
        margin-bottom: 0.25rem !important;
    }

    /* ===== SIDEBAR FAB - HIDDEN (replaced by FAB nav) ===== */
    .sidebar-fab {
        display: none !important;
    }

    /* ===== FOOTER MOBILE ===== */
    footer .grid {
        display: block !important;
        text-align: center !important;
    }

    footer .grid > div {
        display: none !important;
    }

    footer .grid > div:first-child {
        display: block !important;
        text-align: center !important;
    }

    footer .grid > div:first-child .flex {
        justify-content: center !important;
    }

    footer .border-t {
        padding-top: 0.75rem !important;
    }

    footer .border-t .text-sm {
        font-size: 0.6rem !important;
    }
}

/* ===== EXTRA SMALL SCREENS (<=420px) ===== */
@media (max-width: 420px) {
    .filter-option {
        font-size: 0.65rem !important;
        padding: 0.3rem 0.5rem !important;
    }

    .process-step label {
        font-size: 0.75rem !important;
    }

    .process-step {
        padding-left: 0.35rem !important;
    }

    .summary-box {
        padding: 0.6rem !important;
    }
}

/* ===== LANDSCAPE MOBILE ===== */
@media (max-height: 500px) and (orientation: landscape) {
    .filter-bar {
        padding: 0.5rem !important;
    }

    .autocomplete-list {
        max-height: 120px !important;
    }

    .dropdown-list {
        max-height: 120px !important;
    }
}

/* ===== FAB NAVIGATION ===== */
#fabNavContainer {
    display: flex !important;
    position: fixed !important;
    bottom: calc(env(safe-area-inset-bottom, 0.5rem) + 1.5rem) !important;
    left: calc(env(safe-area-inset-left, 0.5rem) + 1.5rem) !important;
    z-index: 999 !important;
}

#fabNavBtn {
    display: flex !important;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 0.85rem;
    min-height: 3rem;
    border-radius: 1.5rem;
    background: rgba(245, 158, 11, 0.2) !important;
    border: 1px solid rgba(245, 158, 11, 0.3) !important;
    box-shadow: 0 4px 20px rgba(245, 158, 11, 0.25), 0 1px 3px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(16px) saturate(1.8);
    -webkit-backdrop-filter: blur(16px) saturate(1.8);
    color: #fbbf24 !important;
    transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

#fabNavBtn i {
    font-size: 0.8rem !important;
}

#fabNavBtn .fab-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: rgba(248, 250, 252, 0.9);
    white-space: nowrap;
}

#fabNavBtn:active {
    transform: scale(0.93) !important;
    background: rgba(245, 158, 11, 0.35) !important;
}

/* FAB Drawer */
#fabNavDrawer {
    display: none !important;
    position: fixed !important;
    bottom: calc(env(safe-area-inset-bottom, 0.5rem) + 5rem) !important;
    left: calc(env(safe-area-inset-left, 0.5rem) + 1.5rem) !important;
    z-index: 998 !important;
    background: linear-gradient(180deg, rgba(20, 20, 35, 0.98) 0%, rgba(13, 13, 20, 0.99) 100%) !important;
    border: 1px solid rgba(139, 92, 246, 0.15) !important;
    border-radius: 1rem !important;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5) !important;
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    padding: 0.5rem !important;
    min-width: 180px;
    transform: scale(0.75) translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#fabNavDrawer.open {
    display: flex !important;
    flex-direction: column !important;
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

#fabNavDrawer a {
    display: flex !important;
    align-items: center;
    gap: 0.6rem !important;
    padding: 0.65rem 0.85rem !important;
    border-radius: 0.6rem !important;
    font-size: 0.8rem !important;
    color: rgba(248, 250, 252, 0.7) !important;
    transition: background-color 0.1s ease, transform 0.1s cubic-bezier(0.4, 0, 0.2, 1);
}

#fabNavDrawer a:active {
    transform: scale(0.97);
    background-color: rgba(139, 92, 246, 0.1) !important;
}

#fabNavDrawer a i {
    font-size: 0.85rem !important;
    width: 1.2rem;
    text-align: center;
}

/* FAB overlay backdrop */
#fabNavOverlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 997;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    transition: opacity 0.25s ease;
}

#fabNavOverlay.open {
    display: block;
    opacity: 1;
}