/* =====================================================
   Dashboard components — يُحمَّل بعد theme.css
   (الكاشير، الإدارة، تسجيل الدخول، مالك المنصة)
   ===================================================== */

/* ---------- Shell: قائمة جانبية + محتوى ---------- */
.shell { display: grid; grid-template-columns: 264px 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; padding: 22px 14px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 6px;
  background: rgba(4,12,31,.72); backdrop-filter: blur(14px); border-inline-end: 1px solid var(--line-soft);
}
.side-brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 18px; margin-bottom: 8px; border-bottom: 1px solid var(--line-soft); }
.side-foot { margin-top: auto; padding: 14px 8px 0; font-size: 12px; color: #55658A; }
.nav-item {
  display: flex; align-items: center; gap: 12px; width: 100%; height: 44px; padding: 0 14px; border-radius: 12px;
  font-size: 14px; font-weight: 500; color: var(--muted); text-align: start; transition: all .2s var(--ease);
}
.nav-item:hover { color: var(--ink); background: rgba(255,255,255,.04); }
.nav-item.active { color: var(--gold-300); background: linear-gradient(135deg, rgba(201,162,75,.16), rgba(201,162,75,.04)); box-shadow: inset 0 0 0 1px var(--line); }
.main { width: 100%; max-width: 1240px; padding: 28px 34px 64px; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 22px; }
.page-title { font-size: 24px; font-weight: 700; letter-spacing: -.2px; }
.page-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.wide { width: 100%; max-width: 1240px; margin: 0 auto; padding: 26px 24px 64px; }

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; flex-direction: row; overflow-x: auto; min-width: 0; padding: 10px 12px; border-inline-end: 0; border-bottom: 1px solid var(--line-soft); }
  .side-brand, .side-foot { display: none; }
  .nav-item { width: auto; white-space: nowrap; flex-shrink: 0; height: 40px; }
  .main { padding: 18px 16px 50px; }
  .wide { padding: 18px 14px 50px; }
  .page-title { font-size: 20px; }
}

