/*
 * JoDeals - Mobile Optimization Stylesheet
 * Covers: Responsive layouts, touch targets, animations, typography, 
 *         skeleton loading, bottom nav, smooth transitions, and RTL support.
 */

/* ============================================================
   SECTION 1: GLOBAL MOBILE RESETS & FOUNDATIONS
   ============================================================ */

/* Prevent horizontal scroll on all devices */
html,
body {
  overflow-x: hidden;
  max-width: 100%;
  box-sizing: border-box;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Remove iOS tap highlight flash */
* {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

/* Allow text selection where needed */
p, h1, h2, h3, h4, h5, h6, span, a, input, textarea {
  -webkit-touch-callout: default;
  -webkit-user-select: text;
  user-select: text;
}

/* Smooth scrolling enhancement */
html {
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* Better touch action on interactive elements */
a, button, [role="button"], input[type="submit"], input[type="button"] {
  touch-action: manipulation;
  cursor: pointer;
}

/* Minimum touch target size (WCAG AA) */
button,
a,
input[type="checkbox"],
input[type="radio"],
select,
[role="button"] {
  min-height: 44px;
  min-width: 44px;
}

/* Exception for inline links that should not enforce min-height */
p a, li a, span a, .text-link {
  min-height: unset;
  min-width: unset;
}

/* ============================================================
   SECTION 2: TYPOGRAPHY — MOBILE SCALE
   ============================================================ */
@media (max-width: 640px) {
  body {
    font-size: 14px;
    line-height: 1.6;
  }

  h1 { font-size: 1.75rem; line-height: 1.2; }
  h2 { font-size: 1.35rem; line-height: 1.25; }
  h3 { font-size: 1.1rem;  line-height: 1.3; }
  h4 { font-size: 0.95rem; line-height: 1.35; }

  /* Prevent iOS auto-zoom on input focus (must be ≥ 16px) */
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="password"],
  input[type="search"],
  input[type="number"],
  textarea,
  select {
    font-size: 16px !important;
  }

  /* Better paragraph spacing */
  p {
    line-height: 1.65;
  }
}

/* ============================================================
   SECTION 3: STICKY HEADER — SCROLL-AWARE
   ============================================================ */

#main-header {
  transition: box-shadow 0.3s ease, background-color 0.3s ease, backdrop-filter 0.3s ease;
  will-change: box-shadow;
}

#main-header.header-scrolled {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08), 0 1px 4px rgba(0, 0, 0, 0.04);
  background-color: rgba(255, 255, 255, 0.98) !important;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.dark #main-header.header-scrolled {
  background-color: rgba(15, 23, 42, 0.98) !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* ============================================================
   SECTION 4: MOBILE HAMBURGER MENU — ANIMATED
   ============================================================ */

/* Replace instant show/hide with smooth animation */
#mobile-menu {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s cubic-bezier(0.16, 1, 0.3, 1),
              opacity 0.3s ease;
  opacity: 0;
  display: block !important; /* override Tailwind hidden */
  visibility: hidden;
}

#mobile-menu.menu-open {
  max-height: 85vh;
  opacity: 1;
  visibility: visible;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Hamburger icon smooth rotation */
#mobile-menu-icon {
  transition: transform 0.3s ease;
}

/* Body scroll lock when menu is open */
body.menu-open-lock {
  overflow: hidden;
  position: fixed;
  width: 100%;
}

@media (min-width: 768px) {
  /* Keep mobile drawer fully hidden on desktop — do not let animation resets expose it */
  #mobile-menu {
    display: none !important;
    max-height: 0;
    opacity: 0;
    visibility: hidden;
    overflow: hidden;
  }
}

/* Mobile menu items — better spacing & touch targets */
@media (max-width: 767px) {
  #mobile-menu a,
  #mobile-menu button {
    min-height: 48px;
    display: flex;
    align-items: center;
  }

  #mobile-menu .grid a {
    min-height: 48px;
    padding: 0.65rem 0.75rem;
  }
}

/* ============================================================
   SECTION 5: HERO BANNER — MOBILE HEIGHTS & TYPOGRAPHY
   ============================================================ */

@media (max-width: 640px) {
  /* Hero banner height on small phones */
  .hero-banner-container {
    height: 200px !important;
  }

  /* Text scaling inside slides */
  .hero-slide-heading {
    font-size: 1.25rem !important;
    line-height: 1.3 !important;
  }

  .hero-slide-sub {
    font-size: 0.75rem !important;
  }

  .hero-slide-cta {
    padding: 0.5rem 1rem !important;
    font-size: 0.75rem !important;
  }

  /* Slider dots — larger touch targets */
  #hero-slider-dots span {
    width: 10px !important;
    height: 10px !important;
    cursor: pointer;
    transition: transform 0.2s ease;
  }

  #hero-slider-dots span:active {
    transform: scale(1.3);
  }

  /* Hero merchant banner image overlay on small screens */
  .hero-slide-img-overlay {
    opacity: 0.25 !important;
  }

  /* Reduce hero section side margin */
  section.hero-section {
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
  }
}

