/* ================= ROOT VARIABLES ================= */
:root {
  --primary: #3498db;
  --secondary: #2c3e50;
  --accent: #e74c3c;
  --success: #27ae60;
  --warning: #f39c12;
  --danger: #e74c3c;
  --light: #ecf0f1;
  --dark: #2c3e50;
  --gray: #95a5a6;
  --light-gray: #f8f9fa;
  --border: #ddd;
  --shadow: rgba(0,0,0,0.1);
  --radius: 10px;
  --transition: all 0.3s ease;
}

/* ================= ضبط نهائي لموضع وحجم أيقونة حذف صورة البروفايل على الجوال (أولوية قصوى) ================ */
@media (max-width: 480px) {
  /* parent containers: مرجع التموضع والسماح بخروج الأيقونة خارج الدائرة */
  .account-avatar-wrapper,
  .account-avatar-inner,
  .account-avatar {
    position: relative !important;
    display: block !important;
    overflow: visible !important;
  }

  /* الأيقونة: خارج حدود الدائرة (أسفل يسار) بحجم صغير ثابت */
  .avatar-delete-btn {
    position: absolute !important;
    top: auto !important;
    right: auto !important;
    left: -15px !important;
    bottom: -8px !important;
    transform: none !important;
    margin: 0 !important;
    width: 20px !important;
    height: 20px !important;
    min-width: 20px !important;
    min-height: 20px !important;
    border-radius: 50% !important;
    background: #fff !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2) !important;
    z-index: 10 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .avatar-delete-btn i {
    width: 10px !important;
    height: 10px !important;
    font-size: 10px !important;
  }
}

/* ================= RESET & BASE ================= */
/* كود التمريض: منع تجاوز عرض الشاشة (يُطبَّق على صفحة إضافة الإعلان في الجوال عبر media query) */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

html {
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  box-sizing: border-box;
  background: var(--light); /* توحيد لون الخلفية */
  min-height: 100vh; /* ضمان تغطية كامل الارتفاع */
  font-size: 22px; /* خط أكبر للموقع بالكامل */
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Cairo', 'Tajawal', sans-serif;
  background: var(--light);
  color: var(--dark);
  font-size: 1rem;
  line-height: 1.6;
  margin: 0;
  padding: 0;
  padding-right: 118px; /* مساحة لشريط التنقل الجانبي */
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  min-height: 100vh; /* ضمان تغطية كامل الارتفاع */
  display: flex; /* جعل الجسم حاوية Flex رأسية لكل الصفحات */
  flex-direction: column;
  font-weight: 500; /* جعل الخط أوضح قليلاً */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

.page {
  display: none;
  animation: fadeIn 0.3s ease;
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  background: var(--light); /* توحيد لون الخلفية مع body */
  min-height: 100vh; /* ضمان تغطية كامل الارتفاع */
}

/* مبدأ المرونة: حاويات متجاوبة — منع خروج أي عنصر عن حدود الشاشة */
.content-area,
.add-ad-container,
.add-ad-card,
.ads-container,
.details-card,
.site-footer,
.footer-container {
  max-width: 100%;
  box-sizing: border-box;
}
.content-area { width: 100%; }
.add-ad-container { width: 100%; }
.add-ad-card { width: 100%; }
.ads-container { width: 100%; }

.page.active {
  display: block;
}

/* إخفاء صفحة حسابي بشكل صارم عند عدم النشاط */
#account-page:not(.active) {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  height: 0 !important;
  overflow: hidden !important;
  position: absolute !important;
  top: -9999px !important;
  width: 0 !important;
  flex-grow: 0 !important;
  flex-shrink: 0 !important;
}

/* استثناء صفحة حسابي - لا تستخدم flexbox مثل صفحة المحادثة */
#account-page.active {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  height: auto !important;
  min-height: 100vh !important; /* توحيد سلوك صفحة حسابي مع بقية الصفحات */
  overflow: visible !important;
  position: relative !important;
  top: 0 !important;
  width: 100% !important;
}

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

/* ================= HEADER ================= */
.header {
  background: white;
  padding: 15px 20px;
  padding-top: calc(15px + env(safe-area-inset-top));
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 100%;
  margin: 0;
  box-sizing: border-box;
  box-shadow: 0 2px 10px var(--shadow);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.header-left {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
}

/* إخفاء الشريط العلوي من جميع الصفحات ما عدا الصفحة الرئيسية */
.header.hidden {
  display: none !important;
}

.header-back-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 8px 12px;
  margin-left: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.header-back-btn:hover {
  color: #2980b9;
}

.header h1 {
  flex: 1;
  font-size: 1.5rem;
  color: var(--primary);
  margin: 0;
  font-weight: 600;
  text-align: center;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.header-actions {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 15px;
  min-width: 0;
}

/* غلاف الأيقونة في الهيدر — يفك ارتباطها عن flex ويسمح بالتحريك بـ position */
.header-actions .btn-icon {
  position: absolute !important;
  top: 50% !important;
  right: 10px !important;
  transform: translateY(-50%) !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  margin: 0 !important;
  pointer-events: none;
}
.header-actions .btn-text {
  display: inline-block;
  margin: 0;
}

/* زر تسجيل الدخول - أزرق فاتح */
.auth-status-btn,
.auth-register-btn,
.admin-btn,
.auth-logout-btn {
  position: relative !important;
  padding-right: 36px !important; /* مساحة للأيقونة من اليمين (بدون تداخل مع النص) */
  padding-left: 20px !important;
}
.auth-status-btn {
  background-color: #3498db !important; /* أزرق فاتح */
  color: black !important;
  border: none !important;
  padding: 10px 20px;
  padding-right: 36px !important;
  border-radius: 25px;
  cursor: pointer;
  display: flex !important;
  align-items: center !important;
  gap: 10px;
  font-weight: 600;
  font-size: 0.95rem;
  transition: all 0.3s ease !important;
  box-shadow: 0 2px 5px rgba(52, 152, 219, 0.2);
  min-width: 120px;
  justify-content: center !important;
}

.auth-status-btn:hover {
  background-color: #2980b9 !important; /* أزرق داكن عند التمرير */
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(52, 152, 219, 0.3);
}

/* زر تسجيل الخروج - أحمر فاتح */
.auth-status-btn.logged-in {
  background-color: #e74c3c !important; /* أحمر فاتح */
  box-shadow: 0 2px 5px rgba(231, 76, 60, 0.2);
}

.auth-status-btn.logged-in:hover {
  background-color: #c0392b !important; /* أحمر داكن عند التمرير */
  box-shadow: 0 4px 8px rgba(231, 76, 60, 0.3);
}

/* زر إنشاء حساب - أخضر */
.auth-register-btn {
  background-color: #27ae60 !important; /* أخضر */
  color: black !important;
  border: none !important;
  padding: 10px 20px;
  padding-right: 36px !important;
  border-radius: 25px;
  cursor: pointer;
  display: flex !important;
  align-items: center !important;
  gap: 10px;
  font-weight: 600;
  font-size: 0.95rem;
  transition: all 0.3s ease !important;
  box-shadow: 0 2px 5px rgba(39, 174, 96, 0.2);
  min-width: 120px;
  justify-content: center !important;
}

.auth-register-btn:hover {
  background-color: #229954 !important; /* أخضر داكن عند التمرير */
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(39, 174, 96, 0.3);
}

/* زر تسجيل الخروج - أحمر */
.auth-logout-btn {
  background-color: #e74c3c !important; /* أحمر فاتح */
  color: white !important;
  border: none !important;
  padding: 10px 20px;
  border-radius: 25px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 0.95rem;
  transition: all 0.3s ease !important;
  box-shadow: 0 2px 5px rgba(231, 76, 60, 0.2);
  min-width: 120px;
  justify-content: center;
}

.auth-logout-btn:hover {
  background-color: #c0392b !important; /* أحمر داكن عند التمرير */
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(231, 76, 60, 0.3);
}

/* منع تمطط أيقونة تسجيل الخروج — أبعاد ثابتة ووضع contain */
.auth-logout-btn .btn-icon {
  width: 24px;
  height: 24px;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-shrink: 0;
}
.auth-logout-btn .btn-icon i {
  font-size: 1rem;
  object-fit: contain;
  display: inline-block;
}

/* إخفاء أزرار المصادقة حسب الحالة (تجاوز display: flex !important) */
.auth-status-btn.auth-hidden,
.auth-register-btn.auth-hidden,
.auth-logout-btn.auth-hidden {
  display: none !important;
}

.admin-btn {
  background: var(--warning);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 25px;
  cursor: pointer;
  display: none;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  transition: var(--transition);
}

.admin-btn:hover {
  background: #e67e22;
  transform: translateY(-2px);
}

/* ================= AUTH PAGE SWITCHER ================= */
.auth-switcher {
  display: flex;
  background: white;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 20px;
  box-shadow: 0 2px 10px var(--shadow);
}

.auth-switch-btn {
  flex: 1;
  padding: 15px;
  background: var(--light-gray);
  border: none;
  font-size: 1rem;
  font-weight: 600;
  color: black;
  cursor: pointer;
  transition: var(--transition);
}

.auth-switch-btn.active {
  background: var(--primary);
  color: black;
}

.auth-switch-btn:hover:not(.active) {
  background: #e8f4fc;
}

/* ================= HOME PAGE ================= */
.filters {
  background: white;
  padding: 15px;
  overflow-x: auto;
  display: flex;
  gap: 10px;
  white-space: nowrap;
  box-shadow: 0 2px 5px var(--shadow);
}

.filter-btn {
  padding: 10px 15px;
  background: var(--light-gray);
  border: 2px solid var(--border);
  border-radius: 25px;
  cursor: pointer;
  font-family: 'Almarai', 'Cairo', 'Tajawal', sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  color: #1a1a1a;
  letter-spacing: 0.3px;
  -webkit-font-smoothing: antialiased;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.filter-btn:hover {
  border-color: var(--primary);
}

.filter-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}


#filters-panel {
  background: white;
  padding: 20px;
  margin: 15px;
  border-radius: var(--radius);
  box-shadow: 0 2px 10px var(--shadow);
  display: none; /* مخفي افتراضياً، يظهر فقط عند اختيار شركة معينة */
}

.sub-top-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
}

.brand-dd-wrap,
.sort-dd-wrap,
.sort-options-wrap,
.mc-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  min-width: 200px;
}

.brand-dd-label,
.sort-dd-label,
.sort-options-label,
.mc-label {
  font-weight: 700;
  color: #1a1a1a;
  font-size: 1.05rem;
  -webkit-font-smoothing: antialiased;
}

.brand-dd-select,
.sort-dd-select,
.mc-select {
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: white;
  font-size: 1.08rem;
  font-weight: 600;
  color: #1a1a1a;
  cursor: pointer;
  transition: var(--transition);
  width: 100%;
  min-width: 200px;
  -webkit-font-smoothing: antialiased;
}

.brand-dd-select option,
.mc-select option {
  font-size: 1rem;
  font-weight: 600;
  padding: 10px;
}

/* سنة الصنع: حقلين من ـ الى */
.year-range-wrap .year-range-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.year-range-wrap .mc-select.year-from,
.year-range-wrap .mc-select.year-to {
  min-width: 90px;
  flex: 1;
}
.year-range-sep {
  font-weight: 700;
  color: var(--dark);
  font-size: 1rem;
}

/* تحسين قائمة اسم القطعة لتكون بنفس الحجم */
#scrapPartWrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  min-width: 200px;
}

#scrapPartDropdown {
  width: 100%;
  min-width: 200px;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: white;
  font-size: 1.08rem;
  font-weight: 600;
  color: #1a1a1a;
  cursor: pointer;
  transition: var(--transition);
  -webkit-font-smoothing: antialiased;
}

.brand-dd-select:hover,
.sort-dd-select:hover,
.mc-select:hover {
  border-color: var(--primary);
}

.sort-dropdown-toggle {
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: white;
  font-size: 1.08rem;
  font-weight: 600;
  color: #1a1a1a;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-width: 200px;
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
}

.sort-dropdown-toggle:hover {
  border-color: var(--primary);
}

.sort-dropdown-toggle i {
  font-size: 0.8rem;
  transition: var(--transition);
}

.sort-options-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 2px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 1000;
  margin-top: 5px;
  padding: 15px;
  display: none;
  max-height: 400px;
  overflow-y: auto;
}

.sort-options-dropdown.show {
  display: block;
}

.sort-options-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sort-options-row {
  display: flex;
  gap: 8px;
}

.sort-option-btn {
  flex: 1;
  padding: 10px 15px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  background: #f5f5f5;
  color: #1a1a1a;
  font-size: 1.02rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
  -webkit-font-smoothing: antialiased;
}

.sort-option-btn:hover {
  border-color: var(--primary);
  background: #e8f4f8;
}

.sort-option-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  font-weight: 600;
}

.search-wrap {
  padding: 15px;
}

.search-container {
  display: flex;
  background: white;
  border-radius: 50px;
  overflow: hidden;
  box-shadow: 0 4px 15px var(--shadow);
}

.search-input {
  flex: 1;
  padding: 15px 20px;
  border: none;
  outline: none;
  font-size: 1.08rem;
  font-weight: 600;
  color: #1a1a1a;
  -webkit-font-smoothing: antialiased;
}

.search-input::placeholder {
  color: #555;
  font-weight: 500;
}

.search-btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0 25px;
  cursor: pointer;
  transition: var(--transition);
}

.search-btn:hover {
  background: #2980b9;
}

/* ================= HOME PAGE ================= */
#home-page {
  background: var(--light); /* توحيد لون الخلفية */
  min-height: 100vh; /* ملء كامل الشاشة */
}

/* ================= ADS CONTAINER ================= */
.ads-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  padding: 20px;
  background: var(--light); /* توحيد لون الخلفية */
}

@media (max-width: 768px) {
  .ads-container {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 14px;
    padding: 14px;
  }
  
  .ad-img {
    aspect-ratio: 4 / 3;
    min-height: 140px;
  }
  
  .ad-title {
    font-size: 0.95rem;
  }
  
  .ad-price {
    font-size: 1.3rem;
  }
}

.ad-card {
  background: white;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  position: relative;
  border: 1px solid rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  font-family: 'Almarai', 'Cairo', 'Tajawal', sans-serif;
  min-height: 0;
}

.ad-card .ad-compare-checkbox {
  overflow: visible !important;
}

.ad-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15);
  border-color: rgba(74, 144, 226, 0.2);
}

/* منطقة الصورة: ارتفاع ثابت (4/3) — لا تتقلص لتبقى البطاقات متوازية */
.ad-img {
  aspect-ratio: 4 / 3;
  width: 100%;
  min-height: 160px;
  flex-shrink: 0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.ad-img::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(to bottom, transparent 0%, rgba(0, 0, 0, 0.1) 100%);
  z-index: 1;
  pointer-events: none; /* الأندرويد: عدم حجب النقر عن الأسهم */
}

.ad-img i {
  font-size: 3.5rem;
  color: white;
  opacity: 0.6;
  z-index: 2;
}

.ad-img img,
.ad-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
  z-index: 0;
  aspect-ratio: 4 / 3;
}

.ad-card:hover .ad-img img {
  transform: scale(1.1);
}

.ad-card:hover .ad-card-slider img {
  transform: none;
}

/* سلايدر صور البطاقة — منع التحديد والـ highlight عند النقر/اللمس */
.ad-card-slider,
.ad-card-slider-track,
.ad-card-slider-arrow {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  tap-highlight-color: transparent;
}
.ad-card-slider-arrow:focus {
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.ad-card-slider {
  position: relative;
  aspect-ratio: 4 / 3;
  width: 100%;
  min-height: 160px;
  flex-shrink: 0;
  overflow: hidden;
}

.ad-card-slider-track {
  position: relative;
  width: 100%;
  height: 100%;
}

.ad-card-slider-track img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.ad-card-slider-track img.active {
  opacity: 1;
  z-index: 1;
  pointer-events: auto;
}

/* أسهم السلايدر — تظهر فقط عند وجود أكثر من صورة (ad-card-slider-single يخفيها) */
.ad-card-slider-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.95);
  color: #1a1a1a;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
  pointer-events: auto;
  touch-action: manipulation;
}

.ad-card-slider-arrow:hover {
  background: #fff;
  transform: translateY(-50%) scale(1.1);
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.3);
}

.ad-card-slider-arrow:active {
  transform: translateY(-50%) scale(1.02);
}

.ad-card-slider-prev {
  right: 10px;
}

.ad-card-slider-next {
  left: 10px;
}

.ad-card-slider-arrow i {
  font-size: 1.1rem;
  color: #1a1a1a;
  display: block;
  line-height: 1;
}

/* إخفاء الأسهم عند صورة واحدة فقط */
.ad-card-slider-single .ad-card-slider-arrow {
  display: none;
}

/* على الجوال: منطقة لمس كافية ومحددة (44px) — على الجانبين فقط دون تداخل مع وسط البطاقة */
@media (max-width: 768px), (hover: none) {
  .ad-card-slider-arrow {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    z-index: 15;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
  }
  .ad-card-slider-prev {
    right: 10px;
    left: auto;
  }
  .ad-card-slider-next {
    left: 10px;
    right: auto;
  }
}

