/* My Reading Box — موقع الإدارة. جوال أولاً، عربي من اليمين لليسار، بألوان الهوية (فيروزي + وردي + برتقالي). */
:root {
  /* التخطيط: عمود واحد بعرض الجوال، إجراءات فوق، تنقل ثابت تحت. */
  --teal: #00bacd;
  --teal-deep: #006e7a;
  --teal-soft: #e2f6f8;
  --ink: #1d3236;
  --muted: #5d7074;
  --paper: #f2f7f7;
  --surface: #ffffff;
  --line: #d6e4e5;
  --pink: #ff779b;
  --orange: #b85f00;
  --orange-soft: #fff1dc;
  --danger: #c22f48;
  --danger-soft: #fde8ec;
  --ok: #17794f;
  --ok-soft: #e1f4ea;
  --font-body: 'Readex Pro', 'Segoe UI', Tahoma, sans-serif;
  --font-display: 'Baloo Bhaijaan 2', 'Readex Pro', Tahoma, sans-serif;
  --radius: 14px;
  --nav-h: 64px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { height: 100%; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.6 var(--font-body);
  font-variant-numeric: tabular-nums;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.25; text-wrap: balance; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--pink); outline-offset: 2px; }
[hidden] { display: none !important; }

#app { max-width: 620px; margin: 0 auto; min-height: 100vh; padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 20px); }

