:root {
  --color-primary: #C9A227;
  --color-bg: #0E0E0E;
  --color-surface: #171717;
  --color-surface-2: #212121;
  --color-text: #F5F1E6;
  --color-muted: #9A968C;
  --color-border: #2A2A2A;
  --color-danger: #C0392B;
  --color-success: #3F8F5F;
  --color-warning: #C9932A;
  --font-display: 'Almarai', sans-serif;
  --font-body: 'Tajawal', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--color-bg); color: var(--color-text); font-family: var(--font-body); direction: rtl; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; }

.app { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: 230px; flex: 0 0 230px;
  background: var(--color-surface);
  border-left: 1px solid var(--color-border);
  display: flex; flex-direction: column;
  padding: 20px 14px;
}
.sidebar__logo { font-family: var(--font-display); font-size: 18px; font-weight: 800; color: var(--color-primary); margin-bottom: 30px; padding: 0 6px; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px; border-radius: 10px;
  font-size: 14px; color: var(--color-muted); margin-bottom: 4px;
}
.nav-link.active { background: var(--color-surface-2); color: var(--color-primary); font-weight: 700; }
.nav-link__badge {
  margin-inline-start: auto; background: var(--color-danger); color: #fff;
  font-size: 11px; font-weight: 800; border-radius: 999px; padding: 1px 7px;
}
.sidebar__footer { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--color-border); }

/* ---------- Main ---------- */
.main { flex: 1; padding: 28px 34px; max-width: 1200px; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.page-title { font-family: var(--font-display); font-size: 22px; font-weight: 800; }
.page-subtitle { color: var(--color-muted); font-size: 13px; margin-top: 4px; }

/* ---------- Stat Cards ---------- */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 28px; }
.stat-card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 14px; padding: 18px; }
.stat-card__label { font-size: 12.5px; color: var(--color-muted); }
.stat-card__value { font-family: var(--font-display); font-size: 26px; font-weight: 800; margin-top: 6px; color: var(--color-primary); }

/* ---------- Table ---------- */
.panel { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 14px; overflow: hidden; margin-bottom: 22px; }
.panel__header { padding: 16px 18px; border-bottom: 1px solid var(--color-border); font-weight: 700; display:flex; justify-content: space-between; align-items:center; }
table { width: 100%; border-collapse: collapse; }
th { text-align: right; padding: 12px 18px; font-size: 12px; color: var(--color-muted); border-bottom: 1px solid var(--color-border); font-weight: 600; }
td { padding: 13px 18px; font-size: 13.5px; border-bottom: 1px solid var(--color-border); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--color-surface-2); }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; }
.badge--pending { background: rgba(201,147,42,0.15); color: var(--color-warning); }
.badge--active, .badge--approved { background: rgba(63,143,95,0.15); color: var(--color-success); }
.badge--rejected, .badge--cancelled, .badge--expired { background: rgba(192,57,43,0.15); color: var(--color-danger); }

.btn { padding: 8px 16px; border-radius: 9px; font-size: 13px; font-weight: 700; }
.btn--primary { background: var(--color-primary); color: #1a1a1a; }
.btn--danger { background: var(--color-danger); color: #fff; }
.btn--ghost { background: var(--color-surface-2); color: var(--color-text); border: 1px solid var(--color-border); }
.btn--sm { padding: 6px 12px; font-size: 12px; }
.btn-row { display: flex; gap: 8px; }

.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; }
.switch { position: relative; width: 46px; height: 26px; background: var(--color-surface-2); border-radius: 999px; border: 1px solid var(--color-border); }
.switch.on { background: var(--color-primary); }
.switch__dot { position: absolute; top: 2px; right: 3px; width: 20px; height: 20px; background: #fff; border-radius: 50%; transition: transform .2s; }
.switch.on .switch__dot { transform: translateX(-20px); }

.receipt-link { color: var(--color-primary); font-size: 12.5px; text-decoration: underline; }

.login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-box { width: 340px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 16px; padding: 30px; }
.login-box h1 { font-family: var(--font-display); color: var(--color-primary); font-size: 20px; margin-bottom: 18px; text-align: center; }
.field { margin-bottom: 14px; }
.field label { font-size: 12.5px; color: var(--color-muted); display: block; margin-bottom: 6px; }
.field input { width: 100%; padding: 11px 13px; border-radius: 9px; background: var(--color-surface-2); border: 1px solid var(--color-border); color: var(--color-text); font-size: 14px; }
.error-text { color: var(--color-danger); font-size: 12.5px; margin-top: 8px; }

.empty-state { text-align: center; padding: 40px; color: var(--color-muted); font-size: 13.5px; }
.hidden { display: none !important; }

.tag-input-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.65); display: flex; align-items: center; justify-content: center; z-index: 60; }
.modal-box { width: 420px; max-width: 92vw; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 16px; padding: 22px; max-height: 86vh; overflow-y: auto; }
.modal-box h2 { font-family: var(--font-display); font-size: 17px; margin-bottom: 14px; }

