:root {
  /* High Contrast System - Definitive Emerald Edition */
  --bg: #ffffff;
  --bg-card: #ffffff;
  --bg-darker: #f9fafb;
  --text: #000000;
  --text-sec: #1f2937;
  --text-muted: #4b5563;
  --border: #d1d5db;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);

  --bg-glass: rgba(255, 255, 255, 0.85);

  --accent: #10b981;
  --accent-soft: rgba(16, 185, 129, 0.1);
  --accent-glow: 0 4px 20px rgba(16, 185, 129, 0.2);

  --danger: #dc2626;
  --success: #10b981;

  /* MOBILE-FIRST: Responsive heights */
  --header-h: clamp(56px, 12vw, 70px);
  --nav-h: clamp(60px, 14vw, 80px);
  --r-3xl: clamp(16px, 4vw, 24px);

  /* Safe area for notches & foldables */
  --safe-top: env(safe-area-inset-top, 0);
  --safe-bottom: env(safe-area-inset-bottom, 0);
  --safe-left: env(safe-area-inset-left, 0);
  --safe-right: env(safe-area-inset-right, 0);
}

body.dark-mode {
  --bg: #000000;
  --bg-card: #0a0a0a;
  --bg-darker: #111827;
  --text: #ffffff;
  --text-sec: #f3f4f6;
  --text-muted: #9ca3af;
  --border: #1f2937;
  --bg-glass: rgba(0, 0, 0, 0.85);
  --accent-glow: 0 4px 30px rgba(16, 185, 129, 0.4);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  font-family:
    "Outfit",
    -apple-system,
    system-ui,
    sans-serif;
  /* Prevent zoom on input focus on iOS */
  -webkit-user-select: none;
  user-select: none;
}

input,
textarea,
button,
select {
  -webkit-user-select: text;
  user-select: text;
}

html {
  /* Enable smooth scrolling */
  scroll-behavior: smooth;
  /* Prevent font scaling on orientation change */
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--bg);
  color: var(--text);
  overflow: hidden;
  /* Mobile-first font sizing */
  font-size: clamp(14px, 3.5vw, 16px);
  line-height: 1.5;
  transition:
    background-color 0.3s,
    color 0.3s;
  /* Support for safe area on notched devices */
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}

/* ---------- Header ---------- */
#app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h);
  padding: clamp(8px, 2vw, 12px) clamp(12px, 3vw, 20px);
  padding-top: calc(clamp(8px, 2vw, 12px) + var(--safe-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(8px, 2vw, 12px);
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 3000;
  border-bottom: 1px solid rgba(150, 150, 150, 0.15);
  flex-wrap: wrap;
}

#app-header img {
  height: clamp(28px, 8vw, 40px);
  width: auto;
  flex-shrink: 0;
}

#app-header button {
  width: clamp(32px, 8vw, 44px);
  height: clamp(32px, 8vw, 44px);
  min-width: clamp(32px, 8vw, 44px);
  min-height: clamp(32px, 8vw, 44px);
}

/* ---------- Footer / Bottom Navigation ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-h);
  padding-bottom: var(--safe-bottom);
  background: var(--bg);
  border-top: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 2000;
  gap: clamp(4px, 1vw, 8px);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(2px, 1vw, 6px);
  color: var(--text-muted);
  text-decoration: none;
  font-size: clamp(9px, 2.5vw, 12px);
  font-weight: 700;
  transition: all 0.2s;
  padding: clamp(4px, 1.5vw, 8px) 0;
  border-radius: clamp(8px, 2vw, 12px);
  position: relative;
}

.nav-item:active {
  transform: scale(0.95);
  background: var(--accent-soft);
}

.nav-item.active {
  color: var(--accent);
  background: var(--accent-soft);
}

.nav-item i {
  width: clamp(18px, 5vw, 24px);
  height: clamp(18px, 5vw, 24px);
}

/* Main Content Area - Account for header and footer */
#app-main {
  position: fixed;
  top: var(--header-h);
  left: 0;
  right: 0;
  bottom: var(--nav-h);
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg);
  -webkit-overflow-scrolling: touch;
  /* For safe area support */
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}

