/* ========================================
   MOBILE RESPONSIVE REDESIGN
   Complete mobile-first redesign for WhiskyPricer
   Only affects screens 768px and below
   Desktop remains unchanged
   ======================================== */

/* ========================================
   GLOBAL MOBILE FOUNDATIONS
   ======================================== */
@media (max-width: 768px) {
    /* Prevent horizontal scroll */
    html, body {
        overflow-x: hidden !important;
        width: 100% !important;
        max-width: 100vw !important;
    }
    
    /* Ensure header doesn't cause overflow */
    .header {
        width: 100% !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
    }
    
    /* Better touch targets */
    * {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    }
    
    /* Improved text rendering on mobile */
    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
        text-rendering: optimizeLegibility;
    }
}

/* ========================================
   MOBILE HEADER REDESIGN
   ======================================== */
@media (max-width: 768px) {
    .header {
        padding: 0.5rem 0 !important; /* Reduced padding */
        padding-left: 0 !important;
        padding-right: 0 !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 10000 !important;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15) !important;
        min-height: auto !important;
        width: 100% !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
    }
    
    .header-content {
        display: flex !important;
        flex-wrap: wrap !important;
        align-items: flex-start !important;
        justify-content: space-between !important;
        padding: 0.4rem 0.5rem !important; /* Further reduced padding */
        gap: 0.4rem !important; /* Reduced gap */
        max-width: 100vw !important;
        box-sizing: border-box !important;
        min-height: auto !important;
        width: 100% !important;
        overflow-x: hidden !important;
        grid-template-columns: none !important; /* Override desktop grid */
    }
    
    /* Logo - smaller and better positioned */
    .logo-small {
        height: 40px !important; /* Reduced from 45px */
        width: auto !important;
        flex-shrink: 0 !important;
        order: 1 !important;
    }
    
    /* Mobile menu toggle - prominent and touch-friendly */
    .mobile-menu-toggle,
    #mobileMenuToggleBtn {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 40px !important; /* Reduced from 44px */
        height: 40px !important; /* Reduced from 44px */
        background: rgba(255, 255, 255, 0.25) !important;
        border: 2px solid rgba(255, 255, 255, 0.4) !important;
        border-radius: 8px !important;
        color: white !important;
        font-size: 1.4rem !important; /* Slightly smaller */
        cursor: pointer !important;
        pointer-events: auto !important;
        transition: all 0.3s ease !important;
        order: 3 !important;
        flex-shrink: 0 !important;
        z-index: 10001 !important;
        visibility: visible !important;
        opacity: 1 !important;
        position: relative !important;
    }
    
    .mobile-menu-toggle:hover,
    .mobile-menu-toggle:active {
        background: rgba(255, 255, 255, 0.35) !important;
        transform: scale(1.05) !important;
    }
    
    .hamburger-icon {
        font-size: 1.5rem !important;
        line-height: 1 !important;
    }
    
    /* Search container - fit within header padding - OVERRIDE ALL DESKTOP STYLES */
    .header .search-container,
    body .header .search-container,
    .header-content .search-container,
    body .header-content .search-container,
    .search-container {
        order: 4 !important;
        width: calc(100% - 1rem) !important; /* Account for header padding (0.5rem each side) */
        max-width: calc(100% - 1rem) !important;
        min-width: auto !important; /* Override desktop min-width */
        padding: 0.4rem 0 0 0 !important; /* Reduced padding */
        margin: 0 auto !important;
        flex-basis: 100% !important;
        box-sizing: border-box !important;
        clear: both !important;
        overflow-x: hidden !important;
        position: relative !important;
        left: 0 !important;
        right: 0 !important;
    }
    
    .search-box,
    .header .search-box,
    .header-content .search-box,
    .search-container .search-box,
    body .search-box,
    html body .search-box {
        width: 100% !important;
        max-width: 100% !important;
        height: 50px !important; /* Match stats.php desktop size */
        min-height: 50px !important; /* Prevent Bootstrap from reducing height */
        max-height: 50px !important; /* Prevent Bootstrap from increasing height */
        padding: 0 !important;
        margin: 0 !important;
        background: #ffffff !important;
        background-color: #ffffff !important;
        -webkit-background-color: #ffffff !important;
        -moz-background-color: #ffffff !important;
        -ms-background-color: #ffffff !important;
        -o-background-color: #ffffff !important;
        background-image: none !important;
        border-radius: 8px !important; /* Smaller border radius */
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1) !important;
        border: 1px solid rgba(255, 255, 255, 0.3) !important;
        display: flex !important;
        align-items: stretch !important;
        overflow: hidden !important;
        box-sizing: border-box !important;
    }
    
    /* EXTREME specificity for real mobile browsers */
    html[style] body .search-box,
    body[style] .search-box,
    html body[style] .search-box {
        background: #ffffff !important;
        background-color: #ffffff !important;
    }
    
    /* ULTRA FORCE white background for real mobile browsers - override everything */
    * .search-box,
    * * .search-box,
    html body .search-box,
    html body * .search-box,
    html body div.search-box,
    html body .header .search-box,
    html body .header-content .search-box,
    html body .search-container .search-box {
        background: #ffffff !important;
        background-color: #ffffff !important;
        -webkit-background-color: #ffffff !important;
        -moz-background-color: #ffffff !important;
        -ms-background-color: #ffffff !important;
        background-image: none !important;
        -webkit-background-image: none !important;
        -moz-background-image: none !important;
    }
    
    /* Force white on search input container too */
    html body .search-box * {
        background-color: transparent !important;
    }
    
    html body .search-box {
        background: #ffffff !important;
        background-color: #ffffff !important;
    }
    
    /* Force white background on ALL search boxes on mobile - ULTRA SPECIFIC for real mobile browsers */
    .header .search-box,
    body .header .search-box,
    html body .header .search-box,
    .header-content .search-box,
    body .header-content .search-box,
    html body .header-content .search-box,
    .search-container .search-box,
    body .search-container .search-box,
    html body .search-container .search-box,
    .header .search-container .search-box,
    body .header .search-container .search-box,
    html body .header .search-container .search-box,
    .mobile-only-header .search-box,
    body .mobile-only-header .search-box,
    html body .mobile-only-header .search-box,
    div.search-box,
    body div.search-box,
    html body div.search-box {
        background: #ffffff !important;
        background-color: #ffffff !important;
        background-image: none !important;
        -webkit-background-color: #ffffff !important;
        -moz-background-color: #ffffff !important;
        -o-background-color: #ffffff !important;
    }
    
    /* Ensure search input has proper background and text color */
    .header .search-box .search-input,
    body .header .search-box .search-input,
    html body .header .search-box .search-input,
    .mobile-only-header .search-box .search-input,
    body .mobile-only-header .search-box .search-input,
    html body .mobile-only-header .search-box .search-input,
    .search-box .search-input,
    body .search-box .search-input,
    html body .search-box .search-input {
        background: transparent !important;
        background-color: transparent !important;
        -webkit-background-color: transparent !important;
        -moz-background-color: transparent !important;
        color: #1f2937 !important;
    }
    
    /* Force search button to have proper styling */
    .header .search-box .search-btn,
    body .header .search-box .search-btn,
    html body .header .search-box .search-btn,
    .mobile-only-header .search-box .search-btn,
    body .mobile-only-header .search-box .search-btn,
    html body .mobile-only-header .search-box .search-btn,
    .search-box .search-btn,
    body .search-box .search-btn,
    html body .search-box .search-btn {
        background: #1e40af !important;
        background-color: #1e40af !important;
        -webkit-background-color: #1e40af !important;
        -moz-background-color: #1e40af !important;
        color: #ffffff !important;
    }
    
    /* Search input - OVERRIDE Bootstrap input styles completely */
    .search-input,
    .search-box .search-input,
    .search-box input.search-input,
    .search-box input[type="text"],
    .search-box input,
    .header .search-box input,
    .header-content .search-box input,
    body .search-box input,
    .search-container .search-box input {
        flex: 1 !important;
        border: none !important;
        padding: 0 18px !important; /* Match stats.php desktop padding */
        font-size: 0.95rem !important; /* Match stats.php desktop font size */
        background: transparent !important;
        outline: none !important;
        color: #1f2937 !important;
        min-width: 0 !important;
        height: 100% !important; /* Ensure full height - matches search-box height */
        min-height: auto !important; /* Override Bootstrap min-height */
        max-height: 100% !important; /* Prevent Bootstrap from making it taller */
        line-height: normal !important; /* Override Bootstrap line-height */
        box-sizing: border-box !important;
        margin: 0 !important; /* Override Bootstrap input margins */
        width: auto !important; /* Override Bootstrap input width */
    }
    
    /* Force white background and proper styling on all search inputs */
    .header .search-input,
    body .header .search-input,
    .header-content .search-input,
    body .header-content .search-input,
    .search-container .search-input,
    body .search-container .search-input,
    .search-box .search-input,
    .search-box input {
        background: transparent !important;
        color: #1f2937 !important;
        height: 100% !important;
        padding: 0 18px !important;
        font-size: 0.95rem !important;
    }
    
    .search-input::placeholder {
        color: #9ca3af !important;
    }
    
    /* Search button - OVERRIDE Bootstrap button styles completely */
    .search-btn,
    .search-box .search-btn,
    .search-box button.search-btn,
    .search-box button,
    .header .search-box button,
    .header-content .search-box button,
    body .search-box button,
    .search-container .search-box button {
        background: var(--primary, #1e40af) !important;
        background-color: #1e40af !important;
        color: white !important;
        border: none !important;
        padding: 0 24px !important; /* Match stats.php desktop padding */
        font-size: 0.95rem !important; /* Match stats.php desktop font size */
        font-weight: 600 !important; /* Match stats.php desktop font weight */
        cursor: pointer !important;
        white-space: nowrap !important;
        display: flex !important;
        align-items: center !important;
        gap: 8px !important; /* Match stats.php desktop gap */
        transition: background 0.2s ease !important;
        flex-shrink: 0 !important;
        min-width: auto !important;
        border-radius: 0 8px 8px 0 !important; /* Match search box */
        border-left: 1px solid rgba(255, 255, 255, 0.2) !important; /* Match stats.php */
        height: 100% !important; /* Ensure full height - matches search-box height */
        min-height: auto !important; /* Override Bootstrap min-height */
        max-height: 100% !important; /* Prevent Bootstrap from making it taller */
        box-sizing: border-box !important;
        line-height: normal !important; /* Override Bootstrap line-height */
        margin: 0 !important; /* Override Bootstrap button margins */
        width: auto !important; /* Override Bootstrap button width */
    }
    
    .search-btn:hover,
    .search-btn:active {
        background: #1e3a8a !important;
    }
    
    .search-btn i {
        font-size: 0.9rem !important; /* Smaller icon */
    }
    
    /* Hide desktop navigation */
    .header-nav {
        display: none !important;
    }
}