@media (min-width: 641px) and (max-width: 1023px) {
  /* Tablets */
  .hero-banner-container {
    height: 260px !important;
  }
}

/* ============================================================
   SECTION 6: FLOATING SEARCH FORM — MOBILE
   ============================================================ */

@media (max-width: 640px) {
  /* Remove negative margin top overlap on very small screens */
  .hero-search-float {
    margin-top: 0.5rem !important;
    border-radius: 1.5rem !important;
    padding: 1rem !important;
  }

  /* Stack all filter elements vertically */
  .hero-search-float form {
    flex-direction: column !important;
    gap: 0.75rem !important;
  }

  /* Full-width inputs */
  .hero-search-float input,
  .hero-search-float select,
  .hero-search-float button {
    width: 100% !important;
    flex: none !important;
    min-width: unset !important;
    max-width: 100% !important;
  }

  /* Geolocation button — full width on mobile */
  #near-me-btn {
    width: 100%;
    justify-content: center;
  }
}

/* ============================================================
   SECTION 7: DEAL CARDS — MOBILE UX
   ============================================================ */

@media (max-width: 640px) {
  /* Single column grid enforced */
  .dining-deals-slider-grid {
    grid-template-columns: 1fr !important;
    gap: 1.25rem !important;
  }

  /* Deal card image: slightly taller on mobile for visual impact */
  .deal-card .zoom-image-container {
    aspect-ratio: 16 / 10 !important;
    max-height: 240px;
  }

  /* Larger, more tappable CTA button */
  .deal-card a.block,
  .deal-card .cta-row a {
    min-height: 48px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 0.9rem !important;
    padding: 0.85rem 1.25rem !important;
    border-radius: 14px !important;
  }

  /* Bigger discount badge on mobile */
  .deal-card .floating-discount {
    font-size: 0.75rem !important;
    padding: 0.45rem 0.85rem !important;
    border-radius: 10px !important;
  }

  /* Larger fav button for touch */
  .deal-card .floating-fav-btn {
    width: 2.75rem !important;
    height: 2.75rem !important;
    border-radius: 12px !important;
  }

  /* Card body padding */
  .deal-card > div:not(.zoom-image-container) {
    padding: 1.15rem 1.15rem !important;
    gap: 0.6rem !important;
  }

  /* Deal title: slightly smaller on phones but still readable */
  .deal-card h3 {
    font-size: 0.925rem !important;
    line-height: 1.35rem !important;
  }
}

/* Tap active state for deal cards (only active when not swiping) */
.deal-card:not(.swiping):not(.swiped-right):not(.swiped-left):active {
  transform: scale(0.985) !important;
  transition: transform 0.15s ease !important;
}

/* ============================================================
   SECTION 8: CATEGORIES GRID — MOBILE IMPROVEMENTS
   ============================================================ */

/* Visual category cards: 2 columns on very small phones */
@media (max-width: 374px) {
  .category-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.65rem !important;
  }

  .category-card {
    padding: 0.85rem 0.5rem 0.75rem !important;
    border-radius: 14px !important;
  }

  .category-card-icon-box {
    width: 2.85rem !important;
    height: 2.85rem !important;
    font-size: 1.15rem !important;
  }

  .category-card-label {
    font-size: 0.65rem !important;
  }
}

/* Normal phone: 3 columns */
@media (min-width: 375px) and (max-width: 479px) {
  .category-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 0.75rem !important;
  }

  .category-card {
    padding: 1rem 0.5rem 0.85rem !important;
    border-radius: 16px !important;
  }

  .category-card-icon-box {
    width: 3.1rem !important;
    height: 3.1rem !important;
    font-size: 1.25rem !important;
  }
}

/* Section spacing: reduce excessive top padding on mobile */
@media (max-width: 640px) {
  #categories-section,
  #trending-deals-section,
  #today-deals-section,
  #ending-soon-section,
  #big-discounts-section,
  #featured-deals-section,
  #all-dining-deals-section {
    padding-top: 2.5rem !important;
  }

  /* Section header icon */
  #categories-section .w-10,
  #trending-deals-section .w-10,
  #today-deals-section .w-10 {
    width: 2rem !important;
    height: 2rem !important;
    font-size: 0.85rem !important;
  }

  /* Section heading */
  #categories-section h2,
  #trending-deals-section h2,
  #today-deals-section h2,
  #ending-soon-section h2,
  #big-discounts-section h2 {
    font-size: 1.25rem !important;
  }

  /* Back button in category grid */
  #cat-back-btn {
    font-size: 0.7rem !important;
    padding: 0.4rem 0.75rem !important;
  }

  /* Default homepage sections spacing */
  #default-homepage-sections {
    padding-top: 1.5rem !important;
    gap: 3rem !important;
  }
}

