/* ============================================================
   style.css — سجلني | ديلز+
   تصميم RTL | أزرق داكن #0F172A | ذهبي #F59E0B
   ============================================================ */

/* ---------- المتغيرات ---------- */
:root {
  --bg-base:       #0F172A;
  --bg-surface:    #1E293B;
  --bg-elevated:   #273548;
  --border:        #334155;
  --gold:          #F59E0B;
  --gold-light:    #FCD34D;
  --gold-dim:      rgba(245,158,11,0.15);
  --blue-accent:   #3B82F6;
  --success:       #10B981;
  --danger:        #EF4444;
  --text-primary:  #F1F5F9;
  --text-secondary:#94A3B8;
  --text-muted:    #64748B;
  --radius-sm:     8px;
  --radius-md:     14px;
  --radius-lg:     20px;
  --shadow-card:   0 4px 24px rgba(0,0,0,0.35);
  --shadow-modal:  0 8px 48px rgba(0,0,0,0.6);
  --transition:    0.2s ease;
  --font-main:     'Cairo', sans-serif;
}

/* ---------- إعادة التعيين ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font-main);
  background: var(--bg-base);
  color: var(--text-primary);
  direction: rtl;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}
button { cursor: pointer; font-family: inherit; border: none; background: none; }
input, select, textarea { font-family: inherit; }
a { color: var(--gold); text-decoration: none; }
img { max-width: 100%; }
ul { list-style: none; }

/* ---------- مساعدات ---------- */
.hidden { display: none !important; }
.text-gold { color: var(--gold); }
.text-muted { color: var(--text-muted); font-size: 0.85rem; }

/* ============================================================
   شاشة تسجيل الدخول
   ============================================================ */
#screen-auth {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(245,158,11,0.12) 0%, transparent 70%),
    var(--bg-base);
  padding: 1.5rem;
}

.auth-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-modal);
}

.auth-logo {
  text-align: center;
  margin-bottom: 2rem;
}
.auth-logo .logo-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 0.5rem;
  filter: drop-shadow(0 0 12px var(--gold));
}
.auth-logo h1 {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--gold);
  letter-spacing: -0.5px;
}
.auth-logo p { color: var(--text-secondary); font-size: 0.9rem; margin-top: 0.25rem; }

#auth-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  color: var(--text-primary);
}

.auth-toggle {
  text-align: center;
  margin-top: 1.25rem;
  font-size: 0.88rem;
  color: var(--text-secondary);
}
.auth-toggle a { color: var(--gold); font-weight: 600; }

/* ============================================================
   التطبيق الرئيسي
   ============================================================ */
#screen-app { display: flex; flex-direction: column; min-height: 100dvh; }

/* ---------- Header ---------- */
.app-header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.header-brand .brand-icon { font-size: 1.5rem; }
.header-brand h1 {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--gold);
  line-height: 1;
}
.header-brand span {
  font-size: 0.7rem;
  color: var(--text-muted);
  display: block;
}

.header-actions { display: flex; align-items: center; gap: 0.5rem; }
.header-user { font-size: 0.78rem; color: var(--text-secondary); }

/* زر AI في الهيدر */
.ai-header-btn {
  position: relative;
  color: var(--gold) !important;
  border: 1px solid rgba(245,158,11,0.3) !important;
  background: rgba(245,158,11,0.08) !important;
}
.ai-header-btn:hover {
  background: rgba(245,158,11,0.18) !important;
}
.ai-header-badge {
  position: absolute;
  top: -3px;
  left: -3px;
  background: var(--gold);
  color: #000;
  font-size: 0.5rem;
  font-weight: 900;
  padding: 1px 3px;
  border-radius: 4px;
  line-height: 1.3;
  letter-spacing: 0.3px;
}

/* ---------- التبويبات ---------- */
.tabs-nav {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 0 0.75rem;
  gap: 0.25rem;
}
.tabs-nav::-webkit-scrollbar { display: none; }

.tab-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.75rem 1rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: var(--transition);
  position: relative;
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}
.tab-btn i { font-size: 1rem; }
.tab-badge {
  background: var(--gold);
  color: #000;
  border-radius: 99px;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 1px 6px;
  min-width: 18px;
  text-align: center;
}

