/* ════════════════════════════════════════════════════════════════
   لوحة الطلاب العائمة — js/quick-panel.js
   ════════════════════════════════════════════════════════════════ */

#qpRoot { font-family: var(--font); }

/* ── الزرّ العائم ───────────────────────────────────────────── */
.qp-fab {
  position: fixed; z-index: 9000; width: 60px; height: 60px; border-radius: 50%;
  display: grid; place-items: center; border: 3px solid #fff; cursor: grab;
  background: var(--grad, linear-gradient(135deg, #013f31, #005b45));
  color: #fff; box-shadow: 0 8px 22px rgba(0, 40, 30, .32);
  touch-action: none; user-select: none;
  transition: transform .18s, box-shadow .18s;
}
.qp-fab:hover { transform: scale(1.06); }
.qp-fab.dragging { cursor: grabbing; transform: scale(1.12); transition: none; }
.qp-fab.qp-hide { display: none; }
/* أثناء اللعب — تعود في شاشة إعداد اللعبة */
#qpRoot.qp-game .qp-fab, #qpRoot.qp-game .qp-panel { display: none; }
.qp-fab.active { box-shadow: 0 0 0 5px rgba(0, 91, 69, .25), 0 8px 22px rgba(0, 40, 30, .32); }

/* ── اللوحة ──────────────────────────────────────────────────── */
.qp-panel {
  position: fixed; z-index: 8999; top: 0; bottom: 0; right: 0;
  width: min(400px, 100vw); display: flex; flex-direction: column;
  background: var(--canvas, var(--surface)); color: var(--ink);
  border-inline-start: 1px solid var(--line, var(--border));
  box-shadow: -14px 0 40px rgba(0, 0, 0, .14);
  transform: translateX(105%); transition: transform .26s cubic-bezier(.2, .8, .2, 1);
  visibility: hidden;
}
.qp-panel.qp-left { right: auto; left: 0; transform: translateX(-105%);
  box-shadow: 14px 0 40px rgba(0, 0, 0, .14); }
.qp-panel.open { transform: none; visibility: visible; }

.qp-head { padding: 14px 14px 10px; display: flex; flex-direction: column; gap: 10px;
  background: var(--surface); border-bottom: 1px solid var(--line, var(--border)); }
.qp-title { display: flex; align-items: center; gap: 8px; font-size: 1.05rem; }
.qp-title .spacer { flex: 1; }
.qp-logo { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center;
  background: var(--brand-50, var(--ok-bg)); color: var(--brand-500, var(--ok)); }
.qp-icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  background: transparent; border: 0; color: var(--ink-muted); cursor: pointer; }
.qp-icon:hover { background: var(--surface-2); color: var(--ink); }

.qp-room, .qp-search input, .qp-set input {
  font: inherit; color: var(--ink); background: var(--field, var(--surface-2));
  border: 1.5px solid var(--line, var(--border)); border-radius: 12px;
}
.qp-room { height: 42px; padding: 0 12px; font-weight: 700; }

.qp-tally { display: flex; flex-wrap: wrap; gap: 6px; }
.qp-tally:empty { display: none; }
.qp-chip { font-size: .8rem; padding: 3px 10px; border-radius: 999px;
  border: 1px solid var(--line, var(--border)); color: var(--ink-muted); }
.qp-chip b { color: var(--ink); }
.qp-chip.ok   { background: var(--ok-bg);     border-color: transparent; color: var(--ok); }
.qp-chip.bad  { background: var(--danger-bg); border-color: transparent; color: var(--danger); }
.qp-chip.warn { background: var(--warn-bg);   border-color: transparent; color: var(--warn); }
.qp-chip.ok b, .qp-chip.bad b, .qp-chip.warn b { color: inherit; }

.qp-tools { display: flex; gap: 8px; }
.qp-search { flex: 1; position: relative; display: flex; align-items: center; }
.qp-search svg { position: absolute; inset-inline-start: 11px; color: var(--ink-faint); pointer-events: none; }
.qp-search input { width: 100%; height: 40px; padding-inline: 34px 10px; }
.qp-allp { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
  font: inherit; font-size: .85rem; font-weight: 700; padding: 0 12px; height: 40px;
  border-radius: 12px; cursor: pointer; color: var(--brand-500, var(--ok));
  background: var(--surface); border: 1.5px solid var(--brand-500, var(--ok)); }
.qp-allp:hover { background: var(--brand-50, var(--ok-bg)); }

.qp-settings { background: var(--surface-2); border-radius: 12px; padding: 10px; }
.qp-set-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.qp-set { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: .85rem; }
.qp-set input { width: 58px; height: 34px; text-align: center; }

/* ── القائمة ─────────────────────────────────────────────────── */
.qp-list { flex: 1; overflow-y: auto; padding: 10px 12px 80px; display: flex; flex-direction: column; gap: 8px;
  overscroll-behavior: contain; }
.qp-muted { color: var(--ink-faint); font-size: .85rem; text-align: center; margin: 14px 0; }
.qp-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 40px 10px;
  color: var(--ink-faint); text-align: center; }
.qp-empty b { color: var(--ink); }

.qp-card { position: relative; background: var(--surface); border: 1px solid var(--line, var(--border));
  border-radius: 16px; padding: 10px 12px; }