/* ============================================================
   SECTION 9: BOTTOM NAVIGATION BAR (MOBILE ONLY) — PREMIUM
   ============================================================ */

#mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9900;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-top: 1px solid rgba(226, 232, 240, 0.8);
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.07), 0 -2px 8px rgba(0, 0, 0, 0.04);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0.25rem 0.5rem;
  padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
  height: calc(62px + max(0px, env(safe-area-inset-bottom)));
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform;
}

#mobile-bottom-nav.nav-hidden {
  transform: translateY(110%);
}

.dark #mobile-bottom-nav {
  background: rgba(10, 16, 30, 0.98);
  border-color: rgba(255, 255, 255, 0.06);
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.45), 0 -2px 8px rgba(0, 0, 0, 0.25);
}

/* ---- Nav Item Base ---- */
.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 0.15rem;
  height: 100%;
  padding: 0.3rem 0.25rem;
  text-decoration: none;
  color: #94a3b8;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  border: none;
  background: none;
  cursor: pointer;
  position: relative;
  border-radius: 16px;
  transition: color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.bottom-nav-item i {
  font-size: 1.2rem;
  line-height: 1;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), color 0.2s ease;
  position: relative;
  z-index: 1;
}

.bottom-nav-item span {
  position: relative;
  z-index: 1;
  transition: color 0.2s ease;
}

/* Tap animation */
.bottom-nav-item:active {
  transform: scale(0.90);
  transition: transform 0.1s ease;
}

/* ---- Active State: Pill Highlight (Talabat/Careem style) ---- */
.bottom-nav-item.active {
  color: #ff4d4d;
}

.bottom-nav-item.active i {
  transform: scale(1.1);
  color: #ff4d4d;
}

/* Active pill background indicator */
.bottom-nav-item.active::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 48px;
  height: 38px;
  background: rgba(255, 77, 77, 0.09);
  border-radius: 12px;
  z-index: 0;
  animation: nav-pill-pop 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.dark .bottom-nav-item.active::after {
  background: rgba(255, 77, 77, 0.14);
}

@keyframes nav-pill-pop {
  from { transform: translate(-50%, -50%) scale(0.7); opacity: 0; }
  to   { transform: translate(-50%, -50%) scale(1);   opacity: 1; }
}

/* ---- Center Deal Button (Special CTA) ---- */
.bottom-nav-item.bnav-deals-cta {
  flex: 0 0 auto;
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff4d4d 0%, #ff9f0a 100%);
  color: #ffffff !important;
  box-shadow: 0 4px 18px rgba(255, 77, 77, 0.38);
  margin-top: -18px;
  padding: 0;
  border: 3px solid rgba(255, 255, 255, 0.9);
  gap: 0;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.2s ease;
}

.dark .bottom-nav-item.bnav-deals-cta {
  border-color: rgba(10, 16, 30, 0.95);
}

.bottom-nav-item.bnav-deals-cta i {
  font-size: 1.1rem;
  color: #ffffff !important;
  transform: none !important;
}

.bottom-nav-item.bnav-deals-cta span {
  display: none; /* icon-only CTA */
}

.bottom-nav-item.bnav-deals-cta:active {
  transform: scale(0.88);
  box-shadow: 0 2px 10px rgba(255, 77, 77, 0.28);
}

.bottom-nav-item.bnav-deals-cta::after {
  display: none; /* no pill on the circle CTA */
}

/* ---- Favorites / Saved badge ---- */
.bottom-nav-fav-badge {
  position: absolute;
  top: 4px;
  right: calc(50% - 1.1rem);
  min-width: 15px;
  height: 15px;
  padding: 0 3px;
  background: #ff4d4d;
  color: white;
  font-size: 0.5rem;
  font-weight: 900;
  font-family: monospace;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid white;
  box-shadow: 0 2px 5px rgba(255, 77, 77, 0.35);
  z-index: 10;
}

.dark .bottom-nav-fav-badge {
  border-color: rgba(10, 16, 30, 0.95);
}

/* ---- Body padding to avoid nav overlap ---- */
@media (max-width: 767px) {
  body.has-bottom-nav {
    padding-bottom: calc(68px + max(0px, env(safe-area-inset-bottom))) !important;
  }
}

/* ---- Hide on desktop ---- */
@media (min-width: 768px) {
  #mobile-bottom-nav {
    display: none !important;
  }
}

/* ============================================================
   SECTION 10: SKELETON LOADING ANIMATION
   ============================================================ */