.screen {
  display: none;
  width: 100%;
  min-height: 100%;
  padding: clamp(12px, 3vw, 20px);
  padding-bottom: clamp(16px, 4vw, 24px);
}

.screen.active {
  display: block;
  animation: screenSlideIn 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

@keyframes screenSlideIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ---------- Buttons ---------- */
.btn-cta {
  background: var(--accent);
  color: #ffffff !important;
  font-weight: 800;
  padding: clamp(14px, 3vw, 18px) clamp(16px, 4vw, 20px);
  border-radius: var(--r-3xl);
  border: none;
  width: 100%;
  font-size: clamp(14px, 3.5vw, 16px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 2vw, 10px);
  box-shadow: var(--accent-glow);
  cursor: pointer;
  transition: all 0.2s;
  touch-action: manipulation;
}
.btn-cta:active {
  transform: scale(0.97);
}
.btn-cta:disabled {
  opacity: 0.6;
  pointer-events: none;
}

/* ---------- Input ---------- */
input {
  font-family: inherit;
  font-size: 16px; /* Prevent zoom on iOS */
}

#plate-input {
  color: var(--text);
  font-weight: 950 !important;
  font-size: clamp(20px, 6vw, 32px) !important;
  text-align: left;
  line-height: 1;
  letter-spacing: -1px;
}

#plate-input::placeholder {
  color: var(--text);
  opacity: 0.4;
}

.search-input {
  font-size: clamp(12px, 3vw, 14px);
  min-width: 0;
  width: auto;
  flex: 1 1 0%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
}

.search-input::placeholder {
  color: var(--text-muted);
  font-weight: 500;
}

.search-pill {
  display: flex;
  align-items: center;
  gap: clamp(4px, 1vw, 6px);
  padding: clamp(6px, 1.5vw, 8px) clamp(8px, 1.5vw, 12px);
  border-radius: 30px;
  background: var(--bg);
  border: 1px solid var(--border);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  flex: 0 1 auto;
  min-width: 0;
  max-width: 180px;
  overflow: hidden;
  transition: box-shadow 0.2s;
}
.search-pill:focus-within {
  box-shadow:
    0 0 0 2px var(--accent-soft),
    0 4px 15px rgba(16, 185, 129, 0.15);
  border-color: var(--accent);
}

/* ---------- Map ---------- */
#map {
  width: 100% !important;
  height: 100% !important;
  background: var(--bg) !important;
  z-index: 1 !important;
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  border: none !important;
}

#screen-home {
  position: relative !important;
  padding: 0 !important;
  margin: 0 !important;
  width: 100% !important;
  height: 100% !important;
}

/* Leaflet overrides */
.leaflet-container {
  font-family: inherit !important;
}

.leaflet-bottom,
.leaflet-control-container {
  z-index: 400 !important;
}

.leaflet-top {
  z-index: 400 !important;
}

/* ---------- Bottom Sheet ---------- */
#bottom-sheet {
  position: fixed;
  /* anchor at bottom=0; when closed, shift down by full height + nav so handle is never visible */
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border-radius: clamp(20px, 5vw, 32px) clamp(20px, 5vw, 32px) 0 0;
  /* Must be below nav (2000) so nav tabs stay visible when sheet is open */
  z-index: 1500;
  transform: translateY(calc(100% + var(--nav-h) + 4px));
  transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1);
  padding: clamp(14px, 3vw, 20px);
  /* push CTA above the nav bar when open */
  padding-bottom: calc(
    var(--nav-h) + clamp(14px, 3vw, 20px) + var(--safe-bottom)
  );
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.12);
  border-top: 1px solid var(--border);
  max-height: calc(100vh - var(--header-h));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#bottom-sheet.open {
  transform: translateY(0);
}

.sheet-handle {
  width: clamp(30px, 8vw, 40px);
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto clamp(12px, 3vw, 20px) auto;
}

/* ---------- Ticket Type Cards ---------- */
.ticket-type-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.ticket-type-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 8px;
  border-radius: 20px;
  border: 2px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.32, 0.72, 0, 1);
  font-family: inherit;
}
.ticket-type-card:active {
  transform: scale(0.95);
}
.ticket-type-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 4px 14px -2px rgba(0, 0, 0, 0.18);
}
/* Gloss highlight */
.ticket-type-icon::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: linear-gradient(
    160deg,
    rgba(255, 255, 255, 0.45) 0%,
    rgba(255, 255, 255, 0) 55%
  );
  pointer-events: none;
}
.ticket-type-icon svg {
  width: 22px;
  height: 22px;
  color: #fff;
  position: relative;
  z-index: 1;
}

