/* ===== الأزرار ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 46px; padding: 0 var(--s5);
  border-radius: var(--r-md); font-weight: 600; font-size: var(--fs-md);
  transition: transform 0.15s var(--ease), background 0.2s, border-color 0.2s, opacity 0.2s;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; pointer-events: none; }
.btn-primary { background: var(--crimson); color: #fff; box-shadow: var(--glow); }
.btn-primary:hover { background: #F21A4A; }
.btn-ghost { border: 1px solid var(--line); background: var(--ink-2); }
.btn-ghost:hover { border-color: var(--fog-2); }
.btn-outline { border: 1px solid var(--crimson); color: var(--crimson); }
.btn-outline:hover { background: var(--crimson-wash); }
.btn-success { background: var(--ok); color: #fff; }
.btn-danger { background: var(--bad-wash); color: var(--bad); border: 1px solid rgba(240, 71, 94, 0.35); }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 0 var(--s3); font-size: var(--fs-sm); border-radius: var(--r-sm); }
.btn-icon { width: 42px; min-height: 42px; padding: 0; border-radius: var(--r-md); }
.btn .spin { display: none; }
.btn.loading .spin { display: block; }
.btn.loading .label { opacity: 0.6; }

.spin { width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.25); border-top-color: currentColor; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== الحقول ===== */
.field { display: grid; gap: 6px; }
.field > label, .label-text { font-size: var(--fs-sm); color: var(--fog); font-weight: 500; }
.input, .select, .textarea {
  width: 100%; min-height: 48px; padding: 0 var(--s4);
  background: var(--ink); border: 1px solid var(--line); border-radius: var(--r-md);
  color: var(--paper); outline: none; transition: border-color 0.2s, box-shadow 0.2s;
}
.textarea { padding: var(--s3) var(--s4); min-height: 96px; resize: vertical; line-height: 1.6; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--crimson); box-shadow: 0 0 0 3px var(--crimson-wash); }
.input::placeholder, .textarea::placeholder { color: var(--fog-2); }
.input.ltr { text-align: left; }
.input-wrap { position: relative; }
.input-wrap > .icon { position: absolute; top: 50%; inset-inline-start: 14px; transform: translateY(-50%); color: var(--fog-2); pointer-events: none; }
.input-wrap > .input { padding-inline-start: 44px; }
.input-wrap > .trail { position: absolute; top: 50%; inset-inline-end: 6px; transform: translateY(-50%); }
.hint { font-size: var(--fs-xs); color: var(--fog); }
.hint.err { color: var(--bad); }

/* ===== الشارات ===== */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; }
.badge.ok { background: var(--ok-wash); color: var(--ok); }
.badge.wait { background: var(--wait-wash); color: var(--wait); }
.badge.bad { background: var(--bad-wash); color: var(--bad); }
.badge.neutral { background: var(--ink-3); color: var(--fog); }
.badge.red { background: var(--crimson); color: #fff; }

/* ===== الأسطح ===== */
.panel { background: var(--ink-2); border: 1px solid var(--line-soft); border-radius: var(--r-lg); padding: var(--s5); }
.panel-title { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s4); }
.panel-title h2, .panel-title h3 { font-size: var(--fs-lg); }

.row { display: flex; align-items: center; gap: var(--s3); }
.row.between { justify-content: space-between; }
.stack { display: grid; gap: var(--s3); }
.stack-lg { display: grid; gap: var(--s5); }
.divider { height: 1px; background: var(--line-soft); margin: var(--s4) 0; }

/* ===== التبويبات المقسمة ===== */
.segmented { display: flex; gap: 4px; padding: 4px; background: var(--ink-2); border: 1px solid var(--line-soft); border-radius: var(--r-md); overflow-x: auto; scrollbar-width: none; }
.segmented::-webkit-scrollbar { display: none; }
.segmented button { flex: 1 0 auto; padding: 9px 14px; border-radius: 9px; color: var(--fog); font-size: var(--fs-sm); font-weight: 600; }
.segmented button.active { background: var(--crimson); color: #fff; }

.chips { display: flex; flex-wrap: wrap; gap: var(--s2); }
.chip { padding: 9px 16px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--ink); font-weight: 600; font-size: var(--fs-sm); transition: border-color 0.15s; }
.chip.active { border-color: var(--crimson); color: var(--paper); box-shadow: inset 0 0 0 1px var(--crimson); background: var(--crimson-wash); }
.chip:disabled { opacity: 0.4; }