@keyframes skeleton-shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton-shimmer {
  background: linear-gradient(
    90deg,
    #f1f5f9 25%,
    #e2e8f0 50%,
    #f1f5f9 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.6s infinite ease-in-out;
  border-radius: 8px;
}

.dark .skeleton-shimmer {
  background: linear-gradient(
    90deg,
    #1e293b 25%,
    #273248 50%,
    #1e293b 75%
  );
  background-size: 200% 100%;
}

/* Skeleton deal card */
.skeleton-deal-card {
  background: white;
  border-radius: 20px;
  border: 1px solid #f1f5f9;
  overflow: hidden;
  box-shadow: 0 4px 15px -3px rgba(0, 0, 0, 0.03);
}

.dark .skeleton-deal-card {
  background: #1e293b;
  border-color: rgba(255, 255, 255, 0.04);
}

.skeleton-img {
  width: 100%;
  aspect-ratio: 16 / 9;
  min-height: 140px;
}

.skeleton-line {
  height: 12px;
  border-radius: 6px;
  margin-bottom: 0.5rem;
}

.skeleton-line.wide  { width: 90%; }
.skeleton-line.mid   { width: 65%; }
.skeleton-line.short { width: 40%; }

.skeleton-btn {
  height: 40px;
  border-radius: 12px;
  width: 100%;
  margin-top: 0.75rem;
}

/* ============================================================
   SECTION 11: PAGE TRANSITION (FADE)
   ============================================================ */

body {
  opacity: 1;
  transition: opacity 0.2s ease;
}

body.page-exit {
  opacity: 0;
}

/* ============================================================
   SECTION 12: SMOOTH SCROLL PROGRESS BAR
   ============================================================ */

#scroll-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, #ff4d4d 0%, #ff9f0a 100%);
  z-index: 9999;
  width: 0%;
  transition: width 0.1s linear;
  border-radius: 0 2px 2px 0;
  box-shadow: 0 0 8px rgba(255, 77, 77, 0.4);
}

/* ============================================================
   SECTION 13: FOOTER — MOBILE IMPROVEMENTS
   ============================================================ */

@media (max-width: 640px) {
  footer {
    padding-top: 2.5rem !important;
    padding-bottom: 2rem !important;
  }

  /* Footer grid: single column on mobile */
  footer .grid {
    grid-template-columns: 1fr !important;
    gap: 1.75rem !important;
    padding-bottom: 2rem !important;
  }

  /* Social icons: ensure 44×44 touch targets */
  footer .flex a[aria-label] {
    width: 44px !important;
    height: 44px !important;
  }

  /* Footer links: 44px min height */
  footer ul li a {
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: 0.25rem 0;
  }

  /* Bottom bar stack */
  footer > div > div:last-child {
    flex-direction: column !important;
    text-align: center;
    gap: 0.75rem !important;
  }
}

@media (min-width: 641px) and (max-width: 1023px) {
  /* Tablet: 2-column footer */
  footer .grid.lg\\:grid-cols-6 {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* ============================================================
   SECTION 14: FORMS — MOBILE OPTIMIZATION
   ============================================================ */

@media (max-width: 640px) {
  /* Input sizing */
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="password"],
  input[type="search"],
  textarea,
  select {
    width: 100%;
    border-radius: 0.875rem !important;
    padding: 0.875rem 1rem !important;
    min-height: 48px;
  }

  /* Select appearance fix for mobile */
  select {
    -webkit-appearance: none;
    appearance: none;
  }

  /* Form validation error messages */
  .form-error {
    font-size: 0.8rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.75rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
    margin-top: 0.35rem;
  }

  /* Contact / support forms */
  .contact-form .form-group {
    margin-bottom: 1rem;
  }

  .contact-form button[type="submit"] {
    width: 100%;
    min-height: 52px;
    font-size: 1rem;
    border-radius: 1rem;
  }
}

/* ============================================================
   SECTION 15: BUTTONS — TOUCH OPTIMIZATION
   ============================================================ */

/* Active tap animation on all buttons */
button:active,
a.btn:active,
[role="button"]:active {
  transform: scale(0.96);
  transition: transform 0.1s ease;
}

/* Floating action buttons (FAB) — better mobile sizing */
@media (max-width: 640px) {
  .floating-discount,
  .floating-fav-btn,
  .floating-countdown {
    /* slightly larger on phones for readability */
    font-size: 0.7rem !important;
  }

  /* Mega menu drawer full-width on phones */
  .mega-menu-drawer {
    max-width: 100% !important;
    width: 100% !important;
  }
}

/* ============================================================
   SECTION 16: CARD HOVER → TOUCH ACTIVE STATE
   ============================================================ */

/* On touch devices, transform hover to active (press) state */
@media (hover: none) {
  .deal-card:active {
    transform: translateY(-2px) scale(0.99) !important;
    box-shadow: 0 8px 20px -5px rgba(0, 0, 0, 0.06) !important;
    transition: all 0.15s ease !important;
  }

  .cat-circle-card:active .icon-box {
    background: #ff4d4d;
    color: white;
    transform: scale(1.06);
  }

  .subcategory-bubble-card:active .icon-box {
    background: #f8fafc;
    color: #ff4d4d;
    border-color: rgba(255, 77, 77, 0.25);
    transform: scale(1.04);
  }

  /* Disable hover-only slider arrows on touch */
  .slider-btn,
  .sub-nav-btn,
  .cat-slider-btn {
    display: none !important;
  }
}

/* ============================================================
   SECTION 17: SCROLLBAR — MOBILE CLEAN
   ============================================================ */

/* Hide scrollbars on mobile for sliders */
@media (max-width: 767px) {
  .slider-container,
  .subcategory-scroll-container,
  .partner-logo-container,
  .category-slider-container {
    scrollbar-width: none !important;
    -ms-overflow-style: none;
  }

  .slider-container::-webkit-scrollbar,
  .subcategory-scroll-container::-webkit-scrollbar,
  .partner-logo-container::-webkit-scrollbar,
  .category-slider-container::-webkit-scrollbar {
    display: none !important;
  }
}

/* Global thin scrollbar on mobile */
@media (max-width: 767px) {
  ::-webkit-scrollbar {
    width: 4px;
    height: 4px;
  }
}

/* ============================================================
   SECTION 18: MODAL & DRAWER IMPROVEMENTS (MOBILE)
   ============================================================ */

/* Favorites drawer full-screen on mobile */
@media (max-width: 640px) {
  #favorites-drawer > div {
    max-width: 100% !important;
    width: 100% !important;
  }
}