/* Icon backgrounds per variant */
.ticket-type-card--free .ticket-type-icon {
  background: linear-gradient(145deg, #34d399, #10b981);
}
.ticket-type-card--paid .ticket-type-icon {
  background: linear-gradient(145deg, #60a5fa, #3b82f6);
  box-shadow: 0 4px 14px -2px rgba(59, 130, 246, 0.4);
}
.ticket-type-card--pmr .ticket-type-icon {
  background: linear-gradient(145deg, #fb923c, #f97316);
  box-shadow: 0 4px 14px -2px rgba(249, 115, 22, 0.4);
}
.ticket-type-label {
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
  text-align: center;
}
.ticket-type-duration {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}
.ticket-type-price {
  font-size: 14px;
  font-weight: 900;
  margin-top: 2px;
}

/* active state per variant */
.ticket-type-card--active {
  border-width: 2.5px;
  box-shadow: 0 4px 16px -4px currentColor;
}
.ticket-type-card--free.ticket-type-card--active {
  border-color: var(--accent);
  background: rgba(16, 185, 129, 0.07);
  color: var(--accent);
}
.ticket-type-card--free .ticket-type-price {
  color: var(--accent);
}

.ticket-type-card--paid.ticket-type-card--active {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.07);
}
.ticket-type-card--paid .ticket-type-price {
  color: #3b82f6;
}

.ticket-type-card--pmr.ticket-type-card--active {
  border-color: #f97316;
  background: rgba(249, 115, 22, 0.07);
}
.ticket-type-card--pmr .ticket-type-price {
  color: #f97316;
}

/* ---------- Ticket Screen ---------- */
.ticket-hero {
  background: linear-gradient(160deg, #064e3b 0%, #10b981 100%);
  padding: clamp(28px, 6vw, 40px) clamp(20px, 5vw, 32px) clamp(20px, 5vw, 32px);
  text-align: center;
  position: relative;
  overflow: hidden;
}
.ticket-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse at 60% 0%,
    rgba(255, 255, 255, 0.12) 0%,
    transparent 65%
  );
  pointer-events: none;
}

.ticket-hero-ring {
  position: relative;
  width: 72px;
  height: 72px;
  margin: 0 auto clamp(10px, 2.5vw, 16px);
}
.ticket-hero-ring__pulse {
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.35);
  animation: ticketPulse 2s ease-in-out infinite;
}
@keyframes ticketPulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.6;
  }
  50% {
    transform: scale(1.15);
    opacity: 0.2;
  }
}
.ticket-check-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(6px);
  border: 2px solid rgba(255, 255, 255, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  position: relative;
}
.ticket-hero-title {
  font-size: clamp(22px, 5vw, 28px);
  font-weight: 900;
  color: #fff;
  margin: 0 0 4px;
  letter-spacing: -0.5px;
}
.ticket-hero-sub {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.75);
  margin: 0;
}

.ticket-plate-pill {
  background: var(--bg-card);
  border: 2px solid var(--accent);
  border-radius: 20px;
  padding: 14px 20px;
  font-family: "Outfit", monospace;
  font-size: clamp(22px, 6vw, 30px);
  font-weight: 900;
  color: var(--accent);
  letter-spacing: 4px;
  text-align: center;
  margin: 16px 0 14px;
  box-shadow: 0 4px 20px rgba(16, 185, 129, 0.15);
}

.ticket-countdown-card {
  background: var(--bg-darker);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 14px 16px;
  margin-bottom: 14px;
}

