/* ============ مكوّنات مشتركة ============ */

/* — الطباعة — */
.t-display { font-family: var(--font-display); font-weight: 700; line-height: 1.18; letter-spacing: -0.01em; }
.t-h1 { font-size: 27px; }
.t-h2 { font-size: 21px; }
.t-h3 { font-size: 17px; font-weight: 600; }
.t-body { font-size: 14.5px; line-height: 1.65; color: var(--text-2); }
.t-label { font-size: 12px; font-weight: 600; color: var(--text-muted); letter-spacing: 0.02em; }
.t-num { font-family: var(--font-display); font-variant-numeric: tabular-nums; }
.dim { color: var(--text-muted); }
.gold { color: var(--gold-500); }
.mint { color: var(--mint-400); }
.coral { color: var(--coral-400); }

/* — رأس الشاشة — */
.appbar {
  display: flex; align-items: center; gap: var(--s-3);
  padding: 10px 20px 12px; flex: none;
}
.appbar__back {
  width: 40px; height: 40px; display: grid; place-items: center;
  border-radius: var(--r-full); background: var(--glass); border: 1px solid var(--line);
  color: var(--text); font-size: 18px; transition: transform var(--t-fast) var(--ease);
}
.appbar__back:active { transform: scale(.94); }
.appbar__title { font-family: var(--font-display); font-size: 16px; font-weight: 600; }
.appbar__spacer { flex: 1; }
.appbar__action { font-size: 13px; font-weight: 600; color: var(--gold-500); }