/* Drawer backdrop on mobile - darker for better focus */
@media (max-width: 767px) {
  #favorites-drawer-overlay,
  #mega-menu-overlay {
    background: rgba(0, 0, 0, 0.55) !important;
  }
}

/* ============================================================
   SECTION 19: CARDS IN SLIDER — MOBILE
   ============================================================ */

@media (max-width: 640px) {
  /* Slider cards: full width on mobile */
  .slider-card {
    flex: 0 0 calc(100% - 1rem) !important;
    min-width: 260px;
  }

  /* Trending section: 1 visible card + peek */
  .slider-card.deal-card {
    flex: 0 0 85vw !important;
    min-width: 260px !important;
    max-width: 340px !important;
  }
}

@media (min-width: 641px) and (max-width: 1023px) {
  /* Tablets: 2 cards visible */
  .slider-card {
    flex: 0 0 calc(50% - 0.75rem);
  }
}

/* ============================================================
   SECTION 20: STATISTICS / COUNTER SECTION
   ============================================================ */

@media (max-width: 640px) {
  /* Counter cards: 2 per row on mobile */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.75rem !important;
  }

  .stat-counter {
    font-size: 1.5rem !important;
  }
}

/* ============================================================
   SECTION 21: CITY CARDS — MOBILE
   ============================================================ */

@media (max-width: 640px) {
  .city-card-bg {
    height: 130px !important;
    border-radius: 16px !important;
  }
}

/* ============================================================
   SECTION 22: PARTNER LOGOS SECTION
   ============================================================ */

@media (max-width: 640px) {
  .partner-logo-card {
    flex: 0 0 110px !important;
    height: 58px !important;
  }
}

/* ============================================================
   SECTION 23: BECOME A PARTNER PAGE — MOBILE
   ============================================================ */

@media (max-width: 640px) {
  .partner-plans-grid {
    grid-template-columns: 1fr !important;
    gap: 1.25rem;
  }

  .partner-hero-section {
    padding: 2rem 1rem !important;
    text-align: center;
  }
}

/* ============================================================
   SECTION 24: SEARCH PAGE — MOBILE
   ============================================================ */

@media (max-width: 640px) {
  .search-filters-panel {
    position: sticky;
    top: 64px;
    z-index: 20;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    margin: 0 -1rem;
  }
}

/* ============================================================
   SECTION 25: DEAL DETAIL PAGE — MOBILE
   ============================================================ */

@media (max-width: 640px) {
  .deal-detail-hero {
    height: 240px !important;
    border-radius: 0 !important;
  }

  .deal-detail-content {
    padding: 1rem !important;
  }

  .deal-cta-sticky {
    position: sticky;
    bottom: 0;
    background: white;
    padding: 0.75rem 1rem;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
    z-index: 30;
    margin: 0 -1rem;
    width: calc(100% + 2rem);
  }
}

/* ============================================================
   SECTION 26: CATEGORIES PAGE — MOBILE
   ============================================================ */

@media (max-width: 640px) {
  /* Sticky categories sub-navbar: offset for bottom nav */
  .sticky-categories-bar {
    top: 60px !important;
  }

  /* Category pill: larger touch targets */
  .subcategory-pill {
    padding: 0.6rem 1rem !important;
    font-size: 0.8rem !important;
    min-height: 40px;
  }

  /* Parent category cards slider on categories page */
  .parent-category-card {
    height: 110px !important;
    padding: 1rem !important;
  }

  .parent-category-card .card-icon-wrapper {
    width: 40px !important;
    height: 40px !important;
    font-size: 1.1rem !important;
  }
}

/* ============================================================
   SECTION 27: RTL (ARABIC) MOBILE FIXES
   ============================================================ */

html[dir="rtl"] #mobile-bottom-nav {
  /* RTL: keep natural flex order; items are symmetric */
}

