/* صفحة الشحن عبر الموقع — المقاساتُ منقولةٌ من الصفحة المرجعيّة،
   والألوانُ ألوانُ محفظة التطبيق. ولكلّ رمزٍ مقابلٌ داكن. */
:root {
  --bg: #F7F6FB; --bar: #FFFFFF; --card: #FFFFFF;
  --t333: #333333; --t2a: #2A2A2A; --t999: #999999; --tccc: #CCCCCC;
  --pill-line: #EAEAEA;
  --brand: #36A4A0; --brand-soft: rgba(54, 164, 160, .12);
  --buy1: #4AE386; --buy2: #29DEC1; --bonus: #FF7F50;
  --shadow: rgba(55, 55, 55, .18); --toast: rgba(0, 0, 0, .78);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0B1517; --bar: #161F22; --card: #161F22;
    --t333: #FFFFFF; --t2a: #FFFFFF; --t999: rgba(255, 255, 255, .55); --tccc: rgba(255, 255, 255, .35);
    --pill-line: #2A3639;
    --brand-soft: rgba(54, 164, 160, .20); --shadow: rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg); color: var(--t333);
  font-family: "Readex Pro", "Segoe UI", Tahoma, system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button { font: inherit; }
.num { font-variant-numeric: tabular-nums; }
.ltr { direction: ltr; unicode-bidi: isolate; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.page { max-width: 414px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); position: relative; }