/* ========== خاص بالأندرويد وكروم: تعطيل الهالة والتظليل على البطاقة والأسهم ========== */
.ad-card,
.ad-card *,
.ad-card .ad-img,
.ad-card .ad-card-slider,
.ad-card .ad-card-slider-track,
.ad-card .ad-card-slider-arrow {
  -webkit-tap-highlight-color: transparent !important;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0) !important;
}
.ad-card .ad-img:active,
.ad-card .ad-card-slider:active,
.ad-card .ad-card-slider-track:active,
.ad-card button.ad-card-slider-arrow:active {
  -webkit-tap-highlight-color: transparent !important;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0) !important;
}
.ad-card .ad-img,
.ad-card .ad-card-slider,
.ad-card .ad-card-slider-track {
  pointer-events: auto;
}
.ad-card .ad-card-slider-arrow {
  pointer-events: auto !important;
}
.ad-card .ad-img::before,
.ad-card .ad-card-slider-track img:not(.active) {
  pointer-events: none !important;
}
/* إزالة تظليل الـ active الذي يظهر على أندرويد عند النقر (الحاويات فقط) */
.ad-card .ad-img:active,
.ad-card .ad-card-slider:active,
.ad-card .ad-card-slider-track:active {
  background-color: transparent !important;
}

/* مساحة محجوزة عند عدم وجود صورة — نفس أبعاد الصورة (4/3) */
.ad-card-placeholder {
  flex-shrink: 0;
}

.ad-card-placeholder i {
  font-size: 3rem;
  color: rgba(255, 255, 255, 0.5);
}

.ad-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
  color: white;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-family: 'Almarai', 'Cairo', 'Tajawal', sans-serif;
  font-weight: 800;
  z-index: 3;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ad-badge.used {
  background: linear-gradient(135deg, #FF9800 0%, #F57C00 100%);
}

/* حاوية المعلومات: تبدأ دائماً أسفل منطقة الصورة (نفس الارتفاع) لظهور الأسعار على خط أفقي واحد */
.ad-body {
  padding: 16px;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
}

.ad-price {
  color: var(--primary);
  font-size: 1.4rem;
  font-family: 'Almarai', 'Cairo', 'Tajawal', sans-serif;
  font-weight: 800;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1.2;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

.ad-price i {
  font-size: 1rem;
  opacity: 0.8;
}

.ad-title {
  font-size: 1rem;
  font-family: 'Almarai', 'Cairo', 'Tajawal', sans-serif;
  font-weight: 800;
  letter-spacing: 0.3px;
  margin-bottom: 12px;
  color: var(--dark);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.8em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

.ad-meta {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

/* لون خط بيانات البطاقة: اسم المعلن، نوع السيارة، المدينة، تاريخ الإعلان */
.ad-meta span {
  display: flex;
  align-items: center;
  gap: 5px;
  color: #374151;
  font-size: 0.85rem;
  font-family: 'Almarai', 'Cairo', 'Tajawal', sans-serif;
  font-weight: 700;
  letter-spacing: 0.3px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.ad-meta span i {
  color: var(--primary);
  font-size: 0.8rem;
  width: 16px;
  text-align: center;
}

.ad-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 10px;
}

.ad-favorite {
  color: var(--gray);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  cursor: pointer;
  transition: all 0.3s ease;
  padding: 5px;
  border-radius: 50%;
}

.ad-favorite:hover {
  background-color: rgba(231, 76, 60, 0.1);
  transform: scale(1.1);
}

.ad-favorite i {
  color: var(--accent);
  font-size: 1.1rem;
  transition: all 0.3s ease;
}

.ad-favorite:hover i {
  color: var(--danger);
}

.ad-favorite .fas.fa-heart {
  color: var(--danger);
  animation: heartBeat 0.3s ease;
}

@keyframes heartBeat {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

.ad-views {
  color: var(--gray);
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 500;
}

.ad-views i {
  color: var(--primary);
  font-size: 0.9rem;
}

.ad-date {
  color: var(--gray);
  font-size: 0.8rem;
  font-weight: 400;
}

.ad-comments-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 15px;
  padding: 12px;
  background: linear-gradient(135deg, var(--primary) 0%, #5a9fd8 100%);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  color: white;
  font-weight: 600;
  font-size: 0.95rem;
  box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3);
}

.ad-comments-icon:hover {
  background: linear-gradient(135deg, #5a9fd8 0%, var(--primary) 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(74, 144, 226, 0.4);
}

.ad-comments-icon i {
  font-size: 1rem;
}

/* ================= AUTH PAGE ================= */
.details-header {
  background: white;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 15px;
  box-shadow: 0 2px 10px var(--shadow);
  position: sticky;
  top: 0;
  z-index: 999;
}

.back-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 5px;
}

/* تغيير لون زر الرجوع إلى الأسود في صفحات المفضلة والرسائل والملف الشخصي */
#favorites-page .back-btn,
#account-page .back-btn {
  color: #000;
}

.details-header h2 {
  flex: 1;
  margin: 0;
  font-weight: 600;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* نقل عنوان المفضلة إلى المنتصف */
#favorites-page .details-header {
  justify-content: center;
  position: relative;
}

#favorites-page .details-header .back-btn {
  position: absolute;
  right: 20px;
}

#favorites-page .details-header h2 {
  text-align: center;
  flex: none;
}

/* صفحة أضف إعلان: سيارتي في المنتصف مع زر الرجوع على الجانب */
#add-ad-page .details-header {
  justify-content: center;
  position: relative;
}
#add-ad-page .details-header .back-btn {
  position: absolute;
  right: 20px;
}
#add-ad-page .details-header h2 {
  text-align: center;
  flex: none;
  color: var(--primary);
  font-size: 1.25rem;
}

/* ================= ACCOUNT PAGE - فصل كامل عن منطق المحادثة ================= */
/* إجبار صفحة حسابي على التصرف كصفحة مقالات عادية - تبدأ من الأعلى */
#account-page {
  padding: 0 !important;
  margin: 0 !important;
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  position: relative !important;
  top: 0 !important;
  min-height: auto !important;
  max-height: none !important;
  height: auto !important;
  background: var(--light) !important;
  display: block !important;
  overflow: visible !important;
  /* إلغاء أي تنسيقات flexbox من الصفحات الأخرى */
  align-items: flex-start !important;
  justify-content: flex-start !important;
  align-content: flex-start !important;
  flex-direction: column !important;
  flex-wrap: nowrap !important;
  flex-grow: 0 !important;
  flex-shrink: 0 !important;
  flex-basis: auto !important;
}

/* إخفاء السطر العلوي (details-header) بالكامل في صفحة الملف الشخصي - بدون أي مساحة */
#account-page .details-header {
  display: none !important;
  height: 0 !important;
  margin: 0 !important;
  margin-top: 0 !important;
  padding: 0 !important;
  padding-top: 0 !important;
  overflow: hidden !important;
  visibility: hidden !important;
  position: absolute !important;
  top: -9999px !important;
  width: 0 !important;
  flex-grow: 0 !important;
  flex-shrink: 0 !important;
}

/* إخفاء صفحة الرسائل بشكل صارم عند فتح صفحة حسابي */
#account-page.active ~ #messages-page,
#account-page.active ~ #chat-page {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  height: 0 !important;
  overflow: hidden !important;
  position: absolute !important;
  top: -9999px !important;
  width: 0 !important;
  flex-grow: 0 !important;
  flex-shrink: 0 !important;
}

.auth-container {
  padding: 20px;
}

.auth-card {
  background: white;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 5px 20px var(--shadow);
  max-width: 500px;
  margin: 0 auto;
}

.auth-header {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  padding: 25px;
  text-align: center;
}

.auth-body {
  padding: 25px;
}

/* تنبيه الحساب غير المفعل في صفحة تسجيل الدخول (متوافق Chrome/Safari) */
.login-unverified-alert {
  background: #fff8e6;
  border: 1px solid #f0c674;
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 18px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.login-unverified-alert .login-unverified-message {
  margin: 0 0 12px 0;
  font-size: 0.95rem;
  line-height: 1.5;
  color: #5a4a2a;
}
.login-unverified-alert .auth-btn-resend {
  margin: 0;
  padding: 12px 16px;
  font-size: 1rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.login-unverified-alert .auth-btn-resend:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.forgot-password-wrap {
  text-align: right;
  margin-top: 12px;
  margin-bottom: 4px;
  position: relative;
  z-index: 2;
}

.forgot-password-link {
  display: inline-block;
  font-size: 15px;
  color: var(--primary);
  text-decoration: none;
  transition: color 0.2s ease;
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(52, 152, 219, 0.2);
  touch-action: manipulation;
  padding: 8px 0;
  min-height: 44px;
  line-height: 28px;
  box-sizing: border-box;
  border: none;
  background: transparent;
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
  outline: none;
  box-shadow: none;
}
.forgot-password-link:hover {
  color: var(--secondary);
  text-decoration: underline;
}
.forgot-password-link:active {
  color: var(--secondary);
}

.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: var(--dark);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.condition-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.condition-option {
  flex: 1;
  min-width: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 15px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: #f5f5f5;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}

.condition-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.condition-option span {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  color: var(--dark);
}

.condition-option span i {
  font-size: 1rem;
  color: var(--gray);
}

.condition-option:hover {
  border-color: var(--primary);
  background: #e8f4f8;
}

.condition-option input[type="radio"]:checked + span {
  color: var(--primary);
  font-weight: 600;
}

.condition-option input[type="radio"]:checked + span i {
  color: var(--primary);
}

.condition-option:has(input[type="radio"]:checked) {
  border-color: var(--primary);
  background: rgba(52, 152, 219, 0.1);
}

.form-input {
  width: 100%;
  padding: 15px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  transition: var(--transition);
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Ensure select options are always visible */
select.form-input {
  opacity: 1 !important;
  visibility: visible !important;
  display: block !important;
  min-height: 50px;
  -webkit-appearance: menulist !important;
  -moz-appearance: menulist !important;
  appearance: menulist !important;
}

select.form-input option {
  display: block !important;
  padding: 10px;
  background: white;
  color: var(--dark);
}

/* حقل حالة السيارة — نفس مقاس وعرض الحقول المجاورة */
#add-ad-page #ad-condition {
  min-height: 60px !important;
  height: 60px !important;
  padding: 14px 16px !important;
  padding-inline-start: 36px !important;
  padding-inline-end: 16px !important;
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  line-height: 1.5 !important;
  vertical-align: middle !important;
}

/* تنسيق قسم معلومات التواصل */
.phone-display-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#add-ad-page #ad-phone {
  text-align: right !important;
  direction: rtl !important;
}

.toggle-switch {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}

.toggle-switch input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: relative;
  width: 50px;
  height: 26px;
  background-color: #ccc;
  border-radius: 26px;
  transition: background-color 0.3s ease;
  flex-shrink: 0;
}

.toggle-slider::before {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  top: 3px;
  background-color: white;
  border-radius: 50%;
  transition: transform 0.3s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch input[type="checkbox"]:checked + .toggle-slider {
  background-color: var(--primary);
}

.toggle-switch input[type="checkbox"]:checked + .toggle-slider::before {
  transform: translateX(24px);
}

.toggle-label {
  font-size: 0.9rem;
  color: var(--dark);
  font-weight: 500;
}

/* غلاف حقل كلمة المرور + أيقونة العين على اليسار فقط */
.password-input-wrap {
  position: relative;
  width: 100%;
}
.password-input-wrap .form-input {
  padding-left: 48px;
  padding-right: 15px;
}
.password-toggle {
  position: absolute;
  top: 50%;
  left: 12px;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #666;
  cursor: pointer;
  padding: 8px;
  font-size: 1.1rem;
  line-height: 1;
  border-radius: 4px;
  transition: color 0.2s ease;
}
.password-toggle:hover {
  color: var(--primary);
}
.password-toggle:focus {
  outline: none;
  color: var(--primary);
}

/* إخفاء أيقونة إظهار/إخفاء كلمة المرور الافتراضية للمتصفح (مثل Edge) */
input[type="password"]::-ms-reveal,
input[type="password"]::-ms-clear {
  display: none;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.form-input.textarea {
  min-height: 120px;
  resize: vertical;
}

.form-input.error,
.form-input.required-error {
  border-color: var(--danger) !important;
  background-color: #fff5f5;
}

.field-error {
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 5px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.field-error::before {
  content: "⚠";
  font-size: 0.9rem;
}

.auth-btn {
  width: 100%;
  padding: 15px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

.auth-btn:hover {
  background: #2980b9;
  transform: translateY(-2px);
}

/* ================= ADD AD PAGE ================= */
#add-ad-page,
#add-ad-page * {
  box-sizing: border-box !important;
}

#add-ad-page {
  color: #1a1a1a !important;
  font-size: 1.22rem !important;
  font-weight: 500 !important;
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  height: auto !important;
  min-height: 100vh !important;
  display: flex !important;
  flex-direction: column !important;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* إخفاء عناوين الحقول (Labels) في صفحة إضافة إعلان والاكتفاء بما داخل الحقول
   مع الإبقاء على عنوان حقل "عنوان الإعلان" في الأعلى فقط */
#add-ad-page .form-label,
#add-ad-page .form-group > label.form-label {
  display: none !important;
}
#add-ad-page .price-label-row .form-label {
  display: none !important;
}

/* إظهار عنوان حقل "عنوان الإعلان" فوق الحقل بتنسيق واضح */
#add-ad-page .form-label.form-label-title {
  display: block !important;
  font-size: 1.28rem !important;
  font-weight: 700 !important;
  color: #1a1a1a !important;
  margin-bottom: 6px !important;
  margin-top: 0 !important;
}
#add-ad-page .form-group label.checkbox-label,
#add-ad-page .form-group .toggle-label {
  display: inline-flex !important;
}

#add-ad-page .form-input,
#add-ad-page select.form-input,
#add-ad-page .form-input::placeholder {
  color: #1a1a1a !important;
  font-size: 1.38rem !important;
  font-weight: 600 !important;
  line-height: 1.5 !important;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#add-ad-page .form-input.textarea {
  font-size: 1.38rem !important;
  font-weight: 500 !important;
  color: #1a1a1a !important;
  line-height: 1.5 !important;
}

#add-ad-page .toggle-label,
#add-ad-page .upload-area p,
#add-ad-page .checkbox-label {
  color: #1a1a1a !important;
  font-size: 1.28rem !important;
  font-weight: 600 !important;
  -webkit-font-smoothing: antialiased;
}

#add-ad-page .add-ad-header h3 {
  font-size: 1.65rem !important;
  font-weight: 700 !important;
  color: white !important;
}

#add-ad-page .submit-btn {
  font-size: 1.3rem !important;
  font-weight: 600 !important;
  color: white !important;
}

#add-ad-page #ad-submit-note {
  font-size: 1.06rem !important;
  color: #333 !important;
  margin-top: 4px !important;
}

/* شريط علوي لتنبيه تفعيل البريد — لا يؤثر على مكان الحقول.
   افتراضياً مخفي (display: none)، ويُظهَر فقط عند الحاجة من الـ JS. */
.add-ad-verify-banner {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  background: #fff8e6;
  border-bottom: 1px solid #f0c674;
  color: #856404;
  font-size: 1.05rem;
  font-weight: 600;
  flex-shrink: 0;
}
.add-ad-verify-banner[hidden],
#add-ad-email-verify-alert[hidden] {
  display: none !important;
  visibility: hidden !important;
  height: 0 !important;
  overflow: hidden !important;
  padding: 0 !important;
  margin: 0 !important;
  border: none !important;
}
.add-ad-verify-banner i {
  font-size: 1.25rem;
  flex-shrink: 0;
}
.add-ad-verify-banner-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.add-ad-verify-resend-btn {
  padding: 10px 20px;
  min-height: 44px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #1a5c34;
  background: rgba(39, 174, 96, 0.1);
  border: 1px solid rgba(39, 174, 96, 0.35);
  border-radius: 20px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
}
.add-ad-verify-resend-btn:hover,
.add-ad-verify-resend-btn:focus {
  background: rgba(39, 174, 96, 0.18);
  border-color: rgba(39, 174, 96, 0.5);
  outline: none;
}
.add-ad-verify-resend-btn:active {
  opacity: 0.85;
}
.add-ad-verify-resend-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
@media (max-width: 480px) {
  .add-ad-verify-resend-btn {
    min-height: 44px;
    padding: 10px 18px;
    font-size: 0.78rem;
  }
}

/* تعطيل حقول النموذج عند عدم تفعيل البريد (الحقول تبقى بعرض كامل) */
#add-ad-page .add-ad-body.add-ad-email-not-verified input,
#add-ad-page .add-ad-body.add-ad-email-not-verified select,
#add-ad-page .add-ad-body.add-ad-email-not-verified textarea,
#add-ad-page .add-ad-body.add-ad-email-not-verified .form-input,
#add-ad-page .add-ad-body.add-ad-email-not-verified .upload-area,
#add-ad-page .add-ad-body.add-ad-email-not-verified .submit-btn {
  pointer-events: none !important;
  opacity: 0.6;
}
#add-ad-page .add-ad-body.add-ad-email-not-verified .submit-btn {
  cursor: not-allowed;
}

#add-ad-page .price-label-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
#add-ad-page .price-label-row .form-label {
  margin-bottom: 0;
}
#add-ad-page .price-option-inline {
  font-weight: 500;
  font-size: 1.06rem;
}
#add-ad-page .price-option {
  margin-top: 4px !important;
}

/* حقل السعر مع «على السوم» داخل حاوية واحدة — لا يؤثر على عمودين */
#add-ad-page .price-group {
  display: flex;
  align-items: center;
  width: 100%;
  min-width: 0;
}
#add-ad-page .price-group .form-input {
  flex: 1 1 auto;
  min-width: 0;
  width: auto !important;
}
#add-ad-page .price-group .price-negotiable-center {
  display: inline-flex !important;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 1.05rem;
  color: #1a1a1a;
  margin: 0;
  margin-left: 10px;
  flex-shrink: 0;
}
#add-ad-page .price-group .price-negotiable-center input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}
#add-ad-page .price-group .form-input:disabled {
  background: #e8e8e8 !important;
  cursor: not-allowed;
  color: #666;
}