/* ---------- المحتوى ---------- */
.app-content {
  flex: 1;
  padding: 1.25rem;
  max-width: 960px;
  margin: 0 auto;
  width: 100%;
}

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

/* ---------- شريط الأدوات ---------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.search-box {
  flex: 1;
  min-width: 180px;
  position: relative;
}
.search-box i {
  position: absolute;
  right: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
.search-box input {
  width: 100%;
  padding: 0.6rem 2.4rem 0.6rem 0.9rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.9rem;
  transition: var(--transition);
}
.search-box input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-dim);
}

/* ============================================================
   بطاقات العروض
   ============================================================ */
.offers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.offer-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  transition: transform var(--transition), box-shadow var(--transition);
  position: relative;
  overflow: hidden;
}
.offer-card::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 3px;
  height: 100%;
  background: var(--gold);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}
.offer-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
  border-color: var(--gold);
}
.offer-card.expired { opacity: 0.65; }
.offer-card.expired::before { background: var(--text-muted); }

.offer-card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.badge-category {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 2px 10px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}
.badge-discount {
  background: var(--gold);
  color: #000;
  border-radius: 99px;
  padding: 2px 10px;
  font-size: 0.75rem;
  font-weight: 800;
  margin-right: auto;
}
.badge-expired {
  background: var(--danger);
  color: #fff;
  border-radius: 99px;
  padding: 2px 8px;
  font-size: 0.72rem;
}

.offer-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.4;
}
.offer-meta {
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.offer-meta i { margin-left: 3px; }

.offer-prices {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}
.price-before {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-decoration: line-through;
}
.price-after {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--gold);
}

.offer-expires {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.offer-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.25rem;
  flex-wrap: wrap;
}

/* ============================================================
   الأزرار
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  transition: var(--transition);
  border: 1px solid transparent;
}
.btn-primary {
  background: var(--gold);
  color: #000;
}
.btn-primary:hover { background: var(--gold-light); }

.btn-buy {
  background: var(--gold);
  color: #000;
  flex: 1;
  justify-content: center;
}
.btn-buy:hover { background: var(--gold-light); }

.btn-edit {
  background: var(--bg-elevated);
  border-color: var(--border);
  color: var(--text-secondary);
}
.btn-edit:hover { border-color: var(--blue-accent); color: var(--blue-accent); }

.btn-archive {
  background: var(--bg-elevated);
  border-color: var(--border);
  color: var(--text-secondary);
}
.btn-archive:hover { border-color: var(--text-muted); color: var(--text-primary); }

.btn-delete {
  background: var(--bg-elevated);
  border-color: var(--border);
  color: var(--text-muted);
}
.btn-delete:hover { border-color: var(--danger); color: var(--danger); }

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

.btn-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  transition: var(--transition);
  background: var(--bg-elevated);
}
.btn-icon:hover { border-color: var(--gold); color: var(--gold); }
.btn-icon.btn-danger:hover { border-color: var(--danger); color: var(--danger); }

/* ---------- زر عائم ---------- */
.fab {
  position: fixed;
  left: 1.5rem;
  bottom: 1.75rem;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--gold);
  color: #000;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(245,158,11,0.45);
  z-index: 200;
  transition: transform var(--transition), box-shadow var(--transition);
}
.fab:hover {
  transform: scale(1.1) rotate(90deg);
  box-shadow: 0 6px 28px rgba(245,158,11,0.6);
}

/* ============================================================
   بطاقات المشتريات
   ============================================================ */
.purchases-list { display: flex; flex-direction: column; gap: 0.75rem; }

.purchase-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.1rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  transition: var(--transition);
}
.purchase-card:hover { border-color: var(--gold); }

.purchase-card-left {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}
.purchase-icon {
  font-size: 1.6rem;
  line-height: 1;
  flex-shrink: 0;
}
.purchase-card-left h4 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 0.2rem;
}
.purchase-card-left p {
  font-size: 0.78rem;
  color: var(--text-secondary);
}
.purchase-notes {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
  font-style: italic;
}