/* ===== العداد ===== */
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; background: var(--ink); }
.stepper button { width: 38px; height: 38px; display: grid; place-items: center; color: var(--fog); }
.stepper button:hover { color: var(--paper); background: var(--ink-3); }
.stepper input { width: 56px; text-align: center; background: none; border: 0; outline: none; font-weight: 700; direction: ltr; -moz-appearance: textfield; }
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }

/* ===== النافذة المنبثقة (Sheet) ===== */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(5, 5, 7, 0.72); backdrop-filter: blur(6px); z-index: 900; display: flex; align-items: flex-end; justify-content: center; animation: fade 0.2s var(--ease); }
.sheet {
  width: min(560px, 100%); max-height: 92dvh; overflow-y: auto;
  background: var(--ink-2); border: 1px solid var(--line); border-bottom: 0;
  border-radius: 22px 22px 0 0; padding: var(--s5) var(--s5) calc(var(--s6) + env(safe-area-inset-bottom));
  animation: rise 0.28s var(--ease);
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s4); }
.sheet-head h3 { font-size: var(--fs-lg); }
.sheet-grip { width: 42px; height: 4px; border-radius: 4px; background: var(--line); margin: -6px auto var(--s4); }
@media (min-width: 720px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 22px; border-bottom: 1px solid var(--line); }
  .sheet-grip { display: none; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }

