/* 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: none !important;
        /* FIXED: Strictly hidden as requested */
        visibility: hidden !important;
        opacity: 0 !important;
        height: 0 !important;
        overflow: hidden !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;
}