.ticket-info-cell {
  background: var(--bg-darker);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 12px 14px;
}
.ticket-info-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.ticket-info-label svg {
  flex-shrink: 0;
  color: var(--text-muted);
}
.ticket-info-value {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

/* ---------- Store Links ---------- */
.store-badges {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  justify-content: center;
}
.store-link {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #000;
  color: #fff;
  padding: 10px 16px;
  border-radius: 12px;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.dark-mode .store-link {
  background: #222;
}

.hidden {
  display: none !important;
}

/* Slider Custom */
input[type="range"] {
  accent-color: var(--accent);
}

/* ---------- Toast Notifications ---------- */
.toast {
  position: fixed;
  bottom: calc(clamp(60px, 14vw, 100px) + var(--nav-h));
  left: clamp(8px, 2vw, 12px);
  right: clamp(8px, 2vw, 12px);
  transform: translateY(120%);
  background: var(--bg-card);
  color: var(--text);
  padding: clamp(12px, 2.5vw, 16px) clamp(16px, 4vw, 24px);
  border-radius: clamp(12px, 3vw, 16px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  z-index: 9999;
  max-width: 100%;
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  border-left: 4px solid var(--accent);
  font-weight: 600;
  font-size: clamp(12px, 3vw, 14px);
  display: flex;
  align-items: center;
  gap: clamp(8px, 2vw, 12px);
}
.toast.show {
  transform: translateY(-10px);
}
.toast.error {
  border-left-color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}
[dir="rtl"] .toast {
  border-left: none;
  border-right: 4px solid var(--accent);
}
[dir="rtl"] .toast.error {
  border-right-color: var(--danger);
}
[dir="rtl"] .toast.success {
  border-right-color: var(--success);
}
.toast.success {
  border-left-color: var(--success);
  background: rgba(16, 185, 129, 0.1);
}
.toast-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* ---------- Loading Spinner ---------- */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.btn-cta.loading {
  opacity: 0.8;
  pointer-events: none;
}
.btn-cta.loading::after {
  content: "";
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-left: 8px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 0.8s linear infinite;
}

/* ---------- Modal Improved ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(12px, 3vw, 20px);
  animation: fadeIn 0.3s ease-out;
}

.modal-overlay.hidden {
  display: none !important;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal-content {
  background: var(--bg-card);
  width: 100%;
  max-width: clamp(280px, 90vw, 500px);
  border-radius: clamp(20px, 5vw, 40px);
  padding: clamp(24px, 5vw, 40px);
  animation: scaleIn 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  max-height: 90vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}
@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

/* ---------- QR Scanner Modal ---------- */
#qr-scanner-modal {
  display: none;
}

#qr-scanner-modal.active {
  display: flex;
  animation: fadeIn 0.2s ease-out;
}

#qr-reader {
  width: 100%;
  max-width: 100%;
  padding: clamp(8px, 2vw, 12px);
}

#qr-reader__scan_region {
  border: 3px dashed var(--accent);
  border-radius: clamp(12px, 3vw, 20px);
  width: clamp(200px, 80vw, 350px) !important;
  height: clamp(200px, 80vw, 350px) !important;
}

/* ---------- Floating Elements ---------- */
#btn-locate {
  width: clamp(48px, 12vw, 56px) !important;
  height: clamp(48px, 12vw, 56px) !important;
  bottom: calc(clamp(90px, 20vw, 110px) + var(--nav-h)) !important;
  right: clamp(14px, 4vw, 20px) !important;
  font-size: clamp(18px, 5vw, 24px);
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-shadow: 0 8px 24px rgba(16, 185, 129, 0.25) !important;
  transition: all 0.2s !important;
}

#btn-locate:active {
  transform: scale(0.92) !important;
}

.fixed.top-24 {
  top: clamp(68px, 14vw, 90px);
  left: clamp(8px, 2vw, 16px);
  right: clamp(8px, 2vw, 16px);
  width: auto;
  max-width: calc(100vw - clamp(16px, 4vw, 32px));
  z-index: 5001;
}

#zone-prompt {
  bottom: var(--nav-h);
  bottom: calc(var(--nav-h) + clamp(10px, 2vw, 20px));
  left: clamp(12px, 3vw, 20px);
  right: clamp(12px, 3vw, 20px);
  width: auto;
  z-index: 1001;
}

/* Enhanced floating card styling */
.fixed.top-24 .card {
  border: 2px solid var(--accent);
  box-shadow: 0 10px 30px rgba(16, 185, 129, 0.2);
  padding: clamp(10px, 2.5vw, 16px);
  gap: clamp(8px, 2vw, 12px);
}