/* الرأس */
.head {
  /* 59 فوق شريط الحالة لا منه: هامشُ الأمان يُضاف إلى الارتفاع ولا يقتطعه. */
  height: calc(59px + env(safe-area-inset-top, 0px)); padding: 0 15px; display: flex; align-items: center; justify-content: center;
  background: var(--bar); position: sticky; top: 0; z-index: 2;
  padding-top: env(safe-area-inset-top, 0px);
}
/* اسمُ البوّابة مكانَ السهم وخيارِ اللغة: سطرٌ واحد في الوسط، يُقصّ ولا يلتفّ. */
.brand { font-size: 16px; font-weight: 600; color: var(--t333); line-height: 23px; text-align: center; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.body { flex: 1; }

/* رقم الشحن */
.search { padding: 15px 15px 0; }
.title { font-size: 16px; font-weight: 600; color: var(--t333); line-height: 23px; margin: 0 0 10px; }
.bottom-search { position: relative; }
/* شريطُ البحث: الخانةُ والزرُّ جسمٌ واحد يملأ العرض — ارتفاعٌ واحد، وهامشٌ داخليٌّ 6 من كلّ
   جهة، وزوايا متّحدةُ المركز (14 للشريط = 8 للزرّ + 6). كانا 54 و40 متباعدَين بـspace-between،
   فتكبر الفجوةُ مع الشاشة (57px على 414). */
.form-box {
  display: flex; align-items: center; gap: 6px;
  height: 56px; padding: 6px;
  background: var(--card); border: 1px solid var(--pill-line); border-radius: 14px;
  transition: border-color .15s, box-shadow .15s;
}
.form-box:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
/* 16px: Safari على آيفون يكبّر الصفحةَ عند لمس خانةٍ نصُّها أصغر. والحلقةُ للشريط لا للخانة. */
.ipt {
  flex: 1; min-width: 0; height: 100%; padding: 0; padding-inline-start: 8px;
  border: 0; background: transparent; color: var(--t333); font: inherit; font-size: 16px;
}
.ipt::placeholder { color: var(--tccc); }
.ipt:focus, .ipt:focus-visible { outline: 0; }
.user { display: flex; align-items: center; gap: 10px; min-width: 0; }
/* البطاقةُ مكانَ الخانة: الصورةُ على بُعد 9 من الحافّة كبُعدها من الأعلى. */
.form-box .user { flex: 1; height: 100%; padding-inline-start: 3px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none; overflow: hidden;
  display: grid; place-items: center; font-weight: 600; font-size: 14px; color: #fff;
  background: linear-gradient(135deg, #36A4A0, #8CE1C6);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.u-txt { display: grid; min-width: 0; }
.u-name { font-size: 14px; font-weight: 500; color: var(--t2a); line-height: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.u-id { font-size: 11px; color: var(--t999); line-height: 18px; }
.confirm {
  flex: none; align-self: stretch; min-width: 80px; padding: 0 16px; border: 0; border-radius: 8px; cursor: pointer;
  background-image: linear-gradient(90deg, var(--buy1), var(--buy2));
  color: #fff; font-size: 15px; font-weight: 600; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: filter .15s, transform .1s;
}
.confirm:hover { filter: brightness(1.05); }
.confirm:active { transform: scale(.97); }
.confirm[aria-busy="true"] { opacity: .6; cursor: progress; }
/* الحساباتُ السابقة: قائمةٌ منسدلة بعرض الشريط تحته، وصفوفُها تُضاء عند المرور. */
.history {
  position: absolute; z-index: 3; top: calc(100% + 6px); inset-inline: 0;
  display: grid; gap: 2px; padding: 6px;
  background: var(--card); border: 1px solid var(--pill-line); border-radius: 14px;
  box-shadow: 0 12px 24px -12px var(--shadow);
}
.history .user { height: 52px; padding: 0 8px; border: 0; border-radius: 10px; background: transparent; cursor: pointer; color: inherit; text-align: start; font: inherit; }
.history .user:hover, .history .user:focus-visible { background: var(--brand-soft); outline: 0; }
@media (prefers-reduced-motion: reduce) { .form-box, .confirm { transition: none; } }

/* اللافتة والشحن */
.bottom-content { padding: 15px; padding-bottom: calc(15px + env(safe-area-inset-bottom, 0px)); }
.banner { width: 100%; display: block; border-radius: 8px; }
.pay-count { padding: 15px 0; display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.pay-count .title { margin: 0; }
.refresh { width: 42px; height: 42px; padding: 10px; margin-block: -10px; border: 0; background: none; cursor: pointer; display: grid; place-items: center; }
/* الأيقونةُ نفسُها تدور حول مركز صندوقها: refresh-ic.png موسَّطةُ الرسم (فحصُ RefreshIconTest)،
   وobject-fit يوسّطها في الصندوق — فلا تأرجح. والدورةُ 0.8 ثانية (createSpinner ينتظر نهايتَها). */
.refresh img { width: 22px; height: 22px; display: block; object-fit: contain; }
.refresh img.spin { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .refresh img.spin { animation: none; } }

/* طرق الدفع */
.method {
  width: 100%; height: 60px; padding: 0 10px; display: flex; justify-content: space-between; align-items: center;
  background: var(--card); border-radius: 6px; margin-bottom: 10px; border: 0; cursor: pointer; color: inherit;
}
.m-left { display: flex; align-items: center; gap: 8px; }
.m-title { font-weight: 600; line-height: 18px; color: var(--t999); font-size: 13px; }
.chev { width: 20px; height: 20px; color: var(--t999); transition: transform .2s; }
.method[aria-expanded="true"] .chev { transform: rotate(180deg); }
.mk { height: 20px; display: inline-flex; align-items: center; justify-content: center; border-radius: 4px; font-size: 10px; font-weight: 700; padding: 0 5px; line-height: 1; }
.mk.gpay { border: 1px solid var(--pill-line); color: var(--t333); background: var(--card); }
.mk.apay { background: var(--t333); color: var(--card); }
.mk.visa { background: #1A1F71; color: #fff; font-style: italic; }
.mk.mc { width: 30px; padding: 0; position: relative; background: transparent; }
.mk.mc::before, .mk.mc::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; top: 2px; }
.mk.mc::before { background: #EB001B; left: 2px; }
.mk.mc::after { background: #F79E1B; left: 12px; opacity: .9; }

/* الباقات: ثلاثة في السطر */
.pkgs { display: flex; flex-wrap: wrap; width: 100%; }
.item-div { width: 33.333%; display: flex; justify-content: center; }
.pkg {
  width: 115px; max-width: 95%; height: 75px; background: var(--card); border-radius: 8px; margin-bottom: 10px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; border: 0; cursor: pointer; padding: 0 2px;
}
/* «🪙 42500+4250» يُقرأ من اليسار في اللغتين: اتّجاهُ الصفحة كان يقلب الصفّ
   فتسبق المكافأةُ الكمّيّةَ وتُقرأ كأنّها الباقة. */
/* clamp كالمرجع: «850000+85000» يتجاوز بطاقته على 320-360 بخطٍّ ثابتٍ 12. */
.top-num { display: flex; align-items: center; white-space: nowrap; font-size: clamp(8px, 2.6vw, 12px); font-weight: 700; color: var(--t333); line-height: 17px; direction: ltr; }
.top-num img { width: 16px; height: 17px; margin-inline-end: 1px; object-fit: contain; }
.top-num .add { color: var(--bonus); }
.money { font-size: 12px; font-weight: 500; color: var(--brand); line-height: 17px; margin-top: 6px; }

/* الورقة السفليّة */
.sheet { position: fixed; inset: 0; z-index: 5; display: flex; justify-content: center; }
.sheet .mask { position: absolute; inset: 0; background: #000; opacity: .5; }
.sheet .content {
  position: absolute; bottom: 0; width: 100%; max-width: 414px; height: 274px; background: var(--card);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.top-btn { display: flex; align-items: center; justify-content: space-between; }
.top-btn button { padding: 15px; font-size: 16px; line-height: 16px; border: 0; background: none; cursor: pointer; }
.top-btn .cancel { color: var(--t333); font-weight: 400; }
.top-btn .sure { color: var(--brand); font-weight: 600; }

/* الرسائل */
.toast {
  position: fixed; z-index: 6; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  background: var(--toast); color: #fff; font-size: 13px; padding: 8px 14px; border-radius: 8px; max-width: 80%; text-align: center; line-height: 1.5;
}

/* سطرُ حالةٍ دائم مكان الباقات: تعذّر التحميل (مع إعادة المحاولة) أو لا باقات. */
.state-line { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 28px 0; color: var(--t999); font-size: 13px; text-align: center; }
.state-line .retry {
  height: 32px; padding: 0 16px; border: 0; border-radius: 6px; cursor: pointer;
  background-image: linear-gradient(90deg, var(--buy1), var(--buy2)); color: #fff; font-size: 13px; font-weight: 500;
}
