/* ============================================================================
 * shared/common.css
 * نظام التصميم الموحد العصري الزاهي (Vibrant Modern Q-Commerce RTL UI System)
 * ============================================================================ */

@import url("https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800;900&display=swap");

:root {
  /* لوحة الألوان العصرية الزاهية */
  --primary: #00a884;
  --primary-hover: #009172;
  --primary-dark: #007960;
  --primary-soft: #e6fcf5;
  --primary-ring: rgba(0, 168, 132, 0.25);
  --primary-gradient: linear-gradient(135deg, #00c49a 0%, #00997a 55%, #0284c7 100%);

  --accent: #ff6b35;
  --accent-hover: #f2551d;
  --accent-soft: #fff2eb;
  --accent-gradient: linear-gradient(135deg, #ff7e47 0%, #ff5722 100%);

  --violet: #7c3aed;
  --violet-soft: #f3e8ff;
  --violet-gradient: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);

  --bg: #f3f6fc;
  --surface: #ffffff;
  --surface-alt: #eef2f9;
  --text: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --border: #dde5f0;

  /* ألوان الحالات الزاهية */
  --success: #10b981;
  --success-soft: #d1fae5;
  --warning: #f59e0b;
  --warning-soft: #fef3c7;
  --danger: #f43f5e;
  --danger-soft: #ffe4e6;
  --info: #0ea5e9;
  --info-soft: #e0f2fe;

  /* الزوايا والظلال */
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-pill: 9999px;

  --shadow-xs: 0 2px 6px rgba(15, 23, 42, 0.05);
  --shadow-sm: 0 4px 14px rgba(15, 23, 42, 0.07);
  --shadow-md: 0 10px 28px rgba(15, 23, 42, 0.11);
  --shadow-lg: 0 18px 44px rgba(15, 23, 42, 0.16);

  /* المساحات الآمنة للهواتف الحديثة */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --header-height: 62px;
  --bottom-nav-height: 70px;

  /* الخطوط */
  --font-ar: "Cairo", -apple-system, BlinkMacSystemFont, "Segoe UI", Tahoma, sans-serif;

  /* طبقات Z-Index */
  --z-sticky: 20;
  --z-header: 30;
  --z-nav: 40;
  --z-backdrop: 50;
  --z-modal: 60;
  --z-toast: 100;
}

/* ============================================================================
 * Reset & Base (RTL Mobile-First)
 * ============================================================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  direction: rtl;
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-ar);
  background:
    radial-gradient(circle at 0% 0%, rgba(0, 196, 154, 0.08), transparent 40%),
    radial-gradient(circle at 100% 10%, rgba(124, 58, 237, 0.07), transparent 42%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.6;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
  color: inherit;
}

/* ============================================================================
 * App Shell Layout
 * ============================================================================ */
.app-shell {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  background: transparent;
  position: relative;
  display: flex;
  flex-direction: column;
}

.app-shell--wide {
  max-width: 1280px;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  min-height: calc(var(--header-height) + var(--safe-top));
  padding: calc(10px + var(--safe-top)) 16px 10px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(221, 229, 240, 0.9);
  box-shadow: 0 2px 12px rgba(15, 23, 42, 0.04);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.app-header__title {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 800;
  color: var(--text);
}

.app-content {
  flex: 1;
  padding: 16px;
  padding-bottom: calc(var(--bottom-nav-height) + var(--safe-bottom) + 22px);
}

.app-content--no-nav {
  padding-bottom: calc(24px + var(--safe-bottom));
}

/* ============================================================================
 * Bottom Navigation Bar (Vibrant Glass PWA Bar)
 * ============================================================================ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: calc(var(--bottom-nav-height) + var(--safe-bottom));
  padding: 6px 8px calc(6px + var(--safe-bottom));
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid rgba(221, 229, 240, 0.95);
  box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: var(--z-nav);
}

.bottom-nav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 48px;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: var(--radius-md);
  transition: color 0.18s ease, background-color 0.18s ease, transform 0.15s ease;
  position: relative;
}

.bottom-nav__item.is-active {
  color: var(--primary-dark);
  background: var(--primary-soft);
  font-weight: 800;
}

.bottom-nav__item:active {
  transform: scale(0.94);
}

.bottom-nav__badge {
  position: absolute;
  top: 2px;
  left: 50%;
  transform: translateX(-16px);
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--accent-gradient);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(255, 107, 53, 0.4);
}

/* ============================================================================
 * Buttons (Vibrant Gradients + 44px+ Touch Targets)
 * ============================================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-weight: 800;
  font-size: 0.94rem;
  transition: filter 0.18s ease, transform 0.12s ease, box-shadow 0.18s ease, opacity 0.18s ease;
  user-select: none;
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.52;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary-gradient);
  color: #ffffff;
  box-shadow: 0 6px 16px rgba(0, 168, 132, 0.28);
}
.btn-primary:hover:not(:disabled) {
  filter: brightness(1.04);
  box-shadow: 0 8px 20px rgba(0, 168, 132, 0.34);
}

.btn-accent {
  background: var(--accent-gradient);
  color: #ffffff;
  box-shadow: 0 6px 16px rgba(255, 107, 53, 0.3);
}
.btn-accent:hover:not(:disabled) {
  filter: brightness(1.04);
}

.btn-violet {
  background: var(--violet-gradient);
  color: #ffffff;
  box-shadow: 0 6px 16px rgba(124, 58, 237, 0.28);
}

.btn-secondary {
  background: var(--surface-alt);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) {
  background: #e2e8f4;
}

.btn-outline {
  background: #ffffff;
  color: var(--primary-dark);
  border: 1.5px solid var(--primary);
}
.btn-outline:hover:not(:disabled) {
  background: var(--primary-soft);
}

.btn-danger {
  background: linear-gradient(135deg, #f43f5e, #e11d48);
  color: #ffffff;
  box-shadow: 0 5px 14px rgba(244, 63, 94, 0.28);
}

.btn-danger-soft {
  background: var(--danger-soft);
  color: #e11d48;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-sm {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
}

.btn-block {
  width: 100%;
}

.btn-icon {
  width: 42px;
  height: 42px;
  min-height: 42px;
  padding: 0;
  border-radius: var(--radius-pill);
  background: var(--surface-alt);
  color: var(--text);
}

.btn.is-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}
.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255, 255, 255, 0.45);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ============================================================================
 * Cards & Surfaces
 * ============================================================================ */
.card {
  background: var(--surface);
  border: 1px solid rgba(221, 229, 240, 0.92);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-xs);
}

.card--interactive {
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}
.card--interactive:active {
  transform: scale(0.99);
}

/* ============================================================================
 * Dual Currency Price Display (USD + LBP)
 * ============================================================================ */
.price-dual {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.25;
}

.price-usd {
  font-size: 1.02rem;
  font-weight: 800;
  color: var(--primary-dark);
  direction: ltr;
  unicode-bidi: embed;
}

.price-lbp {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-muted);
}