/* ===== التنبيهات ===== */
.toasts { position: fixed; top: calc(var(--s3) + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 2000; display: grid; gap: var(--s2); width: min(420px, calc(100% - 24px)); pointer-events: none; }
.toast { display: flex; align-items: center; gap: var(--s3); padding: 12px 16px; border-radius: var(--r-md); background: var(--ink-3); border: 1px solid var(--line); box-shadow: var(--shadow-lift); font-weight: 500; font-size: var(--fs-sm); animation: drop 0.25s var(--ease); pointer-events: auto; }
.toast.ok { border-color: rgba(25, 176, 122, 0.45); }
.toast.ok .icon { color: var(--ok); }
.toast.err { border-color: rgba(240, 71, 94, 0.5); }
.toast.err .icon { color: var(--bad); }
.toast.out { opacity: 0; transform: translateY(-8px); transition: 0.25s; }
@keyframes drop { from { transform: translateY(-12px); opacity: 0; } }

/* ===== الهياكل أثناء التحميل ===== */
.skel { background: linear-gradient(90deg, var(--ink-2) 0%, var(--ink-3) 50%, var(--ink-2) 100%); background-size: 200% 100%; animation: shimmer 1.3s infinite linear; border-radius: var(--r-md); }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ===== الحالة الفارغة ===== */
.empty { text-align: center; padding: var(--s10) var(--s5); color: var(--fog); display: grid; justify-items: center; gap: var(--s3); }
.empty .icon { width: 40px; height: 40px; color: var(--fog-2); }
.empty h3 { color: var(--paper); font-size: var(--fs-lg); }

/* ===== كرت المنتج: شكل بطاقة هدية بثقوب جانبية ===== */
.ticket {
  position: relative; display: flex; flex-direction: column;
  background: var(--ink-2); border: 1px solid var(--line-soft); border-radius: var(--r-lg);
  overflow: hidden; transition: border-color 0.2s, transform 0.2s var(--ease);
}
.ticket:hover { border-color: var(--line); transform: translateY(-2px); }
.ticket-art { position: relative; aspect-ratio: 4 / 3; background: radial-gradient(120% 90% at 80% 0%, #24161B 0%, var(--ink-3) 55%); display: grid; place-items: center; overflow: hidden; }
.ticket-art img { width: 100%; height: 100%; object-fit: cover; }
.ticket-art .fallback { font-family: var(--font-display); font-size: var(--fs-2xl); color: var(--fog-2); }
.ticket-perf { position: relative; height: 0; border-top: 1.5px dashed var(--line); margin: 0 14px; }
.ticket-perf::before, .ticket-perf::after { content: ''; position: absolute; top: -9px; width: 18px; height: 18px; border-radius: 50%; background: var(--ink); border: 1px solid var(--line-soft); }
.ticket-perf::before { right: -24px; }
.ticket-perf::after { left: -24px; }
.ticket-body { padding: 12px 14px 14px; display: grid; gap: 6px; flex: 1; }
.ticket-name { font-weight: 600; font-size: var(--fs-sm); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.9em; }
.ticket-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s2); margin-top: auto; }
.price { font-family: var(--font-display); font-weight: 700; font-size: var(--fs-lg); line-height: 1.1; }
.price small { font-family: var(--font-body); font-size: var(--fs-xs); color: var(--fog); font-weight: 500; margin-inline-start: 3px; }
.price-old { font-size: var(--fs-xs); color: var(--fog-2); text-decoration: line-through; }
.ticket-add { width: 36px; height: 36px; border-radius: 10px; background: var(--crimson); color: #fff; display: grid; place-items: center; flex: none; }
.ticket-add:active { transform: scale(0.92); }
.ticket .off { position: absolute; top: 10px; inset-inline-start: 10px; z-index: 1; }

/* ===== صندوق النسخ ===== */
.code-box { background: var(--ink); border: 1px dashed var(--line); border-radius: var(--r-md); padding: var(--s3) var(--s4); display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s3); }
.code-box pre { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: var(--fs-sm); white-space: pre-wrap; word-break: break-all; direction: ltr; text-align: left; flex: 1; color: var(--paper); }

/* ===== صف قائمة ===== */
.list { display: grid; }
.list-row { display: flex; align-items: center; gap: var(--s3); padding: 14px 0; border-bottom: 1px solid var(--line-soft); }
.list-row:last-child { border-bottom: 0; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .title { font-weight: 600; font-size: var(--fs-md); }
.list-row .sub { font-size: var(--fs-xs); color: var(--fog); }
.thumb { width: 48px; height: 48px; border-radius: 12px; object-fit: cover; background: var(--ink-3); flex: none; }

.banner { display: flex; align-items: center; gap: var(--s3); padding: 12px 16px; border-radius: var(--r-md); font-size: var(--fs-sm); }
.banner.warn { background: var(--wait-wash); color: #F5C77E; border: 1px solid rgba(232, 162, 58, 0.3); }
.banner.info { background: var(--ink-2); border: 1px solid var(--line); }
.banner.danger { background: var(--crimson); color: #fff; justify-content: center; font-weight: 600; border-radius: 0; }

/* مفتاح تشغيل */
.switch { position: relative; display: inline-block; vertical-align: middle; width: 46px; height: 26px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 26px; background: var(--ink-3); border: 1px solid var(--line); transition: 0.2s; }
.switch span::after { content: ''; position: absolute; top: 3px; right: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--fog); transition: 0.2s var(--ease); }
.switch input:checked + span { background: var(--crimson); border-color: var(--crimson); }
.switch input:checked + span::after { transform: translateX(-20px); background: #fff; }
.switch input:focus-visible + span { outline: 2px solid var(--crimson); outline-offset: 2px; }
.grow { flex: 1; min-width: 0; }

/* ===== كود التحقق ===== */
.otp { display: flex; justify-content: center; gap: 8px; }
.otp input { width: 46px; height: 56px; text-align: center; font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; background: var(--ink); border: 1px solid var(--line); border-radius: var(--r-md); color: var(--paper); outline: none; transition: border-color 0.2s, box-shadow 0.2s; }
.otp input:focus { border-color: var(--crimson); box-shadow: 0 0 0 3px var(--crimson-wash); }
@media (max-width: 360px) { .otp { gap: 5px; } .otp input { width: 40px; height: 50px; } }