html[dir="rtl"] .bottom-nav-item.active::after {
  /* Pill indicator stays centered in RTL too */
  left: 50%;
  right: auto;
}

html[dir="rtl"] .bottom-nav-fav-badge {
  right: auto;
  left: calc(50% - 1.1rem);
}

/* Arabic text: tighter leading for display headings */
html[dir="rtl"] h1,
html[dir="rtl"] h2,
html[dir="rtl"] h3 {
  letter-spacing: 0 !important;
  word-spacing: 0.05em;
}

/* RTL mobile menu alignment */
html[dir="rtl"] #mobile-menu .grid a {
  flex-direction: row-reverse;
}

/* ============================================================
   SECTION 28: SAFE AREA INSETS (iPhone X+ / Notch)
   ============================================================ */

/* Respect safe areas */
header {
  padding-top: env(safe-area-inset-top, 0);
}

/* Ensure hero section doesn't overlap notch area */
@supports (padding-top: env(safe-area-inset-top)) {
  header {
    padding-top: env(safe-area-inset-top);
  }

  /* Only apply safe-area overrides on mobile — prevents fighting the desktop display:none rule */
  @media (max-width: 767px) {
    #mobile-bottom-nav {
      padding-bottom: env(safe-area-inset-bottom);
      height: calc(64px + env(safe-area-inset-bottom));
    }
  }
}

/* ============================================================
   SECTION 29: LOADING STATES
   ============================================================ */

/* Full-page loading overlay */
#page-loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 9998;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  transition: opacity 0.3s ease;
}

#page-loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(255, 77, 77, 0.15);
  border-top-color: #ff4d4d;
  border-radius: 50%;
  animation: spin-smooth 0.8s linear infinite;
}

@keyframes spin-smooth {
  to { transform: rotate(360deg); }
}

/* ============================================================
   SECTION 30: CROSS-BROWSER COMPATIBILITY FIXES
   ============================================================ */

/* Samsung Internet: flex gap fix */
@supports not (gap: 1rem) {
  .slider-container > * + * {
    margin-left: 1.5rem;
  }

  .subcategory-scroll-container > * + * {
    margin-left: 1.5rem;
  }

  html[dir="rtl"] .slider-container > * + * {
    margin-left: 0;
    margin-right: 1.5rem;
  }
}

/* Firefox mobile: scrollbar width */
@-moz-document url-prefix() {
  .slider-container,
  .subcategory-scroll-container {
    scrollbar-width: none;
  }
}