/* الحاوية الرئيسية لصفحة الإعلان — إلغاء أي طول محدد وتمديد الصفحة لآخر الشاشة */
#add-ad-page .add-ad-container {
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 12px 16px !important;
  height: auto !important;
  min-height: 100vh !important;
  display: flex !important;
  flex-direction: column !important;
}

#add-ad-page .add-ad-card {
  background: white !important;
  border-radius: var(--radius) !important;
  overflow: hidden !important;
  box-shadow: 0 5px 20px var(--shadow) !important;
  max-width: none !important;
  width: 100% !important;
  height: auto !important;
  min-height: 100vh !important;
  display: flex !important;
  flex-direction: column !important;
}

.add-ad-card {
  background: white;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 5px 20px var(--shadow);
  max-width: none;
}

.add-ad-header {
  background: linear-gradient(135deg, var(--success), #27ae60);
  color: white;
  padding: 10px 14px;
}

#add-ad-page .add-ad-header {
  flex-shrink: 0;
}

/* الحاوية الرئيسية: Grid احترافي عمودين متساويين */
#add-ad-page .add-ad-body,
body #add-ad-page .add-ad-body {
  display: grid !important;
  grid-template-columns: 1fr 1fr !important;
  gap: 20px !important;
  padding: 16px 20px !important;
  margin: 0 !important;
  height: auto !important;
  min-height: 100vh !important;
  align-items: start !important;
  overflow-y: auto !important;
}

/* كل صف عادي = حقلين (عمودين متساويين) */
#add-ad-page .add-ad-body > .form-row:not(.form-row-full):not(.form-row-title-desc),
body #add-ad-page .add-ad-body > .form-row:not(.form-row-full):not(.form-row-title-desc) {
  grid-column: 1 / -1 !important;
  display: grid !important;
  grid-template-columns: 1fr 1fr !important;
  gap: 20px !important;
  width: 100% !important;
  min-width: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  align-items: start !important;
}

/* الحقول الطويلة (عنوان الإعلان، وصف السيارة، صور) — السطر بالكامل */
#add-ad-page .add-ad-body > .form-row.form-row-full,
#add-ad-page .add-ad-body > .form-row.form-row-title-desc,
#add-ad-page .add-ad-body > .form-row:has(.form-group-full),
body #add-ad-page .add-ad-body > .form-row.form-row-full,
body #add-ad-page .add-ad-body > .form-row.form-row-title-desc,
body #add-ad-page .add-ad-body > .form-row:has(.form-group-full) {
  grid-column: span 2 !important;
  display: block !important;
  width: 100% !important;
}

/* كل حقل إدخال يملأ مكانه في الشبكة */
#add-ad-page .add-ad-body .form-group {
  min-width: 0 !important;
  width: 100% !important;
}

#add-ad-page .add-ad-body .form-input,
#add-ad-page .add-ad-body select.form-input,
#add-ad-page .add-ad-body input.form-input,
body #add-ad-page .add-ad-body .form-input,
body #add-ad-page .add-ad-body select.form-input,
body #add-ad-page .add-ad-body input.form-input {
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}

/* حقل بعرض كامل — العنوان فوق الحقل */
#add-ad-page .add-ad-body > .form-row > .form-group.form-group-full,
body #add-ad-page .add-ad-body > .form-row > .form-group.form-group-full {
  grid-column: 1 / -1 !important;
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
}

#add-ad-page .add-ad-body > .form-row > .form-group.form-group-full > .form-label {
  display: block !important;
  margin-bottom: 6px !important;
}

/* خانة فارغة للمحاذاة (نوع الوقود + عمود فارغ) */
#add-ad-page .form-group-spacer {
  min-height: 0;
  visibility: hidden;
  pointer-events: none;
}

/* مسافة خفيفة فوق عنوان الإعلان ووصف السيارة */
#add-ad-page .form-row-title-desc:first-of-type {
  margin-top: 0.5rem;
}

/* إلغاء القاعدة العامة form-group (margin-bottom) داخل صفحة إضافة الإعلان */
#add-ad-page .add-ad-body .form-group {
  margin: 0 !important;
  padding: 0 !important;
  align-self: start !important;
}

#add-ad-page .form-row .form-group,
#add-ad-page .form-row-half .form-group {
  min-width: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 2px !important;
  width: 100% !important;
}

/* حقول العرض الكامل: display block و width 100% */
#add-ad-page .add-ad-body > .form-row > .form-group.form-group-full .form-input,
#add-ad-page .add-ad-body > .form-row > .form-group.form-group-full textarea,
#add-ad-page .add-ad-body > .form-row > .form-group.form-group-full .upload-area {
  display: block !important;
  width: 100% !important;
}

#add-ad-page .form-group {
  margin: 0 !important;
}

#add-ad-page .add-ad-body > .submit-btn {
  grid-column: 1 / -1 !important;
  justify-self: center !important;
  margin: 0 !important;
  margin-top: 24px !important;
  align-self: start !important;
}

#add-ad-page .add-ad-body > #ad-submit-note {
  grid-column: 1 / -1 !important;
  margin: 0 !important;
  padding: 0 !important;
}

#add-ad-page .form-row > .form-group.form-group-full {
  display: block !important;
  width: 100% !important;
}

#add-ad-page .add-ad-body > .form-row,
#add-ad-page .add-ad-body > .form-row-half {
  margin: 0 !important;
  margin-bottom: 0 !important;
}

/* إلغاء القواعد العامة للـ form-row خارج صفحة الإعلان — لا تؤثر على add-ad */
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

/* داخل صفحة الإعلان: إجبار Grid عمودين وتباعد 20px (تجاوز أي قاعدة عامة) */
#add-ad-page .form-row,
#add-ad-page .form-row-half,
body #add-ad-page .form-row,
body #add-ad-page .form-row-half {
  display: grid !important;
  grid-template-columns: 1fr 1fr !important;
  gap: 20px !important;
  width: 100% !important;
  margin-bottom: 0 !important;
}

.form-row-half {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-bottom: 20px;
}
@media (min-width: 768px) {
  .form-row-half {
    flex-direction: row;
  }
  .form-row-half .form-group {
    flex: 1;
  }
}
/* حقول صفحة إضافة إعلان: line-height و padding كافٍ لعدم قص النص العربي */
#add-ad-page .form-input,
#add-ad-page select.form-input {
  background: #f2f2f2 !important;
  border: 1px solid #e5ddd0 !important;
  border-radius: 8px !important;
  min-height: 60px !important;
  height: 60px !important;
  box-sizing: border-box !important;
  width: 100% !important;
  min-width: 150px !important;
  font-size: 1.38rem !important;
  font-weight: 600 !important;
  line-height: 1.5 !important;
  padding-top: 14px !important;
  padding-bottom: 14px !important;
  padding-left: 16px !important;
  padding-right: 16px !important;
}

#add-ad-page select.form-input {
  padding-inline-start: 36px !important;
  padding-inline-end: 16px !important;
  padding-top: 14px !important;
  padding-bottom: 14px !important;
  appearance: menulist !important;
  -webkit-appearance: menulist !important;
  -moz-appearance: menulist !important;
  font-size: 1.38rem !important;
  font-weight: 600 !important;
  line-height: 1.5 !important;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#add-ad-page select.form-input option {
  font-size: 1.28rem !important;
  font-weight: 600 !important;
  padding: 10px 12px !important;
  background: #fff !important;
  color: #1a1a1a !important;
}

#add-ad-page .form-input.textarea,
#add-ad-page #ad-description {
  min-height: 150px !important;
  height: auto !important;
  max-height: none !important;
  padding: 12px !important;
  line-height: 1.5 !important;
  resize: none !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
  background: #ffffff !important;
  border: 1px solid #e5ddd0 !important;
  font-size: 16px !important;
  text-align: right !important;
}

#add-ad-page #ad-description::placeholder,
#add-ad-page .form-input.textarea::placeholder {
  color: #999 !important;
  font-size: 14px !important;
  opacity: 1;
}

/* إخفاء الـ input الافتراضي لرفع الملفات — Android و iPhone */
.file-input-hidden,
#add-ad-page input[type="file"],
input[type="file"].file-input-hidden {
  display: none !important;
  visibility: hidden !important;
  position: absolute !important;
  width: 0 !important;
  height: 0 !important;
  min-width: 0 !important;
  min-height: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  clip-path: inset(50%) !important;
  margin: -1px !important;
  padding: 0 !important;
  border: 0 !important;
}

.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
}

#add-ad-page .upload-area {
  padding: 14px 12px;
  margin-left: auto;
  margin-right: auto;
  max-width: 420px;
  text-align: center;
}

#add-ad-page .upload-area p,
#add-ad-page .upload-area-video p {
  display: none !important;
}

#add-ad-page .upload-area .upload-btn {
  display: inline-block;
}

.upload-area:hover {
  border-color: var(--primary);
  background: var(--light-gray);
}

.upload-area i {
  font-size: 2.5rem;
  color: var(--primary);
  margin-bottom: 10px;
}

.upload-btn {
  display: inline-block;
  background: var(--primary);
  color: white;
  padding: 8px 20px;
  border-radius: 5px;
  margin-top: 10px;
  font-weight: 600;
}

.upload-actions-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 0;
}
.upload-actions-row .upload-area {
  margin-left: 0;
  margin-right: 0;
}
.upload-area-video {
  flex: 0 0 auto;
  min-width: 140px;
}
.upload-area-video .upload-btn {
  margin-top: 10px;
}
.upload-area-video i {
  font-size: 2.5rem;
  color: var(--primary);
  margin-bottom: 10px;
}
.upload-area-video p {
  margin: 0;
  font-size: 0.9rem;
  color: #555;
}

.video-preview-wrap {
  margin-top: 14px;
  padding: 10px 0;
}
.video-preview-label {
  font-size: 0.95rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 8px;
}
.video-preview-inner {
  position: relative;
  display: inline-block;
  max-width: 320px;
}
.video-preview-inner.video-preview-list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  max-width: 100%;
}
.video-preview-item {
  position: relative;
  display: inline-block;
  max-width: 320px;
}
.video-preview-item .video-preview-player {
  display: block;
  max-width: 100%;
}
.video-preview-item .remove-video-btn {
  position: absolute;
  top: 6px;
  left: 6px;
}
.video-preview-player {
  display: block;
  width: 100%;
  max-width: 320px;
  height: auto;
  max-height: 200px;
  border-radius: var(--radius);
  background: #000;
}
.remove-video-btn {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: background 0.2s;
}
.remove-video-btn:hover {
  background: rgba(0,0,0,0.85);
}
/* صفحة التفاصيل: قائمة الفيديوهات */
.details-videos-section {
  margin-top: 20px;
  padding: 16px 0;
}
.details-videos-label {
  font-size: 1rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 12px;
}
.details-videos-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.details-video-item {
  width: 100%;
  max-width: 560px;
}
.details-video-player {
  width: 100%;
  max-height: 320px;
  border-radius: var(--radius);
  background: #000;
}
@media (max-width: 768px) {
  .upload-actions-row {
    flex-direction: column;
    align-items: stretch;
  }
  .upload-area-video {
    min-width: 0;
  }
  .video-preview-inner {
    max-width: 100%;
  }
  .video-preview-item {
    max-width: 100%;
  }
  .video-preview-player {
    max-width: 100%;
  }
  .details-video-item {
    max-width: 100%;
  }
  .details-video-player {
    max-height: 240px;
  }
}

.images-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

/* معاينة الصور المرفوعة — صف عرضي (أفقي) في صفحة إضافة الإعلان */
#add-ad-page .images-preview {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: wrap !important;
  gap: 10px !important;
  margin-top: 10px !important;
  justify-content: flex-start !important;
}

.image-preview-item {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  height: 100px;
}

#add-ad-page .images-preview .image-preview-item {
  flex: 0 0 160px !important;
  width: 160px !important;
  min-width: 160px !important;
  height: 160px !important;
}

.image-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.remove-image {
  position: absolute;
  top: 5px;
  left: 5px;
  background: var(--danger);
  color: white;
  border: none;
  border-radius: 50%;
  width: 25px;
  height: 25px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.submit-btn {
  width: 100%;
  padding: 18px;
  background: linear-gradient(135deg, var(--success), #27ae60);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1.2rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: var(--transition);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  margin-top: 20px;
}

.submit-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(39, 174, 96, 0.3);
}

/* ================= DETAILS PAGE (Like Haraj) ================= */
.details-card {
  background: white;
  margin: 20px;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 2px 10px var(--shadow);
}

.details-body {
  padding: 25px;
}

/* Header Section */
/* Title Section */
.details-title-section {
  margin-bottom: 15px;
}

.details-main-title {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--dark);
  line-height: 1.4;
  margin: 0;
}

/* Location and Time */
.details-location-time {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--light-gray);
  color: var(--gray);
  font-size: 0.95rem;
}

.details-location-text {
  display: flex;
  align-items: center;
  gap: 5px;
}

.details-time-text {
  color: var(--gray);
}

/* Seller Section */
.details-seller-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 25px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--light-gray);
}

.seller-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.seller-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.seller-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.seller-details {
  flex: 1;
}

.seller-name {
  font-weight: 600;
  color: var(--dark);
  font-size: 1rem;
  margin-bottom: 3px;
}

.seller-id {
  font-size: 0.85rem;
  color: var(--gray);
}

.follow-btn {
  padding: 8px 20px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}

.follow-btn:hover {
  background: var(--secondary);
  transform: translateY(-2px);
}

.follow-btn.following {
  background: var(--light-gray);
  color: var(--dark);
}

/* Car Specifications */
.details-specs-section .spec-item {
  margin-bottom: 12px;
}

.details-specs-section .spec-item:last-child {
  margin-bottom: 0;
}

/* Price Section */
.details-price-section {
  margin-bottom: 25px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--light-gray);
}

.details-price {
  color: var(--primary);
  font-size: 2.2rem;
  font-weight: 800;
  margin: 0;
}

.details-header-section {
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--light-gray);
}

.details-meta-top {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  align-items: center;
  margin-top: 15px;
}

.details-meta-top .ad-badge {
  background: var(--success);
  color: white;
  padding: 5px 15px;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 600;
}

.details-location,
.details-views {
  color: var(--gray);
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 5px;
}

.details-location i,
.details-views i {
  color: var(--primary);
}

/* Description Section */
.details-description-section {
  margin-bottom: 30px;
  padding-bottom: 25px;
  border-bottom: 2px solid var(--light-gray);
}

.section-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--primary);
}

.section-title i {
  color: var(--primary);
}

.details-description {
  color: var(--dark);
  line-height: 1.8;
  font-size: 1rem;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* معرض الصور الكامل تحت الوصف - حتى 15 صورة، جودة عالية ومتجاوب */
.details-images-section {
  margin-bottom: 25px;
  padding-bottom: 20px;
}

.images-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 16px;
  width: 100%;
}

@media (min-width: 768px) {
  .images-gallery {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 18px;
  }
}

@media (min-width: 1024px) {
  .images-gallery {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
  }
}

.gallery-image-item {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  background: var(--light-gray);
  transition: var(--transition);
  border: 2px solid var(--border);
}

.gallery-image-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.15);
  border-color: var(--primary);
}

.gallery-image-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  aspect-ratio: 4 / 3;
}

.gallery-image-item .gallery-fallback-img,
.gallery-fallback-img {
  object-fit: contain;
  background: var(--light-gray);
}

.gallery-image-item .image-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: var(--transition);
}

.gallery-image-item:hover .image-overlay {
  opacity: 1;
}

.image-overlay i {
  color: white;
  font-size: 2rem;
}

.gallery-image-item i {
  font-size: 3rem;
  color: var(--gray);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

/* ========== Image Lightbox Modal ========== */
.image-lightbox {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
  z-index: 999999 !important;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: imageLightboxFadeIn 0.2s ease;
}

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

.image-lightbox-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.92);
  cursor: pointer;
}

.image-lightbox-content {
  position: relative;
  max-width: 95vw;
  max-height: 95vh;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  z-index: 1;
}