/* — الأزرار — */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; height: 54px; padding: 0 22px; border-radius: var(--r-md);
  font-family: var(--font-display); font-size: 16px; font-weight: 600;
  transition: transform var(--t-fast) var(--ease), background var(--t-fast), box-shadow var(--t-fast);
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.btn:active { transform: scale(.975); }
.btn--block { display: flex; width: 100%; }
.btn--gold {
  background: linear-gradient(180deg, var(--gold-400), var(--gold-500) 42%, var(--gold-600));
  color: #2A1C02; box-shadow: 0 6px 20px rgba(228,176,74,.28), inset 0 1px 0 rgba(255,255,255,.45);
}
.btn--mint { background: linear-gradient(180deg, var(--mint-400), var(--mint-500)); color: #04231A; }
.btn--ghost { background: var(--glass); border: 1px solid var(--line-strong); color: var(--text); }
.btn--quiet { background: transparent; color: var(--text-2); }
.btn--danger { background: rgba(226,74,92,.14); border: 1px solid rgba(255,107,122,.35); color: var(--coral-400); }
.btn--sm { height: 42px; font-size: 14px; border-radius: var(--r-sm); padding: 0 16px; }
.btn--lg { height: 58px; font-size: 17px; border-radius: var(--r-lg); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn__sub { font-family: var(--font-body); font-size: 12px; font-weight: 500; opacity: .72; }

/* — بطاقة — */
.card {
  background: var(--glass); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: var(--s-4);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.card--raised { background: var(--ink-700); border-color: var(--line-strong); box-shadow: var(--shadow-card); }
.card--gold { border-color: rgba(228,176,74,.34); background: linear-gradient(160deg, rgba(228,176,74,.14), rgba(228,176,74,.03)); }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-3); }
.row { display: flex; align-items: center; gap: var(--s-3); }
.row--between { justify-content: space-between; }
.col { display: flex; flex-direction: column; }
.gap-1 { gap: var(--s-1) } .gap-2 { gap: var(--s-2) } .gap-3 { gap: var(--s-3) }
.gap-4 { gap: var(--s-4) } .gap-5 { gap: var(--s-5) } .gap-6 { gap: var(--s-6) }
.mt-2 { margin-top: var(--s-2) } .mt-3 { margin-top: var(--s-3) }
.mt-4 { margin-top: var(--s-4) } .mt-5 { margin-top: var(--s-5) } .mt-6 { margin-top: var(--s-6) }
.spacer { flex: 1; }

/* — قطع الحروف — */
.tile {
  display: grid; place-items: center;
  width: 52px; height: 52px; border-radius: 13px;
  background: linear-gradient(180deg, #FBF3DF, var(--tile-bg));
  color: var(--tile-ink); font-family: var(--font-display);
  font-size: 26px; font-weight: 700; box-shadow: var(--tile-shadow);
  flex: none;
}
.tile--sm { width: 38px; height: 38px; font-size: 19px; border-radius: 10px; }
.tile--lg { width: 128px; height: 128px; font-size: 68px; border-radius: 26px;
  box-shadow: 0 4px 0 #A99878, 0 22px 50px rgba(0,0,0,.6); }
.tile--gold { background: linear-gradient(180deg, var(--gold-400), var(--gold-600)); color: #241703;
  box-shadow: 0 3px 0 #7E5A18, 0 14px 34px rgba(228,176,74,.32); }
.tile--flat { background: var(--ink-600); color: var(--text); box-shadow: none; border: 1px solid var(--line-strong); }
.tile--xs { width: 28px; height: 28px; font-size: 14px; border-radius: 8px; box-shadow: none; }

/* — شرائح الحالة — */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 26px; padding: 0 10px; border-radius: var(--r-full);
  font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--glass-2); color: var(--text-2);
}
.chip--mint { background: rgba(63,214,168,.14); color: var(--mint-400); box-shadow: inset 0 0 0 1px rgba(63,214,168,.26); }
.chip--gold { background: rgba(228,176,74,.14); color: var(--gold-400); box-shadow: inset 0 0 0 1px rgba(228,176,74,.3); }
.chip--coral { background: rgba(255,107,122,.13); color: var(--coral-400); box-shadow: inset 0 0 0 1px rgba(255,107,122,.26); }
.chip--sky { background: rgba(90,169,255,.13); color: var(--sky-400); box-shadow: inset 0 0 0 1px rgba(90,169,255,.26); }
.chip--dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* — الأفاتار — */
.avatar {
  position: relative; width: 44px; height: 44px; border-radius: 15px;
  display: grid; place-items: center; flex: none;
  font-family: var(--font-display); font-size: 17px; font-weight: 700; color: #0C1220;
  background: linear-gradient(160deg, #F3CE7E, #C89B3E);
}
.avatar--lg { width: 76px; height: 76px; border-radius: 24px; font-size: 30px; }
.avatar--sm { width: 34px; height: 34px; border-radius: 11px; font-size: 14px; }
.avatar--mint { background: linear-gradient(160deg, #6FE7C0, #24B98C); }
.avatar--sky { background: linear-gradient(160deg, #8CC6FF, #4C8FE0); }
.avatar--violet { background: linear-gradient(160deg, #C3AEFF, #8A6BE0); }
.avatar--coral { background: linear-gradient(160deg, #FFA0AA, #E2566A); }
.avatar--dim { background: linear-gradient(160deg, #3A445A, #262F42); color: var(--text-muted); }
.avatar__crown {
  position: absolute; top: -9px; inset-inline-start: -6px; font-size: 15px;
  color: var(--gold-400); filter: drop-shadow(0 2px 4px rgba(0,0,0,.6));
}
.avatar__badge {
  position: absolute; bottom: -3px; inset-inline-end: -3px;
  width: 15px; height: 15px; border-radius: 50%; background: var(--mint-400);
  border: 2.5px solid var(--ink-900);
}

/* — صفوف القوائم — */
.listrow {
  display: flex; align-items: center; gap: var(--s-3);
  padding: 14px 16px; border-radius: var(--r-md);
  background: var(--glass); border: 1px solid var(--line);
  transition: background var(--t-fast), transform var(--t-fast);
  width: 100%; text-align: start;
}
.listrow:active { background: var(--glass-2); transform: scale(.99); }
.listrow__text { flex: 1; min-width: 0; }
.listrow__title { font-size: 14.5px; font-weight: 600; }
.listrow__sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.listrow__icon {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center;
  background: var(--glass-2); color: var(--gold-400); font-size: 18px; flex: none;
}

/* — شريط التبويب السفلي — */
.tabbar {
  position: absolute; inset-inline: 0; bottom: 0; z-index: 20;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: flex; align-items: center; justify-content: space-around;
  background: linear-gradient(180deg, rgba(10,16,28,.72), rgba(7,11,20,.96));
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--line);
}
.tabbar[hidden] { display: none; }
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  height: 100%; justify-content: center; color: var(--text-muted);
  font-size: 10.5px; font-weight: 500; transition: color var(--t-fast);
}
.tab i { font-size: 21px; }
.tab.is-on { color: var(--gold-500); }
.tab.is-on i { stroke-width: 2.1; }

/* — الحقول — */
.field { display: flex; flex-direction: column; gap: 7px; }
.field__label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.input {
  height: 52px; width: 100%; border-radius: var(--r-md);
  background: var(--ink-800); border: 1px solid var(--line-strong);
  padding: 0 16px; font-size: 15px; color: var(--text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.input::placeholder { color: #5C6579; }
.input:focus { outline: none; border-color: rgba(228,176,74,.6); box-shadow: 0 0 0 4px rgba(228,176,74,.12); }
.input--center { text-align: center; }
.field__hint { font-size: 11.5px; color: var(--text-muted); }
.field__hint--error { color: var(--coral-400); }

/* — مقبض الاختيار — */
.segmented { display: flex; gap: 6px; padding: 5px; background: var(--ink-800);
  border: 1px solid var(--line); border-radius: var(--r-md); }
.segmented button {
  flex: 1; height: 40px; border-radius: 11px; font-size: 13.5px; font-weight: 600;
  color: var(--text-muted); transition: all var(--t-fast) var(--ease);
}
.segmented button.is-on { background: var(--gold-500); color: var(--ink-900); }

/* — منتقي الحروف — */
.letter-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 9px; }
.letter-grid button {
  aspect-ratio: 1; border-radius: 14px; background: var(--ink-700);
  border: 1px solid var(--line); color: var(--text);
  font-family: var(--font-display); font-size: 23px; font-weight: 600;
  transition: all var(--t-fast) var(--ease);
}
.letter-grid button:active { transform: scale(.94); }
.letter-grid button.is-on {
  background: linear-gradient(180deg, var(--gold-400), var(--gold-600));
  color: #241703; border-color: transparent; box-shadow: 0 10px 26px rgba(228,176,74,.3);
}

/* — لوحة الأرقام/الحروف لكود الدعوة — */
.code-boxes { display: flex; gap: 7px; justify-content: center; direction: ltr; width: 100%; max-width: 330px; margin: 0 auto; }
.code-box {
  flex: 1; min-width: 0; max-width: 50px; height: 58px; border-radius: 13px;
  background: var(--ink-800); border: 1.5px solid var(--line-strong);
  display: grid; place-items: center;
  font-family: var(--font-display); font-size: 24px; font-weight: 700;
  color: var(--text); transition: all var(--t-fast);
}
.code-box.is-focus { border-color: var(--gold-500); box-shadow: 0 0 0 4px rgba(228,176,74,.14); }
.code-box.is-filled { background: rgba(228,176,74,.1); border-color: rgba(228,176,74,.4); color: var(--gold-400); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; direction: ltr; }
.keypad button {
  height: 50px; border-radius: 13px; background: var(--glass);
  border: 1px solid var(--line); font-family: var(--font-display);
  font-size: 20px; font-weight: 600; color: var(--text);
  transition: background var(--t-fast), transform var(--t-fast);
}
.keypad button:active { background: var(--glass-2); transform: scale(.96); }
.keypad button.key-fn { background: transparent; border-color: transparent; font-size: 16px; color: var(--text-muted); }

/* — المؤقّت الدائري — */
.timer { position: relative; width: 46px; height: 46px; display: grid; place-items: center; }
.timer svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.timer__track { stroke: rgba(255,255,255,.1); }
.timer__bar { stroke: var(--gold-500); stroke-linecap: round; transition: stroke-dashoffset .9s linear, stroke .3s; }
.timer__num { font-family: var(--font-display); font-size: 15px; font-weight: 700; }
.timer--warn .timer__bar { stroke: var(--coral-400); }
.timer--warn .timer__num { color: var(--coral-400); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .45 } }

/* — ألواح سفلية (Sheets) ومودالات — */
.sheetRoot { position: absolute; inset: 0; z-index: 60; pointer-events: none; }
.sheetRoot.is-open { pointer-events: auto; }
.scrim {
  position: absolute; inset: 0; background: rgba(3,6,11,.66);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  animation: fadeIn var(--t-fast) var(--ease) both;
}
.sheet {
  position: absolute; inset-inline: 0; bottom: 0;
  background: var(--ink-800); border-top: 1px solid var(--line-strong);
  border-radius: 26px 26px 0 0; padding: 10px 20px calc(22px + var(--safe-bottom));
  box-shadow: 0 -20px 60px rgba(0,0,0,.6);
  animation: sheetUp var(--t-base) var(--ease) both;
}
.sheet__grip { width: 40px; height: 4px; border-radius: 9px; background: var(--line-strong); margin: 0 auto 16px; }
.modal {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
  width: calc(100% - 56px); background: var(--ink-700); border: 1px solid var(--line-strong);
  border-radius: var(--r-xl); padding: 22px; box-shadow: var(--shadow-float);
  animation: popIn var(--t-base) var(--ease) both;
}
@keyframes fadeIn { from { opacity: 0 } }
@keyframes sheetUp { from { transform: translateY(100%) } }
@keyframes popIn { from { opacity: 0; transform: translate(-50%,-46%) scale(.94) } }

/* — تنبيه عائم — */
.toastRoot {
  position: absolute; inset-inline: 0; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 14px);
  z-index: 70; display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--ink-600); border: 1px solid var(--line-strong);
  color: var(--text); font-size: 13px; font-weight: 600;
  padding: 11px 18px; border-radius: var(--r-full);
  box-shadow: var(--shadow-card); animation: popIn 220ms var(--ease) both;
  display: flex; align-items: center; gap: 8px;
}
.toast--mint { border-color: rgba(63,214,168,.4); color: var(--mint-400); }
.toast--coral { border-color: rgba(255,107,122,.4); color: var(--coral-400); }

/* — شريط انقطاع الشبكة — */
.offline {
  display: flex; align-items: center; gap: 8px;
  margin: 0 20px 10px; padding: 9px 14px; border-radius: var(--r-sm);
  background: rgba(255,107,122,.1); border: 1px solid rgba(255,107,122,.28);
  color: var(--coral-400); font-size: 12px; font-weight: 600;
}

/* — عناصر إحصاء — */
.stat { display: flex; flex-direction: column; gap: 3px; align-items: center; flex: 1; }
.stat__num { font-family: var(--font-display); font-size: 20px; font-weight: 700; }
.stat__label { font-size: 11px; color: var(--text-muted); }
.divider { height: 1px; background: var(--line); margin: var(--s-4) 0; }
.divider--v { width: 1px; height: 28px; background: var(--line); }