.purchase-card-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.2rem;
  flex-shrink: 0;
}
.purchase-total {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--gold);
}
.purchase-total small { font-size: 0.72rem; }
.purchase-qty { font-size: 0.78rem; color: var(--text-muted); }
.purchase-saved {
  font-size: 0.75rem;
  color: var(--success);
  font-weight: 600;
}

/* ============================================================
   التحليلات
   ============================================================ */
.analytics-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.analytics-header label {
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.analytics-header input[type="date"] {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 0.45rem 0.75rem;
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
}
.analytics-header input[type="date"]:focus {
  outline: none;
  border-color: var(--gold);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.5rem;
}

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.1rem 1rem;
  text-align: center;
  transition: var(--transition);
}
.kpi-card:hover { border-color: var(--gold); }
.kpi-card .kpi-icon {
  font-size: 1.4rem;
  margin-bottom: 0.4rem;
}
.kpi-card .kpi-value {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--gold);
  display: block;
}
.kpi-card .kpi-unit { font-size: 0.7rem; color: var(--text-muted); }
.kpi-card .kpi-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 0.2rem;
}

.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 600px) {
  .charts-grid { grid-template-columns: 1fr; }
}

.chart-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem;
}
.chart-box h3 {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.chart-box canvas { max-height: 240px; }

/* ============================================================
   المودالات
   ============================================================ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.modal.active {
  opacity: 1;
  pointer-events: all;
}
.modal.active .modal-box {
  transform: translateY(0);
  opacity: 1;
}

.modal-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%;
  max-width: 520px;
  max-height: 92dvh;
  overflow-y: auto;
  padding: 1.5rem;
  transform: translateY(40px);
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.34,1.3,0.64,1), opacity 0.25s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}
.modal-header h2 {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--gold);
}
.modal-close {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem;
  transition: var(--transition);
}
.modal-close:hover { color: var(--danger); border-color: var(--danger); }

/* ---------- النماذج ---------- */
.form-group { margin-bottom: 1rem; }
.form-label {
  display: block;
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}
.form-control {
  width: 100%;
  padding: 0.65rem 0.85rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
  transition: var(--transition);
}
.form-control:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-dim);
}
.form-control::placeholder { color: var(--text-muted); }

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394A3B8' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 0.85rem center;
  padding-left: 2rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.discount-preview {
  margin-top: 0.4rem;
  font-size: 0.8rem;
  color: var(--success);
  font-weight: 600;
  display: none;
}

.modal-footer {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.modal-footer .btn { flex: 1; justify-content: center; padding: 0.7rem; font-size: 0.9rem; }

/* ---------- مودال الشراء ---------- */
.buy-offer-name {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 1.25rem;
  font-size: 1rem;
}

/* ---------- مودال الإعدادات ---------- */
.settings-section { margin-bottom: 1.5rem; }
.settings-section h3 {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}
.settings-add-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.settings-add-row .form-control { flex: 1; }
.settings-add-row .form-control.emoji-input { width: 70px; flex: none; text-align: center; }
.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  margin-bottom: 0.4rem;
  font-size: 0.88rem;
}
.empty-small { font-size: 0.82rem; color: var(--text-muted); padding: 0.5rem 0; }

/* ============================================================
   الحالة الفارغة
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}
.empty-state i {
  font-size: 3rem;
  margin-bottom: 0.75rem;
  display: block;
  opacity: 0.4;
}
.empty-state p { font-size: 1rem; margin-bottom: 1rem; }

/* ============================================================
   Toast
   ============================================================ */
#toast-container {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
  width: min(340px, 90vw);
}
.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  font-size: 0.88rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  opacity: 0;
  transform: translateY(-12px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  box-shadow: var(--shadow-card);
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { border-color: var(--success); color: var(--success); }
.toast-error   { border-color: var(--danger);  color: var(--danger);  }

/* ============================================================
   الـ Loader
   ============================================================ */
#global-loader {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.8);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1rem;
}
.loader-spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
#global-loader p { color: var(--text-secondary); font-size: 0.88rem; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   عنوان القسم
   ============================================================ */
.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.section-title i { color: var(--gold); }

