/* ==========================================
   رادار — CSS الرئيسي (Apple Design Style)
   ========================================== */
@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;600;700;800&display=swap');

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

:root {
  --primary: #007AFF;
  --primary-dark: #0051D5;
  --primary-light: #E5F0FF;
  --accent: #007AFF;
  --accent-light: #E5F0FF;
  --green: #34C759;
  --green-light: #E8F8ED;
  --red: #FF3B30;
  --red-light: #FFF0EF;
  --blue: #007AFF;
  --blue-light: #E5F0FF;
  --amber: #FF9500;
  --amber-light: #FFF4E5;
  --bg: #F2F2F7;
  --white: #FFFFFF;
  --border: #E5E5EA;
  --text: #1C1C1E;
  --text2: #8E8E93;
  --text3: #AEAEB2;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 1px 4px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.08);
}

html { overflow-x: hidden; max-width: 100%; }
body {
  font-family: -apple-system, 'SF Arabic', 'Tajawal', sans-serif;
  direction: rtl;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  overflow-x: hidden;
  max-width: 100%;
}

a { text-decoration: none; color: inherit; }
button { font-family: -apple-system, 'SF Arabic', 'Tajawal', sans-serif; cursor: pointer; }
input, select, textarea { font-family: -apple-system, 'SF Arabic', 'Tajawal', sans-serif; }
img { max-width: 100%; }

/* ==========================================
   UTILITIES
   ========================================== */
.hidden { display: none !important; }
.loading { opacity: 0.6; pointer-events: none; }

/* وحدات إظهار/إخفاء حسب الشاشة */
.mobile-only { display: none !important; }
.desktop-only { display: block !important; }

/* ==========================================
   TOAST
   ========================================== */
#toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  background: rgba(28,28,30,0.9); color: #fff; padding: 12px 24px;
  border-radius: 30px; font-size: 13px; z-index: 9999;
  opacity: 0; transition: opacity 0.3s;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  white-space: nowrap; max-width: 90vw;
  pointer-events: none; backdrop-filter: blur(10px);
}
#toast.show { opacity: 1; }

/* ==========================================
   BUTTONS
   ========================================== */
.btn {
  padding: 10px 20px; border-radius: var(--radius);
  font-size: 14px; font-weight: 600; border: none;
  cursor: pointer; transition: all 0.15s; display: inline-flex;
  align-items: center; gap: 6px; font-family: -apple-system, 'SF Arabic', 'Tajawal', sans-serif;
}
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