/* ---------- Store Admin extras ---------- */
.field textarea { width: 100%; padding: 11px 13px; border-radius: 9px; background: var(--color-surface-2); border: 1px solid var(--color-border); color: var(--color-text); font-size: 14px; resize: vertical; }
.field select { width: 100%; padding: 11px 13px; border-radius: 9px; background: var(--color-surface-2); border: 1px solid var(--color-border); color: var(--color-text); font-size: 14px; }
.field input[type="file"] { width: 100%; padding: 9px; border-radius: 9px; background: var(--color-surface-2); border: 1px dashed var(--color-border); color: var(--color-muted); font-size: 12.5px; }
.field input[type="color"] { width: 60px; height: 38px; padding: 2px; border-radius: 9px; background: var(--color-surface-2); border: 1px solid var(--color-border); }

.img-preview-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.img-preview { width: 64px; height: 64px; border-radius: 8px; object-fit: cover; border: 1px solid var(--color-border); }

.thumb { width: 42px; height: 42px; border-radius: 8px; object-fit: cover; background: var(--color-surface-2); }
.product-name-cell { display: flex; align-items: center; gap: 10px; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.plan-card, .template-card {
  border: 1px solid var(--color-border); border-radius: 14px; padding: 16px;
  background: var(--color-surface-2); margin-bottom: 10px;
}
.plan-card__price { color: var(--color-primary); font-weight: 800; font-size: 18px; margin: 6px 0; }

.upload-note { font-size: 12px; color: var(--color-muted); margin-top: 8px; line-height: 1.6; }

/* ---------- Template selector cards ---------- */
.template-select-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 6px; }
.template-select-card {
  border: 2px solid var(--color-border); border-radius: 12px; padding: 14px;
  background: var(--color-surface-2); position: relative; cursor: pointer;
}
.template-select-card.chosen { border-color: var(--color-primary); }
.template-select-card.locked { opacity: 0.6; cursor: not-allowed; }
.template-select-card__name { font-weight: 700; font-size: 13.5px; }
.template-select-card__tag { font-size: 10.5px; color: var(--color-muted); margin-top: 3px; }
.template-select-card__lock { position: absolute; top: 10px; left: 10px; font-size: 14px; }
.template-select-card__buy { margin-top: 8px; font-size: 11.5px; color: var(--color-primary); text-decoration: underline; display: block; }