.image-lightbox-content img {
  max-width: 100%;
  max-height: 90vh;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

.image-lightbox-close {
  position: fixed;
  top: 16px;
  left: 16px;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  color: #333;
  font-size: 1.4rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000000;
  transition: background 0.2s, transform 0.2s;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

.image-lightbox-close:hover {
  background: #fff;
  transform: scale(1.05);
}

.image-lightbox-arrow {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  color: #333;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: background 0.2s, transform 0.2s;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
}

.image-lightbox-arrow:hover {
  background: #fff;
  transform: translateY(-50%) scale(1.08);
}

.image-lightbox-prev {
  right: 20px;
}

.image-lightbox-next {
  left: 20px;
}

.image-lightbox-counter {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 16px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border-radius: 20px;
  font-size: 0.9rem;
  z-index: 2;
}

/* Lightbox على الجوال: فوق الكيبورد والقائمة السفلية */
@media (max-width: 768px) {
  .image-lightbox {
    z-index: 999999 !important;
  }
  .image-lightbox-backdrop {
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .image-lightbox-content {
    max-width: 100vw;
    max-height: 100vh;
    padding: 12px;
    box-sizing: border-box;
  }
  .image-lightbox-content img {
    max-width: 100%;
    max-height: 85vh;
    width: auto;
    height: auto;
    object-fit: contain;
  }
  .image-lightbox-close {
    top: 12px;
    left: 12px;
    width: 52px;
    height: 52px;
    min-width: 52px;
    min-height: 52px;
    font-size: 1.8rem;
    font-weight: bold;
    background: #fff !important;
    color: #222 !important;
    z-index: 1000000 !important;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(0, 0, 0, 0.1);
  }
}

/* منع التمرير خلف الـ Lightbox (يُطبّق من JS على body) */
body.body-lightbox-open {
  overflow: hidden !important;
  position: fixed !important;
  width: 100% !important;
}

/* Specifications Section */
.details-specs-section {
  margin-bottom: 30px;
  padding-bottom: 25px;
  border-bottom: 2px solid var(--light-gray);
}

.details-specs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 15px;
  margin-top: 15px;
}

/* Owner Info Section */
.details-owner-section {
  margin-bottom: 30px;
  padding-bottom: 25px;
  border-bottom: 2px solid var(--light-gray);
}

.owner-info {
  margin-top: 15px;
}

.spec-item {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 15px;
  background: var(--light-gray);
  border-radius: 8px;
}

.spec-item i {
  font-size: 1.5rem;
  color: var(--primary);
}

.spec-label {
  font-size: 0.9rem;
  color: var(--gray);
  margin-bottom: 5px;
}

.spec-value {
  font-weight: 600;
  color: var(--dark);
}

/* ================= COMMENTS SYSTEM (Like Haraj) ================= */
.comments-section {
  margin-top: 30px;
  padding-top: 25px;
  border-top: 2px solid var(--light-gray);
}

.comments-header {
  margin-bottom: 20px;
}

.comments-title {
  font-size: 1.3rem;
  color: var(--dark);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.comments-count {
  color: var(--primary);
  font-weight: 600;
}

.add-comment-form {
  margin-bottom: 25px;
  padding: 20px;
  background: var(--light-gray);
  border-radius: var(--radius);
}

.comment-input-wrapper {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.comment-input {
  width: 100%;
  padding: 15px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
  min-height: 80px;
  transition: var(--transition);
}

.comment-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.comment-submit-btn {
  align-self: flex-end;
  padding: 12px 25px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition);
}

.comment-submit-btn:hover {
  background: #2980b9;
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(52, 152, 219, 0.3);
}

.comments-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.comment-item {
  background: white;
  padding: 20px;
  border-radius: var(--radius);
  box-shadow: 0 2px 8px var(--shadow);
  border-right: 3px solid var(--primary);
}

.comment-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.comment-author {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.comment-avatar {
  width: 45px;
  height: 45px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.comment-author-info {
  flex: 1;
}

.comment-author-name {
  font-weight: 600;
  color: var(--dark);
  margin-bottom: 5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.comment-badge {
  background: var(--warning);
  color: white;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.comment-time {
  font-size: 0.85rem;
  color: var(--gray);
}

.comment-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.reply-btn,
.delete-comment-btn {
  background: none;
  border: none;
  color: var(--gray);
  cursor: pointer;
  padding: 5px 10px;
  border-radius: 5px;
  font-size: 0.9rem;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 5px;
}

.reply-btn:hover {
  background: var(--light-gray);
  color: var(--primary);
}

.delete-comment-btn:hover {
  background: var(--light-gray);
  color: var(--danger);
}

.comment-content {
  color: var(--dark);
  line-height: 1.6;
  padding: 10px 0;
  word-wrap: break-word;
}

.comment-replies {
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid var(--light-gray);
  padding-right: 20px;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.reply-item {
  background: var(--light-gray);
  padding: 15px;
  border-radius: 8px;
  border-right: 2px solid var(--primary);
}

.reply-form-container {
  margin-top: 15px;
  padding: 15px;
  background: var(--light-gray);
  border-radius: 8px;
}

.reply-input {
  width: 100%;
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  resize: vertical;
  min-height: 60px;
  margin-bottom: 10px;
  transition: var(--transition);
}

.reply-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.reply-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.reply-submit-btn,
.reply-cancel-btn {
  padding: 8px 20px;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.reply-submit-btn {
  background: var(--primary);
  color: white;
}

.reply-submit-btn:hover {
  background: #2980b9;
}

.reply-cancel-btn {
  background: var(--light-gray);
  color: var(--dark);
}

.reply-cancel-btn:hover {
  background: var(--border);
}

.loading-comments,
.no-comments,
.comments-error {
  text-align: center;
  padding: 40px 20px;
  color: var(--gray);
}

.loading-comments {
  color: var(--primary);
}

.comments-error {
  color: var(--danger);
}

.comments-error i {
  font-size: 2rem;
  margin-bottom: 10px;
  opacity: 0.7;
}

.no-comments i {
  font-size: 3rem;
  margin-bottom: 15px;
  opacity: 0.3;
}

.no-comments p {
  color: var(--gray);
  font-size: 1rem;
}

/* ================= CHAT SYSTEM ================= */
.chat-section {
  margin-top: 30px;
  padding-top: 25px;
  padding-bottom: 20px; /* مسافة إضافية من الأسفل */
  border-top: 2px solid var(--light-gray);
  position: relative;
  display: flex;
  flex-direction: column;
}

.chat-title {
  font-size: 1.2rem;
  color: var(--dark);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-container {
  height: 300px;
  overflow-y: scroll !important; /* إظهار scrollbar دائماً */
  overflow-x: hidden !important;
  padding: 15px;
  padding-bottom: 20px; /* مسافة إضافية من الأسفل */
  background: var(--light-gray);
  border-radius: var(--radius);
  margin-bottom: 20px; /* زيادة المسافة من الأسفل */
  display: flex;
  flex-direction: column;
  gap: 10px;
  /* تحسين الـ scroll */
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  /* إظهار scrollbar واضح ومرئي دائماً */
  scrollbar-width: auto !important;
  scrollbar-color: #888 #f1f1f1 !important;
  /* التأكد من أن المحتوى يظهر بشكل صحيح */
  position: relative;
  scrollbar-gutter: stable;
  /* منع التداخل مع زر الإرسال */
  box-sizing: border-box;
}

/* تخصيص scrollbar للـ Webkit browsers (Chrome, Safari, Edge) - مثل موقع حراج */
.chat-container::-webkit-scrollbar {
  width: 16px !important; /* عرض واضح ومرئي */
  display: block !important;
  -webkit-appearance: none;
}

.chat-container::-webkit-scrollbar-track {
  background: #f1f1f1 !important;
  border-radius: 8px;
  border: 1px solid #ddd;
  -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.1);
}

.chat-container::-webkit-scrollbar-thumb {
  background: #888 !important;
  border-radius: 8px;
  border: 2px solid #f1f1f1;
  -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
}

.chat-container::-webkit-scrollbar-thumb:hover {
  background: #555 !important;
}

.chat-container::-webkit-scrollbar-thumb:active {
  background: #333 !important;
}

.loading-chat,
.chat-error,
.no-messages {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px 20px;
  text-align: center;
  color: var(--gray);
  min-height: 200px;
}

.loading-chat {
  color: var(--primary);
}

.chat-error {
  color: var(--danger);
}

.chat-error i {
  font-size: 2rem;
  margin-bottom: 10px;
  opacity: 0.7;
}

.no-messages i {
  font-size: 3rem;
  margin-bottom: 15px;
  opacity: 0.3;
}

.no-messages p {
  color: var(--gray);
  font-size: 1rem;
}

.message {
  padding: 12px 15px;
  border-radius: 15px;
  max-width: 80%;
  position: relative;
  animation: slideIn 0.3s ease;
  margin-bottom: 5px; /* مسافة إضافية بين الرسائل */
}

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

.message.sent {
  background: var(--primary);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 5px;
}

.message.received {
  background: white;
  color: var(--dark);
  align-self: flex-start;
  border-bottom-left-radius: 5px;
  box-shadow: 0 2px 5px var(--shadow);
}

.message.sender {
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 5px;
  opacity: 0.8;
}

.message-content {
  word-wrap: break-word;
}

.message-time {
  font-size: 0.7rem;
  opacity: 0.7;
  text-align: left;
  margin-top: 5px;
}

.message-image {
  max-width: 200px;
  max-height: 200px;
  border-radius: 10px;
  margin-top: 5px;
  cursor: pointer;
  transition: var(--transition);
}

.message-image:hover {
  transform: scale(1.05);
}

.chat-input-container {
  display: flex;
  align-items: center;
  gap: 12px;
  background: white;
  padding: 12px 15px;
  border-radius: 30px;
  border: 2px solid var(--border);
  box-shadow: 0 2px 10px var(--shadow);
  position: relative;
  z-index: 10;
  margin-top: 0;
}

.chat-attachments {
  display: flex;
}

.chat-attach-btn {
  background: var(--light-gray);
  border: none;
  color: var(--primary);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 10px;
  width: 45px;
  height: 45px;
  border-radius: 50%;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-attach-btn:hover {
  background: var(--primary);
  color: white;
  transform: scale(1.05);
}

.chat-input {
  flex: 1;
  border: none;
  outline: none;
  padding: 12px 15px;
  font-size: 1rem;
  background: transparent;
  color: var(--dark);
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.chat-input::placeholder {
  color: #999;
  opacity: 0.8;
  font-weight: 400;
}

.chat-input:focus {
  outline: none;
}

.chat-input:focus::placeholder {
  opacity: 0.5;
}

.chat-send-btn {
  background: var(--primary);
  color: white;
  border: none;
  width: 45px;
  height: 45px;
  border-radius: 50%;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  box-shadow: 0 2px 8px rgba(52, 152, 219, 0.3);
  flex-shrink: 0;
}

.chat-send-btn:hover {
  background: #2980b9;
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(52, 152, 219, 0.4);
}

.chat-send-btn:active {
  transform: scale(0.95);
}

.chat-send-btn i {
  font-size: 1.1rem;
}

.details-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 15px;
  margin-top: 25px;
}

.action-btn {
  padding: 15px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: var(--transition);
}

.action-btn.whatsapp {
  background: #25D366;
  color: white;
}

.action-btn.call {
  background: var(--primary);
  color: white;
}

.action-btn.favorite {
  background: var(--light-gray);
  color: var(--dark);
}

.action-btn.share {
  background: #6c757d;
  color: white;
}

.action-btn.edit-btn {
  background: #4CAF50;
  color: white;
}

.action-btn.delete-btn {
  background: #f44336;
  color: white;
}

.action-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px var(--shadow);
}

.owner-actions {
  display: flex;
  gap: 15px;
  width: 100%;
  grid-column: 1 / -1;
}

.regular-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 15px;
  width: 100%;
}

/* ================= MESSAGES SECTION ================= */
#messages-section {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100vh;
  max-height: 100vh;
  background: #fff;
  overflow: hidden;
  box-sizing: border-box;
  margin-bottom: 150px !important;
}

/* هيدر قسم الرسائل: عنوان في المنتصف + زر رجوع في الزاوية */
.messages-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 12px;
  border-bottom: 1px solid #eee;
  background: white;
  min-height: 56px;
  flex-shrink: 0;
}

.messages-sidebar-title {
  flex: 1;
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  text-align: center;
  color: #1a1a1a;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: 0.3px;
}

.messages-back-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: 50%;
  color: var(--primary);
  font-size: 1.25rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.messages-back-btn:hover {
  background: rgba(52, 152, 219, 0.1);
  color: #2980b9;
}

.messages-sidebar-spacer {
  width: 44px;
  min-width: 44px;
  height: 44px;
}

#messages-section .chat-layout {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: row;
  overflow: hidden;
}

#messages-section .chat-main-area {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* هيدر منطقة المحادثة: عنوان «الرسائل الواردة» في المنتصف */
#messages-section .chat-area-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 15px;
  border-bottom: 1px solid #ddd;
  background: #fff;
  min-height: 48px;
  flex-shrink: 0;
}
.chat-back-arrow {
  width: 36px;
  height: 36px;
  min-width: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--primary);
  font-size: 1.1rem;
  cursor: pointer;
  flex-shrink: 0;
  border-radius: 50%;
}
.chat-back-arrow:hover {
  background: rgba(52, 152, 219, 0.1);
}
#messages-section .chat-area-title,
#messages-section #chat-title {
  flex: 1;
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  color: #1a1a1a;
}
#messages-section .chat-area-status {
  font-size: 0.75rem;
  color: #666;
  flex-shrink: 0;
}

#messages-section #chat-box,
#messages-section .chat-box-inner {
  flex: 1;
  flex-grow: 1;
  min-height: 0;
  overflow-y: auto;
  direction: ltr;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  padding: 20px;
  padding-bottom: 100px;
  background: #f0f2f5;
}

/* صندوق الإرسال: ثابت في أسفل حاوية الدردشة، لا يتمدد */
/* صندوق الإرسال: ثابت فوق القائمة السفلية */
#messages-section #chat-input-area,
#messages-section .chat-input-area-fixed {
  position: fixed !important;
  bottom: 85px !important;
  left: 0 !important;
  right: 0 !important;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  padding: 12px 15px;
  background: white !important;
  border-top: 1px solid #ddd;
  box-sizing: border-box;
  z-index: 99999 !important;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.08);
}
#messages-section #chat-input-area #msg-input,
#messages-section .chat-input-area-fixed #msg-input {
  flex: 1;
  min-width: 0;
  max-width: 100%;
  padding: 12px 16px;
  border: 1px solid #ddd;
  border-radius: 24px;
  outline: none;
  box-sizing: border-box;
  font-size: 1rem;
}
#messages-section #chat-input-area .chat-send-btn,
#messages-section .chat-send-btn {
  flex-shrink: 0;
  min-width: 64px;
  padding: 12px 20px;
  background: #007bff !important;
  color: #fff;
  border: none;
  border-radius: 24px;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.95rem;
}
#messages-section #chat-input-area .chat-send-btn:hover,
#messages-section .chat-send-btn:hover {
  background: #0056b3 !important;
}

/* أيقونة إرفاق صورة في الدردشة */
#messages-section .chat-attach-btn {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #f0f2f5;
  border: 1px solid #ddd;
  border-radius: 50%;
  color: #555;
  cursor: pointer;
  margin: 0;
  padding: 0;
  transition: background 0.2s, color 0.2s;
}
#messages-section .chat-attach-btn:hover {
  background: #e4e6eb;
  color: var(--primary, #007bff);
}
#messages-section .chat-attach-btn i {
  font-size: 1.2rem;
}

/* صورة في فقاعة الدردشة */
#messages-section #chat-box .chat-msg-image-wrap {
  position: relative;
  margin-top: 4px;
  border-radius: 12px;
  overflow: hidden;
  max-width: 280px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
#messages-section #chat-box .chat-msg-image {
  display: block;
  width: 100%;
  height: auto;
  max-height: 300px;
  object-fit: cover;
  vertical-align: middle;
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
/* طبقة شفافة فوق الصورة لاستقبال اللمس على الجوال */
#messages-section #chat-box .chat-msg-image-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
#messages-section #chat-box .chat-bubble--me .chat-msg-image-wrap {
  border-radius: 14px 14px 4px 14px;
}
#messages-section #chat-box .chat-bubble--other .chat-msg-image-wrap {
  border-radius: 14px 14px 14px 4px;
}

/* علامة تحميل رفع الصورة */
#messages-section #chat-box .chat-loading-bubble .chat-msg-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
}
#messages-section #chat-box .chat-loading-spinner {
  width: 22px;
  height: 22px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: chat-spin 0.8s linear infinite;
}
#messages-section #chat-box .chat-loading-text {
  font-size: 0.9rem;
  opacity: 0.95;
}
@keyframes chat-spin {
  to { transform: rotate(360deg); }
}

/* تمييز رسائل المستخدم الحالي (يمين) ورسائل الطرف الآخر (يسار) */
#messages-section #chat-box .chat-bubble-wrap {
  max-width: 75%;
  display: flex;
}
#messages-section #chat-box .chat-bubble-wrap--me {
  align-self: flex-end;
  flex-direction: row;
  justify-content: flex-end;
}
#messages-section #chat-box .chat-bubble-wrap--other {
  align-self: flex-start;
  flex-direction: row;
  justify-content: flex-start;
}
#messages-section #chat-box .chat-bubble {
  padding: 10px 15px;
  border-radius: 14px;
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
#messages-section #chat-box .chat-bubble--me {
  background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
  color: #fff;
  border-radius: 14px 14px 4px 14px;
  box-shadow: 0 1px 3px rgba(52, 152, 219, 0.3);
}
#messages-section #chat-box .chat-bubble--me .chat-msg-text {
  color: #fff !important;
}
#messages-section #chat-box .chat-bubble--other {
  background: #f0f0f0;
  color: #1a1a1a;
  border: 1px solid #e0e0e0;
  border-radius: 14px 14px 14px 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}
#messages-section #chat-box .chat-bubble--other .chat-msg-text {
  color: #1a1a1a !important;
}

/* خط المحادثة: أكبر وأوضح */
#messages-section #chat-box .chat-msg-text,
#messages-section #chat-box [class*="chat-msg-text"] {
  font-size: 1.1rem !important;
  font-weight: 700 !important;
  line-height: 1.55 !important;
  color: #1a1a1a !important;
  letter-spacing: 0.2px;
  font-family: 'Almarai', 'Cairo', 'Tajawal', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#messages-section #chat-box .chat-msg-sender-name {
  font-size: 0.9rem !important;
  font-weight: 700 !important;
}

/* بطاقة الإعلان داخل فقاعة الدردشة */
#messages-section #chat-box .chat-ad-card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.08);
  max-width: 260px;
  margin-bottom: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
#messages-section #chat-box .chat-ad-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}
#messages-section #chat-box .chat-ad-card-img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  display: block;
  background: #eee;
}
#messages-section #chat-box .chat-ad-card-body {
  padding: 10px 12px;
}
#messages-section #chat-box .chat-ad-card-title {
  font-size: 0.95rem !important;
  font-weight: 700 !important;
  color: #1a1a1a !important;
  margin-bottom: 4px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