/* نموذج إنشاء حساب — أكثر تراصاً لتجنّب التمرير داخل النافذة */
#show-register .form-group { margin-bottom: 7px; }
#show-register .form-label { margin-bottom: 2px; font-size: 12px; }
#show-register .form-control { padding: 6px 10px; font-size: 12px; }
#show-register .modal-title { margin-bottom: 6px; font-size: 15px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-dark { background: var(--primary); color: #fff; }
.btn-dark:hover { background: var(--primary-dark); }
.btn-green { background: var(--green); color: #fff; }
.btn-green:hover { background: #28a745; }
.btn-outline { background: transparent; border: 1px solid currentColor; }
.btn-ghost { background: transparent; color: var(--text2); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); }
.btn-wa { background: #25D366; color: #fff; }
.btn-wa:hover { background: #1da851; }
.btn-full { width: 100%; justify-content: center; }

/* ── إجراءات الطلب (أخضر) */
.btn-action-request { background: linear-gradient(135deg, #16a34a, #085041); color: #fff; border: none; }
.btn-action-request:hover { background: linear-gradient(135deg, #15803d, #063d30); color: #fff; }
.btn-action-request:focus-visible { outline: 2px solid #16a34a; outline-offset: 2px; }
.btn-action-request:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

/* ── إجراءات الإعلان (أزرق) */
.btn-action-listing { background: var(--primary); color: #fff; border: none; }
.btn-action-listing:hover { background: var(--primary-dark); color: #fff; }
.btn-action-listing:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn-action-listing:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

/* ==========================================
   TOPBAR
   ========================================== */
.topbar {
  background: rgba(255,255,255,0.92); color: var(--text);
  height: 56px; padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 100;
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
}
.logo {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; text-decoration: none;
}
.logo img { height: 34px; width: auto; object-fit: contain; filter: brightness(0) saturate(100%) invert(34%) sepia(99%) saturate(2000%) hue-rotate(200deg) brightness(103%); }
.nav { display: flex; gap: 4px; }
.nav-link {
  padding: 6px 14px; border-radius: var(--radius);
  font-size: 13px; color: var(--text2);
  cursor: pointer; transition: all 0.15s; font-weight: 500;
}
.nav-link:hover { background: var(--bg); color: var(--text); }
.nav-link.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.top-user-chip { min-width: 0; }
.top-wa-status {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 6px; border: 0; border-radius: 10px;
  background: rgba(142,142,147,0.12); color: var(--text2);
  font-size: 10px; font-weight: 700; line-height: 1;
  white-space: nowrap; cursor: pointer; transition: background 0.15s, color 0.15s;
}
.top-wa-status:hover { background: rgba(142,142,147,0.2); color: var(--text); }
.top-wa-status:disabled { opacity: 0.6; cursor: wait; }
.top-wa-status-dot {
  width: 7px; height: 7px; flex: 0 0 7px;
  border-radius: 50%; background: #A8A8AD;
  box-shadow: 0 0 0 2px rgba(142,142,147,0.12);
}
.top-wa-status.is-connected { background: var(--green-light); color: #1F7A35; }
.top-wa-status.is-connected .top-wa-status-dot {
  background: var(--green); box-shadow: 0 0 0 2px rgba(52,199,89,0.16);
}
.icon-btn-top {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--bg); border: none; color: var(--text2);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; cursor: pointer; position: relative;
  transition: background 0.15s;
}
.icon-btn-top:hover { background: var(--border); color: var(--text); }
.notif-dot {
  position: absolute; top: 6px; right: 6px;
  width: 8px; height: 8px; background: var(--red);
  border-radius: 50%; border: 2px solid var(--white);
}

/* ==========================================
   PAGES
   ========================================== */
.page { display: none; min-height: calc(100vh - 56px); }
.page.active { display: block; }

/* ==========================================
   CONTAINER
   ========================================== */
.container { max-width: 1100px; margin: 0 auto; padding: 0 20px; }

/* ==========================================
   HERO
   ========================================== */
.hero {
  background: var(--white); color: var(--text);
  padding: 48px 24px 40px; text-align: center;
  border-bottom: 1px solid var(--border);
}
.hero h1 { font-size: 34px; font-weight: 800; margin-bottom: 10px; color: var(--text); letter-spacing: -0.5px; }
.hero h1 span { color: var(--primary); }
.hero-logo { display: block; height: 90px; width: auto; object-fit: contain; margin: 0 auto 16px; filter: brightness(0) saturate(100%) invert(34%) sepia(99%) saturate(2000%) hue-rotate(200deg) brightness(103%); }
.hero p { font-size: 15px; color: var(--text2); margin-bottom: 28px; }
.search-bar {
  display: flex; max-width: 600px; margin: 0 auto;
  border-radius: var(--radius-lg); overflow: hidden;
  box-shadow: var(--shadow-md); border: 1px solid var(--border);
  background: var(--white);
}
.search-bar select {
  padding: 14px 12px; border: none;
  border-left: 1px solid var(--border); font-size: 13px;
  background: var(--bg); color: var(--text); outline: none; min-width: 120px;
  font-family: -apple-system, 'SF Arabic', 'Tajawal', sans-serif; font-weight: 600;
}
.search-bar input {
  flex: 1; padding: 14px 16px; border: none;
  font-size: 14px; color: var(--text); outline: none; background: var(--white);
}
.search-bar button {
  padding: 14px 22px; background: var(--primary); color: #fff;
  border: none; font-size: 14px; font-weight: 700;
  cursor: pointer; white-space: nowrap; transition: background 0.15s;
}
.search-bar button:hover { background: var(--primary-dark); }
.stats-row {
  background: var(--primary);
  display: flex; justify-content: center; gap: 48px; padding: 14px;
}
.stat { text-align: center; }
.stat .n { font-size: 20px; font-weight: 800; color: #fff; }
.stat .l { font-size: 11px; color: rgba(255,255,255,0.7); }

/* ==========================================
   SECTION
   ========================================== */
.section { padding: 28px 0; }
.sec-title {
  font-size: 18px; font-weight: 700; margin-bottom: 18px;
  display: flex; align-items: center; gap: 8px;
}
.sec-title::before {
  content: ''; display: block; width: 4px; height: 22px;
  background: var(--primary); border-radius: 2px;
}

/* ==========================================
   CATEGORIES
   ========================================== */
.cats-grid {
  display: grid; grid-template-columns: repeat(9, 1fr); gap: 10px;
}
.cat-card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px 8px;
  text-align: center; cursor: pointer; transition: all 0.2s;
  box-shadow: var(--shadow);
}
.cat-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.cat-icon { font-size: 28px; margin-bottom: 6px; }
.cat-icon img { width: 36px; height: 36px; object-fit: contain; }
.cat-name { font-size: 12px; font-weight: 600; color: var(--text); }
.cat-count { font-size: 11px; color: var(--text3); margin-top: 2px; }

/* كيف يعمل رادار */
.howit-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.howit-card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 22px;
  display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.howit-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 22px; }
.howit-title { font-size: 18px; font-weight: 800; margin-bottom: 8px; }
.howit-badge {
  display: inline-block; font-size: 11px; font-weight: 700;
  padding: 4px 10px; border-radius: 20px;
}
.howit-badge-seller { background: var(--primary-light); color: var(--primary); }
.howit-badge-buyer { background: var(--green-light); color: #1a7a3c; }
.howit-icon {
  width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 22px;
}
.howit-icon-seller { background: var(--primary-light); color: var(--primary); }
.howit-icon-buyer { background: var(--green-light); color: #1a7a3c; }

.howit-steps { display: flex; flex-direction: column; margin-bottom: 22px; }
.howit-step { display: flex; align-items: center; gap: 14px; position: relative; padding-bottom: 22px; }
.howit-step:last-child { padding-bottom: 0; }
.howit-step:not(:last-child)::before {
  content: ''; position: absolute; right: 13px; top: 28px;
  width: 1px; height: calc(100% - 6px); background: var(--border);
}
.howit-num {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; z-index: 1;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
}
.howit-num-seller { background: var(--primary); }
.howit-num-buyer { background: var(--green); }
.howit-text { font-size: 14px; font-weight: 600; }

.howit-btn {
  width: 100%; padding: 12px; border: none; border-radius: var(--radius);
  font-size: 14px; font-weight: 700; font-family: -apple-system, 'SF Arabic', 'Tajawal', sans-serif;
  cursor: pointer; color: #fff; transition: opacity 0.15s;
}
.howit-btn:hover { opacity: 0.88; }
.howit-btn-seller { background: var(--primary); }
.howit-btn-buyer { background: var(--green); }

.howit-note {
  margin-top: 16px; text-align: center; font-size: 12px; color: var(--text2);
  display: flex; align-items: center; justify-content: center; gap: 6px;
}

/* ==========================================
   FILTER BAR
   ========================================== */
.filter-bar {
  display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; align-items: center;
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 12px 16px;
  box-shadow: var(--shadow);
}
.chip {
  padding: 7px 16px; border-radius: 20px; font-size: 13px;
  border: 1px solid var(--border); background: var(--bg);
  color: var(--text2); cursor: pointer; transition: all 0.15s;
  white-space: nowrap; font-family: -apple-system, 'SF Arabic', 'Tajawal', sans-serif; font-weight: 500;
}
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.mini-select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  padding: 7px 32px 7px 14px; border-radius: 20px; font-size: 13px;
  border: 1px solid var(--border); background-color: var(--bg);
  color: var(--text2); font-weight: 600; cursor: pointer;
  font-family: -apple-system, 'SF Arabic', 'Tajawal', sans-serif; outline: none;
  transition: border-color 0.15s, color 0.15s, background-color 0.15s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238E8E93' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: left 10px center; background-size: 14px;
}
.mini-select:focus, .mini-select:hover { border-color: var(--primary); color: var(--text); background-color: var(--white); }

/* ==========================================
   PRODUCTS GRID
   ========================================== */
.products-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px;
}
.prod-card {
  background: var(--white); border: none;
  border-radius: var(--radius-lg); overflow: hidden;
  cursor: pointer; transition: all 0.2s;
  box-shadow: var(--shadow);
}
.prod-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.prod-img {
  height: 130px; display: flex; align-items: center;
  justify-content: center; font-size: 52px; background: var(--bg);
  overflow: hidden;
}
.prod-img img { width: 100%; height: 100%; object-fit: cover; }
.prod-body { padding: 12px; }
.prod-name { font-size: 13px; font-weight: 700; margin-bottom: 4px; line-height: 1.3; }
.prod-meta { font-size: 11px; color: var(--text3); margin-bottom: 8px; }
.prod-price { font-size: 18px; font-weight: 800; color: var(--primary); }
.prod-price .old { font-size: 12px; color: var(--text3); text-decoration: line-through; font-weight: 400; margin-right: 6px; }
.prod-footer { padding: 0 12px 12px; display: flex; gap: 6px; }
.msg-btn {
  flex: 1; display: flex; align-items: center; justify-content: center;
  gap: 5px; padding: 8px; background: var(--primary); color: #fff;
  border: none; border-radius: 8px; font-size: 12px; font-weight: 700;
  cursor: pointer; font-family: -apple-system, 'SF Arabic', 'Tajawal', sans-serif; transition: background 0.15s;
}
.msg-btn:hover { background: var(--primary-dark); }
.fav-btn {
  width: 34px; height: 34px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: var(--text3); cursor: pointer; transition: all 0.15s;
}
.fav-btn:hover { color: var(--red); border-color: var(--red); }
.fav-btn.active { color: var(--red); border-color: var(--red); background: var(--red-light); }
.wa-btn {
  width: 34px; height: 34px; border-radius: 8px; flex-shrink: 0;
  border: 1px solid var(--border); background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: #25D366; cursor: pointer; transition: all 0.15s;
}
.wa-btn:hover { background: #25D366; color: #fff; border-color: #25D366; }

/* ==========================================
   VIEW TOGGLE (زر تبديل العرض قائمة/شبكة)
   ========================================== */
.view-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.view-toggle-btn { padding: 7px 10px; border: none; background: var(--white); color: var(--text2); cursor: pointer; display: flex; align-items: center; font-size: 16px; transition: background 0.15s, color 0.15s; }
.view-toggle-btn.active { background: var(--primary); color: #fff; }
[data-theme="dark"] .view-toggle-btn { background: #1C1C1E; }
[data-theme="dark"] .view-toggle-btn.active { background: var(--primary); }

/* ==========================================
   BADGES
   ========================================== */
.badge {
  display: inline-block; font-size: 10px;
  padding: 2px 8px; border-radius: 6px; font-weight: 700;
}
.badge-new { background: var(--green-light); color: #1a7a3c; }
.badge-used { background: var(--amber-light); color: #a05c00; }
.badge-orig { background: var(--primary-light); color: var(--primary-dark); }

/* ==========================================
   AVATAR
   ========================================== */
.av {
  border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-weight: 700; flex-shrink: 0;
}
.av-blue { background: var(--primary-light); color: var(--primary-dark); }
.av-green { background: var(--green-light); color: #1a7a3c; }
.av-amber { background: var(--amber-light); color: #a05c00; }

/* ==========================================
   STATUS BADGES
   ========================================== */
.status-badge {
  font-size: 10px; padding: 3px 8px;
  border-radius: 6px; font-weight: 600;
}
.status-active { background: var(--green-light); color: #1a7a3c; }
.status-sold { background: var(--primary-light); color: var(--primary-dark); }
.status-pending { background: var(--amber-light); color: #a05c00; }

/* ==========================================
   FORMS
   ========================================== */
.form-group { margin-bottom: 16px; }
.form-label { font-size: 13px; font-weight: 600; margin-bottom: 6px; display: block; color: var(--text2); }
.form-control {
  width: 100%; padding: 10px 14px; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 13px; outline: none;
  background: var(--bg); color: var(--text); transition: border 0.15s;
  font-family: -apple-system, 'SF Arabic', 'Tajawal', sans-serif;
}
.form-control:focus { border-color: var(--primary); background: var(--white); }
textarea.form-control { resize: vertical; min-height: 90px; }
.radar-switch {
  appearance: none;
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: var(--border);
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}
.radar-switch::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: transform 0.2s;
}
.radar-switch:checked {
  background: var(--primary);
}
.radar-switch:checked::before {
  transform: translateX(20px);
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ==========================================
   MODAL
   ========================================== */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.4); z-index: 200;
  align-items: center; justify-content: center;
  padding: 20px; backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; }

/* عارض الصور (الصور المرفقة بالمحادثات) */
#img-viewer {
  display: none; position: fixed; inset: 0; z-index: 999;
  background: rgba(0,0,0,0.9);
  align-items: center; justify-content: center; cursor: pointer;
}
#img-viewer.open { display: flex; }
#img-viewer img { max-width: 90%; max-height: 90%; object-fit: contain; cursor: default; }
#img-viewer button {
  position: absolute; top: 16px; left: 16px; width: 40px; height: 40px;
  border-radius: 50%; background: rgba(255,255,255,0.15); color: #fff;
  border: none; font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.modal {
  background: var(--white); border-radius: 20px;
  padding: 24px; width: 100%; max-width: 460px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.modal-title {
  font-size: 18px; font-weight: 700; margin-bottom: 20px;
  display: flex; justify-content: space-between; align-items: center;
}
.modal-close {
  background: var(--bg); border: none; font-size: 18px;
  color: var(--text2); cursor: pointer; line-height: 1;
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--border); }

/* ==========================================
   CHAT
   ========================================== */
#page-chat .chat-wrap {
  display: flex; height: calc(100vh - 56px);
}
.chat-sidebar {
  width: 280px; border-left: 1px solid var(--border);
  background: var(--white); display: flex; flex-direction: column;
  flex-shrink: 0;
}
.chat-main {
  flex: 1; display: flex; flex-direction: column; background: var(--bg);
}
.conv-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; cursor: pointer;
  border-bottom: 1px solid var(--border); transition: background 0.1s;
}
.conv-item:hover, .conv-item.active { background: var(--bg); }
.conv-item.active { border-right: 3px solid var(--primary); }
.messages-area {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.msg-wrap { display: flex; flex-direction: column; }
.msg-wrap.me { align-items: flex-start; }
.msg-wrap.other { align-items: flex-end; }
.bubble {
  padding: 10px 14px; border-radius: 18px;
  font-size: 13px; line-height: 1.6; max-width: 65%;
}
.msg-wrap.me .bubble {
  background: var(--white); color: var(--text);
  border-bottom-right-radius: 4px; border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.msg-wrap.other .bubble {
  background: var(--primary); color: #fff;
  border-bottom-left-radius: 4px;
}
.msg-time { font-size: 10px; color: var(--text3); margin-top: 3px; }
.msg-input-row {
  background: var(--white); border-top: 1px solid var(--border);
  padding: 12px 16px; display: flex; align-items: center; gap: 8px;
}
.msg-input-row input {
  flex: 1; padding: 10px 16px; border: 1px solid var(--border);
  border-radius: 22px; font-size: 13px; outline: none;
  background: var(--bg); font-family: -apple-system, 'SF Arabic', 'Tajawal', sans-serif;
  transition: border-color 0.15s;
}
.msg-input-row input:focus { border-color: var(--primary); background: var(--white); }
.send-btn {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--primary); border: none; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; cursor: pointer; transition: background 0.15s;
}
.send-btn:hover { background: var(--primary-dark); }
.chat-back-btn {
  display: none;
  width: 36px; height: 36px; border-radius: 50%;
  border: none; background: var(--bg); color: var(--text);
  align-items: center; justify-content: center;
  font-size: 18px; cursor: pointer; flex-shrink: 0;
}

/* ==========================================
   DASHBOARD
   ========================================== */
.dash-layout {
  display: grid; grid-template-columns: 220px 1fr;
  min-height: calc(100vh - 56px);
}
.dash-sidebar {
  background: var(--white); border-left: 1px solid var(--border);
  padding: 16px 0;
  display: flex; flex-direction: column;
}
.dash-menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 20px; cursor: pointer; font-size: 13px;
  color: var(--text2); transition: all 0.15s;
  border-right: 3px solid transparent;
}
.dash-menu-item:hover { background: var(--bg); color: var(--text); }
.dash-menu-item.active {
  background: var(--primary-light); color: var(--primary);
  font-weight: 600; border-right-color: var(--primary);
}
.dash-menu-item i { font-size: 18px; }
.dash-content { padding: 24px; background: var(--bg); }
.dash-section { display: none; }
.dash-section.active { display: block; }
.dash-title { font-size: 20px; font-weight: 700; margin-bottom: 20px; }
.metrics {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 14px; margin-bottom: 24px;
}
.metric {
  background: var(--white); border: none;
  border-radius: var(--radius-lg); padding: 18px;
  box-shadow: var(--shadow);
}
.metric-label { font-size: 12px; color: var(--text2); margin-bottom: 6px; }
.metric-val { font-size: 26px; font-weight: 800; }
.metric-change { font-size: 11px; margin-top: 4px; }
.metric-change.up { color: var(--green); }
.dash-card {
  background: var(--white); border: none;
  border-radius: var(--radius-lg); padding: 18px;
  box-shadow: var(--shadow);
}
.dash-card-title {
  font-size: 14px; font-weight: 700; margin-bottom: 14px;
  display: flex; align-items: center; justify-content: space-between;
}
table { width: 100%; border-collapse: collapse; }
table th {
  font-size: 12px; font-weight: 600; color: var(--text2);
  text-align: right; padding: 10px 12px;
  border-bottom: 1px solid var(--border); background: var(--bg);
}
table td { font-size: 13px; padding: 11px 12px; border-bottom: 1px solid var(--border); }
table tr:last-child td { border-bottom: none; }
table tr:hover td { background: var(--bg); }

/* ==========================================
   MOBILE BOTTOM NAV
   ========================================== */
.bottom-nav {
  display: none; position: fixed; bottom: 0; left: 0; right: 0;
  background: rgba(255,255,255,0.92); border-top: 1px solid var(--border);
  z-index: 150; padding-bottom: env(safe-area-inset-bottom);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
}
.bnav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; padding: 8px 4px;
  cursor: pointer; color: var(--text3); font-size: 10px; gap: 2px;
  transition: color 0.15s;
}
.bnav-item.active { color: var(--primary); }
.bnav-item i { font-size: 22px; }
.bnav-add {
  width: 42px; height: 42px; background: var(--primary);
  border-radius: 50%; display: flex; align-items: center;
  justify-content: center; margin-top: -16px;
  box-shadow: 0 4px 14px rgba(0,122,255,0.4);
}

/* ==========================================
   ADD BANNER
   ========================================== */
.add-banner {
  background: linear-gradient(135deg, #16a34a, #085041);
  color: #fff; border-radius: var(--radius-lg); padding: 24px 28px;
  display: flex; align-items: center; justify-content: space-between;
  margin: 8px 0 28px; box-shadow: 0 4px 20px rgba(16,163,74,0.28);
}
.add-banner h3 { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.add-banner p { font-size: 13px; opacity: 0.85; }

/* ==========================================
   IMAGE UPLOAD
   ========================================== */
.img-upload {
  border: 2px dashed var(--border); border-radius: var(--radius-lg);
  padding: 32px; text-align: center; cursor: pointer; transition: all 0.2s;
}
.img-upload:hover { border-color: var(--primary); background: var(--primary-light); }

/* ==========================================
   FLOATING WHATSAPP SUPPORT BUTTON
   ========================================== */
#wa-support-float {
  position: fixed; bottom: calc(24px + var(--wa-offset, 0px)); left: 24px; z-index: 1000;
  width: 56px; height: 56px; border-radius: 50%;
  background: #25D366; color: #fff; text-decoration: none;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  transition: transform 0.15s, bottom 0.15s;
}
#wa-support-float:hover { transform: scale(1.08); }
#wa-support-float i { font-size: 30px; }
@media (max-width: 767px) {
  #wa-support-float { bottom: calc(16px + var(--wa-offset, 0px)); left: 16px; width: 50px; height: 50px; }
  #wa-support-float i { font-size: 26px; }
}

/* ==========================================
   PWA BANNER
   ========================================== */
#pwa-banner, #update-banner, #verify-email-banner {
  display: none; position: fixed; bottom: calc(0px + var(--banner-offset, 0px)); left: 0; right: 0;
  background: rgba(255,255,255,0.95); color: var(--text); padding: 14px 20px;
  z-index: 999; align-items: center; justify-content: space-between;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.1); border-top: 1px solid var(--border);
  backdrop-filter: blur(20px);
}

/* ==========================================
   ANIMATIONS
   ========================================== */
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.3s ease; }
.spin { animation: spin 1s linear infinite; }

/* ==========================================
   UTILITY CLASSES
   ========================================== */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-gap-8 { gap: 8px; }
.flex-gap-10 { gap: 10px; }
.flex-gap-12 { gap: 12px; }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }
.items-start { align-items: flex-start; }

.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.text-bold { font-weight: 700; }
.text-semibold { font-weight: 600; }
.text-muted { color: var(--text2); }
.text-subtle { color: var(--text3); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-primary { color: var(--primary); }
.text-center { text-align: center; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-4 { margin-bottom: 4px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.p-8 { padding: 8px; }
.p-12 { padding: 12px; }
.p-16 { padding: 16px; }
.px-12 { padding-left: 12px; padding-right: 12px; }

.bg-green-light { background: var(--green-light); }
.bg-blue-light { background: var(--blue-light); }
.bg-amber-light { background: var(--amber-light); }
.bg-red-light { background: var(--red-light); }
.bg-accent-light { background: var(--accent-light); }
.bg-bg { background: var(--bg); }

.rounded { border-radius: var(--radius); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-full { border-radius: 50%; }
.border { border: 1px solid var(--border); }

.info-box {
  border-radius: var(--radius); padding: 10px 14px;
  font-size: 12px; line-height: 1.7;
}
.info-box-blue { background: var(--blue-light); border: 1px solid #B5D4F4; color: var(--primary-dark); }
.info-box-green { background: var(--green-light); border: 1px solid #9FE1CB; color: #1a7a3c; }
.info-box-amber { background: var(--amber-light); border: 1px solid #FAC775; color: #a05c00; }
.info-box-red { background: var(--red-light); border: 1px solid #FBBBBB; color: #c0392b; }

.overflow-x-auto { overflow-x: auto; }
.overflow-hidden { overflow: hidden; }
.w-full { width: 100%; }
.max-w-fit { width: fit-content; }

.empty-state {
  text-align: center; padding: 40px 20px; color: var(--text2);
}
.empty-state i { font-size: 48px; display: block; margin-bottom: 12px; color: var(--border); }
.empty-state p { font-size: 14px; }
.empty-state-cell { text-align: center; padding: 20px; color: var(--text2); }

/* ==========================================
   CHAT MESSAGES
   ========================================== */
.msg-image {
  max-width: 240px; border-radius: 14px; overflow: hidden;
  cursor: pointer; margin: -4px;
}

/* ==========================================
   MOBILE FIXES
   ========================================== */
@media (min-width: 641px) {
  .bottom-nav { display: none !important; }
}

@media (max-width: 640px) {
  body { font-size: 13px; }

  .topbar { padding: 0 10px; height: 50px; gap: 6px; }
  .logo img { height: 26px; filter: brightness(0) saturate(100%) invert(34%) sepia(99%) saturate(2000%) hue-rotate(200deg) brightness(103%); }
  .nav { display: none !important; }
  .top-actions { gap: 4px; }
  .top-actions > div[data-auth="logged-in"] { gap: 4px; }
  .top-actions > div[data-auth="logged-in"] > .top-user-chip {
    display: flex; padding: 4px 6px !important; gap: 4px !important;
  }
  .top-user-chip [data-user-name] { max-width: 64px !important; }
  .top-wa-status { padding: 3px 5px; }
  .icon-btn-top { width: 44px; height: 44px; font-size: 16px; }

  .hero { padding: 20px 14px; }
  .hero h1 { font-size: 20px; line-height: 1.3; }
  .hero-logo { height: 60px; margin-bottom: 10px; }
  .hero p { font-size: 12px; margin-bottom: 16px; }
  .search-bar { flex-direction: column; border-radius: var(--radius-lg); }
  .search-bar select { border-left: none; border-bottom: 1px solid var(--border); width: 100%; min-width: unset; border-radius: 0; }
  .search-bar input { border-radius: 0; }
  .search-bar button { border-radius: 0; border-bottom-right-radius: var(--radius-lg); border-bottom-left-radius: var(--radius-lg); }
  /* الإحصائيات: شبكة 2×2 على الجوال — نص مقروء بحد أدنى 12px */
  .stats-row { display: grid !important; grid-template-columns: 1fr 1fr; gap: 8px; padding: 12px 10px; }
  .stat { flex: unset; min-width: unset; }
  .stat .n { font-size: 18px; }
  .stat .l { font-size: 12px; white-space: normal; overflow: visible; text-overflow: unset; }

  .cats-grid { grid-template-columns: repeat(3,1fr); gap: 6px; }
  .cat-card { padding: 8px 4px; }
  .cat-icon { font-size: 20px; margin-bottom: 4px; }
  .cat-icon img { width: 26px; height: 26px; }
  .cat-name { font-size: 10px; }

  .howit-grid { grid-template-columns: 1fr; gap: 10px; }
  .howit-card { padding: 16px; }
  .howit-head { margin-bottom: 16px; }
  .cat-count { display: none; }

  .products-grid { grid-template-columns: repeat(2,1fr); gap: 8px; }
  .prod-img { height: 90px; font-size: 34px; }
  .prod-body { padding: 8px; }
  .prod-name { font-size: 12px; }
  .prod-price { font-size: 15px; }
  .prod-meta { font-size: 10px; }
  .prod-footer { padding: 0 8px 8px; gap: 4px; }
  .msg-btn { font-size: 11px; padding: 6px; }

  .container { padding: 0 10px; }
  .section { padding: 16px 0; }
  .sec-title { font-size: 15px; margin-bottom: 12px; }
  .filter-bar { gap: 6px; margin-bottom: 12px; padding: 8px 10px; border-radius: var(--radius); }
  .chip { padding: 5px 10px; font-size: 11px; }
  .mini-select { padding: 5px 26px 5px 10px; font-size: 11px; background-position: left 8px center; background-size: 12px; }

  .add-banner { flex-direction: column; gap: 12px; padding: 16px; text-align: center; border-radius: var(--radius-lg); }
  .add-banner h3 { font-size: 15px; }
  .add-banner p { font-size: 12px; }

  .prod-detail-grid { grid-template-columns: 1fr !important; }
  .main-img { height: 220px; font-size: 70px; }
  .big-price { font-size: 22px; }
  .specs-grid { grid-template-columns: 1fr 1fr; }

  #page-chat.page { height: calc(100vh - 56px - 65px); min-height: unset; overflow: hidden; }
  #page-chat .chat-wrap {
    flex-direction: column !important; height: 100% !important;
    position: relative; overflow: hidden;
  }
  .chat-sidebar { width: 100% !important; height: 100%; max-height: none; border-left: none; border-bottom: none; }
  .chat-main { height: 100%; min-height: unset; display: none; }
  .messages-area { max-height: none; }

  #page-chat .chat-wrap.conv-open .chat-sidebar { display: none; }
  #page-chat .chat-wrap.conv-open .chat-main { display: flex; }
  .chat-back-btn { display: flex !important; }

  .dash-layout { grid-template-columns: 1fr !important; }
  .dash-sidebar { display: none !important; }
  .dash-content { padding: 12px; }
  .metrics { grid-template-columns: repeat(2,1fr); gap: 8px; margin-bottom: 16px; }
  .metric { padding: 12px; }
  .metric-val { font-size: 20px; }
  .metric-label { font-size: 11px; }
  .dash-title { font-size: 16px; margin-bottom: 14px; }
  .dash-card { padding: 14px; }
  .form-grid { grid-template-columns: 1fr !important; }
  table { font-size: 12px; }
  table th, table td { padding: 7px 6px; }

  .modal { padding: 18px; border-radius: 16px; }
  .modal-title { font-size: 16px; }

  .bottom-nav { display: flex !important; }

  #page-search .container > div { grid-template-columns: 1fr !important; }
  #page-search .container > div > div:first-child { display: none; }

  .related-grid { grid-template-columns: repeat(2,1fr); }
  #page-notifications { padding: 14px; }

  /* ── إخفاء أزرار الإضافة المكررة من رأس الصفحة — يبقى زر + فقط في الشريط السفلي */
  #topbar-add-btns { display: none !important; }
  /* ── إخفاء زر "أضف طلب" المكرر بجانب التبويبات — الـ CTA السياقي (add-banner) يكفي */
  #add-request-home-btn { display: none !important; }

  /* ── تسجيل الخروج: أيقونة فقط على الجوال لتوفير المساحة */
  .btn-logout-text { display: none; }
  #btn-logout { padding: 10px 8px; min-width: 44px; min-height: 44px; justify-content: center; }

  /* ── منع الـ zoom التلقائي في iOS (يحدث عند font-size < 16px) */
  .form-control, .search-bar input, .search-bar select,
  input[type="text"], input[type="email"], input[type="tel"],
  input[type="password"], input[type="number"], select, textarea {
    font-size: 16px;
  }
  #show-register .form-control { font-size: 16px !important; }

  /* ── touch targets محسّنة لشريط التنقل السفلي (44px+ وفق HIG) */
  .bnav-item { min-height: 56px; padding: 8px 2px; }
  .bnav-item span { font-size: 10px; margin-top: 1px; }

  /* ── مساحة آمنة أسفل الصفحة تتجاوز شريط التنقل */
  body { padding-bottom: calc(68px + env(safe-area-inset-bottom, 0px)); }

  /* ── إظهار/إخفاء حسب الشاشة */
  .mobile-only { display: block !important; }
  .desktop-only { display: none !important; }

  /* ── زر تبديل العرض: touch target 44px على الجوال */
  .view-toggle-btn { min-width: 44px; min-height: 44px; }

  /* ── بطاقة الطلب: تخطيط جوال — grid بدل flex-wrap */
  .req-card-actions { flex-direction: column !important; align-items: flex-start !important; gap: 10px !important; }
  .req-card .req-card-btns {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 44px;
    gap: 8px !important;
    width: 100%;
    align-items: center;
  }
  .req-card .req-card-owner {
    grid-column: 1 / -1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .req-card .req-card-wa,
  .req-card .req-card-msg {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding: 8px 6px !important;
    justify-content: center !important;
    white-space: nowrap !important;
    font-size: 12px;
  }
  .req-card .req-card-share {
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
  }
}

@media (max-width: 420px) {
  .top-wa-status-text { display: none; }
  .top-user-chip [data-user-name] { max-width: 52px !important; }
}

/* شاشات شديدة الضيق — بطاقة الطلب */
@media (max-width: 359px) {
  .req-card .req-card-btns {
    grid-template-columns: minmax(0, 1fr) 44px;
  }
  .req-card .req-card-owner {
    grid-column: 1;
    grid-row: 1;
  }
  .req-card .req-card-share {
    grid-column: 2;
    grid-row: 1;
  }
  .req-card .req-card-wa {
    grid-column: 1 / -1;
    grid-row: 2;
  }
  .req-card .req-card-msg {
    grid-column: 1 / -1;
    grid-row: 3;
  }
}

/* Tablet */
@media (max-width: 900px) and (min-width: 641px) {
  .products-grid { grid-template-columns: repeat(3,1fr); }
  .cats-grid { grid-template-columns: repeat(3,1fr); }
  .metrics { grid-template-columns: repeat(2,1fr); }
  .dash-layout { grid-template-columns: 180px 1fr; }
}

@media (max-width: 640px) {
  #mobile-dash-menu { display: block !important; margin-bottom: 14px; padding: 12px; }
}

/* ==========================================
   FAB BOTTOM SHEET — Mobile
   ========================================== */
/* Desktop: أخفِ وصف الخيارات */
.fab-option-desc { display: none; }

@media (max-width: 640px) {
  #fab-menu {
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    transform: none !important;
    width: 100% !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
    /* padding-bottom يتجاوز الشريط السفلي */
    padding: 0 16px calc(74px + env(safe-area-inset-bottom, 0px)) !important;
    border-radius: 20px 20px 0 0;
    background: var(--white);
    border-top: 1px solid var(--border);
    box-shadow: 0 -6px 24px rgba(0,0,0,0.12);
  }
  /* Drag handle في الأعلى */
  #fab-menu::before {
    content: '';
    display: block;
    width: 36px; height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 10px auto 6px;
    flex-shrink: 0;
  }
  /* رأس القائمة (عنوان + إغلاق) — مخفي على desktop، يظهر هنا */
  #fab-sheet-header { display: flex !important; margin-bottom: 2px; }
  /* بطاقات الخيارات */
  #fab-menu > [role="button"] {
    border-radius: var(--radius-lg) !important;
    padding: 14px 16px !important;
    box-shadow: none !important;
    background: var(--bg) !important;
    border: 1px solid var(--border) !important;
    white-space: normal !important;
    width: auto !important;
  }
  /* الأيقونة داخل بطاقة الخيار */
  #fab-menu > [role="button"] > div:first-child {
    width: 44px !important; height: 44px !important;
  }
  .fab-option-desc { display: block; }
}
[data-theme="dark"] #fab-menu { background: #1C1C1E; border-top-color: rgba(84,84,88,0.65); }
[data-theme="dark"] #fab-sheet-header { border-bottom-color: rgba(84,84,88,0.65); }
[data-theme="dark"] #fab-menu > [role="button"] { background: #2C2C2E !important; border-color: rgba(84,84,88,0.65) !important; }

/* ==========================================
   BOTTOM SHEET — Mobile Modal
   ========================================== */
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
@keyframes overlayFadeIn {
  from { background: rgba(0,0,0,0); }
  to { background: rgba(0,0,0,0.4); }
}

@media (max-width: 640px) {
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
    animation: none;
  }
  .modal-overlay.open {
    animation: overlayFadeIn 0.25s ease forwards;
  }
  .modal {
    border-radius: 20px 20px 0 0;
    max-height: 88vh;
    max-width: 100%;
    padding: 16px 18px 28px;
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
  }
  .modal-overlay.open .modal {
    animation: slideUp 0.32s cubic-bezier(0.32, 0.72, 0, 1);
  }
  .modal::before {
    content: '';
    display: block;
    width: 36px; height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 0 auto 16px;
  }
}

/* ==========================================
   DARK MODE (Apple System Dark)
   ========================================== */
/* الدارك مود الآن يدوي فقط (عبر السمة data-theme="dark" على <html>) بدل اتباع وضع الجهاز تلقائياً —
   يفتح المجال لإضافة زر تبديل يدوي للمستخدم مستقبلاً عبر JS: document.documentElement.setAttribute('data-theme','dark') */
:root[data-theme="dark"] {
  --bg: #000000;
  --white: #1C1C1E;
  --border: rgba(84,84,88,0.65);
  --text: #FFFFFF;
  --text2: rgba(235,235,245,0.6);
  --text3: rgba(235,235,245,0.3);
  --primary-light: #001F4D;
  --accent-light: #001F4D;
  --blue-light: #001F4D;
  --green-light: #0A2E18;
  --red-light: #2E0A09;
  --amber-light: #2E1C00;
  --shadow: 0 1px 4px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.4);
}

[data-theme="dark"] .topbar { background: rgba(28,28,30,0.92); }
[data-theme="dark"] .bottom-nav { background: rgba(28,28,30,0.92); }

[data-theme="dark"] .hero { background: #1C1C1E; }
[data-theme="dark"] .search-bar { background: #2C2C2E; }
[data-theme="dark"] .search-bar input { background: #2C2C2E; color: #FFFFFF; }
[data-theme="dark"] .search-bar select { background: #3A3A3C; color: #FFFFFF; border-left-color: rgba(84,84,88,0.65); }

[data-theme="dark"] .filter-bar { background: #1C1C1E; }
[data-theme="dark"] .chip { background: #2C2C2E; color: rgba(235,235,245,0.6); }
[data-theme="dark"] .mini-select { background-color: #2C2C2E; color: rgba(235,235,245,0.6); }
[data-theme="dark"] .mini-select:focus, [data-theme="dark"] .mini-select:hover { background-color: #3A3A3C; color: #FFFFFF; }

[data-theme="dark"] .cat-card { background: #1C1C1E; border-color: rgba(84,84,88,0.65); }
[data-theme="dark"] .howit-card { background: #1C1C1E; border-color: rgba(84,84,88,0.65); }
[data-theme="dark"] .brand-row-logo { background: #FFFFFF; border-color: rgba(84,84,88,0.65); }
[data-theme="dark"] .brand-popover { background: #1C1C1E; border-color: rgba(84,84,88,0.65); }
[data-theme="dark"] .brand-text-item { color: rgba(235,235,245,0.8); }
[data-theme="dark"] .brand-text-item:hover { background: #2C2C2E; }
[data-theme="dark"] .prod-card { background: #1C1C1E; }
[data-theme="dark"] .prod-img { background: #2C2C2E; }

[data-theme="dark"] .form-control { background: #2C2C2E; color: #FFFFFF; border-color: rgba(84,84,88,0.65); }
[data-theme="dark"] .form-control:focus { background: #3A3A3C; border-color: var(--primary); }

[data-theme="dark"] .modal { background: #1C1C1E; }
[data-theme="dark"] .modal-close { background: #2C2C2E; color: rgba(235,235,245,0.6); }
[data-theme="dark"] .modal-close:hover { background: #3A3A3C; }
[data-theme="dark"] .modal::before { background: rgba(84,84,88,0.65); }

[data-theme="dark"] .chat-sidebar { background: #1C1C1E; }
[data-theme="dark"] .chat-main { background: #000000; }
[data-theme="dark"] .msg-wrap.me .bubble { background: #2C2C2E; border-color: rgba(84,84,88,0.65); color: #FFFFFF; }
[data-theme="dark"] .msg-input-row { background: #1C1C1E; border-top-color: rgba(84,84,88,0.65); }
[data-theme="dark"] .msg-input-row input { background: #2C2C2E; color: #FFFFFF; border-color: rgba(84,84,88,0.65); }
[data-theme="dark"] .msg-input-row input:focus { background: #3A3A3C; border-color: var(--primary); }

[data-theme="dark"] .dash-sidebar { background: #1C1C1E; border-left-color: rgba(84,84,88,0.65); }
[data-theme="dark"] .dash-content { background: #000000; }
[data-theme="dark"] .dash-card, [data-theme="dark"] .metric { background: #1C1C1E; }
[data-theme="dark"] table th { background: #2C2C2E; }
[data-theme="dark"] table tr:hover td { background: #2C2C2E; }

[data-theme="dark"] .fav-btn, [data-theme="dark"] .wa-btn { background: #2C2C2E; border-color: rgba(84,84,88,0.65); }
[data-theme="dark"] .icon-btn-top { background: #2C2C2E; color: rgba(235,235,245,0.6); }
[data-theme="dark"] .icon-btn-top:hover { background: #3A3A3C; color: #FFFFFF; }
[data-theme="dark"] .btn-ghost { border-color: rgba(84,84,88,0.65); color: rgba(235,235,245,0.6); }
[data-theme="dark"] .btn-ghost:hover { background: #2C2C2E; }
[data-theme="dark"] .img-upload { border-color: rgba(84,84,88,0.65); }
[data-theme="dark"] .img-upload:hover { border-color: var(--primary); background: #001F4D; }

[data-theme="dark"] #pwa-banner, [data-theme="dark"] #update-banner, [data-theme="dark"] #verify-email-banner { background: rgba(28,28,30,0.97); color: #FFFFFF; border-top-color: rgba(84,84,88,0.65); }
[data-theme="dark"] #toast { background: rgba(44,44,46,0.95); }

[data-theme="dark"] .nav-link:hover { background: #2C2C2E; color: #FFFFFF; }
[data-theme="dark"] .nav-link.active { background: #001F4D; color: var(--primary); }
[data-theme="dark"] .conv-item:hover, [data-theme="dark"] .conv-item.active { background: #2C2C2E; }
[data-theme="dark"] .dash-menu-item:hover { background: #2C2C2E; color: #FFFFFF; }
[data-theme="dark"] .dash-menu-item.active { background: #001F4D; color: var(--primary); }

[data-theme="dark"] .info-box-blue { background: #001F4D; border-color: rgba(0,122,255,0.4); color: #7AB5FF; }
[data-theme="dark"] .info-box-green { background: #0A2E18; border-color: rgba(52,199,89,0.4); color: #30D158; }
[data-theme="dark"] .info-box-amber { background: #2E1C00; border-color: rgba(255,149,0,0.4); color: #FF9F0A; }
[data-theme="dark"] .info-box-red { background: #2E0A09; border-color: rgba(255,59,48,0.4); color: #FF6961; }

/* ===== FOOTER ===== */
.site-footer {
  background: var(--white);
  border-top: 1px solid var(--border);
  margin-top: 40px;
  padding: 28px 20px 80px;
}
.footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}
.footer-brand img { opacity: 0.85; }
.footer-brand p { font-size: 12px; color: var(--text3); margin-top: 4px; }
.footer-links { display: flex; gap: 20px; flex-wrap: wrap; }
.footer-links a {
  font-size: 13px;
  color: var(--text2);
  cursor: pointer;
  text-decoration: none;
}
.footer-links a:hover { color: var(--primary); }
.footer-copy { font-size: 12px; color: var(--text3); }

#fee-calc-input::-webkit-inner-spin-button,
#fee-calc-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
#fee-calc-input { -moz-appearance: textfield; }

/* ===== STARS ===== */
.stars-display { display:inline-flex; gap:2px; }
.star-filled { color:#F5A623; }
.star-empty { color:var(--border); }

/* ===== RATING MODAL EXTRAS ===== */
#rating-purchased-yes.active { background: var(--green) !important; color: #fff !important; border-color: var(--green) !important; }
#rating-purchased-no.active { background: var(--red) !important; color: #fff !important; border-color: var(--red) !important; }
.rating-badges-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.rating-badge-card {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 4px 5px; border-radius: var(--radius); border: 1.5px solid var(--border);
  background: var(--bg); cursor: pointer; transition: all 0.15s;
}
.rating-badge-card:hover { border-color: var(--primary); }
.rating-badge-card.active {
  background: linear-gradient(160deg, #FFF8E1, #FFECB3);
  border-color: var(--amber);
  box-shadow: 0 2px 8px rgba(245,166,35,0.25);
}
.rating-badge-medal {
  width: 26px; height: 26px; border-radius: 50%; background: var(--white);
  border: 1px solid var(--border); display: flex; align-items: center; justify-content: center;
  font-size: 13px; box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.rating-badge-card.active .rating-badge-medal { border-color: var(--amber); background: #FFFBEB; }
.rating-badge-label { font-size: 10px; font-weight: 600; color: var(--text2); }
.rating-badge-card.active .rating-badge-label { color: #8A6200; font-weight: 700; }
.rating-badge-info {
  position: absolute; top: 4px; left: 4px; width: 16px; height: 16px; border-radius: 50%;
  background: rgba(0,0,0,0.08); color: var(--text2); font-size: 11px; line-height: 16px;
  text-align: center; cursor: pointer; z-index: 2;
}
.rating-badge-info:hover { background: var(--primary); color: #fff; }
#rating-badge-tooltip {
  position: fixed; background: var(--text); color: #fff; font-size: 12px; padding: 8px 12px;
  border-radius: var(--radius); max-width: 220px; z-index: 9999; text-align: center;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
}

/* ===== BRAND LOGO FILTER ===== */
.brand-filter-wrap { position: relative; display: inline-block; }
.brand-filter-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background-image: none !important;
}
.brand-btn-logo {
  width: 18px; height: 18px; border-radius: 4px; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.brand-btn-logo img { width: 100%; height: 100%; object-fit: contain; filter: grayscale(1); }
.brand-popover {
  position: absolute; top: calc(100% + 6px); right: 0;
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: 0 8px 30px rgba(0,0,0,0.15);
  padding: 6px; width: 180px; max-height: 320px; overflow-y: auto;
  z-index: 300;
}
.brand-text-item {
  padding: 9px 12px; border-radius: var(--radius); cursor: pointer;
  font-size: 13px; color: var(--text);
}
.brand-text-item:hover { background: var(--bg); }
.brand-text-item.active { background: var(--primary-light); color: var(--primary); font-weight: 700; }

/* ===== BRANDS ROW (home page) ===== */
.brands-row { display: flex; gap: 14px; overflow-x: auto; padding: 4px 2px 10px; -webkit-overflow-scrolling: touch; }
.brand-row-card { flex: 0 0 auto; width: 80px; text-align: center; cursor: pointer; }
.brand-row-logo {
  width: 64px; height: 64px; border-radius: 50%; background: var(--white);
  border: 1px solid var(--border); display: flex; align-items: center; justify-content: center;
  margin: 0 auto 6px; overflow: hidden; transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}
.brand-row-card:hover .brand-row-logo { border-color: var(--primary); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.brand-row-logo img { width: 76%; height: 76%; object-fit: contain; mix-blend-mode: multiply; }
.brand-row-logo span { font-size: 13px; font-weight: 700; color: var(--text2); }
.brand-row-name { font-size: 11px; font-weight: 600; color: var(--text); white-space: nowrap; }

/* ===== ADD REQUEST — ADVANCED OPTIONS SECTION ===== */
.ar-advanced-section {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 4px;
  background: var(--bg);
  overflow: hidden;
}
.ar-advanced-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  list-style: none;
  user-select: none;
}
.ar-advanced-summary::-webkit-details-marker { display: none; }
.ar-advanced-section[open] .ar-adv-chevron { transform: rotate(180deg); }
.ar-adv-chevron { transition: transform 0.2s; }
.ar-advanced-section > div { padding: 0 14px 14px; }
[data-theme="dark"] .ar-advanced-section { background: #1C1C1E; }

/* ── إحصائيات واتساب ─────────────────────────────────────────── */
.wa-stat-card {
  background: var(--bg); border-radius: var(--radius-lg);
  padding: 12px 14px; text-align: center;
  border: 1px solid var(--border);
}
.wa-stat-num  { font-size: 22px; font-weight: 800; }
.wa-stat-label { font-size: 11px; color: var(--text2); margin-top: 4px; }
[data-theme="dark"] .wa-stat-card { background: #2C2C2E; border-color: rgba(84,84,88,0.5); }
