/* ═══════════════════════════════════════════════════════════════════
   ثيم «سهرة»: الشكل الافتراضي للموقع
   ليل نيلي عميق، ضوء فانوس نحاسي للأزرار ولرسائلك أنت، وفيروزي من بلاط القدس للحالة الحية،
   ونقش نجمة ثمانية خافت خلف الرسائل. العناوين بخط كوفي (Reem Kufi) والنص بخط Readex Pro.
   كل القواعد هنا محصورة بهذا الثيم، فالثيمات الأخرى (واتساب وغيره) تبقى كما هي.
   ═══════════════════════════════════════════════════════════════════ */

/* الألوان: على أي عنصر يحمل الثيم (حتى معاينة الثيم في نافذة الاختيار) */
[data-theme="sahra"] {
  --bg: #12152b; --surface: #181c36; --surface2: #232849; --border: #2e345b;
  --text: #eeeaf6; --muted: #a1a4c9; --primary: #f0b24a; --primary-text: #2a1c04;
  --bubble: #1f2445; --bubble-me: #4b3716; --bubble-me-text: #fff3dc; --danger: #ff6b7a;
  --admin: #ffd166; --mod: #5fd4c4;
  /* أسماء متغيرات شكل الدردشة (مشتركة مع ثيم واتساب) */
  --wa-header: #151933; --wa-header-text: #eeeaf6; --wa-bar: #151933; --wa-input: #232849; --nick-l: 74%;
  --wa-doodle: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='64' viewBox='0 0 64 64'%3E%3Cdefs%3E%3Cg id='k'%3E%3Crect x='-9' y='-9' width='18' height='18'/%3E%3Crect x='-9' y='-9' width='18' height='18' transform='rotate(45)'/%3E%3C/g%3E%3C/defs%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='.045' stroke-width='1.1'%3E%3Cuse href='%23k' x='32' y='32'/%3E%3Cuse href='%23k' x='0' y='0'/%3E%3Cuse href='%23k' x='64' y='0'/%3E%3Cuse href='%23k' x='0' y='64'/%3E%3Cuse href='%23k' x='64' y='64'/%3E%3C/g%3E%3C/svg%3E");
  --lantern: #f0b24a;
  --lantern-soft: rgb(240 178 74 / .13);
  --tile: #46c2b4;
  --rail-bg: #0f1227;
  --display: 'Reem Kufi', 'Readex Pro', 'Segoe UI', Tahoma, system-ui, sans-serif;
}