/* ——— الشريط العلوي ——— */
.demo-bar { background: var(--ink); color: #fff; font-size: 13px; text-align: center; padding: 6px 16px; }
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--teal-deep); color: #fff;
}
.top__title { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.top h1 { font-size: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.code { font-size: 12px; font-weight: 600; letter-spacing: .04em; color: var(--teal-deep); background: var(--teal-soft); border-radius: 6px; padding: 1px 7px; direction: ltr; }
.code--big { font-size: 13px; background: var(--teal); color: #00343a; }
.jump { position: relative; width: 150px; flex: none; }
.top .jump__input { width: 100%; min-height: 38px; height: 38px; border: 0; border-radius: 10px; padding: 0 12px; background: rgba(255,255,255,.16); color: #fff; font-size: 14px; box-shadow: none; }
.top .jump__input::placeholder { color: rgba(255,255,255,.75); }
.top .jump__input:focus { background: #fff; color: var(--ink); outline: none; }
.top .jump__input:focus::placeholder { color: var(--muted); }
.jump__results { position: absolute; inset-inline-end: 0; top: 44px; width: min(280px, 86vw); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(0,60,66,.18); overflow: hidden; }
.jump__item, .sheet__item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 46px; padding: 8px 14px; border: 0; background: none; text-align: start; color: var(--ink); }
.jump__item + .jump__item { border-top: 1px solid var(--line); }
.jump__item:disabled, .sheet__item:disabled { color: var(--muted); cursor: default; }
.soon { margin-inline-start: auto; font-size: 12px; color: var(--muted); }

/* ——— المحتوى ——— */
.screen { padding: 14px 16px; display: flex; flex-direction: column; gap: 14px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.loading, .empty { text-align: center; color: var(--muted); padding: 40px 0; display: flex; flex-direction: column; gap: 14px; align-items: center; }
.hint { font-size: 13px; color: var(--muted); }
.notice { padding: 10px 14px; border-radius: 12px; background: var(--orange-soft); color: var(--orange); font-weight: 500; font-size: 14px; }
.error { color: var(--danger); font-weight: 500; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actions__note { margin-inline-start: auto; font-size: 13px; color: var(--muted); }
.actions--inline { margin-top: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 46px; padding: 0 18px; border: 1.5px solid transparent; border-radius: 12px;
  font-weight: 600; font-size: 15px; text-decoration: none; transition: transform .08s ease, background .15s ease;
}
.btn:active { transform: scale(.97); }
.btn--primary { background: var(--teal-deep); color: #fff; }
.btn--quiet { background: var(--surface); border-color: var(--line); color: var(--teal-deep); }
.btn--danger { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.btn--small { min-height: 38px; padding: 0 12px; font-size: 14px; }
.btn--block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.is-busy { opacity: .7; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.panel h2 { font-size: 17px; margin-bottom: 10px; }
.panel--flush { padding: 0; overflow: hidden; }
.panel__head { padding: 12px 16px 8px; margin: 0 !important; }
.panel--summary { border-color: var(--teal); background: linear-gradient(180deg, var(--teal-soft), var(--surface) 70%); }

/* ——— النماذج ——— */
.form { display: flex; flex-direction: column; gap: 8px; }
.form h2 { margin-bottom: 2px; }
label, .label { font-size: 14px; font-weight: 500; color: var(--muted); margin-top: 6px; }
input[type='text'], input[type='tel'], input[type='password'], input[type='search'], textarea {
  width: 100%; min-height: 48px; padding: 10px 14px; background: var(--surface);
  border: 1.5px solid var(--line); border-radius: 12px;
}
input:focus, textarea:focus { border-color: var(--teal-deep); outline: none; box-shadow: 0 0 0 3px var(--teal-soft); }
.field--search input { background: var(--surface); }
.money { text-align: start; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; background: var(--paper); border-radius: 12px; }
.seg__item { min-height: 42px; border: 0; border-radius: 9px; background: none; font-size: 14px; font-weight: 500; color: var(--muted); }
.seg__item.is-on { background: var(--surface); color: var(--teal-deep); font-weight: 700; box-shadow: 0 1px 4px rgba(0,60,66,.16); }

.toggle { display: flex; align-items: center; gap: 12px; min-height: 46px; margin: 0; color: var(--ink); font-size: 16px; cursor: pointer; }
.toggle input { appearance: none; width: 46px; height: 28px; border-radius: 99px; background: var(--line); position: relative; flex: none; transition: background .15s; margin: 0; cursor: pointer; }
.toggle input::after { content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.toggle input:checked { background: var(--teal-deep); }
.toggle input:checked::after { transform: translateX(-18px); }

/* ——— الفلاتر ——— */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips--scroll { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 2px 16px; scrollbar-width: none; }
.chips--scroll::-webkit-scrollbar { display: none; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px; border: 1.5px solid var(--line); border-radius: 99px; background: var(--surface); font-size: 14px; font-weight: 500; }
.chip.is-on { background: var(--teal-deep); border-color: var(--teal-deep); color: #fff; }
.chip__count { font-size: 12px; min-width: 20px; padding: 0 5px; border-radius: 99px; background: var(--paper); color: var(--muted); text-align: center; }
.chip.is-on .chip__count { background: rgba(255,255,255,.22); color: #fff; }

/* ——— بطاقات الطلبات ——— */
.cards { display: flex; flex-direction: column; gap: 10px; }
.card { display: flex; flex-direction: column; gap: 6px; width: 100%; padding: 14px 16px; text-align: start; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); transition: transform .08s ease, border-color .15s; }
.card:active { transform: scale(.985); border-color: var(--teal); }
.card.is-done { background: transparent; }
.card.is-cancelled .order__name, .card.is-cancelled .order__total { text-decoration: line-through; color: var(--muted); }
.order__head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.order__name { font-family: var(--font-display); font-size: 18px; direction: ltr; }
.order__name--big { font-size: 24px; }
.order__total { margin-inline-start: auto; font-weight: 700; }
.order__items { font-size: 14px; color: var(--ink); overflow-wrap: anywhere; }
.order__meta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 14px; color: var(--muted); }
.order__foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.order__by { margin-inline-start: auto; font-size: 12px; color: var(--muted); }
mark { background: #ffe27a; color: inherit; border-radius: 3px; padding: 0 1px; }

.badge { font-size: 12px; font-weight: 600; padding: 1px 9px; border-radius: 6px; }
.badge--whatsapp { background: var(--ok-soft); color: var(--ok); }
.badge--web { background: var(--teal-soft); color: var(--teal-deep); }
.pill { font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 99px; background: var(--paper); color: var(--muted); }
.pill--urgent { background: var(--danger-soft); color: var(--danger); }
.pill--late { background: var(--orange-soft); color: var(--orange); }
.pill--owing { background: #ffe9ef; color: #a8244a; }
.pill--done { background: var(--ok-soft); color: var(--ok); }

/* ——— تفاصيل الفاتورة ——— */
.totals { width: 100%; border-collapse: collapse; margin-top: 12px; }
.totals th { text-align: start; font-weight: 400; padding: 8px 0; }
.totals td { text-align: end; padding: 8px 0; white-space: nowrap; }
.totals tr + tr { border-top: 1px solid var(--line); }
.totals small { display: block; color: var(--muted); font-size: 12px; }
.totals .qty { color: var(--muted); }
.totals__total th, .totals__total td { font-weight: 700; font-size: 18px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; }
.facts dt { color: var(--muted); font-size: 14px; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.message { margin: 0; padding: 14px; background: #e9f7ee; border-radius: 12px; font: inherit; font-size: 15px; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ——— اختيار المنتجات ——— */
.picker { display: flex; flex-direction: column; margin-top: 10px; }
.picker__type { font-size: 13px; color: var(--muted); font-family: var(--font-body); font-weight: 600; padding: 12px 0 4px; }
.picker__row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 0; border-top: 1px solid var(--line); }
.picker__row.is-picked { background: var(--teal-soft); margin: 0 -16px; padding: 10px 16px; border-top-color: transparent; }
.picker__row.is-out .picker__title { color: var(--muted); }
.picker__info { flex: 1; min-width: 150px; display: flex; flex-direction: column; }
.picker__title { font-weight: 500; overflow-wrap: anywhere; }
.picker__sub { font-size: 13px; color: var(--muted); display: flex; gap: 10px; }
.picker__discount { flex-basis: 100%; display: flex; align-items: center; gap: 10px; margin: 0; font-size: 13px; }
.picker__discount .money { width: 110px; min-height: 42px; padding: 6px 10px; flex: none; }
.stock--low { color: var(--orange); font-weight: 600; }

.stepper { display: inline-flex; align-items: center; gap: 2px; flex: none; }
.stepper button { width: 42px; height: 42px; border-radius: 50%; border: 1.5px solid var(--teal-deep); background: var(--surface); color: var(--teal-deep); font-size: 22px; line-height: 1; font-weight: 600; }
.stepper button:disabled { border-color: var(--line); color: var(--line); }
.stepper output { min-width: 34px; text-align: center; font-weight: 700; font-size: 17px; }
.stepper--big { display: flex; justify-content: center; gap: 14px; margin: 14px 0 8px; }
.stepper--big button { width: 56px; height: 56px; font-size: 28px; }
.qty-input { width: 110px !important; text-align: center; font-size: 28px; font-weight: 700; font-family: var(--font-display); }

.summary { display: flex; flex-direction: column; gap: 6px; }
.summary__row { display: flex; justify-content: space-between; gap: 12px; }
.summary__row.is-muted { color: var(--muted); font-size: 14px; }
.summary__total { font-size: 21px; font-weight: 700; font-family: var(--font-display); border-top: 1.5px solid var(--teal); padding-top: 8px; margin-top: 4px; }

/* ——— المخزون ——— */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; display: flex; flex-direction: column; }
.tile strong { font-family: var(--font-display); font-size: 26px; line-height: 1.1; }
.tile span { font-size: 12px; color: var(--muted); }
.tile--warn { border-color: var(--orange); background: var(--orange-soft); }
.tile--warn strong { color: var(--orange); }
.stock-row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 58px; padding: 10px 16px; background: none; border: 0; border-top: 1px solid var(--line); text-align: start; }
.stock-row__title { flex: 1; display: flex; flex-direction: column; overflow-wrap: anywhere; }
.stock-row__title small { color: var(--muted); font-size: 13px; }
.qty-badge { flex: none; min-width: 46px; text-align: center; padding: 4px 10px; border-radius: 10px; background: var(--ok-soft); color: var(--ok); font-weight: 700; font-size: 17px; }
.qty--low { background: var(--orange-soft); color: var(--orange); }
.qty--out { background: var(--danger-soft); color: var(--danger); }

/* ——— التنقل السفلي ——— */
.nav {
  position: fixed; bottom: 0; inset-inline: 0; z-index: 6;
  display: flex; justify-content: center;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav__item { flex: 1; max-width: 155px; height: var(--nav-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border: 0; background: none; font-size: 12px; font-weight: 500; color: var(--muted); }
.nav__icon { font-size: 20px; line-height: 1; width: 44px; height: 28px; display: grid; place-items: center; border-radius: 99px; transition: background .15s; }
.nav__item.is-current { color: var(--teal-deep); font-weight: 700; }
.nav__item.is-current .nav__icon { background: var(--teal-soft); }

/* ——— شريط الحفظ الثابت (فاتورة جديدة) ——— */
.dock { position: fixed; z-index: 6; inset-inline: 0; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -6px 18px rgba(0,60,66,.10); }
.dock__inner { max-width: 620px; margin: 0 auto; padding: 8px 16px; display: flex; align-items: center; gap: 8px; }
.dock__inner .btn--primary { flex: 1; }
.dock__total { font-family: var(--font-display); font-weight: 700; font-size: 19px; min-width: 70px; direction: ltr; text-align: center; }
.screen:has(.dock) { padding-bottom: 84px; }
body:has(.dock) .toast { bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 78px); }

/* ——— النوافذ ——— */
.overlay { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px; background: rgba(13,40,44,.5); animation: fade .15s ease; }
.overlay--sheet { place-items: end center; padding: 0; }
.dialog { width: min(380px, 100%); background: var(--surface); border-radius: 18px; padding: 22px; display: flex; flex-direction: column; gap: 10px; }
.dialog__actions { display: flex; gap: 8px; margin-top: 8px; }
.dialog__actions .btn { flex: 1; }
.sheet { width: min(620px, 100%); max-height: 82vh; overflow-y: auto; background: var(--surface); border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); animation: rise .2s ease; }
.sheet__user { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.sheet__user .role { display: block; font-size: 13px; color: var(--muted); }
.sheet__group h3 { font-size: 13px; font-family: var(--font-body); color: var(--muted); padding: 14px 0 2px; }
.sheet__item { padding-inline: 4px; border-radius: 10px; }

.toast { position: fixed; z-index: 30; inset-inline: 16px; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 14px); max-width: 480px; margin: 0 auto; padding: 12px 16px; border-radius: 12px; background: var(--ink); color: #fff; font-weight: 500; text-align: center; opacity: 0; transform: translateY(10px); pointer-events: none; transition: opacity .2s, transform .2s; }
.toast.is-shown { opacity: 1; transform: none; }
.toast--error { background: var(--danger); }

/* ——— الدخول ——— */
.login { min-height: 100vh; padding: 40px 24px; display: flex; flex-direction: column; align-items: center; gap: 4px; background: linear-gradient(180deg, var(--teal-soft), var(--paper) 46%); }
.login__logo { border-radius: 22px; box-shadow: 0 8px 24px rgba(0,110,122,.25); margin-bottom: 10px; }
.login h1 { font-size: 28px; color: var(--teal-deep); direction: ltr; }
.login__sub { color: var(--muted); margin-bottom: 18px; }
.login__form { width: min(360px, 100%); display: flex; flex-direction: column; gap: 6px; }
.login__form .btn { margin-top: 10px; }
.login__demo { width: min(360px, 100%); margin-top: 22px; padding: 14px; border: 1.5px dashed var(--teal); border-radius: var(--radius); display: flex; flex-direction: column; gap: 10px; font-size: 14px; color: var(--muted); }

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(30px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media (max-width: 380px) { .jump { width: 118px; } .top h1 { font-size: 18px; } }