/* iOS Safari: button appearance reset */
button {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

/* iOS Safari: input appearance reset */
input, textarea, select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

/* iOS momentum scrolling */
.overflow-x-auto,
.overflow-y-auto,
[class*="overflow-"] {
  -webkit-overflow-scrolling: touch;
}

/* Prevent text size adjustment on orientation change */
body {
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* ============================================================
   SECTION 31: NEW HERO SECTION — MOBILE OVERRIDES
   ============================================================ */

/* ── Hero headline: prevent overflow on tiny screens ── */
@media (max-width: 480px) {
  .hero-headline {
    font-size: clamp(1.75rem, 8.5vw, 2.4rem) !important;
    letter-spacing: -0.01em !important;
  }

  /* Reduce vertical padding so hero doesn't take the whole screen */
  #hero-section {
    padding-top: 3rem !important;
    padding-bottom: 2rem !important;
  }

  /* Eyebrow badge: smaller on tiny phones */
  .hero-eyebrow-badge {
    font-size: 0.7rem !important;
    padding: 4px 12px !important;
    margin-bottom: 1rem !important;
  }

  /* Subtitle pills: slightly smaller */
  .hero-cat-pill {
    font-size: 0.72rem !important;
    padding: 4px 8px !important;
    gap: 3px !important;
  }
  .hero-cat-sep {
    display: none;
  }
}

/* ── Hero search bar: two-row layout on mobile ── */
@media (max-width: 640px) {
  .hero-search-bar {
    padding: 0 0.5rem;
  }

  .hero-search-inner {
    flex-wrap: wrap !important;
    padding: 10px 12px !important;
    gap: 8px !important;
    border-radius: 14px !important;
  }

  /* Search icon + input take full width on first row */
  .hero-search-icon {
    flex-shrink: 0;
  }

  .hero-search-input {
    flex: 1 1 140px !important;
    min-width: 0;
    font-size: 16px !important; /* prevent iOS zoom */
    padding: 6px 0 !important;
  }

  /* Right controls: full-width second row */
  .hero-search-right {
    width: 100% !important;
    flex-shrink: 0;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    padding-top: 8px;
    gap: 6px !important;
  }

  .hero-search-select {
    flex: 1 !important;
    max-width: none !important;
    font-size: 14px !important;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 8px 10px !important;
    min-height: 40px;
  }

  .hero-search-location-btn {
    flex-shrink: 0;
    min-height: 40px;
    min-width: 40px;
  }

  .hero-search-submit-btn {
    flex: 1 !important;
    min-height: 40px;
    border-radius: 10px !important;
    font-size: 0.8rem !important;
  }
}

/* ── City chips: single horizontal scroll row ── */
@media (max-width: 640px) {
  .hero-city-chips {
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
    justify-content: flex-start !important;
    padding-bottom: 4px;
    gap: 5px !important;
  }

  .hero-city-chips::-webkit-scrollbar {
    display: none !important;
  }

  .hero-city-chip-label {
    flex-shrink: 0;
  }

  .hero-city-chip {
    flex-shrink: 0;
    font-size: 0.72rem !important;
    padding: 4px 10px !important;
  }
}

/* ── Stats bar: 2×2 grid on mobile ── */
@media (max-width: 640px) {
  .hero-stats-bar {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 0 !important;
    padding: 14px 10px !important;
    border-radius: 14px !important;
    max-width: 100% !important;
  }

  /* Hide the vertical dividers — replace with border on grid cells */
  .hero-stat-divider {
    display: none !important;
  }

  .hero-stat-item {
    padding: 10px 8px !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  }

  /* Bottom row items: no bottom border */
  .hero-stat-item:nth-child(5),
  .hero-stat-item:nth-child(7) {
    border-bottom: none !important;
  }

  /* Right column items: left border separator */
  .hero-stat-item:nth-child(3),
  .hero-stat-item:nth-child(7) {
    border-left: 1px solid rgba(255, 255, 255, 0.06);
  }

  html[dir="rtl"] .hero-stat-item:nth-child(3),
  html[dir="rtl"] .hero-stat-item:nth-child(7) {
    border-left: none;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
  }

  .hero-stat-num {
    font-size: 1.4rem !important;
  }

  .hero-stat-label {
    font-size: 0.6rem !important;
  }
}

/* ── CTA buttons: tap press feedback ── */
.hero-cta-primary:active {
  transform: translateY(1px) scale(0.97) !important;
  box-shadow: 0 4px 14px rgba(255, 77, 77, 0.25) !important;
}

.hero-cta-secondary:active {
  transform: translateY(1px) scale(0.97) !important;
  background: rgba(255, 255, 255, 0.08) !important;
}

/* ── Hero pill + chip touch feedback ── */
.hero-cat-pill:active {
  transform: scale(0.95) !important;
  transition: transform 0.1s ease !important;
}

.hero-city-chip:active {
  transform: scale(0.92) !important;
  transition: transform 0.1s ease !important;
}


/* ============================================================
   SECTION 32: LOGIN & REGISTER PAGES — MOBILE
   ============================================================ */

@media (max-width: 640px) {
  /* ── Main page: less vertical padding so form isn't cramped ── */
  main.auth-page {
    padding-top: 1.5rem !important;
    padding-bottom: 1.5rem !important;
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }

  /* ── Card: always rounded on mobile (remove sm: prefix limitation) ── */
  .auth-card {
    border-radius: 1.25rem !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04) !important;
    padding: 1.5rem 1.25rem !important;
    margin-top: 1rem;
  }

  /* ── Form inputs: bigger touch targets ── */
  .auth-card input[type="text"],
  .auth-card input[type="email"],
  .auth-card input[type="password"],
  .auth-card input[type="tel"] {
    padding-top: 0.875rem !important;
    padding-bottom: 0.875rem !important;
    font-size: 16px !important;
    min-height: 52px !important;
    border-radius: 0.875rem !important;
  }

  /* ── Submit button: larger, more tappable ── */
  .auth-card button[type="submit"] {
    min-height: 52px !important;
    font-size: 1rem !important;
    border-radius: 0.875rem !important;
  }

  /* ── Social buttons: stack to single column on very small phones ── */
  .auth-social-grid {
    grid-template-columns: 1fr !important;
    gap: 0.625rem !important;
  }

  .auth-social-grid a {
    min-height: 48px !important;
    justify-content: center !important;
    font-size: 0.875rem !important;
    border-radius: 0.875rem !important;
  }

  /* ── Header section: compact on mobile ── */
  .auth-header h2 {
    font-size: 1.5rem !important;
    line-height: 1.25 !important;
  }

  .auth-header p {
    font-size: 0.8rem !important;
    margin-top: 0.35rem !important;
  }
}

/* Active press feedback for auth form inputs */
@media (hover: none) {
  .auth-card input:focus {
    transform: none !important; /* prevent jump on iOS */
  }
}


/* ============================================================
   SECTION 33: TABLET BREAKPOINTS (768–1023px)
   ============================================================ */