.fixed.top-24 .card .flex {
  gap: clamp(8px, 2vw, 12px);
  flex-wrap: wrap;
}

#plate-input {
  max-width: 100%;
  flex: 1;
  min-width: 0;
}

.animate-bounce-subtle {
  animation: bounce-subtle 2s infinite;
}

@keyframes bounce-subtle {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-4px);
  }
}

/* ---------- Accessibility Improvements ---------- */
.text-muted {
  color: var(--text-muted);
  font-weight: 500;
}

input::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}

/* ---------- Focus/Active States for Accessibility ---------- */
button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Search/History Styles */
.ticket-item {
  padding: clamp(12px, 3vw, 16px);
  background: var(--bg-darker);
  border-radius: clamp(12px, 3vw, 16px);
  border: 1px solid var(--border);
  transition: all 0.2s;
  cursor: pointer;
}

.ticket-item:active {
  transform: scale(0.98);
  background: var(--bg-card);
}

.ticket-item .flex {
  gap: clamp(8px, 2vw, 12px);
}

/* ---------- Card Styles ---------- */
.card {
  border-radius: clamp(12px, 3vw, 20px);
  border: 1px solid var(--border);
  padding: clamp(12px, 3vw, 20px);
  background: var(--bg-card);
  transition: all 0.2s;
}

/* ---------- Responsive Typography ---------- */
h1 {
  font-size: clamp(20px, 6vw, 28px);
  font-weight: 800;
  margin: clamp(12px, 3vw, 20px) 0;
}

h2 {
  font-size: clamp(18px, 5vw, 24px);
  font-weight: 700;
  margin: clamp(10px, 2.5vw, 16px) 0;
}

h3 {
  font-size: clamp(16px, 4vw, 20px);
  font-weight: 700;
  margin: clamp(8px, 2vw, 12px) 0;
}

p {
  font-size: clamp(13px, 3vw, 15px);
  margin: clamp(6px, 1.5vw, 10px) 0;
}

/* ---------- BENTO CARD GRID STYLES ---------- */
.grid {
  display: grid;
  gap: clamp(12px, 3vw, 16px);
}

.grid-cols-2 {
  grid-template-columns: repeat(2, 1fr);
}

.grid-cols-1 {
  grid-template-columns: 1fr;
}