/* ---------- Live Chat ---------- */
.chat { display: flex; flex-direction: column; height: 480px; }
.chat__header { display: flex; align-items: center; justify-content: space-between; padding: 4px 4px 12px; border-bottom: 1px solid var(--color-border); }
.chat__title { font-family: var(--font-display); font-size: 15px; }
.chat__messages { flex: 1; overflow-y: auto; padding: 14px 4px; display: flex; flex-direction: column; gap: 9px; }
.msg { max-width: 75%; padding: 9px 13px; border-radius: 14px; font-size: 13.5px; line-height: 1.5; word-wrap: break-word; }
.msg__time { font-size: 9.5px; opacity: .6; margin-top: 3px; display: block; }
.msg--mine { align-self: flex-start; background: var(--color-primary); color: #fff; border-bottom-right-radius: 4px; }
.msg--theirs { align-self: flex-end; background: var(--color-surface-2); color: var(--color-text); border-bottom-left-radius: 4px; }
.chat__empty { text-align: center; color: var(--color-muted); font-size: 13px; margin: auto; padding: 30px; }
.chat__input-row { display: flex; gap: 8px; padding: 12px 4px 4px; border-top: 1px solid var(--color-border); }
.chat__input-row input { flex: 1; padding: 11px 15px; border-radius: 999px; background: var(--color-surface-2); border: 1px solid var(--color-border); color: var(--color-text); font-size: 13.5px; font-family: inherit; }
.chat__input-row button { width: 42px; height: 42px; border-radius: 50%; background: var(--color-primary); color: #fff; font-size: 17px; flex-shrink: 0; }
.conv-item { display: flex; justify-content: space-between; align-items: center; padding: 13px 14px; border: 1px solid var(--color-border); border-radius: 12px; margin-bottom: 8px; cursor: pointer; background: var(--color-surface-2); }
.conv-item:hover { border-color: var(--color-primary); }
.conv-item__name { font-weight: 700; font-size: 14px; }
.conv-item__time { font-size: 11px; color: var(--color-muted); }

/* ---------- Sidebar sections ---------- */
.nav-section { font-size: 10.5px; font-weight: 700; color: var(--color-muted); text-transform: uppercase; letter-spacing: 1px; padding: 16px 14px 6px; opacity: 0.7; }

/* ==========================================================
   نظام السمات والتركيبات (Attributes & Combinations)
   ========================================================== */
.attrs-block { border: 1px solid var(--color-border); border-radius: 12px; padding: 14px; background: var(--color-surface-2); }
.attrs-hint { font-size: 12px; color: var(--color-muted); line-height: 1.7; margin-bottom: 10px; }
.attrs-empty { font-size: 12.5px; color: var(--color-muted); padding: 12px; text-align: center; border: 1px dashed var(--color-border); border-radius: 10px; margin-top: 8px; }

/* قوالب جاهزة */
.attrs-templates { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 12px; }
.attr-tpl-chip {
  background: var(--color-surface); border: 1px solid var(--color-border);
  color: var(--color-text); padding: 7px 12px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; font-family: inherit; cursor: pointer; transition: all .15s;
}
.attr-tpl-chip:hover { border-color: var(--color-primary); color: var(--color-primary); }

/* بطاقة السمة */
.attr-card { border: 1px solid var(--color-border); border-radius: 10px; padding: 11px; margin-top: 9px; background: var(--color-surface); }
.attr-card__head { display: flex; gap: 8px; align-items: center; margin-bottom: 9px; }
.attr-name-input {
  flex: 1; padding: 8px 11px; border-radius: 8px; font-size: 13px; font-family: inherit;
  background: var(--color-surface-2); border: 1px solid var(--color-border); color: var(--color-text);
}
.attr-type-select {
  padding: 8px 10px; border-radius: 8px; font-size: 12.5px; font-family: inherit;
  background: var(--color-surface-2); border: 1px solid var(--color-border); color: var(--color-text);
}
.attr-values { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.attr-val-chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--color-surface-2); border: 1px solid var(--color-border);
  padding: 5px 10px; border-radius: 999px; font-size: 12px;
}
.attr-val-chip b { cursor: pointer; opacity: .5; font-size: 11px; }
.attr-val-chip b:hover { opacity: 1; color: var(--color-danger); }
.attr-val-dot { width: 12px; height: 12px; border-radius: 50%; border: 1px solid rgba(128,128,128,.4); display: inline-block; }
.attr-val-add {
  min-width: 165px; flex: 1; padding: 6px 10px; border-radius: 999px; font-size: 12px; font-family: inherit;
  background: transparent; border: 1px dashed var(--color-border); color: var(--color-text);
}

/* التركيبات */
.combos-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 9px; flex-wrap: wrap; gap: 8px; }
.combos-title { font-weight: 700; font-size: 13.5px; }
.combos-total { font-size: 11.5px; color: var(--color-muted); }
.combos-bulk { display: flex; gap: 7px; margin-bottom: 9px; }
.combos-bulk input {
  width: 165px; padding: 7px 11px; border-radius: 8px; font-size: 12.5px; font-family: inherit;
  background: var(--color-surface); border: 1px solid var(--color-border); color: var(--color-text);
}
.combos-table-wrap { max-height: 320px; overflow-y: auto; border: 1px solid var(--color-border); border-radius: 10px; }
.combos-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.combos-table thead th {
  position: sticky; top: 0; background: var(--color-surface-2); z-index: 1;
  padding: 9px 8px; text-align: right; font-size: 11.5px; color: var(--color-muted); font-weight: 700;
  border-bottom: 1px solid var(--color-border);
}
.combos-table td { padding: 6px 8px; border-bottom: 1px solid var(--color-border); }
.combos-table tr:last-child td { border-bottom: none; }
.combo-label span {
  display: inline-block; background: var(--color-surface-2); padding: 2px 8px;
  border-radius: 6px; font-size: 11.5px; margin-left: 3px;
}
.combo-in {
  width: 100%; min-width: 68px; padding: 6px 8px; border-radius: 7px; font-size: 12px; font-family: inherit;
  background: var(--color-surface-2); border: 1px solid var(--color-border); color: var(--color-text);
}
.combo-del { background: transparent; color: var(--color-muted); font-size: 13px; padding: 4px 6px; cursor: pointer; }
.combo-del:hover { color: var(--color-danger); }