#messages-section #chat-box .chat-ad-card-price {
  font-size: 1rem !important;
  font-weight: 700 !important;
  color: var(--primary, #3498db) !important;
}
#messages-section #chat-box .chat-bubble--me .chat-ad-card {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.35);
}
#messages-section #chat-box .chat-bubble--me .chat-ad-card-title,
#messages-section #chat-box .chat-bubble--me .chat-ad-card-price {
  color: #fff !important;
}

.chat-delete-btn {
  color: var(--danger, #e74c3c) !important;
}
.chat-delete-btn:hover {
  color: #c0392b !important;
  background: rgba(231, 76, 60, 0.15) !important;
}

/* زر العودة للقائمة في هيدر المحادثة */
/* ================= رسائل - متجاوب للجوال ================= */
@media (max-width: 768px) {
  #messages-section {
    height: 100vh !important;
    max-height: 100vh !important;
    margin-bottom: 150px !important;
  }
  #messages-section .chat-layout {
    flex: 1;
    min-height: 0;
    display: flex;
    overflow: hidden;
  }
  #messages-section .chat-sidebar {
    width: 100% !important;
    max-width: 100% !important;
    flex: 1;
    min-height: 0;
    display: flex !important;
    flex-direction: column;
  }
  #messages-section .chat-layout.chat-view-active .chat-sidebar {
    display: none !important;
  }
  #messages-section .chat-main-area {
    display: none !important;
    flex: 1;
    min-height: 0;
    flex-direction: column;
    width: 100%;
    overflow: hidden;
  }
  #messages-section .chat-layout.chat-view-active .chat-main-area {
    display: flex !important;
  }
  #messages-section #chat-box {
    padding-bottom: 100px !important;
  }
  #messages-section #chat-input-area[style*="display: none"] {
    display: none !important;
  }
  /* صورة الدردشة على الجوال: عرض كامل الفقاعة مع border-radius موحّد */
  #messages-section #chat-box .chat-msg-image-wrap {
    max-width: 100% !important;
    border-radius: 12px !important;
  }
  #messages-section #chat-box .chat-msg-image {
    max-width: 100% !important;
    width: 100% !important;
    height: auto !important;
    border-radius: 12px !important;
    display: block !important;
  }
  #messages-section #chat-box .chat-bubble--me .chat-msg-image-wrap,
  #messages-section #chat-box .chat-bubble--other .chat-msg-image-wrap {
    border-radius: 12px !important;
  }
  /* أيقونة الكاميرا تظهر في الجوال بجانب حقل النص */
  #messages-section .chat-attach-btn {
    display: inline-flex !important;
    flex-shrink: 0 !important;
    width: 44px !important;
    min-width: 44px !important;
    height: 44px !important;
  }
}

/* ================= رسائل - ديسكتوب فقط: توزيع المساحات (لا يمس الجوال) ================= */
@media (min-width: 768px) {
  /* تكبير القائمة الجانبية: 350px (أو 30% على الشاشات الواسعة) */
  #messages-section .chat-sidebar {
    width: 30% !important;
    min-width: 350px !important;
    max-width: 420px !important;
    flex-shrink: 0 !important;
  }
  /* منطقة الدردشة تأخذ المساحة المتبقية تلقائياً */
  #messages-section .chat-main-area {
    flex: 1 !important;
    min-width: 0 !important;
  }
  /* صندوق الإرسال يتمدد مع منطقة الدردشة */
  #messages-section #chat-input-area,
  #messages-section .chat-input-area-fixed {
    position: relative !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 12px 20px;
    box-sizing: border-box !important;
    flex-shrink: 0;
  }
}

/* ================= FAVORITES PAGE ================= */
#favorites-page {
  background: var(--light); /* توحيد لون الخلفية */
  min-height: 100vh; /* ملء كامل الشاشة */
}

.favorites-container {
  padding: 20px;
  min-height: auto;
  background: var(--light); /* توحيد لون الخلفية */
}

/* حاوية الملف الشخصي - فصل كامل عن منطق المحادثة - تبدأ من الأعلى مباشرة */
#account-page .account-container {
  padding: 20px !important;
  padding-top: 20px !important;
  width: 100% !important;
  box-sizing: border-box !important;
  margin: 0 !important;
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  position: relative !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  background: var(--light) !important;
  min-height: auto !important;
  max-height: none !important;
  height: auto !important;
  /* إجبار flexbox على البدء من الأعلى - المفتاح الرئيسي */
  display: flex !important;
  flex-direction: column !important;
  gap: 20px !important;
  align-items: stretch !important;
  align-self: flex-start !important;
  justify-content: flex-start !important; /* هذا هو المفتاح - يبدأ من الأعلى */
  align-content: flex-start !important;
  flex-wrap: nowrap !important;
  flex-grow: 0 !important;
  flex-shrink: 0 !important;
  flex-basis: auto !important;
  /* منع أي تمدد أو توسع */
  overflow: visible !important;
}

.account-header {
  background: white;
  padding: 20px;
  padding-top: 20px !important;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 20px;
  margin: 0 !important;
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  box-shadow: 0 2px 8px var(--shadow);
  flex-shrink: 0 !important;
  flex-grow: 0 !important;
  width: 100%;
  box-sizing: border-box;
  align-self: flex-start !important;
  position: relative !important;
  top: 0 !important;
}

.account-avatar-wrapper {
  position: relative;
  display: inline-block;
}

.account-avatar-inner {
  position: relative;
  display: inline-block;
  overflow: visible;
}

.account-avatar {
  width: 100px;
  height: 100px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  color: white;
  font-weight: 700;
  overflow: hidden;
  position: relative;
  cursor: pointer;
}

.account-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.account-avatar span {
  position: absolute;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* الكاميرا: تحت الصورة يمين — خارج الدائرة بدون تغطية */
.avatar-change-btn {
  position: absolute;
  bottom: -40px;
  right: -40px;
  left: auto;
  top: auto;
  width: 34px;
  height: 34px;
  background: var(--primary);
  border: 2px solid white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
  font-size: 0.95rem;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  z-index: 2;
  -webkit-tap-highlight-color: transparent;
}
.avatar-change-btn:hover {
  background: var(--secondary);
  transform: scale(1.08);
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.25);
}
.avatar-change-btn:active {
  transform: scale(0.98);
}

/* الحذف: فوق الصورة يمين — حجم مناسب لسطح المكتب */
.avatar-delete-btn {
  position: absolute;
  top: -24px;
  right: -18px;
  left: auto;
  bottom: auto;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  border: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  color: #c0392b;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  z-index: 2;
  -webkit-tap-highlight-color: transparent;
}
.avatar-delete-btn i {
  font-size: 0.7rem;
}
.avatar-delete-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}
.avatar-delete-btn:active {
  transform: scale(0.98);
}

.account-info h2 {
  margin-bottom: 5px;
  color: var(--dark);
  font-weight: 600;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.account-info p {
  color: var(--gray);
  margin-bottom: 5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.account-menu {
  background: white;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 2px 8px var(--shadow);
  flex-shrink: 0;
  width: 100%;
  box-sizing: border-box;
  margin: 0 !important;
}

.menu-item {
  display: flex;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid var(--light-gray);
  cursor: pointer;
  transition: var(--transition);
}

.menu-item:hover {
  background: var(--light-gray);
}

.menu-item:last-child {
  border-bottom: none;
}

/* زر/عنصر خطير داخل قائمة الحساب (مثلاً حذف الحساب) */
.menu-item.danger i,
.menu-item.danger .menu-text {
  color: var(--danger);
}

.menu-item.danger .menu-arrow {
  color: var(--danger);
}

.menu-item.danger:hover {
  background: #ffecec;
}

.ads-count-badge {
  color: var(--primary);
  font-weight: 600;
  margin-right: 5px;
}

.menu-item i {
  font-size: 1.5rem;
  color: var(--primary);
  width: 40px;
}

.menu-text {
  flex: 1;
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--dark);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

.menu-arrow {
  color: var(--gray);
}

/* تنسيقات أقسام صفحة الحساب */
.account-section {
  background: white;
  padding: 20px;
  border-radius: var(--radius);
  box-shadow: 0 2px 8px var(--shadow);
  margin: 0 !important;
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  animation: slideIn 0.3s ease;
  width: 100%;
  box-sizing: border-box;
}

#changePasswordSection,
#updatePhoneSection,
#myAdsSection {
  background: white;
  padding: 20px;
  border-radius: var(--radius);
  box-shadow: 0 2px 8px var(--shadow);
  margin: 0 !important;
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  animation: slideIn 0.3s ease;
  width: 100%;
  box-sizing: border-box;
}

.account-section-header {
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 2px solid var(--light-gray);
}

.account-section-header h3 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--dark);
  display: flex;
  align-items: center;
  gap: 10px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

.account-section-header h3 i {
  color: var(--primary);
  font-size: 1.2rem;
}

/* ================= Delete Account Confirmation Modal ================= */
.confirm-modal {
  position: fixed;
  inset: 0;
  z-index: 11000;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
}

.confirm-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}

.confirm-modal-content {
  position: relative;
  background: #fff;
  border-radius: 12px;
  padding: 24px 20px;
  width: 90%;
  max-width: 420px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
  box-sizing: border-box;
  text-align: center;
}

.confirm-modal-title {
  margin: 0 0 12px 0;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--danger);
}

.confirm-modal-text {
  margin: 0 0 20px 0;
  font-size: 1rem;
  line-height: 1.7;
  color: #444;
}

.confirm-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.confirm-modal-btn {
  flex: 1;
  padding: 10px 16px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
}

.confirm-modal-btn.cancel {
  background: #f1f2f6;
  color: #333;
}

.confirm-modal-btn.danger {
  background: var(--danger);
  color: #fff;
}

.confirm-modal-btn.danger:hover {
  background: #c0392b;
}

/* ================= Forgot Password Modal ================= */
.forgot-modal {
  position: fixed !important;
  inset: 0 !important;
  z-index: 999999 !important;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  box-sizing: border-box;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  pointer-events: auto;
}

.forgot-modal-backdrop {
  position: fixed;
  inset: 0;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  cursor: pointer;
  z-index: 1;
}

.forgot-modal-content {
  position: relative;
  z-index: 2;
  background: #fff;
  border-radius: 12px;
  padding: 24px 20px;
  width: 90%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
  box-sizing: border-box;
  text-align: right;
  border-top: 4px solid var(--primary);
  margin: auto;
}

.forgot-modal-title {
  margin: 0 0 8px 0;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.forgot-modal-title i {
  color: var(--primary);
}

.forgot-modal-text {
  margin: 0 0 16px 0;
  font-size: 1rem;
  line-height: 1.6;
  color: #444;
}

.forgot-modal-content .form-group {
  margin-bottom: 16px;
}

.forgot-modal-content .form-group:last-of-type {
  margin-bottom: 12px;
}

.forgot-modal-message {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.95rem;
  line-height: 1.5;
}

.forgot-modal-message.success {
  background: rgba(39, 174, 96, 0.15);
  color: var(--success);
  border: 1px solid rgba(39, 174, 96, 0.3);
}

.forgot-modal-message.error {
  background: rgba(231, 76, 60, 0.1);
  color: var(--danger);
  border: 1px solid rgba(231, 76, 60, 0.25);
}

.forgot-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 16px;
}

.forgot-modal-btn {
  flex: 1;
  padding: 12px 16px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.2s ease, transform 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.forgot-modal-btn.cancel {
  background: #f1f2f6;
  color: #333;
}

.forgot-modal-btn.cancel:hover {
  background: #e4e6eb;
}

.forgot-modal-btn.submit {
  background: var(--primary);
  color: #fff;
}

.forgot-modal-btn.submit:hover {
  background: var(--secondary);
  transform: translateY(-1px);
}

.forgot-modal-btn.submit:disabled {
  opacity: 0.8;
  cursor: not-allowed;
  transform: none;
}

/* Forgot Password Modal - متجاوب للجوال */
@media (max-width: 480px) {
  .forgot-modal {
    padding: 16px;
    align-items: center;
    justify-content: center;
  }
  .forgot-modal-content {
    width: 100%;
    max-width: 100%;
    padding: 20px 16px;
    max-height: 85vh;
  }
}

@media (max-width: 360px) {
  .forgot-modal-content {
    padding: 18px 14px;
  }
  .forgot-modal-title {
    font-size: 1.2rem;
  }
}

/* تحسين عرض إعلاناتي */
#myAdsSection .ads-container {
  padding: 0;
  margin-top: 20px;
}

.following-container {
  margin-top: 20px;
}

.following-user-card {
  background: white;
  padding: 20px;
  border-radius: 12px;
  margin-bottom: 15px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  display: flex;
  align-items: center;
  gap: 15px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.following-user-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* ================= ADMIN PAGE ================= */
.admin-container {
  padding: 20px;
}

.admin-card {
  background: white;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 5px 25px var(--shadow);
}

.admin-header {
  background: linear-gradient(135deg, var(--warning), #e67e22);
  color: white;
  padding: 25px;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  padding: 20px;
}

.stat-card {
  background: var(--light-gray);
  padding: 20px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 20px;
  transition: var(--transition);
}

.stat-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 5px 15px var(--shadow);
}

.stat-icon {
  width: 60px;
  height: 60px;
  background: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.5rem;
}

.stat-number {
  font-size: 2rem;
  font-weight: 700;
  color: var(--dark);
}

.stat-label {
  color: var(--gray);
  font-size: 0.9rem;
}

.admin-tabs {
  padding: 20px;
}

.tab-buttons {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--light-gray);
  padding-bottom: 10px;
}

.tab-btn {
  padding: 10px 25px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray);
  cursor: pointer;
  transition: var(--transition);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

.admin-table-container {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 2px 10px var(--shadow);
}

.admin-table th {
  background: var(--light-gray);
  padding: 15px;
  text-align: right;
  font-weight: 600;
  color: var(--dark);
  border-bottom: 2px solid var(--border);
}

.admin-table td {
  padding: 15px;
  border-bottom: 1px solid var(--light-gray);
}

.admin-table tr:hover {
  background: var(--light-gray);
}

.status-active {
  color: var(--success);
  font-weight: 600;
}

.admin-actions {
  display: flex;
  gap: 10px;
}

.admin-btn-small {
  padding: 8px 15px;
  border: none;
  border-radius: 5px;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: var(--transition);
}

.admin-btn-small:hover {
  transform: translateY(-2px);
}

.admin-btn-view {
  background: var(--primary);
  color: white;
}

.admin-btn-edit {
  background: var(--warning);
  color: white;
}

.admin-btn-delete {
  background: var(--danger);
  color: white;
}

.reports-container {
  background: var(--light-gray);
  padding: 25px;
  border-radius: var(--radius);
}

.report-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 0;
  border-bottom: 1px solid var(--border);
}

.report-item:last-child {
  border-bottom: none;
}

.report-label {
  font-weight: 600;
  color: var(--dark);
}

.report-value {
  color: var(--primary);
  font-weight: 600;
}

/* ================= NOTIFICATION SYSTEM ================= */
/* Notification bell and panel removed */

/* ================= SIDE NAVIGATION ================= */
/* ================= SIDE NAVIGATION (Desktop) ================= */
.bottom-nav {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 118px; /* عرض يكفي لظهور «الرئيسية» و«المفضلة» كاملتين دون قص */
  background: white;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  padding: 20px 6px;
  padding-top: calc(70px + env(safe-area-inset-top));
  box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  gap: 18px;
  overflow-y: auto;
  overflow-x: hidden;
}

.bottom-nav .nav-item {
  margin: 0 4px; /* مسافة أفقية بين الأيقونات داخل الشريط */
  min-height: 78px; /* مساحة كافية للأيقونة + سطرين من النص حتى لا يُقطع الوصف */
  overflow: visible !important;
}

.nav-item {
  display: block !important;
  text-decoration: none;
  color: #2c3e50;
  padding: 14px 5px;
  padding-top: 10px !important;
  border-radius: var(--radius);
  transition: var(--transition);
  position: relative !important;
  width: 100%;
  min-width: auto;
  text-align: center;
  word-wrap: break-word;
  line-height: 1.35;
  overflow: visible !important;
  /* عدم استخدام flex للأيقونة/النص — الأيقونة تُوضَع بـ position مطلق */
}

/* غلاف الأيقونة في الشريط الجانبي — محاذاة أفقية ثابتة ومرتبة */
.nav-item .nav-icon {
  position: absolute !important;
  top: 10px !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  margin: 0 !important;
  pointer-events: none;
  width: 42px;
  box-sizing: border-box;
}
.nav-item .nav-icon i {
  font-size: 2.1rem;
  margin: 0 !important;
  display: inline-block !important;
  position: relative !important;
  text-align: center;
  width: 1em;
}

/* ألوان مخصصة للأيقونات */
.nav-item:nth-child(1) .nav-icon i {
  color: #3498db; /* أزرق للرئيسية */
}

.nav-item:nth-child(2) .nav-icon i {
  color: #e74c3c; /* أحمر للمفضلة */
}

.nav-item:nth-child(3) .nav-icon i {
  color: #27ae60; /* أخضر لإضافة إعلان */
}
/* منع تداخل كلمة "إضافة" مع أيقونة + */
.nav-item:nth-child(3) .nav-text {
  margin-top: 72px !important; /* أيقونة + حوالي 1 سم تحتها */
}

.nav-item:nth-child(4) .nav-icon i {
  color: #f39c12; /* برتقالي للرسائل */
}

