
/* ═══ خط الإيموجي المضمَّن (يضمن ظهور رموز الأزرار على كل الأنظمة) ═══ */
@font-face {
  font-family: 'MS Emoji';
  src: local('Segoe UI Emoji'), local('Apple Color Emoji'), local('Noto Color Emoji'),
       url('/fonts/ms-emoji.woff2') format('woff2');
  font-display: swap;
  unicode-range: U+1F000-1FAFF, U+2600-27BF, U+2190-21FF, U+2B00-2BFF, U+FE0F, U+200D, U+2700-27BF, U+1F1E6-1F1FF;
}
/* Maroc Star — التنسيق (RTL، وضع داكن) */

/* ═══════ إصلاح حرج: كلمة hidden في HTML يجب أن تُخفي العنصر دائماً ═══════
   السبب: أي قاعدة مثل .modal-root{display:grid} تلغي مفعول hidden،
   فبقيت نافذة المنبثقة تغطي الشاشة وتمنع النقر. هذه القاعدة تحسم الأمر. */
[hidden] { display: none !important; }


:root {
  --bg: #070b18;
  --bg-2: #0d1424;
  --panel: rgba(20, 28, 48, .86);
  --panel-solid: #141c30;
  --line: rgba(255, 255, 255, .08);
  --line-strong: rgba(255, 255, 255, .16);
  --text: #eaeefb;
  --muted: #94a3b8;
  --brand: #7c3aed;
  --brand-2: #ec4899;
  --ok: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --info: #38bdf8;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 18px 40px rgba(0, 0, 0, .45);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(1100px 600px at 85% -10%, rgba(124, 58, 237, .28), transparent 60%),
    radial-gradient(900px 500px at 5% 100%, rgba(236, 72, 153, .20), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Tahoma, system-ui, -apple-system, "Noto Naskh Arabic", Arial, "MS Emoji", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  overflow: hidden;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 700; }
code { background: rgba(255,255,255,.08); padding: 1px 6px; border-radius: 6px; direction: ltr; display: inline-block; }

/* ─────────── أزرار ─────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 12px; cursor: pointer;
  background: rgba(255,255,255,.06); border: 1px solid var(--line);
  transition: transform .12s ease, background .18s ease, border-color .18s ease, opacity .18s;
  white-space: nowrap;
}
.btn:hover { background: rgba(255,255,255,.12); border-color: var(--line-strong); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); border: none; color: #fff; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.ghost { background: transparent; }
.btn.danger { background: rgba(239,68,68,.16); border-color: rgba(239,68,68,.4); color: #fecaca; }
.btn.danger:hover { background: rgba(239,68,68,.28); }
.btn.ok { background: rgba(34,197,94,.16); border-color: rgba(34,197,94,.4); color: #bbf7d0; }
.btn.warn { background: rgba(245,158,11,.16); border-color: rgba(245,158,11,.4); color: #fde68a; }
.btn.big { padding: 12px 18px; width: 100%; font-size: 16px; }
.btn.icon { padding: 8px 10px; min-width: 40px; }
.btn.tiny { padding: 4px 9px; font-size: 12px; border-radius: 9px; }
.btn.active { background: linear-gradient(135deg, var(--brand), var(--brand-2)); border-color: transparent; color: #fff; }
.btn.mic-on { background: rgba(34,197,94,.22); border-color: rgba(34,197,94,.55); color: #d1fae5; }

/* ─────────── شاشة الدخول ─────────── */
.auth-screen { position: fixed; inset: 0; display: grid; place-items: center; padding: 20px; overflow: auto; }
.auth-bg {
  position: absolute; inset: 0;
  background: radial-gradient(700px 400px at 50% 0%, rgba(124,58,237,.35), transparent 70%);
  pointer-events: none;
}
.auth-card {
  position: relative; width: min(460px, 100%);
  background: linear-gradient(180deg, rgba(24,32,55,.95), rgba(14,20,36,.96));
  border: 1px solid var(--line-strong); border-radius: 22px;
  box-shadow: var(--shadow); padding: 26px 24px; backdrop-filter: blur(8px);
}
.brand { text-align: center; margin-bottom: 18px; }
.brand-logo {
  width: 62px; height: 62px; margin: 0 auto 10px; border-radius: 20px; display: grid; place-items: center;
  font-size: 30px; background: linear-gradient(135deg, var(--brand), var(--brand-2)); box-shadow: 0 10px 30px rgba(124,58,237,.45);
}
.brand h1 { font-size: 26px; letter-spacing: .5px; }
.brand-sub { color: var(--muted); margin: 4px 0 0; font-size: 13px; }
.auth-tabs { display: flex; gap: 6px; background: rgba(255,255,255,.05); padding: 5px; border-radius: 14px; margin-bottom: 16px; }
.tab { flex: 1; padding: 9px; border: none; background: transparent; border-radius: 10px; cursor: pointer; color: var(--muted); }
.tab.active { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; font-weight: 600; }
.auth-form { display: grid; gap: 12px; }
.auth-form label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.auth-form .opt { color: #64748b; font-size: 11px; }
input, select, textarea {
  width: 100%; padding: 11px 13px; border-radius: 12px; background: rgba(8,12,24,.75);
  border: 1px solid var(--line); outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(124,58,237,.22); }
.hint { color: var(--muted); font-size: 12px; text-align: center; }
.auth-footer { min-height: 22px; margin-top: 10px; text-align: center; }
.error { color: #fca5a5; font-size: 13px; }
.success { color: #86efac; font-size: 13px; }

/* ─────────── الشريط العلوي ─────────── */
.app { height: 100vh; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: rgba(10,15,28,.85); border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px); flex-wrap: wrap;
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.logo-sm {
  width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; font-size: 20px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
}
.site-name { font-weight: 800; letter-spacing: .4px; }
.site-sub { font-size: 11px; color: var(--muted); }
.topbar-center { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 10px var(--ok); }
.dot.off { background: var(--danger); box-shadow: 0 0 10px var(--danger); }
.dot.wait { background: var(--warn); box-shadow: 0 0 10px var(--warn); }
.topbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.user-chip {
  display: flex; align-items: center; gap: 8px; padding: 5px 12px 5px 6px;
  background: rgba(255,255,255,.06); border: 1px solid var(--line); border-radius: 30px;
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-size: 16px;
  background: #334155; flex: none; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 50%; }
.chat-em { width: 34px; height: 34px; vertical-align: middle; margin: 0 2px; }
.seat .s-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.badge {
  font-size: 11px; padding: 2px 9px; border-radius: 20px; background: rgba(148,163,184,.2); color: #cbd5e1;
}
.rank-tag {
  display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700;
  padding: 2px 9px; border-radius: 20px; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.4);
  white-space: nowrap;
}
.badge.rank-badge { color: #fff; font-weight: 700; border: none; }

/* تلوين أسماء الرتب في الشات */
.msg .m-head .rank-tag { margin-inline: 2px; }

.badge.owner { background: linear-gradient(135deg,#f59e0b,#f97316); color: #1a1206; font-weight: 700; }
.badge.admin { background: linear-gradient(135deg,#ef4444,#f97316); color: #fff; font-weight: 700; }
.badge.mod { background: linear-gradient(135deg,#22c55e,#14b8a6); color: #042b1c; font-weight: 700; }
.badge.guest { background: rgba(148,163,184,.18); }

/* ─────────── التخطيط ─────────── */
.layout {
  flex: 1; display: grid; grid-template-columns: 290px minmax(0, 1fr) 300px;
  gap: 12px; padding: 12px; min-height: 0;
}
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  display: flex; flex-direction: column; min-height: 0; overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 11px 14px; border-bottom: 1px solid var(--line);
}
.panel-head h2 { font-size: 14px; color: #cbd5e1; }
.search { padding: 6px 10px; font-size: 12px; border-radius: 9px; max-width: 140px; }

/* الغرف */
.rooms-list { overflow: auto; padding: 8px; display: grid; gap: 7px; max-height: 42vh; }
.room-card {
  padding: 10px 12px; border-radius: 13px; cursor: pointer; border: 1px solid var(--line);
  background: rgba(255,255,255,.03); transition: .15s; position: relative;
}
.room-card:hover { background: rgba(255,255,255,.09); transform: translateX(-2px); }
.room-card.active { border-color: var(--brand); background: linear-gradient(135deg, rgba(124,58,237,.28), rgba(236,72,153,.16)); }
.room-card .rc-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.room-card .rc-name { font-weight: 600; font-size: 14px; }
.room-card .rc-topic { font-size: 11px; color: var(--muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rc-meta { display: flex; gap: 8px; font-size: 11px; color: var(--muted); margin-top: 6px; flex-wrap: wrap; }
.mic-mini { color: var(--ok); }
.mini-avatars { display: flex; gap: -6px; margin-top: 6px; }
.mini-avatars .avatar { width: 20px; height: 20px; font-size: 11px; margin-inline-start: -6px; border: 2px solid #0b1020; }

/* كل المستخدمين */
.site-users { overflow: auto; padding: 8px; display: grid; gap: 5px; flex: 1; }
.user-row {
  display: flex; align-items: center; gap: 8px; padding: 6px 9px; border-radius: 11px;
  border: 1px solid transparent; cursor: pointer;
}
.user-row:hover { background: rgba(255,255,255,.07); border-color: var(--line); }
.user-row .u-name { flex: 1; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-row .u-sub { font-size: 10px; color: var(--muted); }
.on-dot { width: 7px; height: 7px; border-radius: 50%; background: #475569; }
.on-dot.on { background: var(--ok); box-shadow: 0 0 8px var(--ok); }

/* ─────────── الغرفة ─────────── */
.room-view {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  display: flex; flex-direction: column; min-height: 0; overflow: hidden;
}
.room-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.room-title h2 { font-size: 17px; }
.room-topic { font-size: 12px; color: var(--muted); }
.room-stats { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { background: rgba(255,255,255,.07); border: 1px solid var(--line); padding: 3px 10px; border-radius: 20px; font-size: 12px; }
.pill.locked { background: rgba(245,158,11,.16); border-color: rgba(245,158,11,.4); }

.seats-wrap { padding: 12px; overflow: auto; flex: 1; min-height: 130px; }
.seats-title { font-size: 12px; color: var(--muted); margin: 4px 0 10px; }
.listeners-title { margin-top: 18px; display: flex; gap: 8px; align-items: center; }
.seats { display: flex; flex-wrap: wrap; gap: 14px; }
.seat {
  width: 108px; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 6px; border-radius: 16px; border: 1px solid var(--line);
  background: rgba(255,255,255,.03); cursor: pointer; position: relative; transition: .18s;
}
.seat:hover { background: rgba(255,255,255,.08); }
.seat .s-avatar {
  width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; font-size: 26px;
  border: 3px solid rgba(255,255,255,.12); position: relative;
}
.seat.speaking .s-avatar { border-color: var(--ok); animation: pulse 1.1s infinite; }
.seat.hand .s-avatar::after { content: "✋"; position: absolute; top: -6px; left: -6px; font-size: 15px; }
.seat.off-mic .s-avatar { filter: grayscale(.7); opacity: .8; }
.seat .s-name { font-size: 12px; font-weight: 600; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.seat .s-rank { position: absolute; top: 5px; inset-inline-end: 5px; font-size: 13px; }
.seat .s-mic { font-size: 12px; color: var(--muted); }
.seat .s-level {
  position: absolute; bottom: 0; inset-inline-start: 0; height: 3px; border-radius: 3px;
  background: linear-gradient(90deg, var(--ok), #a3e635); width: 0; transition: width .1s linear;
}
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(34,197,94,.5); } 50% { box-shadow: 0 0 0 9px rgba(34,197,94,0); } }
.empty-seat { opacity: .45; border-style: dashed; }

.listeners { display: flex; flex-wrap: wrap; gap: 8px; }
.listener {
  display: flex; align-items: center; gap: 7px; padding: 5px 11px 5px 6px; border-radius: 30px;
  background: rgba(255,255,255,.05); border: 1px solid var(--line); font-size: 12px; cursor: pointer;
}
.listener:hover { background: rgba(255,255,255,.11); }
.listener .avatar { width: 24px; height: 24px; font-size: 12px; }
.listener.guest { font-style: italic; color: #cbd5e1; }

/* الشات */
.chat-wrap { border-top: 1px solid var(--line); display: flex; flex-direction: column; min-height: 210px; max-height: 42%; }
.chat-log { flex: 1; overflow: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.msg { display: flex; gap: 9px; align-items: flex-start; }
.msg .avatar { width: 30px; height: 30px; font-size: 14px; }
.msg .m-body { background: rgba(255,255,255,.05); border: 1px solid var(--line); padding: 7px 11px; border-radius: 13px; max-width: 78%; }
.msg .m-head { font-size: 11px; color: var(--muted); display: flex; gap: 6px; align-items: center; margin-bottom: 2px; }
.msg .m-text { font-size: 14px; word-break: break-word; }
.msg.mine .m-body { background: linear-gradient(135deg, rgba(124,58,237,.3), rgba(236,72,153,.2)); }
.msg.private .m-body { border-color: rgba(56,189,248,.5); background: rgba(56,189,248,.1); }
.msg.sys { justify-content: center; }
.msg.sys .m-body { background: transparent; border: none; color: var(--muted); font-size: 12px; text-align: center; }
.msg.sys.mod .m-body { color: #fca5a5; }
.chat-form { display: flex; gap: 7px; padding: 9px 11px; border-top: 1px solid var(--line); }
.chat-form input { flex: 1; }
.emoji-bar {
  display: flex; flex-wrap: wrap; gap: 4px; padding: 8px 11px; border-top: 1px solid var(--line);
  background: rgba(0,0,0,.25); max-height: 110px; overflow: auto;
}
.emoji-bar button { background: transparent; border: none; font-size: 19px; cursor: pointer; padding: 3px 5px; border-radius: 8px; }
.emoji-bar button:hover { background: rgba(255,255,255,.14); }

/* أزرار التحكم */
.controls {
  display: flex; gap: 9px; padding: 11px 14px; border-top: 1px solid var(--line);
  background: rgba(0,0,0,.22); flex-wrap: wrap;
}
.btn.ctrl { flex: 1; min-width: 108px; padding: 11px; flex-direction: column; gap: 2px; font-size: 19px; }
.btn.ctrl span { font-size: 11px; font-weight: 600; }
.btn.ctrl.small { font-size: 15px; }

/* لوحة المستخدمين في الغرفة */
.room-users { overflow: auto; padding: 8px; display: grid; gap: 5px; max-height: 46%; }
.room-log { overflow: auto; padding: 8px 12px; font-size: 11px; color: var(--muted); flex: 1; display: flex; flex-direction: column; gap: 4px; }
.log-item { border-inline-start: 2px solid var(--line-strong); padding-inline-start: 8px; }

/* ─────────── النوافذ ─────────── */
.modal-root { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(3,6,14,.72); backdrop-filter: blur(3px); }
.modal {
  position: relative; width: min(760px, 100%); max-height: 88vh; overflow: auto;
  background: linear-gradient(180deg, #182038, #0f1626); border: 1px solid var(--line-strong);
  border-radius: 20px; box-shadow: var(--shadow); padding: 20px;
}
.modal h3 { margin-bottom: 4px; font-size: 19px; }
.modal .modal-sub { color: var(--muted); font-size: 13px; margin-bottom: 16px; }
.modal .row { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.modal .grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.modal label { display: grid; gap: 5px; font-size: 12px; color: var(--muted); }
.modal-close { position: absolute; top: 12px; inset-inline-start: 12px; }
.tabs-row { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat { background: rgba(255,255,255,.05); border: 1px solid var(--line); border-radius: 14px; padding: 11px 13px; }
.stat .v { font-size: 22px; font-weight: 800; }
.stat .k { font-size: 11px; color: var(--muted); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 9px; text-align: start; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
tbody tr:hover { background: rgba(255,255,255,.05); }
.actions-cell { display: flex; gap: 4px; flex-wrap: wrap; }
.table-wrap { overflow: auto; max-height: 52vh; border: 1px solid var(--line); border-radius: 14px; }
.tag { font-size: 10px; padding: 2px 7px; border-radius: 20px; background: rgba(148,163,184,.2); }
.tag.ok { background: rgba(34,197,94,.2); color: #bbf7d0; }
.tag.bad { background: rgba(239,68,68,.2); color: #fecaca; }
.tag.warn { background: rgba(245,158,11,.2); color: #fde68a; }

/* ─────────── التنبيهات ─────────── */
.toasts { position: fixed; bottom: 16px; inset-inline-start: 16px; z-index: 80; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #1a2338; border: 1px solid var(--line-strong); border-inline-start: 4px solid var(--brand);
  padding: 11px 15px; border-radius: 12px; box-shadow: var(--shadow); font-size: 13px;
  animation: slide .22s ease; max-width: 340px;
}
.toast.err { border-inline-start-color: var(--danger); }
.toast.ok { border-inline-start-color: var(--ok); }
.toast.warn { border-inline-start-color: var(--warn); }
/* الإشعارات الحاسمة (طرد/حظر) */
#modal-root.critical .modal { border-color: var(--danger); }
@keyframes slide { from { transform: translateY(12px); opacity: 0; } }

.remote-audio { position: absolute; width: 0; height: 0; overflow: hidden; }
.ban-banner {
  position: fixed; inset: 0; background: rgba(4,7,16,.94); z-index: 100; display: grid; place-items: center; text-align: center; padding: 24px;
}
.ban-banner .box { max-width: 520px; background: #1b1220; border: 1px solid rgba(239,68,68,.5); padding: 26px; border-radius: 20px; }
.speaking-now { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ok); }

/* ─────────── استجابة الشاشات ─────────── */
@media (max-width: 1080px) {
  .layout { grid-template-columns: 1fr; overflow: auto; }
  .rooms-panel, .users-panel { max-height: 40vh; }
  .rooms-list { max-height: 24vh; }
  body { overflow: auto; }
  .app { height: auto; min-height: 100vh; }
  .chat-wrap { max-height: none; }
}
@media (max-width: 620px) {
  .topbar { padding: 8px 10px; }
  .site-sub { display: none; }
  .user-chip .u-name { max-width: 74px; overflow: hidden; text-overflow: ellipsis; }
  .seat { width: 92px; }
  .btn.ctrl { min-width: 46%; }
}
