/* ============================================================
   Fairfood Price – Production Mobile Web App (Final)
   Design: Glassmorphism + Dark/Light + Safe Area
   Languages: Arabic (RTL), English (LTR), German (LTR)
   ============================================================ */

/* ---------- Custom Properties ---------- */
:root {
  --primary: #FF5A00;
  --primary-hover: #E04E00;
  --primary-light: rgba(255, 90, 0, 0.08);
  --primary-glow: 0 0 20px rgba(255, 90, 0, 0.25);
  --success: #34C759;
  --warning: #FF9500;
  --danger: #FF3B30;
  --info: #007AFF;

  --bg: #F5F5F7;
  --surface: #FFFFFF;
  --surface-glass: rgba(255, 255, 255, 0.72);
  --text: #1C1C28;
  --text-secondary: #8E8EA0;
  --text-muted: #B0B0C0;
  --border: #F0F0F5;
  --border-light: #F5F5FA;

  --shadow-sm: 0 2px 12px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.12);

  --radius-sm: 12px;
  --radius: 20px;
  --radius-lg: 28px;
  --radius-full: 50px;

  --font: 'Segoe UI', 'Tajawal', system-ui, -apple-system, sans-serif;
  --transition: 0.25s cubic-bezier(0.23, 1, 0.32, 1);
  --glass-blur: blur(20px);

  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

html[data-theme="dark"] {
  --bg: #1C1C28;
  --surface: #2C2C3A;
  --surface-glass: rgba(44, 44, 58, 0.72);
  --text: #F5F5F7;
  --text-secondary: #A0A0B0;
  --text-muted: #6B6B7B;
  --border: #3A3A4A;
  --border-light: #2E2E3A;
  --shadow-sm: 0 2px 12px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.4);
  --primary-light: rgba(255, 90, 0, 0.15);
}

/* ---------- Reset & Base ---------- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

body {
  font-family: var(--font);
  background: var(--bg);
  margin: 0;
  padding: 0;
  overflow: hidden;
  width: 100%;
  height: 100dvh;
  position: relative;
  transition: background 0.3s;
  overscroll-behavior: none;
}

body[dir="rtl"] { direction: rtl; }
body[dir="ltr"] { direction: ltr; }

/* ---------- App Shell (Full Screen) ---------- */
.app-wrapper {
  width: 100%;
  height: 100%;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  transition: background 0.3s;
}

/* ---------- Header ---------- */
.app-header {
  background: var(--surface-glass);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  padding-top: max(12px, var(--safe-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 60px;
  position: sticky;
  top: 0;
  z-index: 10;
  flex-shrink: 0;
}

.location-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: none;
  color: var(--text);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  transition: background var(--transition);
}

.location-trigger:hover {
  background: var(--primary-light);
}

.location-trigger:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lang-switcher {
  display: flex;
  gap: 4px;
}

.lang-btn {
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 700;
  transition: var(--transition);
  color: var(--text-secondary);
}

.lang-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.lang-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.profile-menu-btn {
  background: transparent;
  border: none;
  font-size: 1.8rem;
  color: var(--text);
  cursor: pointer;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}

.profile-menu-btn:hover {
  background: var(--primary-light);
}

.profile-menu-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ---------- Search ---------- */
.search-section {
  padding: 10px 16px;
  background: var(--bg);
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.search-box {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.search-box i {
  position: absolute;
  right: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

body[dir="ltr"] .search-box i {
  right: auto;
  left: 16px;
}

.search-box input {
  width: 100%;
  padding: 14px 48px 14px 20px;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: 0.95rem;
  outline: none;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  font-family: var(--font);
}

body[dir="ltr"] .search-box input {
  padding: 14px 20px 14px 48px;
}

.search-box input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.filter-btn {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 1.2rem;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}

.filter-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.filter-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ---------- Filter Panel ---------- */
.filter-panel {
  padding: 12px 16px;
  background: var(--surface-glass);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.filter-panel.hidden {
  display: none;
}

.filter-panel select {
  flex: 1;
  padding: 10px 16px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--surface);
  font-family: var(--font);
  font-size: 0.85rem;
  color: var(--text);
  outline: none;
  cursor: pointer;
}

.filter-panel select:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* ---------- Main Content ---------- */
.app-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  -webkit-overflow-scrolling: touch;
}

/* Restaurant Card */
.restaurant-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  border: 1px solid transparent;
  animation: fadeInUp 0.4s ease both;
}

.restaurant-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary-light);
}

.restaurant-card:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.card-media {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #f0f0f0;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}

.card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-body h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meta {
  display: flex;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  flex-wrap: wrap;
}

/* Menu Item */
.menu-item {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 14px;
  display: flex;
  gap: 12px;
  align-items: center;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  animation: fadeInUp 0.4s ease both;
}

.menu-item:hover {
  box-shadow: var(--shadow-md);
}

.item-image {
  width: 64px;
  height: 64px;
  border-radius: 10px;
  object-fit: cover;
  background: #f0f0f0;
  flex-shrink: 0;
}

.item-info {
  flex: 1;
}

.item-name {
  font-weight: 700;
  margin-bottom: 4px;
}

.item-desc {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.item-price {
  font-weight: 700;
  color: var(--primary);
}

.add-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  background: #fff;
  color: var(--primary);
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}

.add-btn:hover {
  background: var(--primary);
  color: #fff;
}

.add-btn:active {
  transform: scale(0.9);
}

.add-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ---------- Bottom Navigation ---------- */
.bottom-nav {
  display: flex;
  background: var(--surface-glass);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-top: 1px solid var(--border);
  height: calc(70px + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  flex-shrink: 0;
}

.nav-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.7rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  font-family: var(--font);
}

.nav-btn.active {
  color: var(--primary);
}

.nav-btn i {
  font-size: 1.3rem;
}

.nav-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
  border-radius: var(--radius-sm);
}