/* ═════════ الأساسيات ═════════ */
:root[data-theme="sahra"] body { background: var(--bg); color-scheme: dark; }
:root[data-theme="sahra"] :is(.hero h1, .modal-head h3, #roomName, .page-bar .title strong, .users-panel h3, .rail-brand b, .cat h2, .block-head h2, .block-head h3) {
  font-family: var(--display);
}
:root[data-theme="sahra"] :is(input, select, textarea) { background: var(--surface2); border-color: var(--border); border-radius: 12px; }
:root[data-theme="sahra"] :is(input, select, textarea):focus { border-color: var(--lantern); box-shadow: 0 0 0 3px rgb(240 178 74 / .16); }
:root[data-theme="sahra"] .btn { border-radius: 12px; background: var(--surface2); border-color: var(--border); }
:root[data-theme="sahra"] .btn:hover { filter: none; background: color-mix(in srgb, var(--surface2) 80%, #fff 6%); }
:root[data-theme="sahra"] .btn.primary { background: var(--primary); color: var(--primary-text); border-color: transparent; font-weight: 700; }
:root[data-theme="sahra"] .btn.primary:hover { background: #f5c069; }
:root[data-theme="sahra"] .btn.danger { background: var(--danger); color: #fff; }
:root[data-theme="sahra"] .link { color: var(--lantern); }
:root[data-theme="sahra"] .icon-btn:hover { background: var(--surface2); }
:root[data-theme="sahra"] .tab.active, :root[data-theme="sahra"] .kind-chips .on { background: var(--primary); color: var(--primary-text); border-color: transparent; }

/* الإعلانات: إطار هادئ بلون الصفحة، لا شريط رمادي */
:root[data-theme="sahra"] .ad { background: var(--rail-bg); border-color: var(--border); }
:root[data-theme="sahra"] .ad-placeholder { border: 1px dashed rgb(240 178 74 / .22); background: rgb(255 255 255 / .015); color: var(--muted); border-radius: 12px; }

/* ═════════ صفحة الدخول ═════════ */
:root[data-theme="sahra"] #viewLogin {
  background:
    radial-gradient(70% 42% at 50% -4%, rgb(240 178 74 / .17), transparent 70%),
    radial-gradient(55% 40% at 100% 100%, rgb(70 194 180 / .09), transparent 70%),
    var(--wa-doodle), var(--bg);
}
:root[data-theme="sahra"] .landing-bg { display: none; }
:root[data-theme="sahra"] .landing-inner { gap: 22px; }
:root[data-theme="sahra"] .hero .logo-bubble {
  width: 74px; height: 74px; font-size: 34px; border-radius: 24px 24px 24px 7px;
  background: linear-gradient(160deg, #f7cb74, #c98a2c);
  box-shadow: 0 0 0 7px rgb(240 178 74 / .09), 0 20px 44px rgb(240 178 74 / .26);
  animation: none;
}
:root[data-theme="sahra"] .hero h1 {
  margin: 16px 0 6px; font-size: clamp(42px, 12vw, 66px); font-weight: 700; line-height: 1.08;
  color: #fff4df; text-shadow: 0 0 34px rgb(240 178 74 / .28);
}
:root[data-theme="sahra"] .tagline { font-size: 17px; color: var(--muted); }
:root[data-theme="sahra"] .stat { background: rgb(70 194 180 / .1); border-color: rgb(70 194 180 / .28); color: var(--text); }
:root[data-theme="sahra"] .join-card {
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border: 1px solid color-mix(in srgb, var(--lantern) 16%, var(--border));
  border-radius: 24px; padding: 24px 20px; gap: 12px;
  box-shadow: 0 30px 70px rgb(3 5 18 / .5);
}
:root[data-theme="sahra"] .join-card > label:first-child { font-size: 15px; color: var(--muted); font-weight: 500; }
:root[data-theme="sahra"] .nick-row input { font-size: 18px; background: var(--bg); }
:root[data-theme="sahra"] :is(.dice, .av-pick) { background: var(--bg); border-color: var(--border); border-radius: 14px; }
/* الجنس: مفتاح واحد بثلاث خانات بدل ثلاثة أزرار منفصلة */
:root[data-theme="sahra"] .gender-row { background: var(--bg); border: 1px solid var(--border); border-radius: 14px; padding: 4px; gap: 4px; }
:root[data-theme="sahra"] .gender-row button { border: 0; background: none; border-radius: 10px; color: var(--muted); padding: 8px 6px; }
:root[data-theme="sahra"] .gender-row button.on { background: var(--primary); color: var(--primary-text); }
:root[data-theme="sahra"] .join-btn {
  background: var(--primary); color: var(--primary-text); font-weight: 700; font-size: 18px; border-radius: 16px; padding: 15px;
  box-shadow: 0 12px 30px rgb(240 178 74 / .26);
}
:root[data-theme="sahra"] .join-btn:hover { background: #f5c069; }
:root[data-theme="sahra"] .age-gate input { accent-color: var(--lantern); }
:root[data-theme="sahra"] .lang-switch { background: color-mix(in srgb, var(--surface) 80%, transparent); border-color: var(--border); }
:root[data-theme="sahra"] .lang-switch .lang-btn.on { background: var(--primary); color: var(--primary-text); }

/* ═════════ القائمة اليمنى (الكمبيوتر) ═════════ */
:root[data-theme="sahra"] body:not([data-view="login"]) .rail { background: var(--rail-bg); border-color: var(--border); width: 224px; padding: 14px 12px; }
:root[data-theme="sahra"] .rail-brand b { font-size: 19px; color: #fff4df; }
:root[data-theme="sahra"] .rail-brand .logo-bubble { background: linear-gradient(160deg, #f7cb74, #c98a2c); }
:root[data-theme="sahra"] #rail .nav-item { color: var(--muted); border-radius: 12px; padding: 10px 14px; }
:root[data-theme="sahra"] #rail .nav-item:hover { background: var(--surface); color: var(--text); }
:root[data-theme="sahra"] .rail .nav-item.active { background: var(--lantern-soft); color: var(--lantern); border-radius: 12px; font-weight: 700; }
:root[data-theme="sahra"] .rail .nav-item.active::before {
  content: ''; position: absolute; inset-block: 9px; inset-inline-start: 0; width: 3px; border-radius: 3px; background: var(--lantern);
}
:root[data-theme="sahra"] .rr-main { font-weight: 500; }
:root[data-theme="sahra"] :is(.rr-main, .rr-sub):hover { background: var(--surface); }
:root[data-theme="sahra"] .rr-main.on { background: var(--surface); color: var(--text); font-weight: 700; }
:root[data-theme="sahra"] .rr-sub.on { color: var(--lantern); background: var(--lantern-soft); }
:root[data-theme="sahra"] .rr-count { background: var(--surface2); }
:root[data-theme="sahra"] .rr-count.live { background: rgb(70 194 180 / .16); color: var(--tile); }
:root[data-theme="sahra"] .rr-new { border: 1px solid var(--border); color: var(--lantern); background: none; }
:root[data-theme="sahra"] .rr-new:hover { border-color: var(--lantern); background: var(--lantern-soft); }
:root[data-theme="sahra"] .rail-logout { color: var(--danger) !important; opacity: .85; }

/* ═════════ رأس الدردشة والصفحات ═════════ */
:root[data-theme="sahra"] :is(#viewChat > .chat-bar, .page-bar, #viewMonitor > .bar) {
  background: var(--wa-header); border-bottom: 1px solid var(--border); padding-block: 9px;
}
:root[data-theme="sahra"] .room-av {
  width: 42px; height: 42px; border-radius: 14px; background: var(--surface2); border: 0;
  box-shadow: 0 0 0 2px rgb(240 178 74 / .4);
}
:root[data-theme="sahra"] #roomName { font-size: 19px; font-weight: 700; }
:root[data-theme="sahra"] #usersBtn { background: var(--surface2); border-radius: 999px; padding: 0 12px; font-size: 14px; }
:root[data-theme="sahra"] #usersBtn #userCount { color: var(--tile); font-weight: 700; }
:root[data-theme="sahra"] .room-menu { background: var(--surface); border-color: var(--border); border-radius: 14px; box-shadow: 0 20px 50px rgb(0 0 0 / .45); }

/* ═════════ الرسائل ═════════ */
:root[data-theme="sahra"] #messages {
  background: radial-gradient(90% 40% at 50% 0%, rgb(240 178 74 / .05), transparent 65%), var(--wa-doodle), var(--bg);
  padding: 16px 14px; gap: 4px;
}
:root[data-theme="sahra"] .msg .bubble { border-radius: 16px; padding: 6px 12px 5px; box-shadow: 0 1px 0 rgb(0 0 0 / .28); }
:root[data-theme="sahra"] .msg:not(.me) .bubble { background: var(--bubble); border: 1px solid rgb(255 255 255 / .04); border-top-left-radius: 5px; }
:root[data-theme="sahra"] .msg.me .bubble { background: var(--bubble-me); color: var(--bubble-me-text); border: 1px solid rgb(240 178 74 / .16); border-top-right-radius: 5px; }
:root[data-theme="sahra"] .msg .text { font-size: 15px; line-height: 1.55; }
:root[data-theme="sahra"] .msg .ticks { color: var(--tile); }
:root[data-theme="sahra"] .msg.mentioned .bubble { border-color: var(--lantern); box-shadow: 0 0 0 1px var(--lantern), 0 0 18px rgb(240 178 74 / .18); }
:root[data-theme="sahra"] .msg.system { color: var(--muted); }
:root[data-theme="sahra"] .msg.system:not(.welcome):not(.game) { font-size: 12.5px; }
:root[data-theme="sahra"] .msg.welcome, :root[data-theme="sahra"] .msg.system.welcome {
  background: rgb(240 178 74 / .07); border: 1px solid rgb(240 178 74 / .18); color: #f3dfb8; border-radius: 14px;
}
/* ألوان الجنس أفتح قليلاً لتُقرأ على الخلفية الليلية */
:root[data-theme="sahra"] :is(.gn-m, .msg .nick.gn-m) { color: #5aaaf6; }
:root[data-theme="sahra"] :is(.gn-f, .msg .nick.gn-f) { color: #f47ab8; }
:root[data-theme="sahra"] :is(.gn-u, .msg .nick.gn-u, .users-panel li .ul-name.gn-u) { background: none; color: #a8adbd; }

/* ═════════ مربع الكتابة ═════════ */
:root[data-theme="sahra"] .composer { background: var(--wa-bar); border-top: 1px solid var(--border); padding: 8px 12px; gap: 6px; }
:root[data-theme="sahra"] .composer .input-wrap input { background: var(--wa-input); border: 1px solid transparent; border-radius: 22px; padding: 11px 18px; }
:root[data-theme="sahra"] .composer .input-wrap input:focus { border-color: rgb(240 178 74 / .5); box-shadow: none; }
:root[data-theme="sahra"] .send-btn { background: var(--primary); color: var(--primary-text); box-shadow: 0 6px 18px rgb(240 178 74 / .25); }
:root[data-theme="sahra"] .dm-chip { background: var(--wa-bar); }
:root[data-theme="sahra"] .dm-chip-item { background: var(--surface2); color: var(--text); box-shadow: none; border: 1px solid var(--border); }
:root[data-theme="sahra"] .dm-chip-item.unread { outline: 2px solid var(--lantern); }

/* ═════════ قائمة المتصلين ═════════ */
:root[data-theme="sahra"] .users-panel { background: var(--surface); border-color: var(--border); }
:root[data-theme="sahra"] .users-panel h3 { font-size: 18px; }
:root[data-theme="sahra"] .users-panel #usersTitleCount { color: var(--tile); }
:root[data-theme="sahra"] .users-panel li:hover { background: var(--surface2); }
:root[data-theme="sahra"] .users-panel li.self { background: var(--lantern-soft); }
:root[data-theme="sahra"] .users-panel li .st-note { background: var(--bg); }
:root[data-theme="sahra"] .my-status { background: var(--bg); border-color: var(--border); border-radius: 12px; }

/* ═════════ الشريط السفلي (الهاتف) ═════════ */
@media (max-width: 760px) {
  :root[data-theme="sahra"] body:not([data-view="login"]):not([data-view="monitor"]) .tabbar { background: var(--rail-bg); border-top: 1px solid var(--border); }
  :root[data-theme="sahra"] .tabbar .nav-item { color: var(--muted); }
  :root[data-theme="sahra"] .tabbar .nav-item.active { color: var(--lantern); font-weight: 700; }
  :root[data-theme="sahra"] .tabbar .nav-item.active .ni { background: var(--lantern-soft); border-radius: 999px; }
  :root[data-theme="sahra"] :is(.send-btn, #micBtn) { background: var(--primary); color: var(--primary-text); }
  :root[data-theme="sahra"] #micBtn { background: var(--surface2); color: var(--text); }
  :root[data-theme="sahra"] .composer { padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); }
  :root[data-theme="sahra"] .hero h1 { font-size: clamp(40px, 13vw, 54px); }
}

/* ═════════ النوافذ والتنبيهات ═════════ */
/* خلفية النافذة معتمة بلا تضبيب: التضبيب (backdrop-filter) كان يُخفي النافذة الطويلة في بعض المتصفحات، وهو ثقيل على الهواتف الضعيفة */
:root[data-theme="sahra"] .modal { background: rgb(5 7 20 / .72); }
:root[data-theme="sahra"] .modal-box { background: var(--surface); border: 1px solid var(--border); border-radius: 22px; box-shadow: 0 34px 90px rgb(0 0 0 / .55); }
:root[data-theme="sahra"] .modal-head { border-color: var(--border); padding: 12px 16px; }
:root[data-theme="sahra"] .modal-head h3 { font-size: 20px; }
:root[data-theme="sahra"] .modal-body .panel { background: var(--bg); border-color: var(--border); border-radius: 16px; }
:root[data-theme="sahra"] .theme-opt { border-radius: 14px; }
:root[data-theme="sahra"] .theme-opt.active { border-color: var(--lantern); }
:root[data-theme="sahra"] .toast { background: var(--surface2); color: var(--text); border: 1px solid var(--border); border-inline-start: 3px solid var(--lantern); border-radius: 12px; box-shadow: 0 16px 40px rgb(0 0 0 / .45); }