/* ============================================================
   الاستجابة للشاشات الصغيرة
   ============================================================ */
@media (max-width: 480px) {
  .app-content { padding: 1rem 0.75rem; }
  .offers-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .modal-box { border-radius: var(--radius-md) var(--radius-md) 0 0; padding: 1.25rem 1rem; }
  .fab { left: 1rem; bottom: 1.25rem; }
  .header-user { display: none; }
}

/* ============================================================
   تمرير ناعم للـ scrollbar
   ============================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ============================================================
   إضافات v2 — تنبيهات الأسعار
   ============================================================ */
.alerts-list { display: flex; flex-direction: column; gap: 0.75rem; }

.alert-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  transition: var(--transition);
}
.alert-card:hover { border-color: var(--gold); }
.alert-card.alert-triggered {
  border-color: var(--success);
  background: linear-gradient(135deg, var(--bg-surface) 80%, rgba(16,185,129,0.06));
}

.alert-card-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}
.alert-icon { font-size: 1.6rem; flex-shrink: 0; }
.alert-card h4 { font-size: 0.95rem; font-weight: 700; margin-bottom: 0.2rem; }
.alert-card p  { font-size: 0.82rem; color: var(--text-secondary); }
.alert-triggered-label {
  color: var(--success) !important;
  font-weight: 600;
  margin-top: 0.25rem;
}

/* بيانات meta في بطاقة العرض */
.offer-card-meta-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.offer-version {
  font-size: 0.72rem;
  color: var(--text-muted);
}
.offer-version i { margin-left: 2px; }


/* ============================================================
   🤖 AI CHAT WIDGET — المساعد الذكي v3.0
   ============================================================ */

/* ----------------------------------------------------------
   متغيرات الـ AI Widget
   ---------------------------------------------------------- */
:root {
  --ai-gold:       #F59E0B;
  --ai-gold-glow:  rgba(245, 158, 11, 0.35);
  --ai-bg-panel:   #111827;
  --ai-bg-msg-ai:  #1E293B;
  --ai-bg-msg-usr: rgba(245, 158, 11, 0.15);
  --ai-border:     rgba(255, 255, 255, 0.08);
  --ai-panel-w:    360px;
  --ai-panel-h:    520px;
  --ai-radius:     20px;
  --ai-fab-size:   56px;
  --ai-transition: 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ----------------------------------------------------------
   الحاوية الرئيسية
   ---------------------------------------------------------- */
#ai-chat-widget {
  position: fixed;
  bottom: 24px;
  left: 24px;           /* يسار الشاشة — لا يتعارض مع FAB العائم في اليمين */
  z-index: 9999;
  font-family: var(--font-main, 'Cairo', sans-serif);
  direction: rtl;
}

/* ----------------------------------------------------------
   زر التفعيل العائم (FAB)
   ---------------------------------------------------------- */
.ai-fab {
  position: relative;
  width: var(--ai-fab-size);
  height: var(--ai-fab-size);
  border-radius: 50%;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  border: 2px solid var(--ai-gold);
  color: var(--ai-gold);
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform var(--ai-transition), box-shadow 0.25s;
  box-shadow:
    0 4px 20px rgba(0, 0, 0, 0.5),
    0 0 0 0 var(--ai-gold-glow);
  animation: ai-pulse 3s infinite;
}
.ai-fab:hover {
  transform: scale(1.12);
  box-shadow:
    0 6px 28px rgba(0, 0, 0, 0.6),
    0 0 0 6px var(--ai-gold-glow);
  animation: none;
}
.ai-fab.ai-fab-active {
  background: var(--ai-gold);
  color: #000;
  animation: none;
  border-color: var(--ai-gold);
}

/* نبضة الانتباه */
@keyframes ai-pulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(0,0,0,0.5), 0 0 0 0 var(--ai-gold-glow); }
  50%       { box-shadow: 0 4px 20px rgba(0,0,0,0.5), 0 0 0 10px transparent; }
}