/* ---------- Grids ---------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-12 { display: grid; grid-template-columns: 1fr 2fr; gap: 16px; }
.grid-21 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
@media (max-width: 900px) { .grid-2, .grid-3, .grid-12, .grid-21 { grid-template-columns: 1fr; } }
.form-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.form-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 700px) { .form-3, .form-4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 480px) { .form-2, .form-3, .form-4 { grid-template-columns: 1fr; } }

/* ---------- Stat tiles ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.stat { padding: 18px 20px; border-radius: var(--radius-lg); background: linear-gradient(180deg, rgba(20,42,88,.55), rgba(13,29,66,.55)); border: 1px solid var(--line-soft); }
.stat-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.stat-lbl { font-size: 13px; color: var(--muted); font-weight: 500; }
.stat-ico { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; color: var(--gold-400); background: rgba(201,162,75,.1); border: 1px solid var(--line); }
.stat-val { font-size: 28px; font-weight: 700; line-height: 1.1; letter-spacing: -.5px; }
.stat-unit { font-size: 13px; color: var(--muted); font-weight: 500; margin-inline-start: 6px; }
.stat.warn .stat-val { color: var(--gold-300); }
.stat.good .stat-val { color: var(--success); }

/* ---------- Fields ---------- */
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
.input.sm { height: 42px; font-size: 14px; padding: 0 12px; border-radius: 12px; }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-inline-end: 34px; }
[dir="rtl"] select.input { background-position: 20px 50%, 15px 50%; }
select.input option { background: var(--navy-900); color: var(--ink); }
textarea.input { font-family: inherit; height: auto; padding: 12px; resize: vertical; line-height: 1.7; }
.input[readonly] { opacity: .65; }
.input.mono { font-variant-numeric: tabular-nums; direction: ltr; text-align: start; }
input[type=file].input { padding: 8px 10px; height: auto; font-size: 13px; }
input[type=number]::-webkit-outer-spin-button, input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ---------- Buttons extra ---------- */
.btn-danger { color: #fff; background: linear-gradient(135deg, #ef7a85, #d04554); }
.btn-soft-danger { color: var(--danger); background: rgba(229,100,111,.08); border: 1px solid rgba(229,100,111,.25); }
.btn-soft-danger:hover { background: rgba(229,100,111,.16); }
.btn-ok { color: #04140d; background: linear-gradient(135deg, #6fe0b8, var(--success)); box-shadow: 0 6px 18px rgba(63,191,143,.25); }
.btn-icon { width: 34px; height: 34px; padding: 0; border-radius: 10px; }
.btn-lg { height: 54px; font-size: 15px; border-radius: 16px; }

/* ---------- Segmented ---------- */
.seg { display: flex; gap: 6px; padding: 5px; border-radius: 15px; background: rgba(255,255,255,.04); border: 1px solid var(--line-soft); }
.seg button { flex: 1; height: 42px; border-radius: 11px; font-size: 14px; font-weight: 500; color: var(--muted); display: flex; align-items: center; justify-content: center; gap: 7px; transition: all .2s var(--ease); }
.seg button.active { background: linear-gradient(135deg, var(--navy-600), var(--navy-700)); color: var(--gold-300); font-weight: 600; box-shadow: inset 0 0 0 1px var(--line); }

/* ---------- Tables ---------- */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: start; font-size: 12.5px; font-weight: 500; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
.tbl td { padding: 13px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.tbl tbody tr { transition: background .15s; }
.tbl tbody tr:hover { background: rgba(255,255,255,.025); }
.tbl .c { text-align: center; }
.tbl .empty-row td { text-align: center; color: var(--muted); padding: 30px 12px; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; font-size: 13px; color: var(--muted); }

/* ---------- Lists / badges ---------- */
.lrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-radius: 13px; background: rgba(4,12,31,.4); border: 1px solid var(--line-soft); }
.badge-danger { color: var(--danger); background: rgba(229,100,111,.1); border: 1px solid rgba(229,100,111,.28); }
.badge-info { color: #9DB8EE; background: rgba(120,160,255,.1); border: 1px solid rgba(120,160,255,.25); }
.tag-del { color: var(--danger); display: inline-grid; place-items: center; }

/* ---------- Banners ---------- */
.banner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-radius: 16px; border: 1px solid; }
.banner.warn { border-color: rgba(201,162,75,.5); background: rgba(201,162,75,.1); }
.banner.bad { border-color: rgba(229,100,111,.5); background: rgba(229,100,111,.1); }
.banner.ok { border-color: rgba(63,191,143,.4); background: rgba(63,191,143,.08); }

/* ---------- Charts ---------- */
.hbar-row { margin-bottom: 16px; }
.hbar-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 7px; color: var(--ink-soft); }
.donut { position: relative; width: 150px; height: 150px; border-radius: 50%; flex-shrink: 0; background: conic-gradient(rgba(255,255,255,.08) 0 100%); }
.donut::after { content: ''; position: absolute; inset: 24px; border-radius: 50%; background: var(--navy-900); }
.donut-center { position: absolute; inset: 0; z-index: 1; display: grid; place-items: center; text-align: center; line-height: 1.2; }
.legend { display: flex; flex-direction: column; gap: 10px; font-size: 13.5px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 8px; }

/* ---------- Dialog (بديل confirm/alert) ---------- */
.dialog-back { position: fixed; inset: 0; z-index: 120; display: grid; place-items: center; padding: 16px; background: rgba(2,6,16,.78); backdrop-filter: blur(5px); opacity: 0; pointer-events: none; transition: opacity .2s; }
.dialog-back.open { opacity: 1; pointer-events: auto; }
.dialog { width: 100%; max-width: 420px; padding: 24px; border-radius: 22px; background: linear-gradient(180deg, var(--navy-800), var(--navy-900)); border: 1px solid var(--line); box-shadow: var(--shadow); transform: scale(.96); transition: transform .25s var(--ease); max-height: 90vh; overflow-y: auto; }
.dialog-back.open .dialog { transform: none; }
.dialog h3 { font-size: 17px; font-weight: 600; }
.dialog p { font-size: 14px; color: var(--ink-soft); margin-top: 8px; }

/* ---------- Auth (login) ---------- */
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.auth-hero { position: relative; overflow: hidden; padding: 48px; display: flex; flex-direction: column; justify-content: space-between;
  background: radial-gradient(600px 400px at 100% 0%, rgba(233,211,160,.18), transparent 60%), linear-gradient(145deg, var(--navy-700), var(--navy-900) 60%, var(--navy-950)); border-inline-end: 1px solid var(--line); }
.auth-hero::before { content: ''; position: absolute; inset: 0; opacity: .5; pointer-events: none;
  background-image: repeating-linear-gradient(45deg, rgba(201,162,75,.06) 0 1px, transparent 1px 22px), repeating-linear-gradient(-45deg, rgba(201,162,75,.06) 0 1px, transparent 1px 22px);
  mask-image: linear-gradient(160deg, #000, transparent 70%); -webkit-mask-image: linear-gradient(160deg, #000, transparent 70%); }
.auth-hero > * { position: relative; }
.auth-form-side { display: flex; align-items: center; justify-content: center; padding: 32px 24px; }
.auth-box { width: 100%; max-width: 400px; }
@media (max-width: 860px) { .auth-shell { grid-template-columns: 1fr; } .auth-hero { display: none; } }

/* ---------- Brand picker ---------- */
.brand-tile { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 18px 12px; border-radius: 18px; text-align: center;
  background: rgba(4,12,31,.4); border: 1px solid var(--line-soft); transition: all .2s var(--ease); }
.brand-tile:hover { border-color: var(--gold-500); transform: translateY(-2px); background: rgba(201,162,75,.06); }

/* ---------- Tiers ---------- */
.tier-badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid; }
.tier-bronze   { color: #F0C8A0; border-color: rgba(205,127,50,.55); background: rgba(205,127,50,.16); }
.tier-silver   { color: #DDE3EE; border-color: rgba(221,227,238,.45); background: rgba(221,227,238,.1); }
.tier-gold     { color: var(--gold-300); border-color: rgba(233,211,160,.55); background: rgba(201,162,75,.18); }
.tier-platinum { color: #CFE6FF; border-color: rgba(160,205,255,.6); background: linear-gradient(135deg, rgba(160,205,255,.2), rgba(190,160,255,.18)); }
.check-row { display: flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; }
.check-row input { width: 18px; height: 18px; accent-color: var(--gold-500); }

/* ---------- Cashier ---------- */
.success-card { padding: 18px; border-radius: 18px; border: 1px solid rgba(63,191,143,.5); background: linear-gradient(135deg, rgba(63,191,143,.14), rgba(63,191,143,.04)); }
.pos-note { margin-top: 12px; padding: 12px 14px; border-radius: 12px; font-size: 13px; line-height: 1.7; color: var(--ink-soft); background: rgba(4,12,31,.45); border: 1px solid var(--line-soft); }
.cust-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px; border-radius: 18px;
  background: radial-gradient(300px 140px at 100% 0%, rgba(233,211,160,.22), transparent 60%), linear-gradient(135deg, var(--navy-600), var(--navy-800)); border: 1px solid rgba(233,211,160,.25); }
.scan-frame { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--gold-500); background: #000; }

/* ---------- Logo on small screens ---------- */
.auth-mobile-logo { display: none; width: 84px; height: 84px; border-radius: 22px; margin: 0 auto 22px; }
@media (max-width: 860px) { .auth-mobile-logo { display: block; } }

/* =====================================================
   v2: طي القائمة الجانبية (فكرة تحديث جيمني بألوان الهوية)
   ===================================================== */
.sidebar-toggle-btn {
  display: inline-flex; flex-direction: column; justify-content: space-between; flex-shrink: 0;
  width: 42px; height: 40px; padding: 10px 9px; border-radius: 12px; cursor: pointer;
  background: rgb(var(--accent-rgb) / .08); border: 1px solid var(--line); transition: background .2s, border-color .2s;
}
.sidebar-toggle-btn:hover { background: rgb(var(--accent-rgb) / .16); border-color: var(--gold-500); }
.sidebar-toggle-btn .bar { display: block; width: 100%; height: 2px; border-radius: 2px; background: var(--gold-300); }
body.sidebar-collapsed .shell { grid-template-columns: 1fr; }
body.sidebar-collapsed .side { display: none; }
body.sidebar-collapsed .main { max-width: none; }
@media (max-width: 900px) { .sidebar-toggle-btn { display: none; } body.sidebar-collapsed .side { display: flex; } }

/* أزرار التنقل أوضح (من تحديث جيمني) */
.nav-item { font-size: 14.5px; }
.nav-item .icon { width: 20px; height: 20px; }

/* الخدمات متوقفة: تعطيل التعديل بصرياً (الخادم يرفض أصلاً) */
body.services-off #tab-content-rewards, body.services-off #tab-content-staff, body.services-off #tab-content-brand,
body.services-off #tab-content-campaigns, body.services-off #tab-content-menu-studio { pointer-events: none; opacity: .5; filter: grayscale(.4); }

/* بطاقات العملاء في لوحة مالك المنصة */
.co-head { background: transparent; color: inherit; cursor: pointer; transition: background .2s; }
.co-head:hover { background: rgba(255,255,255,.03); }

.brand-block { display: grid; gap: 6px; padding: 10px 0; border-bottom: 1px dashed var(--line-soft); }
.brand-block:last-child { border-bottom: 0; }
.branch-row { padding-inline-start: 22px; border-inline-start: 2px solid var(--line); margin-inline-start: 6px; }

/* شجرة البراندات والفروع في لوحة المنشأة */
.branch-tree { display: grid; gap: 2px; max-height: 260px; overflow-y: auto; }
.tree-brand { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--gold-300); padding: 8px 6px 4px; }
.tree-brand .icon { width: 14px; height: 14px; }
.tree-branch { display: block; padding: 7px 12px 7px 8px; margin-inline-start: 12px; border-inline-start: 2px solid var(--line-soft); font-size: 13px; color: var(--muted); text-decoration: none; border-radius: 0 8px 8px 0; }
.tree-branch:hover { color: var(--ink); background: rgba(255,255,255,.04); }
.tree-branch.active { color: var(--gold-300); border-inline-start-color: var(--gold-500); background: rgb(var(--accent-rgb) / .08); }
.branch-switch-mobile { display: none; }
@media (max-width: 900px) { .branch-tree { display: none; } .branch-switch-mobile { display: block; } #branch-switch-wrap { min-width: 180px; } }

/* نافذة المستخدمين والصلاحيات */
.perm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; }
.perm-item span { display: flex; flex-direction: column; }
.perm-item small { font-size: 11.5px; color: var(--muted); font-weight: 400; }
@media (max-width: 520px) { .perm-grid { grid-template-columns: 1fr; } }

/* إخفاء أزرار لا يملكها مستخدم المنصة */
body.no-edit .co-body [onclick^="addBranch"], body.no-edit .co-body [onclick^="addBrand"], body.no-edit .co-body [onclick^="editBrand"],
body.no-edit .co-body [onclick^="editCompany"], body.no-edit .co-body [onclick^="resetPassword"], body.no-edit .co-body [onclick^="toggleCompany"],
body.no-edit .co-body [onclick^="toggleBranch"] { display: none; }
body.no-billing .co-body [onclick^="newSubscription"], body.no-billing .co-body [onclick^="cancelSub"] { display: none; }
.field label.check-row, .dialog label.check-row { display: flex; align-items: flex-start; gap: 10px; margin: 0; color: var(--ink); font-size: 13.5px; }
.field label.check-row input { flex-shrink: 0; margin-top: 2px; }

.tbl tr.active-row td { background: rgb(var(--accent-rgb) / .06); }

/* أيقونة البحث داخل الخانة الصغيرة */
.input-icon .input.sm { padding-inline-start: 40px; }

/* ===== v2.7: جرس التنبيهات ===== */
.bell { position: relative; }
.bell .bell-dot { position: absolute; top: -6px; inset-inline-end: -6px; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--danger, #e5484d); color: #fff; font-size: 11.5px; font-weight: 700; display: grid; place-items: center; box-shadow: 0 0 0 2px var(--navy-900, #040c1f); }
.bell.ring i, .bell.ring svg { animation: bell-ring 1.4s ease-in-out 2; transform-origin: 50% 10%; }
@keyframes bell-ring { 0%, 100% { transform: rotate(0); } 15% { transform: rotate(14deg); } 30% { transform: rotate(-12deg); } 45% { transform: rotate(8deg); } 60% { transform: rotate(-5deg); } }
.notif-panel { position: fixed; z-index: 130; width: min(400px, calc(100vw - 24px)); max-height: min(70vh, 560px); overflow-y: auto; border-radius: 18px; border: 1px solid var(--line); background: var(--navy-800, #0b1730); box-shadow: 0 24px 60px rgba(0,0,0,.45); padding: 8px; }
.notif-panel .n-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px 10px; font-weight: 700; }
.notif-item { display: flex; gap: 10px; align-items: flex-start; width: 100%; text-align: start; padding: 12px; border-radius: 12px; border: 0; background: none; color: var(--ink); font: inherit; cursor: pointer; }
.notif-item:hover { background: rgba(255,255,255,.05); }
.notif-item.new { background: rgb(var(--accent-rgb) / .08); }
.notif-item .n-ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; background: rgba(255,255,255,.06); color: var(--gold-300); }
.notif-item .n-t { font-weight: 600; font-size: 13.5px; line-height: 1.6; }
.notif-item .n-s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.notif-empty { padding: 26px 10px; text-align: center; color: var(--muted); font-size: 13px; }
/* تبويبات خدمات غير مشترك بها */
.nav-item.locked { opacity: .5; }
.nav-item.locked:hover { opacity: .8; }
.nav-item.super-unsub { opacity: .5; }
.nav-item.super-unsub:hover, .nav-item.super-unsub.active { opacity: .85; }
.nav-item .lock-ico { margin-inline-start: auto; width: 14px; height: 14px; }
.plan-current { border-color: rgb(var(--accent-rgb) / .7) !important; background: rgb(var(--accent-rgb) / .08) !important; box-shadow: 0 0 0 1px rgb(var(--accent-rgb) / .35) inset; }
.receipt-view { max-height: 60vh; overflow: auto; border-radius: 12px; border: 1px solid var(--line); background: #fff; }
.receipt-view img { display: block; max-width: 100%; margin: auto; }

/* أرشيف الطلبات: أشرطة توزيع أسباب الرفض */
.arc-bar { display: grid; grid-template-columns: minmax(130px, 220px) 1fr auto; align-items: center; gap: 12px; width: 100%; padding: 6px 8px; border: 1px solid transparent; border-radius: 10px; background: none; color: inherit; font: inherit; font-size: 13px; text-align: start; cursor: pointer; }
.arc-bar:hover, .arc-bar.on { border-color: var(--line-soft); background: rgba(255,255,255,.03); }
.arc-track { height: 8px; border-radius: 99px; background: rgba(255,255,255,.07); overflow: hidden; }
.arc-track > span { display: block; height: 100%; border-radius: 99px; background: var(--gold-300, #E9D3A0); }
.arc-n { font-size: 12px; color: var(--muted); white-space: nowrap; }
@media (max-width: 600px) { .arc-bar { grid-template-columns: 1fr auto; } .arc-track { grid-column: 1 / -1; grid-row: 2; } }