@media (max-width: 480px) {
  .grid-cols-2 {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 1024px) {
  .grid-cols-2 {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ---------- SCREEN TRANSITIONS & ANIMATIONS ---------- */
@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideOutRight {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(20px);
  }
}

@keyframes slideOutLeft {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(-20px);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Apply animations to screen transitions */
.screen.active {
  animation: fadeIn 0.3s ease-out;
}

/* Enhanced navigation transitions */
.nav-item {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-item.active {
  animation: scaleIn 0.3s ease-out;
}

/* Smooth scrolling for all screens */
.screen {
  transition: opacity 0.3s ease-out;
}

/* ---------- ENHANCED CARD STYLES ---------- */
.card,
[class*="card"],
[class*="bg-gray"],
[class*="rounded"] {
  border-radius: clamp(12px, 3vw, 20px);
  transition: all 0.2s ease-out;
}

.card:active,
[class*="card"]:active,
button:active {
  transform: scale(0.98);
  transition: transform 0.15s ease-out;
}

/* Specific styling for ticket cards and content cards */
.card p,
.card h3,
.card span {
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* ---------- FLOATING ANIMATION ---------- */
@keyframes float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

.animate-float {
  animation: float 3s ease-in-out infinite;
}

@keyframes pulse-soft {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

.animate-pulse-soft {
  animation: pulse-soft 2s ease-in-out infinite;
}

/* ---------- RESPONSIVE MEDIA QUERIES ---------- */

/* VERY SMALL SCREENS (320px - 480px) - iPhone SE, older phones */
@media (max-width: 480px) {
  :root {
    --header-h: 56px;
    --nav-h: 64px;
  }

  #app-header {
    padding: 6px clamp(10px, 2vw, 12px);
  }

  .nav-item {
    gap: 2px;
  }

  #bottom-sheet {
    padding: 12px;
    padding-bottom: calc(12px + var(--nav-h) + var(--safe-bottom));
  }

  .screen {
    padding: 10px;
  }

  input[type="range"] {
    height: 6px;
  }
}

/* SMALL TABLETS (481px - 768px) */
@media (min-width: 481px) and (max-width: 768px) {
  :root {
    --header-h: 62px;
    --nav-h: 72px;
  }
}

/* MEDIUM TABLETS & LANDSCAPE (769px - 1024px) */
@media (min-width: 769px) {
  :root {
    --header-h: 70px;
    --nav-h: 80px;
  }

  #app-main {
    display: flex;
    flex-direction: column;
  }

  .screen {
    padding: clamp(16px, 4vw, 28px);
  }

  .bottom-nav {
    gap: clamp(12px, 3vw, 16px);
  }

  .nav-item {
    padding: clamp(8px, 2vw, 12px) clamp(16px, 3vw, 24px);
  }
}

/* LARGE SCREENS & DESKTOPS (1025px+) */
@media (min-width: 1025px) {
  :root {
    --header-h: 70px;
    --nav-h: 80px;
    --max-width: 1200px;
  }

  body {
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  #app-header,
  #app-main,
  .bottom-nav {
    max-width: var(--max-width);
    width: 100%;
    margin: 0 auto;
  }

  .screen {
    max-width: 100%;
  }

  #bottom-sheet {
    max-width: var(--max-width);
    left: 50%;
    right: auto;
    transform: translateX(-50%) translateY(105%);
  }

  #bottom-sheet.open {
    transform: translateX(-50%) translateY(0);
  }
}

/* FOLDABLE DEVICES & LARGE TABLETS (horizontal orientation) */
@media (min-height: 1000px) and (orientation: portrait) {
  .screen {
    min-height: auto;
    padding-bottom: clamp(20px, 5vw, 40px);
  }

  #bottom-sheet {
    max-height: 60vh;
  }
}

/* LANDSCAPE MODE ADJUSTMENTS */
@media (orientation: landscape) and (max-height: 500px) {
  :root {
    --header-h: 48px;
    --nav-h: 48px;
  }

  #app-header {
    padding: 4px clamp(8px, 2vw, 12px);
  }

  .nav-item {
    gap: 0;
    font-size: 9px;
  }

  .nav-item i {
    width: 18px;
    height: 18px;
  }

  .screen {
    padding: 8px;
  }

  #bottom-sheet {
    padding: 10px;
  }
}

/* DARK MODE ADJUSTMENTS */
@media (prefers-color-scheme: dark) {
  body.dark-mode {
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  }
}

/* REDUCED MOTION */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* TOUCH DEVICES OPTIMIZATION */
@media (hover: none) and (pointer: coarse) {
  .nav-item,
  .btn-cta,
  .card,
  button {
    min-height: 44px;
    min-width: 44px;
  }

  .nav-item {
    padding: 10px 8px;
  }
}

/* ---------- UTILITY CLASSES (Tailwind compatibility) ---------- */
.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.flex-shrink-0 {
  flex-shrink: 0;
}

.items-center {
  align-items: center;
}

.items-start {
  align-items: flex-start;
}

.items-end {
  align-items: flex-end;
}

.justify-center {
  justify-content: center;
}

.justify-between {
  justify-content: space-between;
}

.justify-around {
  justify-content: space-around;
}

.gap-2 {
  gap: 8px;
}

.gap-3 {
  gap: 12px;
}

.gap-4 {
  gap: 16px;
}

.gap-6 {
  gap: 24px;
}

.p-4 {
  padding: 16px;
}

.p-6 {
  padding: 24px;
}

.p-8 {
  padding: 32px;
}

.px-3 {
  padding-left: 12px;
  padding-right: 12px;
}

.py-3 {
  padding-top: 12px;
  padding-bottom: 12px;
}

.mb-1 {
  margin-bottom: 4px;
}

.mb-2 {
  margin-bottom: 8px;
}

.mb-4 {
  margin-bottom: 16px;
}

.mb-6 {
  margin-bottom: 24px;
}

.mb-8 {
  margin-bottom: 32px;
}

.mt-4 {
  margin-top: 16px;
}

.mt-8 {
  margin-top: 32px;
}

.mt-12 {
  margin-top: 48px;
}

.w-full {
  width: 100%;
}

.w-auto {
  width: auto;
}