@media (min-width: 768px) and (max-width: 1023px) {

  /* ── Deal cards: 2-column grid on tablets ── */
  #deals-grid,
  .dining-deals-slider-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 1.25rem !important;
  }

  /* ── Category grid: 4-column on tablets ── */
  .category-grid {
    grid-template-columns: repeat(4, 1fr) !important;
  }

  /* ── Hero headline: medium size between mobile and desktop ── */
  .hero-headline {
    font-size: clamp(2.4rem, 4.5vw, 3.5rem) !important;
  }

  /* ── Hero stats bar: keep as 1 row but reduce gap ── */
  .hero-stats-bar {
    max-width: 90% !important;
    padding: 16px 20px !important;
  }

  .hero-stat-num {
    font-size: 1.5rem !important;
  }

  /* ── Hero CTAs: side by side (no full-width stacking) ── */
  .hero-cta-group {
    flex-direction: row !important;
  }

  .hero-cta-primary,
  .hero-cta-secondary {
    width: auto !important;
    padding: 13px 24px !important;
  }

  /* ── Slider cards on tablet: 2 visible ── */
  .slider-card.deal-card {
    flex: 0 0 calc(50% - 0.75rem) !important;
    max-width: 360px !important;
  }

  /* ── Section headings ── */
  #trending-deals-section h2,
  #categories-section h2,
  #today-deals-section h2 {
    font-size: 1.5rem !important;
  }

  /* ── Footer: 3-column layout on tablets ── */
  footer .grid.lg\:grid-cols-6 {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 1.5rem !important;
  }

  /* ── Mobile menu: hidden on tablets (they get the desktop nav) ── */
  #mobile-bottom-nav {
    display: none !important;
  }
}


/* ============================================================
   SECTION 34: FOOTER — MOBILE ACCORDION
   ============================================================ */

@media (max-width: 640px) {
  /* Remove default top padding on mobile footer for a tighter layout */
  #main-footer {
    padding-top: 1.75rem !important;
    padding-bottom: 5rem !important; /* extra bottom padding for bottom nav */
  }

  /* Brand column always stays visible */
  #footer-brand-col {
    margin-bottom: 0.5rem;
  }

  /* Link columns: collapsed by default on mobile */
  .footer-link-col {
    border-top: 1px solid rgba(255, 255, 255, 0.06);
  }

  /* Column header button styling */
  .footer-col-toggle {
    display: flex !important;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 0;
    cursor: pointer;
    background: none;
    border: none;
    color: white;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    -webkit-tap-highlight-color: transparent;
  }

  .footer-col-toggle i.toggle-chevron {
    transition: transform 0.3s ease;
    font-size: 0.65rem;
    opacity: 0.6;
  }

  .footer-col-toggle.open i.toggle-chevron {
    transform: rotate(180deg);
  }

  /* Collapsed link list */
  .footer-col-links {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s cubic-bezier(0.16, 1, 0.3, 1),
                opacity 0.3s ease,
                padding 0.3s ease;
    opacity: 0;
    padding-bottom: 0;
  }

  .footer-col-links.open {
    max-height: 300px;
    opacity: 1;
    padding-bottom: 0.875rem;
  }

  /* Social icons: larger touch targets on mobile */
  #main-footer .flex a[aria-label] {
    width: 40px !important;
    height: 40px !important;
    border-radius: 10px !important;
  }

  /* Bottom bar: simplified */
  #main-footer > div > div:last-child {
    padding-top: 1rem !important;
    border-top: 1px solid rgba(255, 255, 255, 0.06) !important;
    flex-direction: column !important;
    gap: 0.5rem !important;
    text-align: center !important;
  }
}


/* ============================================================
   SECTION 35: ADMIN DASHBOARD — MOBILE TABLE FIXES
   ============================================================ */

/* Responsive table wrapper — applied via JS on dashboard */
.table-mobile-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 0 0 12px 12px;
}

/* Stats grid: 2-column on mobile */
@media (max-width: 640px) {
  .admin-stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.75rem !important;
  }

  .admin-stat-card {
    padding: 0.875rem 1rem !important;
  }

  .admin-stat-card .stat-value {
    font-size: 1.5rem !important;
  }

  /* Dashboard tabs: horizontal scroll */
  .admin-tabs-bar {
    overflow-x: auto !important;
    flex-wrap: nowrap !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
  }

  .admin-tabs-bar::-webkit-scrollbar {
    display: none;
  }

  .admin-tab-btn {
    flex-shrink: 0 !important;
    white-space: nowrap !important;
    font-size: 0.7rem !important;
    padding: 0.5rem 0.875rem !important;
  }

  /* Action buttons in tables: icon-only on mobile */
  .admin-action-btn span.btn-label {
    display: none !important;
  }

  .admin-action-btn {
    padding: 0.375rem 0.625rem !important;
    min-width: 36px;
    min-height: 36px;
  }

  /* Form sections in dashboard: full width */
  .admin-form-grid {
    grid-template-columns: 1fr !important;
  }

  /* Modal dialogs: full screen on mobile */
  .admin-modal-box {
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 1rem 1rem 0 0 !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    margin: 0 !important;
    max-height: 85vh !important;
    overflow-y: auto !important;
  }
}

