/* ═══════════════════════════════════════════════════════════════
   لوحة إدارة Khaled Games

   عربية من اليمين إلى اليسار، بهوية المنصة نفسها، وتعمل على
   الكمبيوتر والهاتف والآيباد. واضحة وغير مزدحمة.
   ═══════════════════════════════════════════════════════════════ */

@font-face {
  font-family: 'Tajawal';
  src: url('/assets/fonts/tajawal-arabic-500-normal.woff2') format('woff2');
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Tajawal';
  src: url('/assets/fonts/tajawal-arabic-700-normal.woff2') format('woff2');
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Tajawal';
  src: url('/assets/fonts/tajawal-arabic-800-normal.woff2') format('woff2');
  font-weight: 800; font-style: normal; font-display: swap;
}

:root {
  --navy-900: #070E22;
  --navy-800: #0B1430;
  --navy-700: #122145;
  --navy-600: #1B2E5C;

  --blue: #2E9BFF;
  --cyan: #6FE3FF;
  --gold: #FFD166;
  --gold-deep: #F2B420;
  --green: #5BD98A;
  --orange: #F0934E;

  --text: #EAF2FF;
  --text-soft: #A9BDDF;
  --line: rgba(111, 227, 255, 0.20);

  --font: 'Tajawal', 'Segoe UI', Tahoma, Arial, sans-serif;
  --radius: 16px;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; padding: 0; min-height: 100%; }

body {
  min-height: 100dvh;
  font-family: var(--font);
  font-weight: 500;
  color: var(--text);
  background:
    radial-gradient(110% 80% at 85% 5%, rgba(46, 155, 255, 0.16) 0%, transparent 58%),
    linear-gradient(170deg, var(--navy-800) 0%, var(--navy-900) 100%);
  background-attachment: fixed;
  overflow-x: hidden;
}

/* ═══════════ شاشة الدخول ═══════════ */

.gate {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 4vw, 40px);
}

.gate[hidden] { display: none; }

.gate-card {
  width: 100%;
  max-width: 400px;
  padding: clamp(20px, 4vw, 32px);
  border-radius: var(--radius);
  border: 1.5px solid var(--line);
  background: linear-gradient(150deg, rgba(27, 46, 92, 0.78), rgba(18, 33, 69, 0.68));
  text-align: center;
}

.gate-logo { width: 62px; height: auto; }

.gate-title {
  margin: 8px 0 2px;
  font-size: clamp(20px, 3.4vw, 26px);
  font-weight: 800;
}

.gate-sub {
  margin: 0 0 20px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--cyan);
}

.pane { display: flex; flex-direction: column; gap: 13px; text-align: start; }
.pane[hidden] { display: none; }

.pane-title {
  margin: 0;
  font-size: clamp(16px, 2.4vw, 19px);
  font-weight: 800;
  text-align: center;
}

.pane-text {
  margin: 0;
  font-size: 13px;
  line-height: 1.65;
  color: var(--text-soft);
  text-align: center;
}

/* ═══════════ الحقول ═══════════ */

.field { display: flex; flex-direction: column; gap: 6px; }

.field-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-soft);
}

.field input {
  width: 100%;
  min-height: 46px;
  padding: 0 13px;
  font-family: inherit;
  font-size: 15px;
  color: var(--text);
  background: rgba(7, 14, 34, 0.78);
  border: 2px solid rgba(111, 227, 255, 0.28);
  border-radius: 12px;
}

.field input:focus-visible {
  outline: none;
  border-color: var(--cyan);
}

.code-field {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 26px !important;
  font-weight: 700;
  letter-spacing: 0.35em;
  text-align: center;
}

/* إظهار وإخفاء كلمة المرور */
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-inline-start: 74px; }

.pw-toggle {
  position: absolute;
  inset-inline-start: 6px;
  top: 50%;
  transform: translateY(-50%);
  min-height: 34px;
  padding: 0 11px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  color: var(--cyan);
  background: rgba(111, 227, 255, 0.10);
  border: 1.5px solid rgba(111, 227, 255, 0.32);
  border-radius: 9px;
  cursor: pointer;
}