.h-auto {
  height: auto;
}

.rounded-full {
  border-radius: 9999px;
}

.rounded-2xl {
  border-radius: clamp(12px, 3vw, 16px);
}

.rounded-3xl {
  border-radius: clamp(16px, 4vw, 24px);
}

.border {
  border: 1px solid var(--border);
}

.border-2 {
  border: 2px solid var(--border);
}

.border-accent {
  border-color: var(--accent);
}

.border-white {
  border-color: white;
}

.bg-white {
  background-color: white;
}

.bg-black {
  background-color: black;
}

.bg-dark {
  background-color: var(--bg-darker);
}

.text-white {
  color: white;
}

.text-black {
  color: black;
}

.text-accent {
  color: var(--accent);
}

.text-gray-400 {
  color: #6b7280; /* WCAG AA fix: 4.64:1 on white */
}

.text-gray-500 {
  color: #4b5563; /* WCAG AA fix: 7.15:1 on white */
}

.text-center {
  text-align: center;
}

.text-left {
  text-align: left;
}

.text-right {
  text-align: right;
}

.font-bold {
  font-weight: 700;
}

.font-extrabold {
  font-weight: 800;
}

.font-black {
  font-weight: 900;
}

.text-sm {
  font-size: clamp(12px, 3vw, 14px);
}

.text-lg {
  font-size: clamp(16px, 4vw, 18px);
}

.text-xl {
  font-size: clamp(18px, 5vw, 20px);
}

.text-2xl {
  font-size: clamp(20px, 6vw, 24px);
}

.space-y-4 > * + * {
  margin-top: 16px;
}

.opacity-50 {
  opacity: 0.5;
}

.opacity-60 {
  opacity: 0.6;
}

.opacity-80 {
  opacity: 0.8;
}

.shadow-lg {
  box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
}

.shadow-xl {
  box-shadow: 0 20px 25px rgba(0, 0, 0, 0.15);
}

.shadow-2xl {
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.2);
}

.transition-all {
  transition: all 0.3s ease;
}

.transition-colors {
  transition:
    background-color 0.3s,
    color 0.3s;
}

.duration-300 {
  transition-duration: 300ms;
}

.no-underline {
  text-decoration: none;
}

.divide-y > * + * {
  border-top: 1px solid var(--border);
}

.divide-y > * {
  padding-top: 16px;
  padding-bottom: 16px;
}

.absolute {
  position: absolute;
}

.relative {
  position: relative;
}

.fixed {
  position: fixed;
}

.inset-0 {
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

.mx-auto {
  margin-left: auto;
  margin-right: auto;
}

.max-w-sm {
  max-width: clamp(280px, 90vw, 500px);
}

.backdrop-blur-md {
  backdrop-filter: blur(12px);
}

.cursor-pointer {
  cursor: pointer;
}

.pointer-events-auto {
  pointer-events: auto;
}

.pointer-events-none {
  pointer-events: none;
}

/* ---------- COLOR & BACKGROUND UTILITIES ---------- */
.bg-accent\/20 {
  background-color: rgba(16, 185, 129, 0.2);
}

.bg-white\/20 {
  background-color: rgba(255, 255, 255, 0.2);
}

.bg-white\/95 {
  background-color: rgba(255, 255, 255, 0.95);
}

.bg-black\/60 {
  background-color: rgba(0, 0, 0, 0.6);
}

.bg-gray-50 {
  background-color: #f9fafb;
}

.bg-gray-100 {
  background-color: #f3f4f6;
}

.bg-zinc-900\/95 {
  background-color: rgba(24, 24, 27, 0.95);
}

.border-accent\/30 {
  border-color: rgba(16, 185, 129, 0.3);
}

.text-gray-300 {
  color: #d1d5db;
}

.text-white\/80 {
  color: rgba(255, 255, 255, 0.8);
}

.text-white\/60 {
  color: rgba(255, 255, 255, 0.6);
}

.leading-relaxed {
  line-height: 1.625;
}

.leading-tight {
  line-height: 1.25;
}

.dark-mode .bg-white {
  background-color: var(--bg-card);
}

.dark-mode .text-black {
  color: var(--text);
}

.dark-mode .bg-gray-50 {
  background-color: #18181b;
}

.dark-mode .bg-gray-100 {
  background-color: #1f1f23;
}

.dark-mode .border-gray-100,
.dark-mode .border-gray-200 {
  border-color: #27272a;
}

.dark-mode .text-gray-400 {
  color: #a1a1aa;
}

.dark-mode .text-gray-500 {
  color: #a1a1aa;
}

.dark-mode .text-gray-300 {
  color: #71717a;
}

.dark-mode .dark\:bg-zinc-900\/95 {
  background-color: rgba(24, 24, 27, 0.95);
}

.dark-mode .dark\:text-white {
  color: white;
}

.dark-mode .dark\:bg-zinc-800 {
  background-color: #27272a;
}

.dark-mode .dark\:border-gray-800 {
  border-color: #27272a;
}

.dark-mode .dark\:divide-gray-800 > * + * {
  border-top-color: #27272a;
}

/* ---------- RTL Support (Arabic) ---------- */
[dir="rtl"] {
  text-align: right;
}

[dir="rtl"] .search-pill {
  flex-direction: row-reverse;
}

[dir="rtl"] #app-header {
  flex-direction: row-reverse;
}