/* ==========================================================
   التجار والمندوبين (Vendors & Resellers)
   ========================================================== */
.link-cell { color: var(--color-primary); font-weight: 700; cursor: pointer; text-decoration: none; }
.link-cell:hover { text-decoration: underline; }
.coupon-code {
  background: var(--color-surface-2); border: 1px dashed var(--color-primary);
  padding: 4px 10px; border-radius: 6px; font-size: 12.5px; font-weight: 700;
  letter-spacing: 1px; color: var(--color-primary); font-family: monospace;
}
.feature-lock {
  text-align: center; padding: 40px 24px; border: 1px dashed var(--color-border);
  border-radius: 14px; background: var(--color-surface);
}
.feature-lock__icon { font-size: 40px; margin-bottom: 10px; }
.feature-lock__title { font-family: var(--font-display); font-size: 17px; margin-bottom: 6px; }
.feature-lock__text { font-size: 13px; color: var(--color-muted); margin-bottom: 16px; }
.settle-summary {
  border: 1px solid var(--color-border); border-radius: 10px; padding: 12px;
  background: var(--color-surface-2);
}
.settle-summary > div {
  display: flex; justify-content: space-between; padding: 6px 0;
  font-size: 13px; border-bottom: 1px dashed var(--color-border);
}
.settle-summary > div:last-child { border-bottom: none; }
.settle-summary span { color: var(--color-muted); }
.panel__title { font-family: var(--font-display); font-size: 15px; font-weight: 700; }

/* ---------- تقسيم الطلب على التجار ---------- */
.split-group {
  border: 1px solid var(--color-border); border-radius: 11px;
  padding: 12px; margin-bottom: 11px; background: var(--color-surface-2);
}
.split-group--store { border-color: var(--color-primary); }
.split-group__head {
  display: flex; justify-content: space-between; align-items: center;
  padding-bottom: 9px; margin-bottom: 9px; border-bottom: 1px solid var(--color-border);
  flex-wrap: wrap; gap: 8px; font-size: 13.5px;
}
.split-group__badge { margin-left: 5px; }
.split-item {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 7px 0; font-size: 13px; border-bottom: 1px dashed var(--color-border);
}
.split-item:last-child { border-bottom: none; }
.vendor-tag {
  font-size: 10.5px; background: var(--color-surface-2); color: var(--color-muted);
  padding: 2px 8px; border-radius: 999px; margin-right: 6px; white-space: nowrap;
}