.pw-toggle:hover { background: rgba(111, 227, 255, 0.18); }

/* ═══════════ الأزرار ═══════════ */

.btn {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 18px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  border-radius: 12px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: filter 0.15s ease, background-color 0.15s ease, transform 0.08s ease;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: default; }

.btn:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 2px;
}

.btn-block { width: 100%; }

.btn-sm { min-height: 36px; padding: 0 13px; font-size: 13px; }

.btn-primary {
  color: var(--navy-900);
  background: linear-gradient(95deg, var(--cyan), var(--blue));
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }

.btn-ghost {
  color: var(--cyan);
  background: transparent;
  border-color: rgba(111, 227, 255, 0.45);
}
.btn-ghost:hover:not(:disabled) { background: rgba(111, 227, 255, 0.10); }

.btn-danger {
  color: #3A1B06;
  background: var(--orange);
}
.btn-danger:hover:not(:disabled) { filter: brightness(1.06); }

.link-btn {
  padding: 6px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-soft);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
}

.link-btn:hover { color: var(--cyan); }

/* ملاحظة هادئة مكان زرّ لا يفيد الضغط عليه —
   مثل الاستعادة بالبريد حين لا يكون SMTP مضبوطاً */
.hint {
  margin: 0;
  padding: 6px 2px;
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--text-soft);
  opacity: 0.8;
  text-align: center;
}

.hint code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(111, 227, 255, 0.1);
  color: var(--cyan);
  direction: ltr;
  display: inline-block;
}

.msg {
  margin: 0;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.6;
  background: rgba(240, 147, 78, 0.14);
  border: 1.5px solid rgba(240, 147, 78, 0.45);
  color: #FFD9BC;
}

.msg[hidden] { display: none; }
.msg.ok {
  background: rgba(91, 217, 138, 0.13);
  border-color: rgba(91, 217, 138, 0.45);
  color: #C9F4D9;
}

/* ═══════════ اللوحة ═══════════ */

.app { padding: clamp(12px, 2.4vw, 26px); }
.app[hidden] { display: none; }

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: clamp(10px, 1.8vh, 16px);
  border-bottom: 1px solid var(--line);
  margin-bottom: clamp(12px, 2vh, 20px);
}

.bar-brand { display: inline-flex; align-items: center; gap: 9px; }
.bar-brand img { width: 40px; height: auto; }

.bar-title {
  font-size: clamp(16px, 2.2vw, 20px);
  font-weight: 800;
}

.bar-actions { display: inline-flex; gap: 7px; flex-wrap: wrap; }

/* ── بطاقات الحالة ── */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  gap: 9px;
  margin-bottom: clamp(14px, 2.4vh, 24px);
}

.stat {
  padding: 12px 14px;
  border-radius: 13px;
  border: 1.5px solid var(--line);
  background: rgba(27, 46, 92, 0.5);
}

.stat-label {
  display: block;
  font-size: 12px;
  color: var(--text-soft);
  margin-bottom: 3px;
}

.stat-value {
  display: block;
  font-size: clamp(19px, 2.8vw, 25px);
  font-weight: 800;
  color: var(--cyan);
  font-variant-numeric: tabular-nums;
}

/* ── الغرف ── */

.section-title {
  margin: 0 0 4px;
  font-size: clamp(15px, 2.2vw, 19px);
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
}

.count {
  font-size: 12px;
  font-weight: 700;
  color: var(--navy-900);
  background: var(--cyan);
  border-radius: 999px;
  padding: 1px 9px;
}

.rooms-wrap, .log-wrap { margin-bottom: clamp(16px, 3vh, 30px); }

.rooms {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 11px;
  margin-top: 11px;
}

.room {
  padding: 14px;
  border-radius: var(--radius);
  border: 1.5px solid var(--line);
  background: linear-gradient(150deg, rgba(27, 46, 92, 0.62), rgba(18, 33, 69, 0.52));
}

.room-head {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.room-code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--gold);
  background: rgba(7, 14, 34, 0.6);
  border: 2px dashed rgba(255, 209, 102, 0.4);
  border-radius: 10px;
  padding: 2px 11px;
}