/* ============================================================================
 * Form Controls + Coordinate Inputs
 * ============================================================================ */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.form-label {
  font-size: 0.87rem;
  font-weight: 800;
  color: var(--text);
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 0.94rem;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.textarea {
  min-height: 88px;
  resize: vertical;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-ring);
}

/* صندوق إدخال خطوط الطول والعرض السريع */
.coord-box {
  background: linear-gradient(135deg, #f0fdfa 0%, #eff6ff 100%);
  border: 1.5px solid #99f6e4;
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 12px;
}
.coord-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 8px;
}
.quick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.quick-chip {
  padding: 5px 11px;
  border-radius: var(--radius-pill);
  background: #ffffff;
  border: 1.5px solid var(--border);
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--text-secondary);
  transition: all 0.15s ease;
}
.quick-chip:hover,
.quick-chip.is-active {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary-dark);
}

/* حقل رقم الهاتف اللبناني +961 */
.phone-input-wrap {
  display: flex;
  align-items: center;
  direction: ltr;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.phone-input-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-ring);
}

.phone-input-prefix {
  padding: 0 12px;
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  background: var(--surface-alt);
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 0.92rem;
  border-right: 1px solid var(--border);
}

.phone-input-wrap input {
  flex: 1;
  border: none;
  outline: none;
  padding: 10px 12px;
  min-height: 46px;
  background: transparent;
  font-size: 1rem;
  letter-spacing: 0.4px;
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 52px;
  height: 28px;
  cursor: pointer;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: #cbd5e1;
  border-radius: var(--radius-pill);
  transition: background-color 0.22s ease;
}

