/* =============================================================
   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;
}