.tag {
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  padding: 2px 9px;
  white-space: nowrap;
}

.tag-phase { background: rgba(46, 155, 255, 0.22); color: var(--cyan); }
.tag-open { background: rgba(91, 217, 138, 0.2); color: var(--green); }
.tag-closed { background: rgba(169, 189, 223, 0.16); color: var(--text-soft); }
.tag-boss { background: rgba(255, 209, 102, 0.22); color: var(--gold); }

.room-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin-bottom: 10px;
  font-size: 12.5px;
  color: var(--text-soft);
}

.room-meta b { color: var(--text); font-weight: 700; }

.players {
  list-style: none;
  margin: 0 0 11px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.player {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 9px;
  border-radius: 9px;
  background: rgba(7, 14, 34, 0.42);
  font-size: 13px;
}

.dot {
  flex: 0 0 auto;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.25);
}

.player-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-state { font-size: 11.5px; color: var(--text-soft); white-space: nowrap; }
.player-state.down { color: var(--orange); }
.player-state.off { color: #8598BC; }

.mini {
  min-height: 30px;
  padding: 0 9px;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--orange);
  background: rgba(240, 147, 78, 0.12);
  border: 1.5px solid rgba(240, 147, 78, 0.4);
  border-radius: 8px;
  cursor: pointer;
}

.mini:hover { background: rgba(240, 147, 78, 0.22); }

.room-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.room-actions .btn { min-height: 34px; padding: 0 11px; font-size: 12.5px; }

.room-msg {
  margin-top: 8px;
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.room-msg select {
  flex: 1 1 150px;
  min-width: 0;
  min-height: 34px;
  padding: 0 9px;
  font-family: inherit;
  font-size: 12.5px;
  color: var(--text);
  background: rgba(7, 14, 34, 0.7);
  border: 1.5px solid var(--line);
  border-radius: 9px;
}

.empty {
  margin: 14px 0;
  padding: 18px;
  text-align: center;
  color: var(--text-soft);
  font-size: 14px;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
}

.empty[hidden] { display: none; }

/* ── السجل ── */

.log-note {
  margin: 0 0 9px;
  font-size: 12px;
  color: var(--text-soft);
}

.log {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 260px;
  overflow-y: auto;
}

.log li {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 7px 11px;
  border-radius: 9px;
  background: rgba(7, 14, 34, 0.42);
  font-size: 12.5px;
  color: var(--text-soft);
}

.log time { color: var(--cyan); font-variant-numeric: tabular-nums; }
.log .act { color: var(--text); font-weight: 700; }

/* ═══════════ التأكيد والرسائل ═══════════ */

.confirm {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(7, 14, 34, 0.78);
  backdrop-filter: blur(3px);
}

.confirm[hidden] { display: none; }

.confirm-card {
  width: 100%;
  max-width: 400px;
  padding: 22px;
  border-radius: var(--radius);
  border: 1.5px solid var(--line);
  background: linear-gradient(150deg, var(--navy-600), var(--navy-700));
  text-align: center;
}

.confirm-title { margin: 0 0 8px; font-size: 19px; font-weight: 800; }

.confirm-text {
  margin: 0 0 18px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-soft);
}

.confirm-actions { display: flex; gap: 9px; justify-content: center; flex-wrap: wrap; }

.toast {
  position: fixed;
  inset-inline: 0;
  top: 14px;
  z-index: 60;
  margin-inline: auto;
  width: max-content;
  max-width: 88vw;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(7, 14, 34, 0.94);
  border: 1.5px solid var(--line);
  font-size: 13.5px;
  font-weight: 500;
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show { opacity: 1; transform: translateY(0); }
.toast.bad { border-color: rgba(240, 147, 78, 0.6); color: #FFD9BC; }
.toast.good { border-color: rgba(91, 217, 138, 0.6); color: #C9F4D9; }

/* ═══════════ الهاتف ═══════════ */

@media (max-width: 640px) {
  .rooms { grid-template-columns: 1fr; }
  .bar { justify-content: center; }
  .bar-actions { width: 100%; justify-content: center; }
  .room-actions .btn { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