/* شارة AI */
.ai-fab-label {
  position: absolute;
  top: -4px;
  right: -4px;         /* أيقونة صغيرة تظهر فوق يمين الزر */
  background: var(--ai-gold);
  color: #000;
  font-size: 0.55rem;
  font-weight: 900;
  padding: 1px 4px;
  border-radius: 6px;
  letter-spacing: 0.5px;
  line-height: 1.4;
}

/* ----------------------------------------------------------
   لوحة المحادثة
   ---------------------------------------------------------- */
.ai-panel {
  position: absolute;
  bottom: calc(var(--ai-fab-size) + 14px);
  left: 0;
  width: var(--ai-panel-w);
  max-height: var(--ai-panel-h);
  display: flex;
  flex-direction: column;
  background: var(--ai-bg-panel);
  border: 1px solid var(--ai-border);
  border-radius: var(--ai-radius);
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.7),
    0 0 0 1px var(--ai-gold-glow);
  overflow: hidden;

  /* حالة الإغلاق */
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.28s ease, transform 0.28s var(--ai-transition);
  transform-origin: bottom left;
}
.ai-panel.ai-panel-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* ----------------------------------------------------------
   رأس اللوحة
   ---------------------------------------------------------- */
.ai-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: linear-gradient(90deg, rgba(245,158,11,0.08) 0%, transparent 100%);
  border-bottom: 1px solid var(--ai-border);
  flex-shrink: 0;
}
.ai-panel-info {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ai-panel-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ai-gold) 0%, #d97706 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #000;
  font-size: 1rem;
  flex-shrink: 0;
}
.ai-panel-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: #F1F5F9;
  margin: 0;
  line-height: 1.3;
}
.ai-panel-status {
  font-size: 0.72rem;
  color: #10B981;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  line-height: 1;
}
.ai-status-dot {
  width: 7px;
  height: 7px;
  background: #10B981;
  border-radius: 50%;
  display: inline-block;
  animation: ai-status-blink 2s infinite;
}
@keyframes ai-status-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

.ai-panel-actions { display: flex; align-items: center; gap: 6px; }
.ai-clear-btn,
.ai-close-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--ai-border);
  color: #94A3B8;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.ai-clear-btn:hover { background: rgba(245,158,11,0.12); color: var(--ai-gold); }
.ai-close-btn:hover { background: rgba(239,68,68,0.12); color: #EF4444; }

/* ----------------------------------------------------------
   منطقة الرسائل
   ---------------------------------------------------------- */
.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.08) transparent;
}
.ai-messages::-webkit-scrollbar { width: 4px; }
.ai-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

/* ----------------------------------------------------------
   رسالة واحدة
   ---------------------------------------------------------- */
.ai-msg {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  max-width: 92%;
  animation: ai-msg-in 0.25s ease forwards;
}
@keyframes ai-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* رسائل المستخدم — تظهر على اليسار (لأن التطبيق RTL) */
.ai-msg-user {
  flex-direction: row-reverse;
  align-self: flex-start;
}
/* رسائل المساعد — تظهر على اليمين */
.ai-msg-assistant {
  align-self: flex-end;
}

.ai-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ai-gold) 0%, #d97706 100%);
  color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  flex-shrink: 0;
  margin-top: 2px;
}
.ai-msg-user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(59, 130, 246, 0.25);
  border: 1px solid rgba(59, 130, 246, 0.4);
  color: #60A5FA;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.ai-msg-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.83rem;
  line-height: 1.65;
  max-width: 100%;
  word-break: break-word;
}
.ai-msg-assistant .ai-msg-bubble {
  background: var(--ai-bg-msg-ai);
  color: #E2E8F0;
  border-radius: 4px 16px 16px 16px;
  border: 1px solid var(--ai-border);
}
.ai-msg-user .ai-msg-bubble {
  background: var(--ai-bg-msg-usr);
  color: #FCD34D;
  border: 1px solid rgba(245,158,11,0.25);
  border-radius: 16px 4px 16px 16px;
}