[dir="rtl"] .flex {
  flex-direction: row-reverse;
}

[dir="rtl"] .text-left {
  text-align: right;
}

[dir="rtl"] .text-right {
  text-align: left;
}

/* ---------- TOGGLE SWITCH ---------- */
.toggle-switch {
  width: 51px;
  height: 31px;
  background-color: #e5e5ea;
  border-radius: 15.5px;
  position: relative;
  cursor: pointer;
  transition: background-color 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

.dark-mode .toggle-switch {
  background-color: #39393d; /* iOS dark mode off state */
}

.toggle-knob {
  width: 27px;
  height: 27px;
  background-color: white;
  border-radius: 50%;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  box-shadow:
    0 3px 8px rgba(0, 0, 0, 0.15),
    0 3px 1px rgba(0, 0, 0, 0.06);
}

.toggle-switch.active {
  background-color: #34c759; /* iOS green */
}

.toggle-switch.active .toggle-knob {
  transform: translateX(20px);
  background-color: white; /* iOS keeps knob white */
}

/* ---------- SEARCH STYLES ---------- */
.search-pill i {
  flex-shrink: 0;
}

/* ---------- BADGE STYLES ---------- */
.border-white\/20 {
  border-color: rgba(255, 255, 255, 0.2);
}

/* ---------- LINK STYLES ---------- */
a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  opacity: 0.8;
  transition: opacity 0.2s;
}

/* ---------- EXTRA RESPONSIVE GRIDS ---------- */
.grid-cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

.grid-cols-4 {
  grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 640px) {
  .grid-cols-3,
  .grid-cols-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .grid-cols-3,
  .grid-cols-4 {
    grid-template-columns: 1fr;
  }
}

/* ---------- FLEX WRAP UTILITIES ---------- */
.flex-wrap {
  flex-wrap: wrap;
}

/* ---------- TRACKING & LETTER SPACING ---------- */
.tracking-widest {
  letter-spacing: 0.1em;
}

.tracking-tighter {
  letter-spacing: -0.05em;
}

/* ---------- LINE HEIGHT ---------- */
.line-height-1 {
  line-height: 1;
}

/* ---------- OVERFLOW ---------- */
.overflow-hidden {
  overflow: hidden;
}

.overflow-y-auto {
  overflow-y: auto;
}

/* ---------- DISPLAY UTILITIES ---------- */
.inline-block {
  display: inline-block;
}

.block {
  display: block;
}

.inline {
  display: inline;
}

/* ---------- MIN/MAX WIDTH ---------- */
.max-w-xs {
  max-width: clamp(240px, 90vw, 320px);
}

.max-w-md {
  max-width: clamp(280px, 90vw, 448px);
}

.max-w-lg {
  max-width: clamp(320px, 90vw, 512px);
}

.max-w-none {
  max-width: none;
}

/* ---------- ASPECT RATIO ---------- */
.aspect-square {
  aspect-ratio: 1;
}

/* ---------- SCALE UTILITIES ---------- */
.scale-98 {
  transform: scale(0.98);
}

.scale-95 {
  transform: scale(0.95);
}
