/* =============================================================
   5G System — Design System (mobile-first)
   ألوان مستخرجة من اللوغو: أزرق، سماوي، أصفر، أبيض، أسود
   ============================================================= */

:root {
  /* --- Brand palette from logo --- */
  --blue:        #0A6BFF;   /* الأزرق الأساسي */
  --blue-deep:   #0A47B8;   /* أزرق غامق */
  --cyan:        #00B4FF;   /* السماوي داخل الدائرة */
  --yellow:      #FFD400;   /* الأصفر */
  --yellow-deep: #E6BE00;
  --ink:         #0B1220;   /* أسود مائل للأزرق */
  --white:       #FFFFFF;

  /* --- Semantic --- */
  --bg:          #EEF3FB;
  --surface:     #FFFFFF;
  --text:        #0B1220;
  --text-soft:   #5B6675;
  --border:      #E2E8F2;
  --success:     #17A673;
  --danger:      #E5484D;

  --grad-brand: linear-gradient(135deg, var(--blue) 0%, var(--cyan) 100%);

  /* --- Shape & motion --- */
  --radius:    18px;
  --radius-lg: 26px;
  --shadow:    0 8px 26px rgba(10,71,184,.12);
  --shadow-lg: 0 14px 40px rgba(10,71,184,.20);
  --tap:       56px;   /* حجم الهدف اللمسي (أكبر من 44px) */
  --ease:      cubic-bezier(.22,.61,.36,1);

  --font: "Segoe UI", "Tajawal", system-ui, -apple-system, Roboto, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

body { min-height: 100vh; min-height: 100dvh; }

/* ---------- App shell ---------- */
.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh; min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  background: var(--grad-brand);
  color: #fff;
  box-shadow: var(--shadow);
}
.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; letter-spacing: .5px; }
.topbar .brand .logo-badge {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--ink);
  display: grid; place-items: center;
  color: var(--yellow); font-weight: 900; font-size: 15px;
  border: 2px solid var(--cyan);
}
.topbar .who { text-align: left; font-size: 13px; line-height: 1.3; opacity: .95; }
.topbar .who b { display: block; font-size: 15px; }

/* ---------- Content ---------- */
.content { flex: 1; padding: 18px; padding-bottom: 96px; }

/* ---------- Card ---------- */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 20px;
  border: 1px solid var(--border);
}

