/* ================================================================
   1. DESKTOP & IPAD DEFAULT (Greater than 768px)
   ================================================================ */
  /* ================================================================
   1. TABLET & MOBILE VIEW (768px and Below)
   ================================================================ */
  @media screen and (max-width: 768px) {

    /* FIX: Ensure Header stays visible with background */
    .site-header {
      background: #fff !important;
      border-bottom: 1px solid var(--border);
      position: fixed;
      top: 0;
      width: 100%;
      z-index: 1000;
    }

    /* FIX: Hide 'Create Hub' button on mobile */
    .btn-primary-header {
      display: none !important;
    }

    /* FIX: Reduce excessive padding in main content */
    .main-content {
      padding: 15px !important;
      /* Reduced from 2rem */
      margin-top: 70px !important;
      /* Push content below fixed header */
      background: #fafafa;
      /* Restore background color */
      min-height: 100vh;
    }

    .content-card {
      padding: 10px;
    }

    /* NAVIGATION: Hamburger & Sidebar drawer */
    #navToggle {
      display: block !important;
      z-index: 2001;
    }

    .sidebar {
      position: fixed !important;
      left: -320px;
      width: 300px;
      height: 100vh;
      background: #fff !important;
      /* Restore Sidebar background */
      z-index: 2000 !important;
      transition: left 0.3s ease-in-out;
      box-shadow: 2px 0 15px rgba(0, 0, 0, 0.1);
      padding-top: 20px;
    }

    .sidebar.is-open {
      left: 0 !important;
    }

    /* GRID: Adjust Hub Cards for smaller screens */
    .community-grid {
      grid-template-columns: 1fr !important;
      gap: 12px !important;
      padding: 5px 0;
    }

    /* FORMS: Compact form for mobile */
    .submission-container {
      width: 100% !important;
      margin: 0 !important;
      padding: 15px !important;
      border-radius: 0;
      box-shadow: none;
    }

    .community-switcher {
      display: none;
    }

    .mobile-menu-toggle {
      display: flex !important;
      /* Force show */
      align-items: center;
      justify-content: center;
      background: var(--primary-light);
      /* Light purple tint */
      color: var(--primary);
      border: none;
      width: 42px;
      height: 42px;
      border-radius: 8px;
      cursor: pointer;
      transition: all 0.2s ease;
      margin-right: 10px;
      /* Space between button and logo */
    }

    .mobile-menu-toggle:active {
      transform: scale(0.9);
      /* Visual feedback when tapped */
      background: var(--primary-glow);
    }

    .mobile-menu-toggle i {
      font-size: 1.25rem;
    }

    .header-container {
      display: flex;
      align-items: center;
      padding: 0 15px;
      height: 60px;
      background: #fff;
      /* Restore background */
      border-bottom: 1px solid var(--border);
    }

    /* Ensure the logo doesn't shrink too much */
    .logo {
      font-size: 1.1rem !important;
      white-space: nowrap;
      font-size: 1.1rem !important;
      white-space: nowrap;
    }

    /* 1. Force the grid into a single column */
    .ad-detail-grid {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
        padding: 10px !important;
    }

    /* 3. Re-adjust the Hero Image for mobile aspect ratios */
    .main-image-container {
        height: 300px !important;
        border-radius: 12px !important;
        background: #f8f9fa !important;
    }

    /* 4. Fix the Price/Info Card */
    .ad-info-column > div {
        padding: 20px !important;
        margin-top: 10px;
        box-shadow: none !important;
        border: 1px solid #eee !important;
    }

    /* 5. Header adjustments: Stack title and back button if needed */
    .ad-detail-header {
        flex-direction: column-reverse !important;
        align-items: flex-start !important;
        gap: 15px !important;
    }

    .ad-detail-header h2 {
        font-size: 1.5rem !important;
    }

    /* 6. Make thumbnails scrollable horizontally instead of wrapping */
    .thumbnail-grid {
        display: flex !important;
        overflow-x: auto !important;
        gap: 10px !important;
        padding-bottom: 10px !important;
    }

    .thumb {
        flex: 0 0 80px !important;
        height: 80px !important;
    }
  }

  /* ================================================================
   2. IPHONE OPTIMIZATION (480px and Below)
   ================================================================ */
  @media screen and (max-width: 480px) {
    .sidebar {
      width: 280px !important;
      left: -280px;
    }

    .content-card {
      padding: 10px;
    }

    /* Fix stats bar overlapping on tiny screens */
    .stats-bar {
      flex-direction: column;
      gap: 5px;
      padding: 10px;
      background: var(--primary-light);
      border-radius: 8px;
    }

    /* Shrink Header Logo to save space */
    .logo {
      font-size: 1.1rem !important;
    }

    .community-switcher {
      display: none;
    }

    .price-tag, .ad-info-column div[style*="font-size: 2.2rem"] {
        font-size: 1.8rem !important;
    }

    .btn-sync {
        width: 100% !important; /* Full width back button on very small screens */
        justify-content: center !important;
    }
  }