.qp-card.off { background: var(--surface-2); }
.qp-card.off .qp-name { color: var(--ink-muted); }
.qp-row { display: flex; align-items: center; gap: 8px; }
.qp-name { flex: 1; font-size: .98rem; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qp-net { font-weight: 800; font-size: .85rem; min-width: 26px; text-align: center; font-variant-numeric: tabular-nums; }
.qp-net.pos { color: var(--ok); }
.qp-net.neg { color: var(--danger); }

.qp-st { display: inline-flex; align-items: center; gap: 4px; font: inherit; font-size: .8rem; font-weight: 700;
  height: 30px; min-width: 78px; justify-content: center; padding: 0 10px; border-radius: 999px; cursor: pointer;
  border: 1.5px solid transparent; }
.qp-st[data-st="present"] { background: var(--ok-bg);     color: var(--ok); }
.qp-st[data-st="absent"]  { background: var(--danger-bg); color: var(--danger); }
.qp-st[data-st="late"]    { background: var(--warn-bg);   color: var(--warn); }
.qp-st[data-st="excused"] { background: var(--surface-3, var(--surface-2)); color: var(--ink-soft);
  border-color: var(--line, var(--border)); }

.qp-acts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 8px; }
.qp-act { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  height: 46px; border-radius: 12px; cursor: pointer; font: inherit; font-size: .7rem; font-weight: 700;
  border: 1.5px solid transparent; transition: transform .08s, filter .15s; touch-action: manipulation;
  -webkit-user-select: none; user-select: none; }
.qp-act:active { transform: scale(.93); }
.qp-act:disabled { opacity: .32; cursor: not-allowed; transform: none; }
.qp-plus  { background: #e7f6ec; color: #15803d; }
.qp-minus { background: #fde8e8; color: #b91c1c; }
.qp-warn  { background: #fdf0d5; color: #a1620a; }
.qp-star  { background: #fbf3dc; color: #a37812; }
.qp-act:not(:disabled):hover { filter: brightness(.96); border-color: currentColor; }
[data-theme="dark"] .qp-plus  { background: #0d2b1a; color: #4ade80; }
[data-theme="dark"] .qp-minus { background: #2f1212; color: #f87171; }
[data-theme="dark"] .qp-warn  { background: #2e2008; color: #fbbf24; }
[data-theme="dark"] .qp-star  { background: #2c2510; color: #f0cf6b; }

/* الرقم الطائر بعد كل ضغطة */
.qp-float { position: absolute; top: 4px; inset-inline-start: 50%; font-weight: 900; font-size: 1.15rem;
  pointer-events: none; animation: qpFloat .9s ease-out forwards; }
.qp-float.pos { color: var(--ok); }
.qp-float.neg { color: var(--danger); }
@keyframes qpFloat { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-26px); } }

/* ── قائمة الشارات ───────────────────────────────────────────── */
.qp-picker { margin-top: 8px; padding: 8px; border-radius: 12px; background: var(--surface-2); }
.qp-picker-head { display: flex; align-items: center; justify-content: space-between; font-size: .85rem; }
.qp-picker-head .qp-icon { width: 30px; height: 30px; }
.qp-picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; margin-top: 6px; }
.qp-pick { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px; cursor: pointer;
  font: inherit; font-size: .75rem; font-weight: 700; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line, var(--border)); border-radius: 10px; }
.qp-pick:hover { border-color: var(--brand-500, var(--ok)); }
.qp-coin { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  color: #fff; background: var(--c); }

/* ── شريط التراجع ───────────────────────────────────────────── */
.qp-undo { position: absolute; bottom: 14px; inset-inline: 14px; display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 14px; background: #1f2a30; color: #fff; font-size: .88rem;
  box-shadow: 0 10px 24px rgba(0, 0, 0, .25); animation: qpUp .2s ease-out; }
.qp-undo[hidden] { display: none; }
.qp-undo span { flex: 1; }
.qp-undo.danger { background: #8f1d1d; }
.qp-undo button { font: inherit; font-weight: 800; color: #9fe3c6; background: none; border: 0; cursor: pointer;
  padding: 4px 8px; border-radius: 8px; }
.qp-undo button:hover { background: rgba(255, 255, 255, .1); }
@keyframes qpUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ── النافذة المستقلّة (فوق كل البرامج) ─────────────────────── */
#qpRoot.qp-pipped .qp-fab { display: none; }
.qp-pip-body { margin: 0; height: 100vh; overflow: hidden; background: var(--canvas, var(--surface)); }
.qp-panel.qp-pip { position: relative; inset: auto; width: 100%; height: 100vh; transform: none;
  visibility: visible; transition: none; box-shadow: none; border: 0; }
.qp-panel.qp-pip .qp-pipbtn { display: none; }
.qp-foldbtn { display: none; }
.qp-panel.qp-pip .qp-foldbtn { display: grid; }

/* مطويّة: أيقونة خضراء بشكل الزرّ داخل الموقع، وضغطها يعيد اللوحة */
.qp-mini { display: none; }
/* بلاطة خضراء تملأ النافذة كلّها — المتصفح لا يسمح بنافذة دائريّة */
.qp-pip-body.qp-folded { display: block; background: #005b45; }
.qp-pip-body.qp-folded .qp-panel { display: none; }
.qp-pip-body.qp-folded .qp-mini {
  display: grid; place-items: center; position: static; cursor: pointer;
  width: 100vw; height: 100vh; border: 0; border-radius: 0; box-shadow: none;
  background: var(--grad, linear-gradient(135deg, #013f31, #005b45 55%, #1a6b58));
  transform: none; transition: filter .15s;
}
.qp-pip-body.qp-folded .qp-mini:hover { transform: none; filter: brightness(1.12); }
.qp-pip-body.qp-folded .qp-mini svg { width: min(40vw, 55vh, 50px); height: auto; }

@media print { #qpRoot { display: none !important; } }