.nav-item:nth-child(5) .nav-icon i {
  color: #9b59b6; /* بنفسجي للملف الشخصي */
}

/* أيقونة حسابي: خط أوضح وأكبر */
.bottom-nav .nav-item:nth-child(5) .nav-text {
  font-size: 1.28rem !important;
  font-weight: 800;
  color: #1a1a1a !important;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: 0.5px;
  margin-top: 74px !important; /* أيقونة + حوالي 1 سم تحتها */
}
.bottom-nav .nav-item:nth-child(5) .nav-icon i {
  font-size: 2.2rem !important;
}
.bottom-nav .nav-item:nth-child(5).active .nav-text {
  color: var(--primary) !important;
}

.nav-item .nav-text {
  display: block !important;
  font-size: 1.18rem;
  font-weight: 800;
  text-align: center;
  line-height: 1.35;
  word-break: break-word;
  white-space: normal;
  max-width: 100%;
  letter-spacing: 0.5px;
  margin-top: 66px !important; /* مسافة تحت الأيقونة (أيقونة + حوالي 1 سم) */
  padding: 0 4px;
  overflow: visible !important;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: #2c3e50;
}

.nav-item.active {
  background: rgba(52, 152, 219, 0.22);
  border-right: 3px solid var(--primary);
}

.nav-item.active .nav-icon i {
  transform: scale(1.1);
  color: var(--primary) !important;
}

.nav-item.active .nav-text {
  color: var(--primary);
  font-weight: 800;
}

.nav-item:hover {
  background: rgba(0, 0, 0, 0.03);
}

.nav-item:hover .nav-icon i {
  transform: scale(1.05);
  transition: transform 0.2s ease;
}

/* عداد الرسائل غير المقروءة: دائرة حمراء صغيرة + رقم أبيض، يختفي عند 0، متوافق iOS/Android */
.nav-badge {
  position: absolute;
  top: 4px;
  right: 50%;
  transform: translateX(50%);
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  box-sizing: border-box;
  border-radius: 50%;
  background: #e74c3c;
  background: var(--danger, #e74c3c);
  color: #fff !important;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1;
  display: none;
  align-items: center;
  justify-content: center;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  border: 2px solid #fff;
  z-index: 10;
  visibility: hidden;
}
.nav-badge.nav-badge-show {
  display: flex !important;
  visibility: visible !important;
}
.nav-badge:empty {
  min-width: 18px;
  padding: 0;
}

/* ================= ALERT ================= */
.alert {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary);
  color: white;
  padding: 15px 25px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 15px;
  box-shadow: 0 5px 20px rgba(0,0,0,0.2);
  z-index: 9999;
  animation: slideDown 0.3s ease;
  max-width: 90%;
  width: auto;
}

.alert i {
  font-size: 1.2rem;
}

.alert.success {
  background: var(--success);
}

.alert.error {
  background: var(--danger);
}

.alert.warning {
  background: var(--warning);
}

@keyframes slideDown {
  from {
    transform: translate(-50%, -100%);
    opacity: 0;
  }
  to {
    transform: translate(-50%, 0);
    opacity: 1;
  }
}

/* ================= LOADING SPINNER ================= */
.loading-spinner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loading-spinner[style*="display: none"],
.loading-spinner[style*="display:none"] {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 5px solid var(--light-gray);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 20px;
}

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

.loading-text {
  color: var(--dark);
  font-size: 1.1rem;
  font-weight: 500;
}

/* ================= Contact Modal ================= */
.contact-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  font-family: inherit;
}

.contact-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
}

.contact-modal-content {
  position: relative;
  background: #fff;
  width: 90%;
  max-width: 400px;
  border-radius: 16px;
  padding: 20px 24px 24px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  direction: rtl;
  border: 1px solid rgba(52, 152, 219, 0.15);
}

.contact-modal-title {
  margin: 0 0 4px 0;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--primary);
  text-align: right;
}

.contact-modal-close {
  position: absolute;
  top: 14px;
  left: 14px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 1.25rem;
  color: #333;
  padding: 4px;
  line-height: 1;
}

.contact-modal-close:hover {
  color: #000;
}

.contact-modal-divider {
  height: 1px;
  background: #eee;
  margin: 14px 0;
}

.contact-modal-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 16px;
  background: #fff;
  border: 1px solid #e8e8e8;
  border-radius: 12px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  color: #1a1a1a;
  text-align: right;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.contact-modal-row:hover {
  background: #f5f9ff;
  border-color: var(--primary);
  color: var(--primary);
}

.contact-modal-row-text {
  flex: 1;
}

.contact-modal-row-icon {
  font-size: 1.25rem;
  color: var(--primary);
  margin-right: 12px;
  flex-shrink: 0;
}

.contact-modal-row:hover .contact-modal-row-icon {
  color: var(--primary);
}

.contact-modal-row-phone .contact-modal-row-icon {
  color: #25D366;
}

.contact-modal-row-phone:hover .contact-modal-row-icon {
  color: #20bd5a;
}

.contact-modal-phone-row {
  margin-top: 0;
}

/* ================= EMPTY STATES ================= */
.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--gray);
}

.empty-state i {
  font-size: 4rem;
  margin-bottom: 20px;
  opacity: 0.3;
}

.empty-state h3 {
  color: var(--dark);
  margin-bottom: 10px;
}

/* ================= RESPONSIVE DESIGN ================= */
@media (max-width: 768px) {
  .header h1 {
    font-size: 1.2rem;
  }
  
  /* صفحات بدون شريط تنقل سفلي: تقليل المسافة السفلية */
  body.standalone-page {
    padding-bottom: 25px;
    padding-bottom: calc(25px + env(safe-area-inset-bottom));
  }
  
  /* صفحات النصوص (نظام العمولة، اتفاقية الاستخدام، إلخ) */
  .terms-page,
  .legal-page,
  .privacy-page {
    padding: 20px 15px 40px;
  }
  .terms-page h1,
  .legal-page h1,
  .privacy-page h1 {
    font-size: 1.5rem;
  }
  .terms-article h2,
  .legal-section h2,
  .privacy-section h2 {
    font-size: 1.1rem;
  }
  .terms-article img,
  .legal-section img,
  .privacy-section img {
    max-width: 100%;
    height: auto;
  }
  
  /* أزرار الهيدر مناسبة للمس (44px كحد أدنى) */
  .back-btn {
    min-width: 44px;
    min-height: 44px;
    padding: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }
  .header-home-btn {
    min-height: 44px;
    padding: 10px 16px;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    box-sizing: border-box;
    flex-shrink: 0;
  }
  .header-actions {
    flex-wrap: nowrap;
    gap: 10px;
  }
  
  .auth-status-btn,
  .admin-btn {
    padding: 8px 16px;
    font-size: 0.9rem;
  }
  
  /* في الجوال يُطبّق أيقونات فقط من الـ media block اللاحق (768px) */
  .auth-status-btn .btn-icon i {
    margin: 0;
  }
  
  .filters {
    padding: 10px;
  }
  
  .filter-btn {
    padding: 8px 12px;
    font-size: 1rem;
    font-weight: 700;
  }
  
  .sub-top-row {
    grid-template-columns: 1fr;
  }
  
  .ads-container {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    padding: 15px;
    gap: 15px;
  }
  
  .details-specs {
    grid-template-columns: 1fr;
  }
  
  .details-header-section {
    padding-bottom: 15px;
  }
  
  .details-price {
    font-size: 1.6rem;
  }
  
  .details-title {
    font-size: 1.2rem;
  }
  
  .details-meta-top {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  
  .images-gallery {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
  }
  
  .section-title {
    font-size: 1.1rem;
  }
  
  .details-actions {
    grid-template-columns: 1fr;
  }
  
  .admin-stats {
    grid-template-columns: 1fr;
  }
  
  
  /* إرجاع شريط التنقل للأسفل في الشاشات الصغيرة - تصميم مثل تطبيقات الجوال */
  .bottom-nav {
    position: fixed;
    bottom: 0;
    top: auto;
    right: 0;
    left: 0;
    width: 100%;
    height: auto;
    flex-direction: row;
    justify-content: space-around;
    align-items: center;
    padding: 12px 8px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom)); /* دعم للشاشات مع notch */
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    gap: 12px; /* مسافة بين الأيقونات في الشريط السفلي */
  }
  
  /* إضافة مساحة فارغة في أسفل الصفحة لتجنب تغطية المحتوى */
  body {
    padding-right: 0;
    padding-bottom: 70px;
    padding-bottom: calc(70px + env(safe-area-inset-bottom)); /* دعم للشاشات مع notch */
  }
  
  /* إخفاء النصوص في الشاشات الصغيرة */
  .bottom-nav .nav-text {
    display: none !important;
  }
  
  /* تحسين تصميم العناصر في الشاشات الصغيرة */
  .nav-item {
    min-width: 50px;
    width: auto;
    padding: 8px 12px;
    flex: 1;
    max-width: none;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
  
  /* على الجوال: توسيط الأيقونة في العنصر (النص مخفي) */
  .nav-item .nav-icon {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    transform: none !important;
  }
  
  .nav-item .nav-icon i {
    font-size: 1.65rem;
    margin: 0 !important;
  }
  
  .nav-item .nav-text {
    margin-top: 0 !important;
  }
  
  /* تحسين موضع الـ badge في الشاشات الصغيرة (متوافق مع safe-area) */
  .nav-badge {
    top: 2px;
    right: 50%;
    transform: translateX(50%);
    min-width: 16px;
    height: 16px;
    font-size: 0.65rem;
    padding: 0 4px;
  }
  .nav-badge:empty {
    min-width: 16px;
  }
  
  /* تحسين تصميم العنصر النشط في الشاشات الصغيرة */
  .nav-item.active {
    background: rgba(52, 152, 219, 0.25);
    border-radius: 12px;
    border-right: 3px solid var(--primary);
  }
  .nav-item.active .nav-icon i {
    color: var(--primary) !important;
  }
}

/* ================= FOOTER ================= */
.site-footer {
  background: #2c3e50;
  color: #ecf0f1;
  padding: 50px 20px 20px;
  margin-top: auto; /* دفع الفوتر لأسفل الشاشة عند قلة المحتوى عبر Flexbox */
  margin-right: calc(-118px);
  width: calc(100% + 118px);
  direction: rtl;
  box-sizing: border-box;
  position: relative;
  left: 0;
  right: 0;
}

.footer-container {
  max-width: 1200px;
  margin: 0 auto;
  padding-right: 118px; /* مساحة لشريط التنقل الجانبي */
  box-sizing: border-box;
}

.footer-content {
  display: flex;
  justify-content: space-between;
  gap: 40px;
  margin-bottom: 30px;
  flex-wrap: wrap;
}

.footer-column {
  flex: 1;
  min-width: 200px;
}

.footer-logo {
  font-size: 1.8rem;
  font-weight: 700;
  color: #fff;
  margin: 0 0 15px 0;
  text-align: right;
}

.footer-description {
  font-size: 0.95rem;
  line-height: 1.6;
  color: #bdc3c7;
  margin: 0 0 20px 0;
  text-align: right;
}

.social-links {
  display: flex;
  gap: 15px;
  justify-content: flex-start;
}

.social-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  color: #ecf0f1;
  text-decoration: none;
  transition: all 0.3s ease;
  font-size: 1.2rem;
}

.social-link:hover {
  background: var(--primary);
  color: #fff;
  transform: translateY(-3px);
}

.footer-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: #fff;
  margin: 0 0 20px 0;
  text-align: right;
}

.footer-links {
  list-style: none;
  padding: 0;
  margin: 0;
}

.footer-links li {
  margin-bottom: 12px;
}

.footer-link {
  color: #bdc3c7;
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.3s ease;
  display: block;
  text-align: right;
}

.footer-link:hover {
  color: var(--primary);
  padding-right: 5px;
}

/* إخفاء أيقونة العمولة — لإظهارها لاحقاً: احذف صنف hide-commission من الـ <li> في index.html */
.hide-commission {
  display: none !important;
}

/* رابط/أيقونة العمولة في الفوتر — لا تتأثر بقيود Flexbox */
.footer-commission-link {
  display: inline-flex !important;
  align-items: center !important;
  gap: 8px !important;
  flex: none !important;
  cursor: pointer;
}
.footer-commission-link i {
  flex-shrink: 0;
  font-size: 1rem;
}

.footer-bottom {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 20px;
  text-align: center;
  margin-top: 30px;
}

/* ================= نافذة منبثقة نظام العمولة ================= */
.commission-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
}

.commission-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  cursor: pointer;
}

.commission-modal-box {
  position: relative;
  background: #fff;
  border-radius: 12px;
  padding: 28px 24px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(39, 174, 96, 0.2);
  box-sizing: border-box;
}

.commission-modal-title {
  margin: 0 0 16px 0;
  font-size: 1.35rem;
  font-weight: 700;
  color: #27ae60;
  text-align: center;
  font-family: inherit;
}

.commission-modal-text {
  margin: 0 0 24px 0;
  font-size: 1.05rem;
  line-height: 1.7;
  color: #2c3e50;
  text-align: center;
}

/* نسبة العمولة 0.5% — أكبر وأوضح */
.commission-rate {
  font-size: 1.65rem;
  font-weight: 800;
  color: #27ae60;
  letter-spacing: 0.02em;
}

.commission-modal-close {
  display: block;
  width: 100%;
  padding: 12px 20px;
  background: #27ae60;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
  font-family: inherit;
}

.commission-modal-close:hover {
  background: #229954;
  transform: translateY(-1px);
}

.commission-modal-close:active {
  transform: translateY(0);
}

.copyright {
  color: #95a5a6;
  font-size: 0.85rem;
  margin: 0;
}

/* ================= Scroll to Top Button ================= */
.scroll-to-top {
  position: fixed;
  bottom: 100px;
  left: 30px;
  width: 50px;
  height: 50px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: all 0.3s ease;
  z-index: 999;
}

.scroll-to-top:hover {
  background: #2980b9;
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.scroll-to-top.show {
  display: flex;
}

/* ================= COMPARE FEATURE ================= */
/* Checkbox في بطاقة السيارة */
.ad-compare-checkbox {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 100;
  overflow: visible !important;
}

.compare-checkbox {
  display: none;
}

.compare-checkbox-label {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 35px;
  height: 35px;
  background: white;
  border: 2px solid var(--primary);
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  position: relative;
  overflow: visible;
  color: #000;
}

.compare-checkbox-label:hover {
  background: white;
  color: #000;
  transform: scale(1.1);
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.compare-checkbox:checked + .compare-checkbox-label {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.compare-checkbox-label i {
  font-size: 1rem;
  color: #000;
  font-weight: 900;
}

.compare-checkbox:checked + .compare-checkbox-label i {
  color: white;
}

.compare-tooltip {
  position: absolute;
  top: 50%;
  left: calc(100% + 10px);
  transform: translateY(-50%) translateX(0);
  background: white;
  color: #000;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: 'Almarai', 'Cairo', 'Tajawal', sans-serif;
  font-weight: 800;
  letter-spacing: 0.5px;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  z-index: 10001;
  text-align: center;
  border: 2px solid #e0e0e0;
  word-break: keep-all;
  display: block;
  width: max-content;
}

.compare-tooltip::after {
  content: '';
  position: absolute;
  top: 50%;
  right: 100%;
  transform: translateY(-50%);
  border: 6px solid transparent;
  border-right-color: white;
}

.compare-checkbox-label:hover .compare-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateY(-50%) translateX(3px);
}

/* الشريط العائم للمقارنة */
.compare-bar {
  position: fixed;
  bottom: 0;
  right: 0;
  left: 0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 15px 20px;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  direction: rtl;
  margin-right: 118px; /* مساحة لشريط التنقل الجانبي */
}

.compare-bar-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 1200px;
  gap: 20px;
}

.compare-bar-text {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.1rem;
  font-weight: 600;
}

.compare-bar-text i {
  font-size: 1.3rem;
}

#compareCount {
  font-weight: 700;
  color: #ffd700;
  font-size: 1.2rem;
}

.compare-bar-actions {
  display: flex;
  gap: 10px;
}

.compare-bar-btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.3s ease;
}

.compare-bar-btn.cancel {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.compare-bar-btn.cancel:hover {
  background: rgba(255, 255, 255, 0.3);
}

.compare-bar-btn.compare {
  background: #ffd700;
  color: #333;
  font-weight: 700;
}

.compare-bar-btn.compare:hover {
  background: #ffed4e;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 215, 0, 0.4);
}

/* Modal المقارنة */
.compare-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  font-family: inherit;
}

.compare-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.compare-modal-content {
  position: relative;
  background: white;
  width: 95%;
  max-width: 1000px;
  max-height: 90vh;
  border-radius: 16px;
  padding: 25px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  direction: rtl;
  overflow-y: auto;
}

.compare-modal-close {
  position: absolute;
  top: 15px;
  left: 15px;
  background: #f0f0f0;
  border: none;
  border-radius: 50%;
  width: 35px;
  height: 35px;
  cursor: pointer;
  font-size: 1.1rem;
  color: #666;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  z-index: 1;
}

.compare-modal-close:hover {
  background: #e0e0e0;
  color: #333;
}

