/* سداد — واجهة تطبيق موبايل أولاً، RTL */

/* خط Cairo — مستضاف ذاتياً (متغيّر الوزن 400–800) */
@font-face {
  font-family: 'Cairo';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('fonts/cairo-arabic.woff2') format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+08E3-08FF, U+200C-200E, U+2010-2011, U+FB50-FDFF, U+FE70-FEFC;
}
@font-face {
  font-family: 'Cairo';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('fonts/cairo-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122, U+FEFF, U+FFFD;
}

:root {
  --primary: #0F766E; --primary-d: #0b5c55;
  --ink: #111827; --muted: #6B7280; --line: #E5E7EB; --bg: #F3F4F6;
  --green: #12b76a; --green-bg: #ecfdf3; --red: #f04438; --red-bg: #fef3f2;
  --amber: #f79009; --amber-bg: #fffaeb;
  --radius: 14px; --nav-h: 64px; --top-h: 56px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 16px; line-height: 1.6;
  font-feature-settings: 'kern';
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-family: inherit; }

/* أيقونات SVG */
.ic { width: 1.25em; height: 1.25em; vertical-align: -0.25em; fill: none;
  stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.ic-lg { width: 1.5em; height: 1.5em; }

/* شريط علوي */
.app-top {
  position: sticky; top: 0; z-index: 20; height: var(--top-h);
  background: var(--primary); color: #fff; display: flex; align-items: center;
  justify-content: space-between; padding: 0 16px; padding-top: env(safe-area-inset-top);
}
.app-top-title { font-size: 1.15rem; font-weight: 700; }
.app-top-academy { font-size: .8rem; opacity: .85; }

/* المحتوى */
.app-main { padding: 12px 12px calc(var(--nav-h) + 20px); max-width: 640px; margin: 0 auto; }

/* شريط سفلي */
.app-nav {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 30; height: var(--nav-h);
  background: #fff; border-top: 1px solid var(--line); display: flex;
  padding-bottom: env(safe-area-inset-bottom);
}
.app-nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; text-decoration: none; color: var(--muted); font-size: .72rem; min-height: 44px;
}
.app-nav-item.on { color: var(--primary); font-weight: 700; }
.app-nav-icon { font-size: 1.3rem; }

/* شريط الشهر */
.month-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.mb-nav {
  width: 48px; height: 48px; display: flex; align-items: center; justify-content: center;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; font-size: 1.6rem;
  color: var(--primary); text-decoration: none; font-weight: 700;
}
.mb-center { flex: 1; text-align: center; position: relative; }
.mb-month { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }
.mb-label { font-size: 1.2rem; font-weight: 800; padding: 12px; background: #fff;
  border: 1px solid var(--line); border-radius: 12px; }

/* منتقي المجموعة */
.group-picker { margin-bottom: 12px; }
.group-select, .field, select.field, input.field, textarea.field {
  width: 100%; padding: 13px 14px; border: 1px solid var(--line); border-radius: 12px;
  font-size: 1.05rem; font-family: inherit; background: #fff; min-height: 50px;
}
.group-select { font-weight: 700; }

/* ملخص الدفع */
.paid-summary { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.ps-count { font-size: 1rem; font-weight: 700; white-space: nowrap; }
.ps-paid { color: var(--green); font-size: 1.2rem; }
.ps-search { flex: 1; padding: 11px 14px; border: 1px solid var(--line); border-radius: 12px; font-size: 1rem; min-height: 46px; }
.ps-partial { display: inline-block; margin-inline-start: 8px; font-size: .78rem; font-weight: 700;
  padding: 2px 8px; border-radius: 999px; background: #FEF3C7; color: #B45309; vertical-align: middle; }
.ps-partial[hidden] { display: none; }

/* قائمة الطلاب */
.player-list { display: flex; flex-direction: column; gap: 8px; }
.player-card {
  display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 10px;
  padding: 12px; background: #fff; border: 1px solid var(--line);
  border-inline-start: 4px solid var(--red); border-radius: var(--radius);
}
.player-card.paid { border-inline-start-color: var(--green); background: var(--green-bg); }
.player-card.partial { border-inline-start-color: #B45309; background: var(--amber-bg); }
.pc-toggle {
  width: 46px; height: 46px; border-radius: 50%; border: 2px solid var(--red);
  background: #fff; font-size: 1.5rem; color: var(--green); cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.player-card.paid .pc-toggle { border-color: var(--green); background: var(--green); color: #fff; }
.player-card.partial .pc-toggle { border-color: #B45309; background: #B45309; color: #fff; }
.pc-toggle:active { transform: scale(.9); }
.pc-body { min-width: 0; }
.pc-name { font-weight: 700; font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-sub, .pc-note-preview { font-size: .8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-note-preview { color: var(--amber); }
.pc-status { text-align: center; }
.pc-badge { font-size: .72rem; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--red-bg); color: #b42318; white-space: nowrap; }
.player-card.paid .pc-badge { background: #fff; color: #067647; }
.player-card.partial .pc-badge { background: #FEF3C7; color: #B45309; }
.pc-multi { display: block; font-size: .68rem; color: var(--muted); margin-top: 2px; }
.pc-note-btn { width: 44px; height: 44px; border: none; background: transparent; font-size: 1.3rem; cursor: pointer; border-radius: 10px; }
.pc-note-btn:active { background: var(--line); }

/* البطاقات العامة */
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.card-title { font-size: 1.05rem; font-weight: 800; margin-bottom: 12px; }
.card-title.mt { margin-top: 18px; }
.field { margin-bottom: 10px; }
.field-label { display: block; font-size: .85rem; font-weight: 600; color: var(--muted); margin: 6px 0 4px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hint { font-size: .78rem; color: var(--muted); margin: 2px 0 12px; }
.hint code { background: var(--bg); padding: 1px 5px; border-radius: 5px; }

/* أزرار */
.btn-primary, .btn-ghost, .btn-danger {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 14px 20px; border-radius: 12px; font-size: 1.05rem; font-weight: 700;
  cursor: pointer; text-decoration: none; border: none; min-height: 52px;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:active { background: var(--primary-d); }
.btn-primary:disabled { opacity: .5; }
.btn-ghost { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
.btn-danger { background: var(--red-bg); color: #b42318; }
.btn-block { width: 100%; margin-top: 6px; }
.btn-icon-danger { border: none; background: transparent; font-size: 1.3rem; cursor: pointer; padding: 8px; min-height: 44px; }

/* الشرائح */
.group-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip { padding: 9px 14px; border-radius: 999px; background: var(--bg); color: var(--ink);
  text-decoration: none; font-weight: 600; font-size: .9rem; border: 1px solid var(--line); min-height: 40px; display: inline-flex; align-items: center; gap: 6px; }
.chip.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.chip-count { background: rgba(0,0,0,.12); border-radius: 999px; padding: 0 7px; font-size: .78rem; }
.chip.on .chip-count { background: rgba(255,255,255,.25); }

/* عناصر الصفوف */
.row-item { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 4px; border-bottom: 1px solid var(--line); }
.row-item:last-child { border-bottom: none; }
.ri-name { font-weight: 600; }
.ri-sub { font-size: .8rem; color: var(--muted); }

.inline-add, .inline-filters { display: flex; gap: 8px; }
.inline-add .field, .inline-filters input, .inline-filters select { margin-bottom: 0; }
.inline-filters { margin-bottom: 12px; }

/* التذكيرات */
.reminder-count { font-size: 1.05rem; margin: 10px 0; text-align: center; }
.reminder-count b { font-size: 1.4rem; color: var(--red); }
.send-result { margin-top: 10px; text-align: center; font-weight: 600; }
.preview-list { margin-top: 12px; }
.preview-list summary { cursor: pointer; font-weight: 600; color: var(--primary); padding: 8px 0; }
.preview-list ul { margin: 6px 0; padding-inline-start: 20px; }
.preview-list li { padding: 3px 0; }
.muted { color: var(--muted); font-size: .85rem; }

/* مفتاح تبديل */
.switch { display: flex; align-items: center; gap: 10px; padding: 12px 0; cursor: pointer; }
.switch input { width: 22px; height: 22px; }

/* تنبيهات */
.toast-ok, .toast-err { padding: 12px 14px; border-radius: 12px; margin-bottom: 12px; font-weight: 600; }
.toast-ok { background: var(--green-bg); color: #067647; }
.toast-err { background: var(--red-bg); color: #b42318; }
.empty-state { text-align: center; padding: 30px 16px; color: var(--muted); }
.empty-state a { color: var(--primary); font-weight: 600; }

/* ورقة سفلية */
.sheet-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.4);
  display: flex; align-items: flex-end; }
.sheet-backdrop[hidden] { display: none; }
.sheet { background: #fff; width: 100%; border-radius: 20px 20px 0 0; padding: 18px;
  padding-bottom: calc(18px + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto;
  animation: sheetUp .2s ease; }
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sheet-title { font-size: 1.15rem; font-weight: 800; }
.sheet-close { border: none; background: var(--bg); width: 48px; height: 48px; border-radius: 50%; font-size: 1.1rem; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.sheet-label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.sheet-textarea { width: 100%; padding: 13px; border: 1px solid var(--line); border-radius: 12px; font-size: 1.05rem; font-family: inherit; resize: vertical; }
.sheet-marks { margin: 12px 0; font-size: .85rem; color: var(--muted); }
.sheet-marks .mk { padding: 5px 0; border-bottom: 1px dashed var(--line); }
.sheet-save { width: 100%; background: var(--primary); color: #fff; border: none; padding: 15px; border-radius: 12px; font-size: 1.05rem; font-weight: 700; cursor: pointer; margin-top: 8px; min-height: 52px; }

/* ورقة اختيار حالة الدفع */
.paysheet-btn { display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 56px; margin-bottom: 10px; border-radius: 14px;
  border: 2px solid var(--line); background: #fff; font-size: 1.1rem; font-weight: 800;
  cursor: pointer; color: var(--ink); }
.paysheet-btn:active { transform: scale(.98); }
.paysheet-btn.full { border-color: var(--green); color: #067647; background: var(--green-bg); }
.paysheet-btn.partial { border-color: #B45309; color: #B45309; background: #FEF3C7; }
.paysheet-btn.none { border-color: var(--line); color: var(--muted); background: var(--bg); }
.paysheet-btn.cur { outline: 3px solid var(--primary); outline-offset: 1px; }
.paysheet-partial-box { margin-top: 4px; }
.paysheet-partial-box[hidden] { display: none; }
.paysheet-input.input-err { border-color: var(--red); background: var(--red-bg); animation: shakeX .3s; }
@keyframes shakeX { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* لوحة المشغّل */
.op-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.op-stat { background: var(--bg); border-radius: 12px; padding: 14px; text-align: center;
  display: flex; flex-direction: column; }
.op-stat b { font-size: 1.4rem; }
.op-stat span { font-size: .75rem; color: var(--muted); margin-top: 3px; }

/* دخول */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; background: var(--primary); }
.login-card { background: #fff; border-radius: 20px; padding: 32px 24px; width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px; }
.login-logo { font-size: 3rem; text-align: center; }
.login-logo-img { display: block; margin: 0 auto; border-radius: 22px; }
.login-title { text-align: center; font-size: 1.3rem; margin: 0 0 8px; }
.login-card input { padding: 14px; border: 1px solid var(--line); border-radius: 12px; font-size: 1.05rem; min-height: 52px; }
.login-card button { background: var(--primary); color: #fff; border: none; padding: 15px; border-radius: 12px; font-size: 1.1rem; font-weight: 700; cursor: pointer; min-height: 54px; }
.login-err { background: var(--red-bg); color: #b42318; padding: 10px; border-radius: 10px; text-align: center; font-size: .9rem; }