.badge {
  position: absolute;
  top: 4px;
  right: 50%;
  transform: translateX(50%);
  background: var(--danger);
  color: #fff;
  font-size: 0.65rem;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  font-weight: 700;
}

.badge.hidden {
  display: none;
}

/* ---------- Bottom Sheet (Sliding) ---------- */
.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  max-height: 75vh;
  background: var(--surface-glass);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.2);
  z-index: 50;
  transform: translateY(100%);
  visibility: hidden;
  transition: transform var(--transition), visibility var(--transition);
  display: flex;
  flex-direction: column;
}

.bottom-sheet.hidden {
  transform: translateY(100%);
  visibility: hidden;
}

.bottom-sheet.open,
.bottom-sheet:not(.hidden) {
  transform: translateY(0);
  visibility: visible;
}

.sheet-content {
  padding: 20px;
  padding-bottom: calc(20px + var(--safe-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.close-sheet {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}

.close-sheet:hover {
  background: var(--border-light);
}

.close-sheet:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ---------- Form Inputs inside Sheets ---------- */
.sheet-content label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 0.85rem;
  color: var(--text);
}

.sheet-content input[type="text"],
.sheet-content input[type="email"],
.sheet-content input[type="password"],
.sheet-content select,
.sheet-content textarea {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-family: var(--font);
  font-size: 0.9rem;
  margin-bottom: 16px;
  color: var(--text);
  outline: none;
  transition: border-color var(--transition);
}

.sheet-content input:focus,
.sheet-content select:focus,
.sheet-content textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.sheet-content textarea {
  resize: vertical;
  min-height: 60px;
}

.sheet-content select {
  cursor: pointer;
}

/* Coupon Input */
.coupon-input {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.coupon-input input {
  flex: 1;
  margin-bottom: 0;
}

.coupon-input .btn-small {
  flex-shrink: 0;
}

/* ---------- Buttons ---------- */
.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-full);
  padding: 14px 24px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.95rem;
  width: 100%;
  text-align: center;
  font-family: var(--font);
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-primary:active {
  transform: scale(0.97);
}

.btn-primary:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.btn-primary:disabled {
  background: #CCC;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: transparent;
  border: 2px solid var(--primary);
  color: var(--primary);
  border-radius: var(--radius-full);
  padding: 12px 24px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.9rem;
  width: 100%;
  text-align: center;
  font-family: var(--font);
}

.btn-secondary:hover {
  background: var(--primary-light);
}

.btn-secondary:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.btn-small {
  background: var(--primary-light);
  border: none;
  color: var(--primary);
  border-radius: var(--radius-full);
  padding: 8px 16px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.85rem;
}

.btn-small:hover {
  background: var(--primary);
  color: #fff;
}

.btn-small:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ---------- Overlay (اختياري، أضف العنصر لـ HTML إن أردت) ---------- */
.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 49;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition), visibility var(--transition);
}

.sheet-overlay.open {
  opacity: 1;
  visibility: visible;
}

/* ---------- Tracking Container ---------- */
.tracking-container {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 60;
  display: flex;
  flex-direction: column;
  visibility: hidden;
  opacity: 0;
  transition: opacity var(--transition), visibility var(--transition);
}

.tracking-container.open {
  visibility: visible;
  opacity: 1;
}

/* hidden الأولي فقط يخفي بصرياً، لكن يبقى في التدفق حتى لا يتعارض مع open */
.tracking-container.hidden {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.tracking-map {
  flex: 1;
  background: #dbeafe;
}

.tracking-status-card {
  padding: 20px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  text-align: center;
  flex-shrink: 0;
}

/* ---------- Loading & Empty States ---------- */
.loading-spinner {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 40px;
  color: var(--text-secondary);
}

/* ---------- Toast ---------- */
.toast-container {
  position: fixed;
  top: calc(20px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

/* ---------- Animations ---------- */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- Accessibility ---------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ---------- Noscript ---------- */
.noscript-warning {
  background: var(--danger);
  color: #fff;
  padding: 16px;
  text-align: center;
  font-weight: 700;
}

/* ---------- Responsive (Tablet/Desktop) ---------- */
@media (min-width: 768px) {
  body {
    background: #E8ECF1;
    display: flex;                /* تمت الإضافة */
    align-items: center;
    justify-content: center;
  }

  .app-wrapper {
    max-width: 500px;
    height: 90vh;
    border-radius: 32px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.25), inset 0 0 0 1px rgba(255, 255, 255, 0.1);
    overflow: hidden;
  }

  .bottom-sheet {
    left: 50%;
    transform: translate(-50%, 100%);
    max-width: 500px;
  }

  .bottom-sheet.open,
  .bottom-sheet:not(.hidden) {
    transform: translate(-50%, 0);
  }

  .tracking-container {
    max-width: 500px;
    left: 50%;
    transform: translateX(-50%);
  }
  .tracking-container.open {
    transform: translateX(-50%);
  }
}