/* ============================================================
   صِلَة — أنماط لوحات المنصة (هوية موحّدة مع صفحة الهبوط)
   ============================================================ */
:root {
  --primary: #0F172A;
  --secondary: #2563EB;
  --accent: #06B6D4;
  --success: #10B981;
  --warning: #F59E0B;
  --bg: #F8FAFC;
  --card: #FFFFFF;
  --border: #E2E8F0;
  --ink-2: #334155;
  --ink-3: #64748B;
  --blue-soft: #EFF6FF;
  --cyan-soft: #ECFEFF;
  --green-soft: #ECFDF5;
  --amber-soft: #FFFBEB;
  --grad: linear-gradient(135deg, #2563EB, #06B6D4);
  --shadow-sm: 0 4px 12px -2px rgba(15, 23, 42, .07);
  --shadow-md: 0 12px 32px -8px rgba(15, 23, 42, .12);
  --r: 14px;
  --sidebar-w: 250px;
}

* { box-sizing: border-box; }
body {
  font-family: "Cairo", Tahoma, sans-serif;
  background: var(--bg);
  color: var(--ink-2);
  margin: 0;
  min-height: 100dvh;
}
h1, h2, h3 { color: var(--primary); font-weight: 800; }
:focus-visible { outline: 3px solid rgba(37, 99, 235, .5); outline-offset: 2px; border-radius: 6px; }

/* ---------- أزرار ---------- */
.btn { font-weight: 700; border-radius: 12px; }
.btn-silah { background: var(--grad); color: #fff; border: 0; padding: .55rem 1.4rem; }
.btn-silah:hover { color: #fff; filter: brightness(1.06); }
.btn-silah:disabled { opacity: .65; }
.btn-ghost { background: #fff; border: 1.5px solid var(--border); color: var(--primary); padding: .55rem 1.4rem; }
.btn-ghost:hover { border-color: var(--secondary); color: var(--secondary); }
.btn-icon {
  background: transparent; border: 0; color: var(--ink-3);
  width: 40px; height: 40px; border-radius: 10px;
  display: grid; place-items: center; cursor: pointer;
}
.btn-icon:hover { background: var(--blue-soft); color: var(--secondary); }

/* ---------- هيكل التطبيق ---------- */
.app-shell { display: flex; }
.sidebar {
  width: var(--sidebar-w);
  background: var(--primary);
  color: #CBD5E1;
  min-height: 100dvh;
  position: fixed;
  inset-inline-start: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  z-index: 1040;
  transition: transform .25s ease;
}
.sidebar-brand {
  display: flex; align-items: center; gap: .6rem;
  font-size: 1.3rem; font-weight: 900; color: #fff;
  padding: 1.1rem 1.2rem .9rem;
}
.sidebar-nav { flex: 1; overflow-y: auto; padding: .4rem .7rem; }
.nav-item {
  display: flex; align-items: center; gap: .65rem;
  color: #94A3B8; text-decoration: none;
  font-weight: 600; font-size: .92rem;
  padding: .6rem .8rem; border-radius: 10px;
  margin-bottom: 2px;
}
.nav-item:hover { color: #fff; background: rgba(255, 255, 255, .06); }
.nav-item.active { color: #fff; background: var(--grad); box-shadow: 0 8px 20px -8px rgba(37, 99, 235, .6); }
.nav-item.disabled { opacity: .45; cursor: default; pointer-events: none; }
.nav-item .soon {
  margin-inline-start: auto; font-size: .62rem; font-weight: 700;
  background: rgba(255, 255, 255, .09); border-radius: 999px; padding: .1rem .5rem;
}
.sidebar-footer {
  display: flex; align-items: center; gap: .6rem;
  padding: .9rem 1rem; border-top: 1px solid rgba(255, 255, 255, .08);
}
.sidebar-footer .btn-icon { color: #94A3B8; }
.sidebar-footer .btn-icon:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.tenant-chip {
  width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0;
  background: var(--grad); color: #fff;
  display: grid; place-items: center; font-weight: 800;
}
.tenant-meta { line-height: 1.25; min-width: 0; }
.tenant-meta strong { color: #fff; font-size: .82rem; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px; }
.tenant-meta span { font-size: .72rem; color: #94A3B8; }

.main-wrap { flex: 1; margin-inline-start: var(--sidebar-w); min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: .8rem;
  background: rgba(255, 255, 255, .85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: .7rem 1.4rem;
  position: sticky; top: 0; z-index: 1020;
}
.topbar-title { font-size: 1.15rem; font-weight: 800; margin: 0; }
.topbar-actions { margin-inline-start: auto; display: flex; align-items: center; gap: .5rem; }
.lang-switch {
  font-weight: 800; font-size: .8rem; color: var(--ink-3);
  border: 1.5px solid var(--border); border-radius: 10px;
  padding: .3rem .7rem; text-decoration: none;
}
.lang-switch:hover { color: var(--secondary); border-color: var(--secondary); }

.content { padding: 1.5rem 1.4rem 3rem; max-width: 1320px; }

/* ---------- مكوّنات ---------- */
.panel {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r); padding: 1.3rem;
  box-shadow: var(--shadow-sm);
}
.panel-title { font-size: 1.02rem; font-weight: 800; margin-bottom: 1rem; }
.welcome-line { color: var(--ink-3); font-weight: 600; margin-bottom: 1rem; }

.stat-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r); padding: 1rem 1.1rem;
  display: flex; align-items: center; gap: .8rem;
  box-shadow: var(--shadow-sm); height: 100%;
}
.stat-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; }
.stat-value { font-size: 1.25rem; font-weight: 900; color: var(--primary); display: block; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat-label { font-size: .78rem; color: var(--ink-3); font-weight: 600; }

.starter-list { padding-inline-start: 1.2rem; margin: 0; }
.starter-list li { margin-bottom: .6rem; font-weight: 600; }
.branch-row { display: flex; flex-direction: column; padding: .45rem 0; border-bottom: 1px dashed var(--border); }
.branch-row:last-child { border-bottom: 0; }
.badge-sub { background: var(--green-soft); color: #047857; font-size: .78rem; font-weight: 700; border-radius: 999px; padding: .25rem .8rem; }

.table-wrap { overflow-x: auto; }
.table thead th {
  background: var(--bg); color: var(--ink-3);
  font-size: .78rem; font-weight: 700;
  border-bottom: 1px solid var(--border);
  padding: .7rem 1rem; white-space: nowrap;
}
.table tbody td { padding: .75rem 1rem; font-size: .9rem; }
.badge-state { font-size: .74rem; font-weight: 700; border-radius: 999px; padding: .2rem .7rem; }
.badge-state.ok { background: var(--green-soft); color: #047857; }
.badge-state.off { background: #FEF2F2; color: #B91C1C; }

.form-panel { max-width: 640px; }
.form-label { font-weight: 700; color: var(--primary); font-size: .88rem; }
.form-control, .form-select { border-radius: 10px; border-color: var(--border); padding: .55rem .85rem; font-family: inherit; }
.form-control:focus, .form-select:focus { border-color: var(--secondary); box-shadow: 0 0 0 .2rem rgba(37, 99, 235, .12); }
.req { color: #DC2626; }
.pw-toggle {
  position: absolute; inset-inline-end: .6rem; top: 50%; transform: translateY(-50%);
  background: none; border: 0; color: var(--ink-3); cursor: pointer; padding: .3rem;
}

/* ---------- الضيوف ---------- */
.guest-shell {
  display: grid; place-items: center; min-height: 100dvh; padding: 1.5rem;
  background:
    radial-gradient(40rem 22rem at 85% -5%, rgba(37, 99, 235, .09), transparent 60%),
    radial-gradient(34rem 20rem at 10% 105%, rgba(6, 182, 212, .09), transparent 60%),
    var(--bg);
}
.guest-main { width: 100%; max-width: 420px; }
.login-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 20px; padding: 2.2rem 1.8rem;
  box-shadow: var(--shadow-md);
}
.login-title { font-size: 1.45rem; font-weight: 900; margin: 0; }
.login-sub { color: var(--ink-3); font-size: .9rem; margin: .3rem 0 0; }

.error-card { text-align: center; background: var(--card); border: 1px solid var(--border); border-radius: 20px; padding: 2.5rem 2rem; box-shadow: var(--shadow-md); }
.error-card h1 { font-size: 3.2rem; font-weight: 900; background: var(--grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; margin: 0; }
.error-card h2 { font-size: 1.2rem; }
.error-card p { color: var(--ink-3); }

.empty-state { text-align: center; padding: 2.5rem 1.5rem; }

/* ---------- استجابة ---------- */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(100%); }
  [dir="ltr"] .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-wrap { margin-inline-start: 0; }
  .sidebar-backdrop {
    position: fixed; inset: 0; background: rgba(15, 23, 42, .5);
    z-index: 1035; opacity: 0; visibility: hidden; transition: opacity .25s;
  }
  .sidebar-backdrop.show { opacity: 1; visibility: visible; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* ---------- نقطة البيع ---------- */
.pos-wrap { display: grid; grid-template-columns: 1fr 360px; gap: 1rem; align-items: start; }
.pos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .7rem; }
.pos-product {
  font-family: inherit; text-align: start; cursor: pointer;
  background: var(--card); border: 1.5px solid var(--border); border-radius: 12px;
  padding: .8rem .9rem; display: flex; flex-direction: column; gap: .15rem;
  transition: border-color .15s, transform .15s; min-height: 92px;
}
.pos-product:hover { border-color: var(--secondary); transform: translateY(-2px); }
.pos-product:active { transform: scale(.97); }
.pos-product strong { color: var(--primary); font-size: .88rem; line-height: 1.35; }
.pos-product .price { color: var(--secondary); font-weight: 800; font-size: .85rem; font-variant-numeric: tabular-nums; }
.pos-product .qty { color: var(--ink-3); font-size: .72rem; font-variant-numeric: tabular-nums; }
.pos-cart { position: sticky; top: 76px; display: flex; flex-direction: column; }
.pos-cart-items { max-height: 300px; overflow-y: auto; margin-bottom: .6rem; }
.cart-row { display: flex; align-items: center; gap: .5rem; padding: .45rem 0; border-bottom: 1px dashed var(--border); }
.cart-row .c-name { flex: 1; font-size: .85rem; font-weight: 700; color: var(--primary); }
.cart-row .c-controls { display: flex; align-items: center; gap: .35rem; }
.cart-row .c-controls button {
  width: 26px; height: 26px; border-radius: 8px; border: 1.5px solid var(--border);
  background: #fff; font-weight: 800; cursor: pointer; line-height: 1;
}
.cart-row .c-controls button:hover { border-color: var(--secondary); color: var(--secondary); }
.cart-row .c-qty { min-width: 22px; text-align: center; font-weight: 800; font-variant-numeric: tabular-nums; }
.cart-row .c-total { font-size: .82rem; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cart-row .c-del { border: 0; background: none; color: #DC2626; font-size: 1.1rem; cursor: pointer; }
.pos-totals > div { display: flex; justify-content: space-between; align-items: center; padding: .3rem 0; font-size: .9rem; }
.pos-totals .grand { border-top: 2px solid var(--border); margin-top: .3rem; padding-top: .55rem; font-size: 1.08rem; font-weight: 900; color: var(--primary); }
.pos-totals strong { font-variant-numeric: tabular-nums; }
.method.active { border-color: var(--secondary); color: var(--secondary); background: var(--blue-soft); }
.net-badge { font-size: .75rem; font-weight: 800; border-radius: 999px; padding: .3rem .8rem; }
.net-badge.on { background: var(--green-soft); color: #047857; }
.net-badge.off { background: #FEF2F2; color: #B91C1C; }
@media (max-width: 991.98px) {
  .pos-wrap { grid-template-columns: 1fr; }
  .pos-cart { position: static; }
}

/* ---------- بطاقات الإعدادات ---------- */
.setting-card {
  display: flex; align-items: center; gap: .9rem;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r); padding: 1.1rem 1.2rem;
  text-decoration: none; color: var(--ink-2);
  box-shadow: var(--shadow-sm); transition: all .18s ease; height: 100%;
}
.setting-card:hover { border-color: var(--secondary); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.setting-card strong { display: block; color: var(--primary); font-size: .95rem; }
.setting-card small { color: var(--ink-3); font-size: .76rem; line-height: 1.5; display: block; }
.setting-card .arrow { margin-inline-start: auto; color: var(--ink-3); flex-shrink: 0; }
.form-check-input:checked { background-color: var(--secondary); border-color: var(--secondary); }

/* ---------- محادثة أوامر الشراء ---------- */
.chat-box { max-height: 320px; overflow-y: auto; display: flex; flex-direction: column; gap: .5rem; }
.chat-msg { background: var(--bg); border: 1px solid var(--border); border-radius: 12px 12px 12px 4px; padding: .5rem .8rem; max-width: 85%; align-self: flex-start; }
.chat-msg.mine { background: var(--blue-soft); border-color: rgba(37,99,235,.25); border-radius: 12px 12px 4px 12px; align-self: flex-end; }
.chat-msg small { color: var(--ink-3); font-size: .68rem; display: block; margin-bottom: .15rem; }
.chat-msg p { margin: 0; font-size: .88rem; }

/* ---------- القيود المحاسبية ---------- */
.je-item { border-bottom: 1px dashed var(--border); padding: .45rem 0; }
.je-item summary { cursor: pointer; font-size: .85rem; font-weight: 600; }
.je-item[open] summary { color: var(--secondary); }

/* ---------- الإشعارات ---------- */
.notif-badge {
  position: absolute; top: 2px; inset-inline-end: 2px;
  background: #DC2626; color: #fff;
  font-size: .6rem; font-weight: 800;
  border-radius: 999px; padding: .05rem .32rem; line-height: 1.3;
}
.notif-row {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem;
  padding: .85rem 1.2rem; border-bottom: 1px solid var(--border);
  color: var(--ink-2); text-decoration: none; transition: background .15s;
}
.notif-row:hover { background: var(--bg); color: var(--ink-2); }
.notif-row:last-child { border-bottom: 0; }
.notif-row.unread { background: var(--blue-soft); }
.notif-row strong { color: var(--primary); font-size: .92rem; display: block; }
.notif-row p { font-size: .82rem; color: var(--ink-3); }
.notif-row small { color: var(--ink-3); font-size: .72rem; white-space: nowrap; }

/* ---------- توثيق API ---------- */
.api-doc { background: var(--primary); color: #7DD3FC; border-radius: 12px; padding: .9rem 1.1rem; font-size: .8rem; overflow-x: auto; }

/* ---------- POS v2: تصنيفات، صور، دفع مجزأ، نوافذ ---------- */
.pos-cats { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .5rem; margin-bottom: .5rem; scrollbar-width: thin; }
.cat-chip {
  font-family: inherit; font-weight: 700; font-size: .82rem; white-space: nowrap;
  background: #fff; border: 1.5px solid var(--border); color: var(--ink-2);
  border-radius: 999px; padding: .35rem 1rem; cursor: pointer;
}
.cat-chip.active { background: var(--grad); color: #fff; border-color: transparent; }
.pos-product { flex-direction: row; align-items: center; gap: .6rem; text-align: start; }
.pos-product img, .pos-product .p-thumb {
  width: 44px; height: 44px; border-radius: 10px; object-fit: cover; flex-shrink: 0;
}
.pos-product .p-thumb {
  display: grid; place-items: center; background: var(--blue-soft);
  color: var(--secondary); font-weight: 900; font-size: 1.1rem;
}
.pos-product .p-info { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.pos-product .p-info strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pay-line {
  display: flex; align-items: center; gap: .45rem;
  padding: .3rem 0; border-bottom: 1px dashed var(--border); font-size: .85rem;
}
.pay-line .pl-m { font-weight: 700; min-width: 64px; }
.pay-line .pl-amt { width: 92px; text-align: left; }
.pay-line .pl-ref { flex: 1; color: var(--ink-3); font-size: .72rem; direction: ltr; text-align: end; overflow: hidden; text-overflow: ellipsis; }
.pay-line .c-del { border: 0; background: none; color: #DC2626; font-size: 1rem; cursor: pointer; }
.pos-modal {
  position: fixed; inset: 0; background: rgba(15,23,42,.55);
  display: grid; place-items: center; z-index: 2000; padding: 1rem;
}
.pos-modal-card {
  background: #fff; border-radius: 18px; padding: 1.4rem;
  width: min(420px, 94vw); box-shadow: var(--shadow-md);
}
.pos-modal-card h3 { font-size: 1.05rem; margin-bottom: .8rem; }
.held-row {
  display: flex; align-items: center; gap: .7rem; width: 100%;
  font-family: inherit; text-align: start; cursor: pointer;
  background: var(--bg); border: 1.5px solid var(--border); border-radius: 10px;
  padding: .55rem .8rem; margin-bottom: .4rem;
}
.held-row:hover { border-color: var(--secondary); }
.held-row strong { flex: 1; color: var(--primary); font-size: .9rem; }
.held-row small { color: var(--ink-3); }