/* Markdown داخل فقاعات المساعد */
.ai-msg-bubble strong { color: var(--ai-gold); font-weight: 700; }
.ai-msg-bubble em     { color: #A5B4FC; font-style: italic; }
.ai-msg-bubble code {
  background: rgba(0,0,0,0.4);
  color: #86EFAC;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.78rem;
  font-family: monospace;
}
.ai-msg-bubble ul {
  padding-right: 1.2rem;
  margin: 6px 0;
  list-style: disc;
}
.ai-msg-bubble li { margin-bottom: 3px; }
.ai-msg-bubble h3 { font-size: 0.88rem; color: var(--ai-gold); margin: 8px 0 4px; }
.ai-msg-bubble h4 { font-size: 0.82rem; color: #CBD5E1; margin: 6px 0 3px; }

/* ----------------------------------------------------------
   مؤشر الكتابة (3 نقاط)
   ---------------------------------------------------------- */
.ai-typing-bubble {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 16px;
  min-width: 54px;
}
.ai-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ai-gold);
  opacity: 0.4;
  animation: ai-dot-bounce 1.2s infinite;
}
.ai-dot:nth-child(2) { animation-delay: 0.2s; }
.ai-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes ai-dot-bounce {
  0%, 100% { transform: translateY(0);   opacity: 0.3; }
  50%       { transform: translateY(-5px); opacity: 1; }
}

/* ----------------------------------------------------------
   رسالة الترحيب
   ---------------------------------------------------------- */
.ai-welcome {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 4px 0;
}
.ai-welcome-avatar {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--ai-gold) 0%, #d97706 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #000;
  font-size: 1rem;
  flex-shrink: 0;
  margin-top: 2px;
}
.ai-welcome-text {
  font-size: 0.82rem;
  color: #CBD5E1;
  line-height: 1.65;
  background: var(--ai-bg-msg-ai);
  border: 1px solid var(--ai-border);
  border-radius: 4px 14px 14px 14px;
  padding: 10px 14px;
}
.ai-welcome-text p { margin-bottom: 6px; }
.ai-welcome-text p:last-child { margin-bottom: 0; }
.ai-welcome-text strong { color: var(--ai-gold); }
.ai-welcome-text ul {
  padding-right: 1rem;
  margin: 6px 0;
  list-style: none;
}
.ai-welcome-text li {
  margin-bottom: 4px;
  padding-right: 4px;
}
.ai-welcome-hint {
  margin-top: 10px !important;
  color: #64748B;
  font-size: 0.77rem;
  font-style: italic;
}

/* ----------------------------------------------------------
   الاقتراحات السريعة (Chips)
   ---------------------------------------------------------- */
.ai-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 8px 14px 0;
  flex-shrink: 0;
}
.ai-chip {
  background: rgba(245,158,11,0.08);
  border: 1px solid rgba(245,158,11,0.25);
  color: var(--ai-gold);
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.77rem;
  font-family: var(--font-main);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  white-space: nowrap;
}
.ai-chip:hover {
  background: rgba(245,158,11,0.18);
  transform: translateY(-1px);
}

/* ----------------------------------------------------------
   حقل الإدخال
   ---------------------------------------------------------- */
.ai-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--ai-border);
  background: rgba(0,0,0,0.3);
  flex-shrink: 0;
}
.ai-input {
  flex: 1;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--ai-border);
  border-radius: 12px;
  padding: 9px 14px;
  color: #F1F5F9;
  font-size: 0.83rem;
  font-family: var(--font-main);
  direction: rtl;
  transition: border-color 0.2s;
  outline: none;
}
.ai-input::placeholder { color: #475569; }
.ai-input:focus {
  border-color: rgba(245,158,11,0.4);
  background: rgba(255,255,255,0.07);
}
.ai-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--ai-gold);
  color: #000;
  border: none;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s, background 0.2s;
  flex-shrink: 0;
}
.ai-send-btn:hover:not(:disabled) { transform: scale(1.08); background: #FBBF24; }
.ai-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ----------------------------------------------------------
   تكيّف الشاشات الصغيرة
   ---------------------------------------------------------- */
@media (max-width: 480px) {
  #ai-chat-widget {
    left: 12px;
    bottom: 80px;   /* فوق شريط التنقل السفلي إذا وُجد */
  }
  .ai-panel {
    width: calc(100vw - 24px);
    left: 0;
    max-height: 70dvh;
  }
}