.compare-modal-title {
  margin: 0 0 25px 0;
  font-size: 1.5rem;
  color: var(--primary);
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

/* جدول المقارنة */
.compare-table-container {
  overflow-x: auto;
  margin-bottom: 20px;
}

.compare-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.compare-table thead {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.compare-table th {
  padding: 15px;
  text-align: center;
  font-weight: 600;
  font-size: 1rem;
}

.compare-table th:first-child {
  background: rgba(255, 255, 255, 0.1);
  text-align: right;
}

.compare-car-col {
  width: 40%;
}

.compare-car-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.compare-car-title {
  font-size: 0.9rem;
  font-weight: 500;
  text-align: center;
  line-height: 1.3;
}

.compare-table tbody tr {
  border-bottom: 1px solid #eee;
  transition: background 0.2s ease;
}

.compare-table tbody tr:hover {
  background: #f8f9fa;
}

.compare-table tbody tr:last-child {
  border-bottom: none;
}

.compare-label {
  padding: 15px;
  background: #f8f9fa;
  font-weight: 600;
  color: var(--dark);
  text-align: right;
  width: 20%;
  vertical-align: middle;
}

.compare-label i {
  margin-left: 8px;
  color: var(--primary);
}

.compare-value {
  padding: 15px;
  text-align: center;
  vertical-align: middle;
}

.compare-image-cell {
  text-align: center;
  padding: 20px;
}

.compare-image {
  max-width: 150px;
  max-height: 100px;
  border-radius: 8px;
  object-fit: cover;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.compare-icon {
  font-size: 3rem;
  color: #ccc;
}

.price-negotiable {
  color: #f39c12;
  font-weight: 600;
  font-size: 1.1rem;
}

.price-value {
  color: var(--primary);
  font-weight: 700;
  font-size: 1.1rem;
}

.compare-actions {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 2px solid #eee;
}

.compare-action-btn {
  padding: 12px 30px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.3s ease;
}

.compare-action-btn:hover {
  background: #2980b9;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

/* Responsive Design للمقارنة */
@media (max-width: 768px) {
  .compare-bar {
    margin-right: 0;
    padding: 12px 15px;
    padding-bottom: calc(80px + 12px + env(safe-area-inset-bottom)); /* مساحة لشريط التنقل السفلي */
  }

  .compare-bar-content {
    flex-direction: column;
    gap: 12px;
  }

  .compare-bar-text {
    font-size: 1rem;
  }

  .compare-bar-actions {
    width: 100%;
    justify-content: space-between;
  }

  .compare-bar-btn {
    flex: 1;
    justify-content: center;
    padding: 10px 15px;
    font-size: 0.9rem;
  }

  .compare-modal-content {
    width: 98%;
    padding: 20px 15px;
    max-height: 95vh;
  }

  .compare-table {
    font-size: 0.85rem;
  }

  .compare-table th,
  .compare-table td {
    padding: 10px 8px;
  }

  .compare-image {
    max-width: 100px;
    max-height: 70px;
  }

  .compare-car-title {
    font-size: 0.8rem;
  }
}

/* Footer Responsive Design */
@media (max-width: 768px) {
  body {
    padding-right: 0; /* إزالة padding في الشاشات الصغيرة */
  }

  .site-footer {
    padding: 40px 15px 20px;
    margin: 40px 0 0 0;
    margin-right: 0; /* إزالة التعويض في الشاشات الصغيرة */
    width: 100%; /* عرض كامل في الشاشات الصغيرة */
    padding-bottom: 90px; /* مساحة لشريط التنقل السفلي */
  }
  body.standalone-page .site-footer {
    padding-bottom: 25px;
    padding-bottom: calc(25px + env(safe-area-inset-bottom));
  }

  .footer-container {
    padding-right: 0; /* إزالة المساحة الجانبية في الشاشات الصغيرة */
    padding-left: 0;
  }

  .footer-content {
    flex-direction: column;
    gap: 30px;
    text-align: center;
  }

  .footer-column {
    min-width: 100%;
  }

  .footer-logo,
  .footer-description,
  .footer-title {
    text-align: center;
  }

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

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

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

  .scroll-to-top {
    bottom: 90px;
    left: 20px;
    width: 45px;
    height: 45px;
    font-size: 1rem;
  }
}

/* تصغير عام للجوال — نسبة بصرية أفضل (مقياس، هوامش، هيدر، كروت) */
@media (max-width: 768px) {
  /* المقياس العام: خط أساس 14px لتقليل الإحساس بالضخامة */
  html {
    font-size: 14px;
  }

  /* الحاوية الرئيسية: عرض 92% مع توسيط لفراغ حقيقي يميناً ويساراً */
  .content-area,
  body .content-area {
    width: 92% !important;
    max-width: 92% !important;
    margin: 0 auto !important;
    padding: 12px 0 !important;
    box-sizing: border-box !important;
  }

  /* الهيدر: تصغير الارتفاع + شعار لا يتجاوز 120px */
  .header {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 5px 10px !important;
    padding-top: calc(5px + env(safe-area-inset-top)) !important;
    min-height: 40px !important;
    max-height: 48px !important;
    flex-wrap: nowrap !important;
  }
  .header-left {
    flex: 0 0 auto !important;
    min-width: 0 !important;
  }
  /* شعار سيارتي: لا يتجاوز 120px ليتنفس التصميم */
  .header h1 {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    max-width: 120px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    font-size: 0.8rem !important;
  }
  .header-actions {
    flex: 0 0 auto !important;
    flex-shrink: 0 !important;
    gap: 6px !important;
  }

  /* أزرار الدخول/الحساب/الخروج: أيقونات ثابتة لمنع التمطط */
  .auth-status-btn,
  .auth-register-btn,
  .auth-logout-btn {
    padding: 6px !important;
    min-width: 36px !important;
    min-height: 36px !important;
    font-size: 13px !important;
    border-radius: 50% !important;
    justify-content: center !important;
    align-items: center !important;
  }
  .auth-status-btn .btn-text,
  .auth-register-btn .btn-text,
  .auth-logout-btn .btn-text {
    display: none !important;
  }
  /* أيقونات الدخول/الخروج: aspect-ratio 1/1 و min-width ثابت لمنع التشوه */
  .auth-status-btn .btn-icon,
  .auth-register-btn .btn-icon,
  .auth-logout-btn .btn-icon {
    position: static !important;
    right: auto !important;
    transform: none !important;
    width: 28px !important;
    height: 28px !important;
    min-width: 28px !important;
    min-height: 28px !important;
    aspect-ratio: 1 / 1 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 !important;
    flex-shrink: 0 !important;
  }
  .auth-status-btn .btn-icon i,
  .auth-register-btn .btn-icon i,
  .auth-logout-btn .btn-icon i {
    font-size: 0.95rem !important;
    display: inline-block !important;
  }
  .auth-logout-btn .btn-icon {
    margin: 0 !important;
  }


  .auth-status-btn,
  .auth-register-btn,
  .auth-logout-btn {
    aspect-ratio: 1 / 1 !important;
    min-width: 40px !important;
    min-height: 40px !important;
  }

  /* كروت الإعلانات: max-width 100%، padding 8px، عنوان وسعر أصغر */
  .ads-container {
    gap: 6px;
    padding: 6px 0 !important;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    max-width: 100%;
    box-sizing: border-box !important;
  }

  .ad-card {
    border-radius: 10px;
    padding: 0;
    margin: 0;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  .ad-body {
    padding: 8px !important;
  }

  /* صورة الكرت: ارتفاع 180px لرؤية التفاصيل دون سحب كثير */
  .ad-img,
  .ad-card-slider {
    min-height: 140px;
    max-height: 180px;
    height: 180px;
    aspect-ratio: auto;
  }
  .ad-img img,
  .ad-card-slider-track img {
    object-fit: cover;
  }

  /* منع التحديد والـ highlight الرمادي على البطاقة والسلايدر في الجوال */
  .ad-card,
  .ad-card .ad-img,
  .ad-card .ad-card-slider,
  .ad-card .ad-card-slider-track,
  .ad-card .ad-card-slider-arrow {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    tap-highlight-color: transparent;
  }

  .ad-title {
    font-size: 0.82rem !important;
    line-height: 1.3;
  }

  .ad-price {
    font-size: 1rem !important;
  }

  .ad-meta {
    gap: 6px;
    margin-bottom: 6px;
    padding-bottom: 6px;
  }

  .ad-meta span {
    font-size: 0.7rem;
  }

  .ad-footer {
    padding-top: 8px;
  }

  .ad-comments-icon {
    margin-top: 12px;
    padding: 10px;
    font-size: 0.85rem;
  }

  .add-ad-card,
  .details-card {
    margin: 8px;
    padding: 14px;
  }

  .form-group {
    margin-bottom: 14px;
  }

  .form-label,
  .form-input {
    font-size: 0.9rem;
  }

  .form-input,
  .textarea {
    padding: 10px 12px;
  }

  .submit-btn {
    padding: 12px 18px;
    font-size: 0.95rem;
  }

  .details-body {
    padding: 20px;
  }

  .details-main-title,
  .details-title-section h1 {
    font-size: 1.62rem;
  }

  .details-price {
    font-size: 1.26rem;
  }

  .content-area {
    width: 92% !important;
    max-width: 92% !important;
    margin: 0 auto !important;
    padding: 12px 0 !important;
  }

  .page {
    padding: 0;
  }
}

@media (max-width: 480px) {
  .header {
    padding: 5px 10px !important;
    padding-top: calc(5px + env(safe-area-inset-top)) !important;
    max-height: 48px !important;
  }

  .content-area {
    width: 92% !important;
    max-width: 92% !important;
    margin: 0 auto !important;
    padding: 12px 0 !important;
  }

  .header-actions {
    gap: 6px;
  }
  
  .auth-switch-btn {
    padding: 12px;
    font-size: 0.9rem;
  }
  
  .ads-container {
    grid-template-columns: 1fr;
  }
  
  .account-header {
    flex-direction: column;
    text-align: center;
    gap: 12px;
  }

  /* حاوية صورة البروفايل للجوال: مرجع التموضع، وبلا Flex داخل الدائرة */
  .account-avatar-wrapper,
  .account-avatar-inner,
  .account-avatar {
    position: relative !important;
    display: block !important;
    overflow: visible !important;
  }

  .account-avatar {
    width: 100px !important;
    height: 100px !important;
    font-size: 2rem !important;
  }
  
  /* أيقونة حذف صورة البروفايل على الجوال (≤ 480px):
     - خارج إطار الدائرة (أسفل يسار)
     - حجم صغير ثابت
     - بلا أي تمركز للمنتصف أو تحريك إضافي */
  .avatar-delete-btn {
    position: absolute !important;
    top: auto !important;
    left: -10px !important;
    bottom: -5px !important;
    right: auto !important;
    transform: none !important;
    margin: 0 !important;
    width: 22px !important;
    height: 22px !important;
    min-width: 22px !important;
    border-radius: 50% !important;
    background: #fff !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2) !important;
    z-index: 10 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
  .avatar-delete-btn i {
    width: 12px !important;
    height: 12px !important;
    font-size: 12px !important;
  }

  .avatar-change-btn {
    width: 28px !important;
    height: 28px !important;
    font-size: 0.8rem !important;
    bottom: -36px;
    right: -36px;
  }

  .account-info h2 {
    font-size: 18px !important;
  }
  .account-info p {
    font-size: 14px !important;
  }

  .menu-text {
    font-size: 1rem;
  }
  
  .chat-section {
    margin-top: 20px;
    padding-top: 20px;
  }
  
  .chat-container {
    height: 250px;
  }
  
  .details-card {
    margin: 10px;
  }
  
  .details-body {
    padding: 15px;
  }
  
  .images-gallery {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }
  
  .details-price {
    font-size: 1.4rem;
  }
  
  .details-title {
    font-size: 1.1rem;
  }
  
  /* صفحات النصوص على الشاشات الصغيرة جداً */
  .terms-page,
  .legal-page,
  .privacy-page {
    padding: 16px 12px 30px;
  }
  .terms-page h1,
  .legal-page h1,
  .privacy-page h1 {
    font-size: 1.35rem;
  }
  .footer-bottom .copyright {
    font-size: 0.8rem;
    padding: 0 10px;
    word-break: break-word;
  }
}

/* ================= LAYOUT OVERRIDE (Higher Specificity) ================= */
/* توزيع العناصر: قوة اختيار أعلى + !important لضمان تفوق التنسيق على أي CSS خارجي (Font Awesome, Google Fonts) */
body .page {
  display: none !important;
  position: relative !important;
  margin: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}

body .page.active {
  display: block !important;
  position: relative !important;
  margin: 0 !important;
}

body #account-page:not(.active) {
  display: none !important;
  position: absolute !important;
  margin: 0 !important;
  visibility: hidden !important;
  overflow: hidden !important;
}

body #account-page.active {
  display: block !important;
  position: relative !important;
  margin: 0 !important;
}

body .header {
  display: flex !important;
  position: sticky !important;
  margin: 0 !important;
  top: 0 !important;
  width: 100% !important;
  box-sizing: border-box !important;
}

body #home-page,
body #auth-page,
body #add-ad-page,
body #details-page {
  display: none !important;
  position: relative !important;
  margin: 0 !important;
}

body #home-page.active,
body #auth-page.active,
body #add-ad-page.active,
body #details-page.active {
  display: block !important;
  position: relative !important;
  margin: 0 !important;
}

/* صفحة تسجيل الدخول فوق الشريط السفلي حتى لا يغطي الـ overlay الرابط/الزر */
body #auth-page.active {
  z-index: 1001 !important;
}

body .ads-container {
  display: grid !important;
  position: relative !important;
  margin: 0 !important;
  box-sizing: border-box !important;
}

body .content-area {
  display: block !important;
  position: relative !important;
  margin: 0 !important;
  box-sizing: border-box !important;
}

@media (max-width: 768px) {
  body .content-area {
    width: 92% !important;
    max-width: 92% !important;
    margin: 0 auto !important;
  }
}

body .bottom-nav {
  display: flex !important;
  position: fixed !important;
  margin: 0 !important;
  box-sizing: border-box !important;
}

body .ad-card {
  display: flex !important;
  position: relative !important;
  margin: 0 !important;
  box-sizing: border-box !important;
}

/* أيقونات Font Awesome داخل التخطيط: منع تغيير display من قوى خارجية من التأثير على التوزيع */
body .header i.fas,
body .header i.far,
body .header i.fab,
body .bottom-nav i.fas,
body .bottom-nav i.far,
body .bottom-nav i.fab {
  display: inline-block !important;
  position: relative !important;
  margin: 0 !important;
}

/* ================= توافق الجوال (iOS & Android) — 768px ================= */
@media (max-width: 768px) {
  /* منع أي حركة عرضية (اهتزاز) على الجوال */
  body {
    overflow-x: hidden !important;
    align-items: stretch !important;
  }
  #add-ad-page.active {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100vw !important;
    align-self: stretch !important;
  }
  /* كود التمريض: تصفير القيود في صفحة إضافة الإعلان فقط */
  #add-ad-page,
  #add-ad-page * {
    max-width: 100vw !important;
  }

  /* ===== استهداف مباشر للعناصر (بدون الاعتماد على الكلاسات فقط) — Android & iPhone ===== */
  #add-ad-page div[class*="container"],
  #add-ad-page div[class*="Container"],
  #add-ad-page div[class*="wrapper"],
  #add-ad-page div[class*="Wrapper"],
  #add-ad-page .add-ad-body,
  #add-ad-page .form-row,
  #add-ad-page .form-row-half {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
  /* السعر ورقم الجوال: كل حقل لوحده في سطر كامل على الجوال */
  #add-ad-page .form-row:has(#ad-price):has(#ad-phone),
  body #add-ad-page .form-row:has(#ad-price):has(#ad-phone) {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    gap: 0 !important;
  }
  #add-ad-page .form-row:has(#ad-price):has(#ad-phone) .form-group,
  body #add-ad-page .form-row:has(#ad-price):has(#ad-phone) .form-group {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    margin-bottom: 15px !important;
  }
  #add-ad-page .form-row:has(#ad-price):has(#ad-phone) .form-group:last-child {
    margin-bottom: 0 !important;
  }
  #add-ad-page input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
  #add-ad-page select,
  #add-ad-page textarea,
  #add-ad-page .form-input,
  #add-ad-page .add-ad-body input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
  #add-ad-page .add-ad-body select,
  #add-ad-page .add-ad-body textarea {
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    display: block !important;
    font-size: 16px !important;
    padding: 8px !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
  #add-ad-page .add-ad-body select,
  #add-ad-page .add-ad-body select.form-input {
    padding-left: 8px !important;
    padding-right: 8px !important;
    padding-inline-start: 36px !important;
    padding-inline-end: 8px !important;
  }
  #add-ad-page .add-ad-body textarea {
    overflow: auto !important;
    text-overflow: clip !important;
    white-space: pre-wrap !important;
  }
  #add-ad-page .add-ad-body input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
  #add-ad-page .add-ad-body select {
    white-space: nowrap !important;
  }
  /* محاذاة النصوص من اليمين + مسافة داخلية بسيطة */
  #add-ad-page .add-ad-body input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
  #add-ad-page .add-ad-body select,
  #add-ad-page .add-ad-body textarea {
    text-align: right !important;
    padding-inline-end: 15px !important;
  }
  /* توحيد العرض: السعر والكيلومترات 100% مثل بقية الحقول */
  #add-ad-page #ad-km,
  #add-ad-page #ad-price,
  #add-ad-page .form-group:has(#ad-km),
  #add-ad-page .form-group:has(#ad-price),
  #add-ad-page .price-group .form-input {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }
  /* زر إضافة الإعلان: عرض كامل + مسافة كافية فوقه لتفادي النقر بالخطأ */
  #add-ad-page .add-ad-body > .submit-btn {
    width: 100% !important;
    max-width: 100% !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    padding: 16px !important;
    min-height: 52px !important;
    font-size: 1.15rem !important;
    font-weight: 700 !important;
    background: linear-gradient(135deg, var(--success), #27ae60) !important;
    color: #fff !important;
    border: none !important;
    border-radius: 10px !important;
    margin-top: 28px !important;
    box-shadow: 0 4px 14px rgba(39, 174, 96, 0.35) !important;
  }

  /* تغيير الأب: إلغاء أي Fixed Width — الحاوية 100% في الجوال */
  #add-ad-page .add-ad-container,
  #add-ad-page .add-ad-card {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  #add-ad-page .add-ad-body {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 12px 8px !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
  }
  #add-ad-page .add-ad-container,
  #add-ad-page .add-ad-card {
    overflow-x: hidden !important;
    max-width: 100vw !important;
  }
  /* إلغاء max-width ثابت لمنطقة رفع الصور/الفيديو (كان 420px) */
  #add-ad-page .upload-area,
  #add-ad-page .upload-area-video {
    max-width: 100% !important;
    width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
  #add-ad-page input[type="file"],
  #add-ad-page .file-input-hidden {
    display: none !important;
    visibility: hidden !important;
    position: absolute !important;
    width: 0 !important;
    height: 0 !important;
    opacity: 0 !important;
    pointer-events: none !important;
    overflow: hidden !important;
  }
  /* تعطيل Flexbox العرضي — ما عدا السعر+على السوم (سطر واحد 70%/30%) */
  #add-ad-page .price-label-row,
  #add-ad-page .upload-actions-row {
    flex-direction: column !important;
    align-items: stretch !important;
    width: 100% !important;
  }
  /* دمج السعر وعلى السوم في سطر واحد: السعر 70%، على السوم 30% */
  #add-ad-page .price-group {
    display: flex !important;
    flex-direction: row !important;
    align-items: stretch !important;
    width: 100% !important;
    max-width: 100% !important;
    gap: 10px !important;
    flex-wrap: nowrap !important;
  }
  #add-ad-page .price-group .form-input {
    flex: 0 0 70% !important;
    width: 70% !important;
    max-width: 70% !important;
    min-width: 0 !important;
  }
  #add-ad-page .price-group .price-negotiable-center {
    flex: 0 0 30% !important;
    width: 30% !important;
    max-width: 30% !important;
    min-width: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
  /* ترتيب: السعر+على السوم أولاً ثم الكيلومترات سطر كامل تحته */
  #add-ad-page .form-row:has(#ad-km) {
    display: flex !important;
    flex-direction: column !important;
  }
  #add-ad-page .form-row:has(#ad-km) .form-group:has(.price-group) {
    order: 1 !important;
    margin-bottom: 15px !important;
  }
  #add-ad-page .form-row:has(#ad-km) .form-group:has(#ad-km) {
    order: 2 !important;
    margin-bottom: 0 !important;
  }
  /* نوع السيارة وحالة السيارة — سطر كامل (100%) لكل واحد */
  #add-ad-page .form-row:has(#ad-car-type),
  #add-ad-page .form-row:has(#ad-condition) {
    display: flex !important;
    flex-direction: column !important;
  }
  #add-ad-page .form-row:has(#ad-car-type) > .form-group,
  #add-ad-page .form-row:has(#ad-condition) > .form-group {
    width: 100% !important;
    max-width: 100% !important;
  }
  #add-ad-page .add-ad-body > .form-row,
  #add-ad-page .add-ad-body > .form-row-half {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    max-width: 100% !important;
    margin-bottom: 15px !important;
    padding: 0 !important;
    gap: 0 !important;
  }
  #add-ad-page .add-ad-body > .form-row:last-child,
  #add-ad-page .add-ad-body > .form-row-half:last-child {
    margin-bottom: 0 !important;
  }
  #add-ad-page .add-ad-body > .form-row > .form-group,
  #add-ad-page .add-ad-body > .form-row-half > .form-group {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    margin-bottom: 15px !important;
    padding: 0 !important;
  }
  #add-ad-page .add-ad-body > .form-row > .form-group:last-child,
  #add-ad-page .add-ad-body > .form-row-half > .form-group:last-child {
    margin-bottom: 15px !important;
  }
  #add-ad-page .add-ad-body > .form-row.form-row-full,
  #add-ad-page .add-ad-body > .form-row.form-row-title-desc,
  #add-ad-page .add-ad-body > .form-row:has(.form-group-full) {
    display: flex !important;
    flex-direction: column !important;
  }
  /* قاعدة 100vw: منع أي margin/padding من تجاوز عرض الشاشة — ثبات الصفحة على Android و iPhone */
  body #add-ad-page.active,
  #add-ad-page.active {
    padding-left: 0 !important;
    padding-right: 0 !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
  }
  #add-ad-page .add-ad-body .form-group,
  #add-ad-page .add-ad-body .form-row,
  #add-ad-page .add-ad-body .form-row-half {
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  /* تنسيق المدخلات: 16px على الأقل — منع زوم Safari التلقائي في الآيفون */
  input,
  select,
  textarea,
  .form-input,
  #add-ad-page .form-input,
  #add-ad-page select.form-input {
    font-size: 16px !important;
    min-height: 50px;
    line-height: 1.5 !important;
  }
  input:not([type="checkbox"]):not([type="radio"]),
  textarea {
    -webkit-appearance: none;
    appearance: none;
  }
  #add-ad-page .form-input.textarea,
  #add-ad-page #ad-description {
    min-height: 150px !important;
    padding: 12px !important;
    font-size: 16px !important;
    text-align: right !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  /* ===== صفحة إضافة إعلان — حقول بعرض كامل (الوالد تم تعطيل flex/grid أعلاه) ===== */
  #add-ad-page .form-group,
  #add-ad-page .input-container {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    box-sizing: border-box !important;
  }
  /* حقول الإدخال: padding 8px (يمين/يسار) لظهور النص كاملاً + ellipsis إن طال */
  #add-ad-page input,
  #add-ad-page select,
  #add-ad-page textarea,
  #add-ad-page .form-control,
  #add-ad-page .form-input,
  #add-ad-page .add-ad-body .form-input,
  #add-ad-page .add-ad-body input.form-input,
  #add-ad-page .add-ad-body textarea.form-input,
  #add-ad-page .add-ad-body input[type="text"],
  #add-ad-page .add-ad-body input[type="number"],
  #add-ad-page .add-ad-body input[type="tel"] {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    display: block !important;
    box-sizing: border-box !important;
    padding: 8px !important;
    font-size: 16px !important;
    min-height: 44px !important;
    line-height: 1.5 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
  #add-ad-page .add-ad-body textarea.form-input {
    overflow: auto !important;
    text-overflow: clip !important;
    white-space: pre-wrap !important;
  }
  #add-ad-page .add-ad-body input.form-input,
  #add-ad-page .add-ad-body select.form-input {
    white-space: nowrap !important;
  }
  #add-ad-page .add-ad-body select.form-input,
  #add-ad-page .add-ad-body select {
    padding-inline-start: 36px !important;
    padding-inline-end: 8px !important;
  }
  #add-ad-page .add-ad-body > .form-row .form-input,
  #add-ad-page .add-ad-body > .form-row-half .form-input,
  #add-ad-page .add-ad-body > .form-row input.form-input,
  #add-ad-page .add-ad-body > .form-row select.form-input,
  #add-ad-page .add-ad-body > .form-row-half input.form-input,
  #add-ad-page .add-ad-body > .form-row-half select.form-input {
    font-size: 15px !important;
  }
  #add-ad-page #ad-condition {
    padding: 8px !important;
    padding-inline-start: 36px !important;
    padding-inline-end: 8px !important;
  }
  #add-ad-page .add-ad-body > .form-row,
  #add-ad-page .add-ad-body > .form-row-half {
    margin-bottom: 15px !important;
  }
  #add-ad-page .add-ad-body > .form-row:last-child,
  #add-ad-page .add-ad-body > .form-row-half:last-child {
    margin-bottom: 0 !important;
  }
  /* حقل السعر + «على السوم»: سطر واحد 70%/30% (مُعرَّف أعلاه في نفس الـ media) — تنسيق فرعي */
  #add-ad-page .price-group .price-negotiable-center,
  #add-ad-page .price-group .price-negotiable-center.checkbox-label {
    font-size: 14px !important;
    line-height: 1.4 !important;
    padding: 4px 6px !important;
    cursor: pointer !important;
    flex-wrap: nowrap !important;
  }
  #add-ad-page .price-group .price-negotiable-center input[type="checkbox"] {
    width: 20px !important;
    height: 20px !important;
    flex-shrink: 0 !important;
  }
  #add-ad-page .price-group .price-negotiable-center span {
    min-width: 0 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
  #add-ad-page #ad-condition {
    min-height: 44px !important;
    height: auto !important;
  }
  #add-ad-page .form-input.textarea,
  #add-ad-page #ad-description {
    padding: 12px !important;
    min-height: 150px !important;
    font-size: 16px !important;
    text-align: right !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  #add-ad-page .form-label.form-label-title {
    font-size: 16px !important;
    margin-bottom: 8px !important;
  }

  /* تحسين اللمس: مساحة داخلية للأزرار لا تقل عن 12px */
  button,
  .submit-btn,
  .auth-switch-btn,
  .btn,
  .nav-item,
  .ad-card,
  .condition-option {
    padding: 12px 16px !important;
    min-height: 44px;
    min-width: 44px;
  }
  .bottom-nav .nav-item {
    padding: 12px 16px !important;
    min-height: 48px;
  }

  /* شريط الأزرار السفلي (App-like): ثابت في الأسفل — التأكيد على العرض الكامل */
  .bottom-nav {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    flex-direction: row !important;
    justify-content: space-around !important;
    padding: 12px 0 !important;
    padding-bottom: calc(12px + env(safe-area-inset-bottom)) !important;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.12);
    border-top: 1px solid rgba(0,0,0,0.08);
    z-index: 1000;
  }

  /* دعم الشاشات العالية (Retina): أوضح للأيقونات والخطوط */
  html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
  }
  .bottom-nav .nav-icon i,
  .nav-item .nav-icon i,
  .header i.fas,
  .header i.far {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
  img,
  .ad-img img,
  .details-images-section img {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
}

/* ================= شاشات الجوال الصغيرة (≤600px): صف كامل للحقول الطويلة + padding 6px + ellipsis ================= */
@media (max-width: 600px) {
  body {
    overflow-x: hidden !important;
  }
  #add-ad-page .add-ad-container,
  #add-ad-page .add-ad-card {
    max-width: 100% !important;
    padding: 0 !important;
  }
  #add-ad-page .add-ad-body {
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: 1fr !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 12px 6px !important;
    gap: 0 !important;
  }
  #add-ad-page .add-ad-body > .form-row,
  #add-ad-page .add-ad-body > .form-row-half {
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: 1fr !important;
    width: 100% !important;
    max-width: 100% !important;
    margin-bottom: 15px !important;
    padding: 0 !important;
    gap: 0 !important;
  }
  #add-ad-page .add-ad-body > .form-row:last-child,
  #add-ad-page .add-ad-body > .form-row-half:last-child {
    margin-bottom: 0 !important;
  }
  #add-ad-page .add-ad-body > .form-row > .form-group,
  #add-ad-page .add-ad-body > .form-row-half > .form-group,
  #add-ad-page .add-ad-body .form-group,
  #add-ad-page .form-row .form-group,
  #add-ad-page .form-row-half .form-group {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    margin-bottom: 15px !important;
    padding: 0 !important;
    display: block !important;
    box-sizing: border-box !important;
  }
  #add-ad-page .add-ad-body > .form-row > .form-group:last-child,
  #add-ad-page .add-ad-body > .form-row-half > .form-group:last-child {
    margin-bottom: 15px !important;
  }
  /* السعر ورقم الجوال: كل حقل لوحده في سطر كامل */
  #add-ad-page .form-row:has(#ad-price):has(#ad-phone),
  body #add-ad-page .form-row:has(#ad-price):has(#ad-phone) {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    gap: 0 !important;
  }
  #add-ad-page .form-row:has(#ad-price):has(#ad-phone) .form-group,
  body #add-ad-page .form-row:has(#ad-price):has(#ad-phone) .form-group {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    margin-bottom: 15px !important;
  }
  #add-ad-page .form-row:has(#ad-price):has(#ad-phone) .form-group:last-child {
    margin-bottom: 0 !important;
  }

  /* الحقول الطويلة (الشركة المصنعة، حالة الاستمارة، حالة الفحص) — صف كامل 100% لكل حقل */
  #add-ad-page .form-row:has(#ad-manufacturer),
  #add-ad-page .form-row:has(#ad-registration-status),
  #add-ad-page .form-row:has(#ad-inspection-status) {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  #add-ad-page .form-group:has(#ad-manufacturer),
  #add-ad-page .form-group:has(#ad-registration-status),
  #add-ad-page .form-group:has(#ad-inspection-status) {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }
  #add-ad-page #ad-manufacturer,
  #add-ad-page #ad-registration-status,
  #add-ad-page #ad-inspection-status {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }
  #add-ad-page .add-ad-body > .form-row.form-row-full,
  #add-ad-page .add-ad-body > .form-row.form-row-title-desc,
  #add-ad-page .add-ad-body > .form-row:has(.form-group-full) {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
  }
  /* padding 6px (و 15px لجهة النص) — ظهور أكبر قدر من النص + محاذاة يمين */
  #add-ad-page .add-ad-body .form-input,
  #add-ad-page .add-ad-body input.form-input,
  #add-ad-page .add-ad-body select.form-input,
  #add-ad-page .add-ad-body textarea.form-input,
  #add-ad-page .add-ad-body input:not([type="checkbox"]):not([type="radio"]):not([type="file"]) {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    padding: 6px !important;
    padding-left: 6px !important;
    padding-right: 15px !important;
    padding-inline-start: 32px !important;
    padding-inline-end: 15px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    text-align: right !important;
  }
  #add-ad-page .add-ad-body textarea.form-input {
    white-space: pre-wrap !important;
    overflow: auto !important;
    text-overflow: clip !important;
    padding: 6px !important;
  }
  #add-ad-page .add-ad-body select.form-input,
  #add-ad-page .add-ad-body select {
    padding-inline-start: 32px !important;
    padding-inline-end: 15px !important;
  }
  #add-ad-page #ad-condition,
  #add-ad-page #ad-manufacturer,
  #add-ad-page #ad-registration-status,
  #add-ad-page #ad-inspection-status {
    padding: 6px !important;
    padding-inline-start: 32px !important;
    padding-inline-end: 15px !important;
  }
  /* محاذاة النصوص من اليمين + مسافة داخلية بسيطة */
  #add-ad-page .add-ad-body input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
  #add-ad-page .add-ad-body select,
  #add-ad-page .add-ad-body textarea.form-input {
    text-align: right !important;
    padding-inline-end: 15px !important;
  }
  /* دمج السعر وعلى السوم في سطر واحد: 70% / 30% */
  #add-ad-page .price-group {
    display: flex !important;
    flex-direction: row !important;
    align-items: stretch !important;
    width: 100% !important;
    gap: 10px !important;
    flex-wrap: nowrap !important;
  }
  #add-ad-page .price-group .form-input {
    flex: 0 0 70% !important;
    width: 70% !important;
    max-width: 70% !important;
    min-width: 0 !important;
  }
  #add-ad-page .price-group .price-negotiable-center {
    flex: 0 0 30% !important;
    width: 30% !important;
    max-width: 30% !important;
    min-width: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
  /* ترتيب: السعر+على السوم أولاً ثم الكيلومترات سطر كامل (100%) */
  #add-ad-page .form-row:has(#ad-km) .form-group:has(.price-group) {
    order: 1 !important;
  }
  #add-ad-page .form-row:has(#ad-km) .form-group:has(#ad-km) {
    order: 2 !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  #add-ad-page #ad-km {
    width: 100% !important;
    max-width: 100% !important;
  }
  /* نوع السيارة وحالة السيارة — سطر كامل لكل واحد */
  #add-ad-page .form-row:has(#ad-car-type) > .form-group,
  #add-ad-page .form-row:has(#ad-condition) > .form-group {
    width: 100% !important;
    max-width: 100% !important;
  }
  /* المسافات: 15px بين كل سطر وسطر */
  #add-ad-page .add-ad-body > .form-row,
  #add-ad-page .add-ad-body > .form-row-half {
    margin-bottom: 15px !important;
  }
  #add-ad-page .add-ad-body > .form-row > .form-group,
  #add-ad-page .add-ad-body > .form-row-half > .form-group {
    margin-bottom: 15px !important;
  }
  #add-ad-page .add-ad-body > .form-row > .form-group:last-child,
  #add-ad-page .add-ad-body > .form-row-half > .form-group:last-child {
    margin-bottom: 15px !important;
  }
  #add-ad-page .form-input.textarea,
  #add-ad-page #ad-description {
    padding: 12px !important;
    min-height: 150px !important;
    font-size: 16px !important;
    text-align: right !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  /* زر إضافة الإعلان: عرض الشاشة كامل + مسافة كافية فوقه */
  #add-ad-page .add-ad-body > .submit-btn {
    width: 100% !important;
    max-width: 100% !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    padding: 16px !important;
    min-height: 52px !important;
    font-size: 1.15rem !important;
    font-weight: 700 !important;
    background: linear-gradient(135deg, var(--success), #27ae60) !important;
    color: #fff !important;
    border: none !important;
    border-radius: 10px !important;
    margin-top: 28px !important;
    box-shadow: 0 4px 14px rgba(39, 174, 96, 0.35) !important;
  }
  #add-ad-page .form-label,
  #add-ad-page .form-label.form-label-title {
    display: block !important;
    width: 100% !important;
    margin-bottom: 6px !important;
  }
}