/* Mobile Optimization Styles */

/* Touch-friendly buttons and links */
@media (max-width: 768px) {

    /* Minimum touch target size: 44px */
    button,
    .btn,
    a.button,
    input[type="submit"],
    input[type="button"] {
        min-height: 44px;
        min-width: 44px;
        padding: 12px 20px;
    }

    /* Larger tap targets for navigation */
    nav a,
    .nav-link,
    .menu-item {
        min-height: 48px;
        display: flex;
        align-items: center;
        padding: 12px 16px;
    }

    /* Form inputs */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="tel"],
    input[type="number"],
    textarea,
    select {
        min-height: 44px;
        font-size: 16px;
        /* Prevents zoom on iOS */
        padding: 12px 16px;
    }

    /* MOBILE HEADER SPECIFIC OVERRIDES - Must come after generic input styles */
    #oldSearchInput {
        min-height: 24px !important;
        height: 24px !important;
        line-height: 24px !important;
        font-size: 13px !important;
        padding: 0 8px !important;
        flex: 1 !important;
        min-width: 0 !important;
    }

    #searchCategory {
        min-height: 24px !important;
        height: 24px !important;
        font-size: 12px !important;
        padding: 0 6px !important;
        max-width: 100px !important;
        flex-shrink: 0 !important;
    }

    .search-box {
        padding: 2px 8px !important;
        border-radius: 12px !important;
        flex: 1 !important;
        width: 100% !important;
        max-width: 100% !important;
        display: flex !important;
        gap: 4px !important;
    }

    .header-row1 {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        height: auto !important;
        overflow: visible !important;
    }

    .search-filter-container {
        display: flex !important;
        gap: 8px !important;
        align-items: center !important;
        width: 100% !important;
        max-width: 100% !important;
        flex: 1 !important;
        order: 1 !important;
    }

    #searchWrapper {
        flex: 1 !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    #searchForm {
        flex: 1 !important;
        width: 100% !important;
        max-width: 100% !important;
        display: flex !important;
    }

    /* Filter button should be on the right */
    .filter-toggle-btn,
    #filterToggle,
    .search-filter-btn {
        order: 2 !important;
        flex-shrink: 0 !important;
        margin-left: auto !important;
    }

    /* Ensure header container is full width */
    .header-container {
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Redundant toggle styles removed - controlled by header.php */
    /* .mobile-sidebar-toggle { ... } */

    /* Larger font sizes for readability */
    body {
        font-size: 16px;
        line-height: 1.6;
    }

    h1 {
        font-size: 28px;
    }

    h2 {
        font-size: 24px;
    }

    h3 {
        font-size: 20px;
    }

    h4 {
        font-size: 18px;
    }

    /* Spacing improvements */
    .container,
    .content {
        padding-left: 16px;
        padding-right: 16px;
    }

    /* Cards and sections */
    .card,
    .section {
        margin-bottom: 16px;
        padding: 16px;
    }

    /* Tables - make scrollable */
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Images responsive */
    img {
        max-width: 100%;
        height: auto;
    }

    /* Hide desktop-only elements */
    .desktop-only {
        display: none !important;
    }

    /* Show mobile-only elements */
    .mobile-only {
        display: block !important;
    }
}

/* Tablet optimizations */
@media (min-width: 769px) and (max-width: 1024px) {
    .container {
        max-width: 720px;
    }

    /* Adjust grid layouts */
    .grid-3-col {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Landscape phone optimizations */
@media (max-width: 768px) and (orientation: landscape) {

    /* Reduce header height in landscape */
    header {
        min-height: 60px;
    }

    /* Adjust modal heights */
    .modal-content {
        max-height: 90vh;
        overflow-y: auto;
    }
}

/* Prevent text selection on buttons (better mobile UX) */
button,
.btn,
a.button {
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* Smooth scrolling on mobile */
html {
    -webkit-overflow-scrolling: touch;
}

/* Fix viewport issues */
@viewport {
    width: device-width;
    zoom: 1.0;
}

/* ==========================================================================
   NUCLEAR MOBILE COMBAT STYLES (Ported from index-mobile.php - User Request)
   "So this devil will not flash or come out without asking"
   ========================================================================== */
@media (max-width: 980px) {

    /* 1. Global Reset & Tightening */
    body,
    html,
    .main-content,
    main {
        margin: 0 !important;
        padding-top: 0 !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        overflow-x: hidden !important;
    }

    /* 2. Remove Header Gaps & Fix Banner */
    #mainHeader {
        margin-bottom: 0 !important;
        padding-bottom: 0 !important;
    }

    #redCrisisBanner {
        margin-top: 10px !important;
        /* Removed negative margin that caused overlap */
        position: relative !important;
        z-index: 995 !important;
    }

    /* 3. Center and Compact the Navigator (Tight Layout) */
    #navigator-container {
        display: flex !important;
        justify-content: center !important;
        gap: 1px !important;
        width: 100% !important;
        margin: 0 auto !important;
        padding: 0 1px !important;
        pointer-events: auto !important;
        z-index: 20002 !important;
        position: relative !important;
    }

    #navigator-container .nav-item {
        margin: 0 !important;
        padding: 0 !important;
        pointer-events: auto !important;
        z-index: 20003 !important;
    }

    #navigator-container .nav-btn {
        padding: 2px 4px !important;
        /* Ultra-tight touch target to fit 7+ items */
        cursor: pointer !important;
        pointer-events: auto !important;
        z-index: 20003 !important;

        /* Show Icon + Text tiny */
        font-size: 10px !important;
        color: #111827 !important;
        /* Deep dark color for visibility */
        font-weight: 600 !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 2px !important;
        width: auto !important;
        min-width: 25px !important;
        /* Ensure click area */
    }

    /* Ensure Icons are visible and sized correctly */
    #navigator-container .nav-btn i {
        font-size: 18px !important;
        color: #333 !important;
        /* Default dark icon */
        display: block !important;
        visibility: visible !important;
        margin: 0 !important;
    }

    /* Specific colors for specific icons (re-apply if needed) */
    #navigator-container .nav-btn i.fa-home {
        color: #3b82f6 !important;
    }

    #navigator-container .nav-btn i.fa-heart {
        color: #ec4899 !important;
    }

    #navigator-container .nav-btn i.fa-images {
        color: #6366f1 !important;
    }

    #navigator-container .nav-btn i.fa-gavel {
        color: #f97316 !important;
    }

    #navigator-container .nav-btn i.fa-shopping-bag {
        color: #10b981 !important;
    }

    #navigator-container .nav-btn i.fa-chart-line {
        color: #8b5cf6 !important;
    }

    #navigator-container .nav-btn i.fa-globe {
        color: #14b8a6 !important;
    }

    #navigator-container .nav-btn i.fa-tools {
        color: #ef4444 !important;
    }

    /* Show text spans (Match Desktop) */
    #navigator-container .nav-btn span,
    #navigator-container .nav-text {
        display: inline !important;
    }

    /* 4. KILL THE FLASHING DEVIL (UFO Panel)
       But allow it if .mobile-summoned (The Strip) is active. */
    /* DISABLED - Relying on .ufo-mobile-hidden class
    #ufoControlPanel:not(.mobile-summoned),
    .ufo-right-control-panel:not(.mobile-summoned) {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
        left: -9999px !important;
        width: 0 !important;
        height: 0 !important;
        overflow: hidden !important;
    }
    */

    /* 5. Sanity Bar (Visual Confidence) */
    .sanity-bar {
        height: 3px !important;
        background: #39ff14 !important;
        /* Neon Green */
        width: 100% !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        z-index: 2147483647 !important;
    }
}