/* Tablet view (between 768px and 992px) */
@media (min-width: 769px) and (max-width: 992px) {
    .header {
        padding: 0.6rem 0 !important;
        width: 100% !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
    }
    
    .header-content {
        display: flex !important;
        flex-wrap: wrap !important;
        padding: 0.4rem 0.75rem !important;
        gap: 0.5rem !important;
        width: 100% !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
        grid-template-columns: none !important; /* Override desktop grid */
    }
    
    .logo-small {
        height: 42px !important;
    }
    
    .mobile-menu-toggle {
        display: flex !important;
        width: 42px !important;
        height: 42px !important;
        font-size: 1.4rem !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    .header-nav {
        display: none !important; /* Hide desktop nav on tablet */
    }
    
    .header .search-container,
    body .header .search-container,
    .header-content .search-container,
    body .header-content .search-container,
    .search-container {
        order: 4 !important;
        width: calc(100% - 1.5rem) !important;
        max-width: calc(100% - 1.5rem) !important;
        min-width: auto !important;
        padding: 0.4rem 0 0 0 !important;
        margin: 0 auto !important;
        flex-basis: 100% !important;
        box-sizing: border-box !important;
        overflow-x: hidden !important;
    }
    
    .search-box {
        height: 50px !important; /* Match stats.php desktop size */
        width: 100% !important;
        max-width: 100% !important;
    }
    
    .main-content {
        margin-top: 110px !important;
        padding: 1.5rem 1rem !important;
    }
}

/* Extra small phones */
@media (max-width: 480px) {
    .header {
        padding: 0.5rem 0 !important;
        width: 100% !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
    }
    
    .header-content {
        padding: 0 0.5rem !important; /* Further reduced padding */
        gap: 0.5rem !important;
        width: 100% !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
        grid-template-columns: none !important; /* Override desktop grid */
    }
    
    .search-container {
        width: calc(100% - 1rem) !important; /* Account for header padding */
        max-width: calc(100% - 1rem) !important;
    }
    
    .logo-small {
        height: 38px !important;
    }
    
    .mobile-menu-toggle {
        width: 40px !important;
        height: 40px !important;
        font-size: 1.3rem !important;
    }
    
    .header .search-container,
    body .header .search-container,
    .header-content .search-container,
    body .header-content .search-container,
    .search-container {
        width: calc(100% - 1rem) !important; /* Account for header padding */
        max-width: calc(100% - 1rem) !important;
        min-width: auto !important; /* Override desktop min-width */
        padding-left: 0 !important;
        padding-right: 0 !important;
        margin: 0 auto !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
    }
    
    .search-box {
        height: 50px !important; /* Match stats.php desktop size */
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
    }
    
    .mobile-menu-toggle {
        visibility: visible !important;
        opacity: 1 !important;
        display: flex !important;
    }
    
    .search-btn {
        padding: 0 0.875rem !important; /* Smaller padding */
        font-size: 0.8rem !important; /* Smaller font */
    }
    
    .search-input {
        padding: 0 0.875rem !important;
        font-size: 16px !important;
    }
    
    .search-btn {
        padding: 0 1rem !important;
        font-size: 0.875rem !important;
    }
}

/* ========================================
   MOBILE MENU REDESIGN
   ======================================== */
@media (max-width: 768px) {
    .mobile-menu {
        display: none !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        background: rgba(0, 0, 0, 0.95) !important;
        z-index: 99999 !important;
        padding: 0 !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    .mobile-menu.active,
    .mobile-menu.show {
        display: flex !important;
        flex-direction: column !important;
    }
    
    /* Remove any ::before pseudo-elements that might create duplicate X */
    .mobile-menu::before {
        display: none !important;
        content: none !important;
    }
    
    /* Menu items */
    .mobile-menu a {
        display: flex !important;
        align-items: center !important;
        gap: 1rem !important;
        padding: 1.125rem 1.5rem !important;
        color: white !important;
        text-decoration: none !important;
        font-size: 1.05rem !important;
        font-weight: 500 !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
        transition: all 0.2s ease !important;
        background: transparent !important;
        min-height: 56px !important; /* Touch target */
    }
    
    .mobile-menu a:hover,
    .mobile-menu a:active {
        background: rgba(255, 255, 255, 0.1) !important;
        padding-left: 2rem !important;
    }
    
    .mobile-menu a i {
        font-size: 1.25rem !important;
        width: 24px !important;
        text-align: center !important;
        flex-shrink: 0 !important;
    }
    
    .mobile-menu a:last-child {
        border-bottom: none !important;
    }
    
    /* Badges in mobile menu */
    .mobile-menu .nav-badge {
        margin-left: auto !important;
        min-width: 24px !important;
        height: 24px !important;
        font-size: 0.75rem !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    /* Close button - real element, not pseudo - ONLY ONE */
    .mobile-menu-close {
        position: fixed !important;
        top: 1rem !important;
        right: 1rem !important;
        width: 50px !important;
        height: 50px !important;
        min-width: 50px !important;
        min-height: 50px !important;
        display: none !important; /* Hidden by default */
        align-items: center !important;
        justify-content: center !important;
        background: rgba(255, 255, 255, 0.25) !important;
        color: white !important;
        border: 2px solid rgba(255, 255, 255, 0.4) !important;
        border-radius: 50% !important;
        font-size: 1.8rem !important;
        cursor: pointer !important;
        pointer-events: auto !important;
        z-index: 100001 !important;
        transition: all 0.2s ease !important;
        padding: 0 !important;
        margin: 0 !important;
        line-height: 1 !important;
        font-weight: bold !important;
        -webkit-tap-highlight-color: rgba(255, 255, 255, 0.5) !important;
        user-select: none !important;
        -webkit-user-select: none !important;
        -moz-user-select: none !important;
        -ms-user-select: none !important;
    }
    
    /* Show close button only when menu is active */
    .mobile-menu.active .mobile-menu-close,
    .mobile-menu.show .mobile-menu-close {
        display: flex !important;
        pointer-events: auto !important;
    }
    
    .mobile-menu-close:hover,
    .mobile-menu-close:active,
    .mobile-menu-close:focus {
        background: rgba(255, 255, 255, 0.4) !important;
        transform: scale(1.1) !important;
        outline: none !important;
    }
    
    /* Hide ALL duplicate close buttons - only first one shows */
    .mobile-menu .mobile-menu-close ~ .mobile-menu-close {
        display: none !important;
        pointer-events: none !important;
    }
    
    /* Remove any pseudo-elements that might create duplicate X */
    .mobile-menu-close::before,
    .mobile-menu-close::after {
        display: none !important;
        content: none !important;
    }
    
    /* Also remove any ::before on mobile-menu that might show X or Menu text */
    .mobile-menu::before {
        display: none !important;
        content: none !important;
    }
    
    /* Ensure close button is above everything */
    .mobile-menu.active .mobile-menu-close,
    .mobile-menu.show .mobile-menu-close {
        z-index: 100002 !important;
    }
    
    /* Ensure only one close button shows */
    .mobile-menu .mobile-menu-close:first-of-type {
        display: flex !important;
    }
    
    .mobile-menu .mobile-menu-close:not(:first-of-type) {
        display: none !important;
    }
}

/* ========================================
   MAIN CONTENT AREA
   ======================================== */
@media (max-width: 768px) {
    .main-content {
        margin-top: 100px !important; /* Reduced space for header + search bar */
        padding: 1.5rem 1rem !important;
        min-height: calc(100vh - 100px) !important;
    }
    
    .container {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
        max-width: 100% !important;
        width: 100% !important;
    }
    
    .container-fluid {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    /* Fix for search_optimized.php - results section spacing */
    .results-section {
        margin-top: 0 !important; /* Reset desktop margin */
        padding-top: 120px !important; /* Space for header + search bar */
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    /* Fix "searches this week" positioning - ensure it's visible and not blocked */
    .results-section > div[style*="background: #e7f3ff"],
    .results-section > div[style*="Search Usage"] {
        position: relative !important;
        margin-top: 0 !important;
        margin-bottom: 1.5rem !important;
        margin-left: auto !important;
        margin-right: auto !important;
        z-index: 10 !important;
        width: calc(100% - 2rem) !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        padding: 1rem !important;
        font-size: 1rem !important;
    }
    
    .results-section > div[style*="background: #e7f3ff"] strong,
    .results-section > div[style*="background: #e7f3ff"] span {
        font-size: 1rem !important;
    }
    
    /* Fix results header positioning on mobile - make it relative not fixed */
    .results-header {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        right: auto !important;
        margin-top: 0 !important;
        margin-bottom: 1.5rem !important;
        padding: 1rem 0 !important;
        width: 100% !important;
        box-shadow: none !important;
        border-bottom: 1px solid #e5e7eb !important;
    }
    
    /* Fix sort controls positioning - make relative not fixed */
    .sort-controls {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        right: auto !important;
        margin-bottom: 1.5rem !important;
        padding: 1rem 0 !important;
        width: 100% !important;
        box-shadow: none !important;
        border-bottom: 1px solid #e5e7eb !important;
    }
}

@media (max-width: 480px) {
    .main-content {
        margin-top: 90px !important; /* Reduced for smaller screens */
        padding: 1rem 0.75rem !important;
    }
    
    .container {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }
    
    /* Fix for search_optimized.php on small phones */
    .results-section {
        margin-top: 0 !important;
        padding-top: 110px !important;
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }
    
    .results-section > div[style*="background: #e7f3ff"] {
        margin-top: 0 !important;
        padding: 0.875rem !important;
        font-size: 0.95rem !important;
    }
    
    .results-section > div[style*="background: #e7f3ff"] strong,
    .results-section > div[style*="background: #e7f3ff"] span {
        font-size: 0.95rem !important;
    }
    
    .results-section > div[style*="background: #e7f3ff"] i {
        font-size: 1.1rem !important;
    }
}

/* ========================================
   TYPOGRAPHY FOR MOBILE
   ======================================== */
@media (max-width: 768px) {
    h1 {
        font-size: 1.75rem !important;
        line-height: 1.3 !important;
        margin-bottom: 1rem !important;
    }
    
    h2 {
        font-size: 1.5rem !important;
        line-height: 1.35 !important;
        margin-bottom: 0.875rem !important;
    }
    
    h3 {
        font-size: 1.25rem !important;
        line-height: 1.4 !important;
        margin-bottom: 0.75rem !important;
    }
    
    h4 {
        font-size: 1.1rem !important;
        line-height: 1.4 !important;
    }
    
    h5, h6 {
        font-size: 1rem !important;
        line-height: 1.4 !important;
    }
    
    p {
        font-size: 0.95rem !important;
        line-height: 1.6 !important;
        margin-bottom: 1rem !important;
    }
    
    .lead {
        font-size: 1.1rem !important;
        line-height: 1.6 !important;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.5rem !important;
    }
    
    h2 {
        font-size: 1.3rem !important;
    }
    
    h3 {
        font-size: 1.15rem !important;
    }
    
    p {
        font-size: 0.9rem !important;
    }
}

/* ========================================
   CARDS REDESIGN FOR MOBILE
   ======================================== */
@media (max-width: 768px) {
    .card {
        margin-bottom: 1.25rem !important;
        border-radius: 12px !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08) !important;
        border: 1px solid rgba(0, 0, 0, 0.05) !important;
        overflow: hidden !important;
    }
    
    .card-body {
        padding: 1.25rem !important;
    }
    
    .card-title {
        font-size: 1.15rem !important;
        font-weight: 600 !important;
        line-height: 1.4 !important;
        margin-bottom: 0.75rem !important;
    }
    
    .card-text {
        font-size: 0.95rem !important;
        line-height: 1.6 !important;
        color: #4b5563 !important;
    }
    
    .card-header {
        padding: 1rem 1.25rem !important;
        font-size: 1.05rem !important;
        font-weight: 600 !important;
    }
    
    .card-footer {
        padding: 1rem 1.25rem !important;
    }
}

@media (max-width: 480px) {
    .card-body {
        padding: 1rem !important;
    }
    
    .card-title {
        font-size: 1.05rem !important;
    }
    
    .card-text {
        font-size: 0.9rem !important;
    }
}

/* ========================================
   BUTTONS - TOUCH FRIENDLY
   ======================================== */
@media (max-width: 768px) {
    /* EXCLUDE search box button from general button styles */
    .search-box button,
    .search-box .search-btn,
    button.search-btn {
        min-height: auto !important;
        padding: 0 24px !important;
        font-size: 0.95rem !important;
        height: 100% !important;
    }
    
    .btn:not(.search-btn):not(.search-box button) {
        min-height: 44px !important; /* iOS recommended touch target */
        padding: 0.75rem 1.5rem !important;
        font-size: 1rem !important;
        font-weight: 500 !important;
        border-radius: 10px !important;
        transition: all 0.2s ease !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 0.5rem !important;
        cursor: pointer !important;
        border: none !important;
        white-space: nowrap !important;
    }
    
    .btn-sm {
        min-height: 38px !important;
        padding: 0.625rem 1.25rem !important;
        font-size: 0.9rem !important;
    }
    
    .btn-lg {
        min-height: 52px !important;
        padding: 1rem 2rem !important;
        font-size: 1.1rem !important;
    }
    
    .btn:active {
        transform: scale(0.98) !important;
    }
    
    /* Full width buttons on mobile for primary actions */
    .btn-primary,
    .btn-success,
    .btn-danger {
        width: 100% !important;
        max-width: 100% !important;
    }
    
    /* Button groups - prevent overflow */
    .btn-group {
        width: 100% !important;
        max-width: 100% !important;
        display: flex !important;
        flex-wrap: wrap !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
    }
    
    .btn-group .btn {
        flex: 1 1 auto !important;
        min-width: 0 !important;
        max-width: 100% !important;
        white-space: normal !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }
    
    /* Container overflow prevention */
    .container,
    .container-fluid,
    .row,
    .col,
    [class*="col-"] {
        max-width: 100% !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
    }
    
    /* Card body overflow */
    .card-body {
        overflow-x: hidden !important;
        max-width: 100% !important;
    }
}

@media (max-width: 480px) {
    .btn {
        min-height: 42px !important;
        padding: 0.7rem 1.25rem !important;
        font-size: 0.95rem !important;
    }
}

/* ========================================
   FORMS - MOBILE OPTIMIZED
   ======================================== */
@media (max-width: 768px) {
    /* EXCLUDE search box input from general input styles */
    .search-box input,
    .search-box .search-input,
    input.search-input {
        min-height: auto !important;
        padding: 0 18px !important;
        height: 100% !important;
        font-size: 0.95rem !important;
    }
    
    .form-control:not(.search-input),
    .form-select,
    input[type="text"]:not(.search-input):not(.search-box input),
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="search"]:not(.search-input),
    textarea,
    select {
        min-height: 48px !important; /* Touch target */
        padding: 0.875rem 1rem !important;
        font-size: 16px !important; /* Prevents iOS zoom */
        border-radius: 10px !important;
        border: 2px solid #e5e7eb !important;
        width: 100% !important;
        box-sizing: border-box !important;
        transition: border-color 0.2s ease !important;
    }
    
    .form-control:focus,
    .form-select:focus,
    input:focus,
    textarea:focus,
    select:focus {
        border-color: var(--primary, #1e40af) !important;
        outline: none !important;
        box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1) !important;
    }
    
    .form-label {
        font-size: 0.95rem !important;
        font-weight: 500 !important;
        margin-bottom: 0.5rem !important;
        color: #374151 !important;
    }
    
    .form-group {
        margin-bottom: 1.25rem !important;
    }
    
    textarea {
        min-height: 120px !important;
        resize: vertical !important;
    }
}

/* ========================================
   GRID LAYOUTS - MOBILE FIRST
   ======================================== */
@media (max-width: 768px) {
    .row {
        margin-left: -0.5rem !important;
        margin-right: -0.5rem !important;
    }
    
    [class*="col-"],
    [class^="col-"] {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
        margin-bottom: 1rem !important;
    }
    
    /* Force single column on mobile */
    .col-md-6,
    .col-md-4,
    .col-md-3,
    .col-lg-4,
    .col-lg-3,
    .col-lg-6 {
        width: 100% !important;
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }
    
    /* Results grid */
    .results-grid {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
        padding: 0 !important;
    }
    
    /* Listings grid */
    .listings-grid {
        grid-template-columns: 1fr !important;
        gap: 1.25rem !important;
    }
}

/* ========================================
   TABLES - MOBILE FRIENDLY
   ======================================== */
@media (max-width: 768px) {
    .table {
        font-size: 0.875rem !important;
        width: 100% !important;
        display: block !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    .table thead {
        display: none !important;
    }
    
    .table tbody {
        display: block !important;
        width: 100% !important;
    }
    
    .table tr {
        display: block !important;
        margin-bottom: 1rem !important;
        background: white !important;
        border: 1px solid #e5e7eb !important;
        border-radius: 10px !important;
        padding: 1rem !important;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05) !important;
    }
    
    .table td {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding: 0.75rem 0 !important;
        border: none !important;
        border-bottom: 1px solid #f3f4f6 !important;
        text-align: right !important;
    }
    
    .table td:last-child {
        border-bottom: none !important;
    }
    
    .table td::before {
        content: attr(data-label) !important;
        font-weight: 600 !important;
        color: #6b7280 !important;
        text-align: left !important;
        flex: 1 !important;
    }
    
    .table td:last-child::before {
        border-bottom: none !important;
    }
}

/* ========================================
   MODALS - MOBILE OPTIMIZED
   ======================================== */
@media (max-width: 768px) {
    .modal-dialog {
        margin: 0.5rem !important;
        max-width: calc(100% - 1rem) !important;
    }
    
    .modal-content {
        border-radius: 16px !important;
        border: none !important;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2) !important;
    }
    
    .modal-header {
        padding: 1.25rem 1.5rem !important;
        border-bottom: 1px solid #e5e7eb !important;
    }
    
    .modal-body {
        padding: 1.5rem !important;
        max-height: calc(100vh - 200px) !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    .modal-footer {
        padding: 1rem 1.5rem !important;
        border-top: 1px solid #e5e7eb !important;
        flex-direction: column !important;
        gap: 0.75rem !important;
    }
    
    .modal-footer .btn {
        width: 100% !important;
        margin: 0 !important;
    }
}

/* ========================================
   PAGINATION - MOBILE FRIENDLY
   ======================================== */
@media (max-width: 768px) {
    .pagination {
        display: flex !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 0.5rem !important;
        margin: 1.5rem 0 !important;
    }
    
    .pagination .page-link,
    .pagination a,
    .pagination span {
        min-width: 44px !important;
        min-height: 44px !important;
        padding: 0.75rem !important;
        font-size: 0.95rem !important;
        border-radius: 10px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        margin: 0 !important;
    }
}

/* ========================================
   ALERTS AND BADGES
   ======================================== */
@media (max-width: 768px) {
    .alert {
        padding: 1rem 1.25rem !important;
        font-size: 0.95rem !important;
        border-radius: 10px !important;
        margin-bottom: 1rem !important;
    }
    
    .badge {
        font-size: 0.8rem !important;
        padding: 0.375rem 0.625rem !important;
        border-radius: 6px !important;
    }
}

/* ========================================
   NAVIGATION BADGES
   ======================================== */
@media (max-width: 768px) {
    .nav-badge {
        min-width: 20px !important;
        height: 20px !important;
        font-size: 0.7rem !important;
        padding: 0 !important;
    }
}

/* ========================================
   MARKETPLACE SPECIFIC
   ======================================== */
@media (max-width: 768px) {
    .marketplace-badge {
        font-size: 0.75rem !important;
        padding: 0.25rem 0.5rem !important;
        border-radius: 8px !important;
    }
    
    .listing-card {
        border-radius: 12px !important;
    }
    
    .listing-image {
        height: 250px !important;
    }
    
    .listing-info {
        padding: 1rem !important;
    }
    
    .message-bubble {
        max-width: 85% !important;
        padding: 0.875rem 1rem !important;
        font-size: 0.9rem !important;
    }
}

/* ========================================
   SEARCH RESULTS
   ======================================== */
@media (max-width: 768px) {
    .result-card {
        padding: 1rem !important;
        margin-bottom: 1rem !important;
        border-radius: 12px !important;
    }
    
    .whisky-name {
        font-size: 1.25rem !important;
        line-height: 1.4 !important;
    }
    
    .result-body {
        flex-direction: column !important;
        gap: 1rem !important;
    }
    
    .whisky-image img {
        max-width: 100% !important;
        width: 100% !important;
        height: auto !important;
    }
}

/* ========================================
   FILTERS AND SIDEBARS
   ======================================== */
@media (max-width: 768px) {
    .filter-section {
        padding: 1rem !important;
        margin-bottom: 1.5rem !important;
        background: white !important;
        border-radius: 12px !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08) !important;
    }
    
    .filter-section .form-control,
    .filter-section .form-select {
        margin-bottom: 1rem !important;
    }
    
    .filter-section .btn {
        width: 100% !important;
    }
}

/* ========================================
   HERO SECTIONS
   ======================================== */
@media (max-width: 768px) {
    .hero-section {
        padding: 2rem 1.25rem !important;
        margin: 1.5rem 0 !important;
        border-radius: 16px !important;
    }
    
    .hero-section h1 {
        font-size: 1.75rem !important;
    }
    
    .hero-section p {
        font-size: 1rem !important;
    }
}

/* ========================================
   UTILITY CLASSES FOR MOBILE
   ======================================== */
@media (max-width: 768px) {
    .d-mobile-none {
        display: none !important;
    }
    
    .d-mobile-block {
        display: block !important;
    }
    
    .d-mobile-flex {
        display: flex !important;
    }
    
    .text-mobile-center {
        text-align: center !important;
    }
    
    .mb-mobile-2 {
        margin-bottom: 1rem !important;
    }
    
    .mt-mobile-2 {
        margin-top: 1rem !important;
    }
}

/* ========================================
   BACK TO TOP BUTTON
   ======================================== */
@media (max-width: 768px) {
    #backToTop,
    .back-to-top {
        width: 48px !important;
        height: 48px !important;
        bottom: 1.5rem !important;
        right: 1rem !important;
        font-size: 1.25rem !important;
        border-radius: 50% !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2) !important;
    }
}

/* ========================================
   IMAGES AND MEDIA
   ======================================== */
@media (max-width: 768px) {
    img {
        max-width: 100% !important;
        height: auto !important;
    }
    
    .whisky-image,
    .listing-image {
        width: 100% !important;
        max-width: 100% !important;
    }
}

/* ========================================
   CHARTS AND GRAPHS
   ======================================== */
@media (max-width: 768px) {
    .chart-container {
        height: 250px !important;
        margin-bottom: 1.5rem !important;
    }
    
    .chart-container canvas {
        max-width: 100% !important;
        height: auto !important;
    }
}

/* ========================================
   SPACING ADJUSTMENTS
   ======================================== */
@media (max-width: 768px) {
    .mb-4 {
        margin-bottom: 1.5rem !important;
    }
    
    .mb-3 {
        margin-bottom: 1.25rem !important;
    }
    
    .mt-4 {
        margin-top: 1.5rem !important;
    }
    
    .mt-3 {
        margin-top: 1.25rem !important;
    }
    
    .py-4 {
        padding-top: 1.5rem !important;
        padding-bottom: 1.5rem !important;
    }
    
    .px-3 {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
}

/* ========================================
   FIXES FOR COMMON ISSUES
   ======================================== */
@media (max-width: 768px) {
    /* Prevent text overflow */
    * {
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }
    
    /* Better scrolling */
    * {
        -webkit-overflow-scrolling: touch !important;
    }
    
    /* Remove fixed widths that break mobile */
    [style*="width"] {
        max-width: 100% !important;
    }
    
    /* Make "Login to view" message more prominent on mobile */
    .whisky-price .blurred-value + div,
    .whisky-price div[style*="font-size: 0.75rem"] {
        display: block !important;
        margin-top: 0.5rem !important;
        padding: 0.5rem !important;
        background: #fef3c7 !important;
        border-radius: 6px !important;
        text-align: center !important;
    }
    
    .whisky-price .blurred-value + div a,
    .whisky-price div[style*="font-size: 0.75rem"] a {
        color: #92400e !important;
        font-weight: 600 !important;
        font-size: 0.875rem !important;
        text-decoration: underline !important;
    }
    
    /* Add message for sections that require login - more visible */
    .whisky-card:has(.blurred-value) {
        position: relative !important;
    }
    
    .whisky-card:has(.blurred-value)::before {
        content: "🔒 Not logged in - Login to view prices" !important;
        display: block !important;
        background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%) !important;
        color: #92400e !important;
        padding: 0.75rem !important;
        border-radius: 8px !important;
        font-size: 0.9rem !important;
        margin-bottom: 1rem !important;
        text-align: center !important;
        font-weight: 600 !important;
        border: 2px solid #fbbf24 !important;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1) !important;
    }
}