/* ---------- Form fields ---------- */
.field { margin-bottom: 16px; }
.field > label {
  display: block; font-weight: 700; font-size: 15px;
  margin-bottom: 8px; color: var(--text);
}
.input {
  width: 100%;
  min-height: var(--tap);
  font-size: 20px; font-weight: 600;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: #F8FAFF;
  color: var(--text);
  outline: none;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(10,107,255,.14);
  background: #fff;
}
.input::placeholder { color: #A7B2C2; font-weight: 500; }

/* حقل السعر: يعرض اللاحقة "ألف" */
.price-wrap { position: relative; }
.price-wrap .suffix {
  position: absolute; inset-inline-start: 16px; top: 50%;
  transform: translateY(-50%);
  font-weight: 800; color: var(--blue); pointer-events: none; font-size: 15px;
}
.price-wrap .input { padding-inline-start: 64px; }
.price-hint { margin-top: 6px; font-size: 13px; color: var(--text-soft); }
.price-hint b { color: var(--blue); }

/* ---------- Buttons ---------- */
.btn {
  width: 100%;
  min-height: var(--tap);
  font-size: 19px; font-weight: 800;
  border: none; border-radius: var(--radius);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  transition: transform .08s var(--ease), box-shadow .15s var(--ease), background .15s;
  user-select: none;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--grad-brand); color: #fff; box-shadow: var(--shadow-lg); }
.btn-yellow  { background: var(--yellow); color: var(--ink); box-shadow: 0 10px 26px rgba(255,212,0,.35); }
.btn-ghost   { background: #fff; color: var(--blue); border: 2px solid var(--blue); }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-soft    { background: #EDF2FE; color: var(--blue); }
.btn-lg      { min-height: 64px; font-size: 21px; }
.btn:disabled { opacity: .5; pointer-events: none; }

.btn-row { display: flex; gap: 12px; }
.btn-row .btn { flex: 1; }

/* ---------- Chips (frequent products) ---------- */
.section-label { font-weight: 800; font-size: 14px; color: var(--text-soft); margin: 22px 4px 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  min-height: 46px;
  padding: 10px 16px;
  border-radius: 999px;
  background: #fff; border: 2px solid var(--border);
  font-weight: 700; font-size: 15px; color: var(--text);
  cursor: pointer;
  transition: all .12s var(--ease);
}
.chip:active { transform: scale(.95); }
.chip.on { background: var(--blue); color: #fff; border-color: var(--blue); }

/* ---------- Toast / notifications ---------- */
.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff;
  padding: 14px 22px; border-radius: 999px;
  font-weight: 700; font-size: 15px;
  box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none;
  transition: opacity .2s var(--ease), transform .2s var(--ease);
  z-index: 60; display: flex; align-items: center; gap: 10px;
  max-width: 90%;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
.toast .undo-btn {
  background: var(--yellow); color: var(--ink);
  border: none; border-radius: 999px; padding: 6px 14px;
  font-weight: 800; cursor: pointer; font-size: 14px;
}

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px;
  display: flex; justify-content: space-around;
  background: #fff; border-top: 1px solid var(--border);
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  z-index: 30;
}
.bottom-nav a {
  flex: 1; text-align: center; text-decoration: none;
  color: var(--text-soft); font-size: 12px; font-weight: 700;
  padding: 6px 0; border-radius: 14px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.bottom-nav a .ic { font-size: 22px; line-height: 1; }
.bottom-nav a.active { color: var(--blue); }
.bottom-nav a.active .ic { transform: translateY(-1px); }

/* ---------- PIN screen ---------- */
.pin-screen {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px; gap: 22px;
  background: radial-gradient(120% 90% at 50% 0%, #0A47B8 0%, #08122A 70%);
}
.pin-logo {
  width: 110px; height: 110px; border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, var(--cyan), var(--blue) 70%);
  border: 4px solid var(--ink);
  box-shadow: 0 0 40px rgba(0,180,255,.5);
  display: grid; place-items: center;
  font-weight: 900; font-size: 44px; color: #fff;
}
.pin-logo span { color: var(--yellow); }
.pin-title { color: #fff; font-weight: 800; font-size: 20px; opacity: .9; }
.pin-dots { display: flex; gap: 16px; margin: 4px 0; }
.pin-dot { width: 18px; height: 18px; border-radius: 50%; background: rgba(255,255,255,.22); transition: all .15s var(--ease); }
.pin-dot.filled { background: var(--yellow); transform: scale(1.15); box-shadow: 0 0 14px rgba(255,212,0,.7); }
.pin-error { color: #FFB4B4; font-weight: 700; min-height: 20px; }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; width: 100%; max-width: 320px; }
.key {
  height: 74px; border-radius: 22px; border: none;
  background: rgba(255,255,255,.10); color: #fff;
  font-size: 28px; font-weight: 800; cursor: pointer;
  backdrop-filter: blur(6px);
  transition: transform .07s var(--ease), background .12s;
}
.key:active { transform: scale(.93); background: rgba(255,255,255,.22); }
.key.action { background: rgba(255,212,0,.16); color: var(--yellow); font-size: 22px; }

/* ---------- Dashboard grid ---------- */
.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
}
.kpi .k-label { font-size: 13px; color: var(--text-soft); font-weight: 700; }
.kpi .k-value { font-size: 24px; font-weight: 900; margin-top: 6px; color: var(--ink); }
.kpi .k-value small { font-size: 14px; color: var(--text-soft); font-weight: 700; }
.kpi.accent { background: var(--grad-brand); border: none; color: #fff; }
.kpi.accent .k-label, .kpi.accent .k-value, .kpi.accent .k-value small { color: #fff; }
.kpi.wide { grid-column: 1 / -1; }

.chart-card { margin-top: 16px; }
.chart-card canvas { width: 100% !important; height: 200px !important; }

/* ---------- List / table rows ---------- */
.txn { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 4px; border-bottom: 1px solid var(--border); }
.txn:last-child { border-bottom: none; }
.txn .t-main { font-weight: 800; font-size: 16px; }
.txn .t-sub { font-size: 13px; color: var(--text-soft); margin-top: 2px; }
.txn .t-price { font-weight: 900; color: var(--blue); font-size: 16px; white-space: nowrap; }
.txn .t-actions { display: flex; gap: 6px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: none; cursor: pointer;
  display: grid; place-items: center; font-size: 17px; background: #EDF2FE; color: var(--blue);
}
.icon-btn.del { background: #FDECEC; color: var(--danger); }

/* ---------- Filters ---------- */
.filters { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 12px; }
.filters::-webkit-scrollbar { display: none; }
.filter-pill {
  white-space: nowrap; padding: 10px 16px; border-radius: 999px;
  border: 2px solid var(--border); background: #fff; color: var(--text);
  font-weight: 700; font-size: 14px; cursor: pointer; min-height: 44px;
}
.filter-pill.on { background: var(--blue); color: #fff; border-color: var(--blue); }

/* ---------- Modal ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(8,18,42,.55);
  display: none; align-items: center; justify-content: center; z-index: 80; padding: 20px;
}
.modal-back.show { display: flex; }
.modal {
  background: #fff; border-radius: var(--radius-lg); padding: 22px;
  width: 100%; max-width: 400px; box-shadow: var(--shadow-lg);
}
.modal h3 { margin: 0 0 14px; font-size: 19px; }

/* ---------- Utility ---------- */
.muted { color: var(--text-soft); }
.center { text-align: center; }
.spinner {
  width: 22px; height: 22px; border: 3px solid rgba(255,255,255,.4);
  border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; color: var(--text-soft); padding: 40px 10px; }
.fade-in { animation: fade .25s var(--ease); }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

@media (min-width: 481px) {
  .app, .bottom-nav { box-shadow: 0 0 0 1px var(--border); }
}

/* ---------- صور اللوغو الحقيقية ---------- */
.topbar .brand .logo-img {
  width: 40px; height: 40px; border-radius: 50%;
  object-fit: cover; background: #08122A;
  box-shadow: 0 0 0 2px rgba(255,255,255,.55), 0 4px 10px rgba(0,0,0,.25);
}
.pin-logo-img {
  width: 124px; height: 124px; border-radius: 50%;
  object-fit: cover; background: #08122A;
  box-shadow: 0 0 44px rgba(0,180,255,.55), 0 0 0 4px rgba(11,18,32,.9);
}

/* ---------- زر صغير ---------- */
.btn-sm {
  width: auto; min-height: 44px;
  padding: 8px 20px; font-size: 15px;
  display: inline-flex;
}

/* ============ v2: قائمة جانبية + عناصر جديدة ============ */
.hamburger{ background:rgba(255,255,255,.18); border:none; color:#fff; width:44px; height:44px; border-radius:12px; font-size:22px; cursor:pointer; }
.hamburger:active{ transform:scale(.94); }
.topbar .who{ text-align:left; font-size:12px; opacity:.95; line-height:1.25; }
.topbar .who b{ display:block; font-size:15px; }

.drawer{ position:fixed; top:0; right:-300px; width:280px; max-width:82%; height:100%; background:#fff; z-index:90;
  box-shadow:-12px 0 40px rgba(8,18,42,.25); transition:right .25s var(--ease); display:flex; flex-direction:column; }
.drawer.open{ right:0; }
.drawer-back{ position:fixed; inset:0; background:rgba(8,18,42,.5); z-index:85; opacity:0; pointer-events:none; transition:opacity .25s; }
.drawer-back.show{ opacity:1; pointer-events:auto; }
.drawer-head{ display:flex; align-items:center; gap:12px; padding:22px 18px; background:var(--grad-brand); color:#fff; }
.drawer-head img{ width:52px; height:52px; border-radius:50%; background:#08122A; box-shadow:0 0 0 2px rgba(255,255,255,.5); }
.drawer-head b{ display:block; font-size:17px; }
.drawer-head .muted{ color:#EAF3FF; font-size:13px; }
.drawer-items{ flex:1; overflow-y:auto; padding:10px; }
.drawer-item{ width:100%; display:flex; align-items:center; gap:14px; padding:15px 16px; border:none; background:transparent;
  border-radius:14px; font-size:16px; font-weight:700; color:var(--text); cursor:pointer; text-align:right; }
.drawer-item .di-ic{ font-size:22px; }
.drawer-item:active{ transform:scale(.98); }
.drawer-item.active{ background:#EDF2FE; color:var(--blue); }
.drawer-logout{ margin:10px; padding:15px; border:none; background:#FDECEC; color:var(--danger); border-radius:14px; font-size:16px; font-weight:800; cursor:pointer; }

.link-btn{ background:none; border:none; color:#EAF3FF; font-size:15px; font-weight:700; margin-top:8px; cursor:pointer; text-decoration:underline; opacity:.9; }

.balance-box{ font-size:22px; font-weight:900; color:var(--blue); padding:12px 16px; background:#EDF2FE; border-radius:var(--radius); }
.t-price.paid{ color:var(--success); }

select.input{ appearance:none; background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%230A6BFF' stroke-width='3'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat:no-repeat; background-position:left 16px center; padding-inline-start:44px; }

/* سبينر داكن على الخلفيات الفاتحة (حالة تحميل القسم) */
.spinner.dark{ border:3px solid rgba(10,107,255,.25); border-top-color:var(--blue); display:inline-block; vertical-align:middle; margin-inline-end:8px; }

/* ============================================================
   إضافات الإصدار v3 (نقدي/آجل، إلغاء، موردون، تقرير موظفين، تحديث)
   ============================================================ */
.topbar .brand { flex: 1; min-width: 0; }
.topbar-refresh{ width:42px; height:42px; flex:0 0 auto; border:none; border-radius:12px;
  background:rgba(255,255,255,.18); color:#fff; font-size:22px; line-height:1; cursor:pointer; }
.topbar-refresh:active{ transform:scale(.92); }
.topbar-refresh.spin{ animation:spin360 .8s linear infinite; }
@keyframes spin360{ to{ transform:rotate(360deg); } }

/* مبدّل الخيارات (نقدي/آجل، مبيعات/تحصيلات) */
.seg-toggle{ display:flex; gap:8px; }
.seg-opt{ flex:1; padding:12px; min-height:48px; border:2px solid var(--border); background:var(--surface);
  border-radius:14px; font-weight:800; font-size:15px; color:var(--text-soft); cursor:pointer; transition:all .15s var(--ease); }
.seg-opt.on{ border-color:var(--blue); background:#EAF1FF; color:var(--blue); }

.credit-box{ border:1px dashed var(--border); border-radius:14px; padding:12px; margin:0 0 14px; background:#F7FAFF; }
.row-inline{ display:flex; gap:8px; align-items:stretch; }
.row-inline .input{ flex:1; }
.row-inline .btn{ flex:0 0 auto; white-space:nowrap; }

/* وسوم الحالة */
.tag{ font-size:11px; font-weight:800; padding:2px 8px; border-radius:999px; vertical-align:middle; }
.tag-cash{ background:#E7F7F0; color:var(--success); }
.tag-credit{ background:#FFF6DA; color:var(--yellow-deep); }
.tag-void{ background:#FDECEC; color:var(--danger); }
.txn.is-void{ opacity:.6; }
.txn.is-void .t-price{ text-decoration:line-through; }

/* بطاقة مؤشر بلون التحذير (إجمالي ديون الموردين) */
.kpi.danger{ background:#FDECEC; border-color:#F6C9CB; }
.kpi.danger .k-label{ color:#9B2C2C; }
.kpi.danger .k-value{ color:var(--danger); }

.balance-box{ padding:12px 14px; border-radius:14px; background:#EAF1FF; color:var(--blue);
  font-weight:900; font-size:18px; text-align:center; }

/* تقرير مبيعات الموظفين */
.er-head{ display:grid; grid-template-columns:1fr 52px 1fr; gap:8px; padding:6px 4px 10px;
  font-size:12px; color:var(--text-soft); font-weight:800; }
.er-row{ display:grid; grid-template-columns:1fr 52px 1fr; gap:8px; align-items:center; width:100%; text-align:right;
  background:var(--surface); border:none; border-top:1px solid var(--border); padding:12px 4px; cursor:pointer; }
.er-name{ font-weight:800; font-size:15px; }
.er-sub{ font-size:11px; color:var(--text-soft); font-weight:600; margin-top:3px; line-height:1.5; }
.er-c{ text-align:center; font-weight:800; }
.er-t{ text-align:left; font-weight:900; color:var(--blue); }

/* ===== إضافات v2: شريط المزامنة + شاشة البداية ===== */
.sync-banner{ font-size:12px; font-weight:700; text-align:center; padding:4px; color:#fff; }
.sync-banner.idle{ background:#17A673; }
.sync-banner.syncing{ background:#0A6BFF; }
.sync-banner.offline{ background:#5B6675; }
.sync-banner.error{ background:#E5484D; }
.splash{ position:fixed; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:14px; background:#EEF3FB; z-index:999; transition:opacity .3s; }
.splash.hide{ opacity:0; pointer-events:none; }
.splash__logo{ width:96px; height:96px; border-radius:24px; }
.splash__name{ font-weight:900; font-size:22px; color:#0B1220; }