.toggle-slider::before {
  content: "";
  position: absolute;
  height: 22px;
  width: 22px;
  left: 3px;
  bottom: 3px;
  background: #ffffff;
  border-radius: 50%;
  box-shadow: var(--shadow-xs);
  transition: transform 0.22s ease;
}

.toggle-switch input:checked + .toggle-slider {
  background: linear-gradient(135deg, #10b981, #00a884);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(24px);
}

/* ============================================================================
 * Status Badges & Pills (Vibrant)
 * ============================================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.77rem;
  font-weight: 800;
  white-space: nowrap;
}

.badge-pending {
  background: var(--warning-soft);
  color: #b45309;
}

.badge-preparing {
  background: var(--accent-soft);
  color: #ea580c;
}

.badge-ready {
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.badge-info,
.badge-on-the-way {
  background: var(--info-soft);
  color: #0284c7;
}

.badge-delivered {
  background: var(--success-soft);
  color: #047857;
}

.badge-cancelled {
  background: var(--danger-soft);
  color: #e11d48;
}

.badge-trial {
  background: linear-gradient(135deg, #ede9fe, #e0e7ff);
  color: #6d28d9;
  border: 1px solid #c4b5fd;
}

.badge-vip {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #92400e;
  border: 1px solid #fcd34d;
}

.badge-neutral {
  background: var(--surface-alt);
  color: var(--text-secondary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  background: currentColor;
}

/* ============================================================================
 * Bottom Sheet / Modal (Mobile-Native)
 * ============================================================================ */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.52);
  backdrop-filter: blur(4px);
  z-index: var(--z-backdrop);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

.sheet-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.bottom-sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translate(-50%, 100%);
  width: 100%;
  max-width: 480px;
  max-height: 92dvh;
  background: var(--surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: var(--shadow-lg);
  z-index: var(--z-modal);
  display: flex;
  flex-direction: column;
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  padding-bottom: var(--safe-bottom);
}

.bottom-sheet.is-open {
  transform: translate(-50%, 0);
}

.sheet-handle {
  width: 42px;
  height: 4px;
  background: #cbd5e1;
  border-radius: var(--radius-pill);
  margin: 10px auto 6px;
  flex-shrink: 0;
}

.sheet-body {
  padding: 14px 18px 22px;
  overflow-y: auto;
}

/* ============================================================================
 * Toast Notifications
 * ============================================================================ */
.toast-container {
  position: fixed;
  top: calc(14px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 440px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: var(--z-toast);
  pointer-events: none;
}

.toast {
  background: #1e293b;
  color: #ffffff;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 700;
  box-shadow: var(--shadow-md);
  pointer-events: auto;
  animation: toastSlideIn 0.22s ease forwards;
}

.toast--success {
  background: linear-gradient(135deg, #059669, #00a884);
}
.toast--error {
  background: linear-gradient(135deg, #e11d48, #be123c);
}
.toast--warning {
  background: linear-gradient(135deg, #d97706, #ea580c);
}

/* ============================================================================
 * Skeleton Loaders & Empty States
 * ============================================================================ */
.skeleton {
  background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.35s infinite;
  border-radius: var(--radius-md);
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-state__icon {
  font-size: 2.7rem;
  margin-bottom: 10px;
}

.empty-state__title {
  margin: 0 0 6px;
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 800;
}

/* ============================================================================
 * Utilities
 * ============================================================================ */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.85rem; }
.text-xs { font-size: 0.76rem; }
.font-bold { font-weight: 700; }
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hidden { display: none !important; }

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

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

@keyframes toastSlideIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}
