/* سينما خاصة — تصميم سينمائي مظلم، عربي RTL، محسّن للجوال */
:root {
  --bg: #0b0a10;
  --bg-2: #121019;
  --panel: #17151f;
  --panel-2: #201d2b;
  --line: #2b2739;
  --line-2: #3a3550;
  --text: #f2eefb;
  --muted: #9c94ad;
  --muted-2: #6f6883;
  --amber: #f6b23a;
  --amber-2: #e0940f;
  --red: #ec5a44;
  --green: #45c98a;
  --blue: #5b8def;
  --radius: 16px;
  --radius-sm: 11px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  --gutter: 16px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1100px 520px at 50% -12%, #241c33 0%, transparent 62%),
    var(--bg);
  color: var(--text);
  font-family: "Tajawal", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  direction: rtl;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input { font-family: inherit; }
.hidden { display: none !important; }
::selection { background: rgba(246, 178, 58, 0.28); }

/* التمرير */
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 8px; }

/* ===== شاشة الدخول ===== */
.gate {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 28px var(--gutter);
}
.gate-card {
  width: 100%;
  max-width: 400px;
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg-2) 100%);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow), 0 0 80px rgba(246, 178, 58, 0.05);
  padding: 42px 30px 34px;
}
.gate-card .brand {
  justify-content: center;
  margin-bottom: 32px;
}
.gate-card .brand h1 { font-size: 30px; }

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand .dot {
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 5px rgba(236, 90, 68, 0.16), 0 0 20px rgba(236, 90, 68, 0.5);
}
.brand h1 { font-size: 22px; font-weight: 800; margin: 0; letter-spacing: -0.5px; }

.field { margin-bottom: 15px; }
.field label {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 700;
}
.input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.input::placeholder { color: var(--muted-2); }
.input:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(246, 178, 58, 0.16);
}
.input:disabled { opacity: 0.55; cursor: not-allowed; }

.row { display: flex; gap: 10px; }
.row .input { flex: 1; }

.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 13px 18px;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.06s, filter 0.15s, background 0.15s, opacity 0.15s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary {
  width: 100%;
  background: linear-gradient(180deg, var(--amber), var(--amber-2));
  color: #241600;
  box-shadow: 0 6px 18px rgba(246, 178, 58, 0.22);
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.06); }
.btn-ghost {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
}
.btn-ghost:hover:not(:disabled) { background: var(--line); border-color: var(--line-2); }

/* أزرار أيقونية */
.icon-btn {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  width: 36px; height: 36px;
  font-size: 16px;
  cursor: pointer;
  display: grid; place-items: center;
  transition: background 0.15s, transform 0.08s, border-color 0.15s;
  flex: none;
}
.icon-btn:hover { background: var(--line); }
.icon-btn:active { transform: translateY(1px); }
.icon-btn.locked { border-color: var(--red); box-shadow: 0 0 0 2px rgba(236, 90, 68, 0.18); }

/* ===== واجهة الغرفة ===== */
.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 336px;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
  height: 100%;
  max-width: 1440px;
  margin: 0 auto;
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 15px;
  flex-wrap: wrap;
}
.topbar .brand h1 { font-size: 18px; }
.room-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12.5px;
  color: var(--muted);
}
.spacer { flex: 1 1 auto; }

.watchers { display: flex; align-items: center; }
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 800;
  color: #16121f;
  border: 2px solid var(--panel);
  margin-inline-start: -9px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}
.avatar:first-child { margin-inline-start: 0; }
.watch-count { font-size: 12.5px; color: var(--muted); margin-inline-start: 6px; white-space: nowrap; }

/* ===== المسرح ===== */
.stage-wrap { min-width: 0; display: flex; flex-direction: column; gap: 12px; min-height: 0; }

.stage {
  position: relative;
  background: #000;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 16 / 9;
  width: 100%;
  box-shadow: var(--shadow);
}
.stage iframe,
.stage video,
.stage img,
.stage canvas,
.stage .hb-holder {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  object-fit: contain;
  background: #000;
}
.stage .hb-holder video,
.stage .hb-holder canvas {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain;
}

.stage-empty {
  position: absolute; inset: 0;
  display: grid; place-content: center;
  text-align: center; gap: 12px;
  color: var(--muted); padding: 24px;
}
.stage-empty .big {
  font-size: 52px;
  filter: drop-shadow(0 6px 18px rgba(246, 178, 58, 0.25));
}
.stage-empty p { margin: 0; font-size: 14px; line-height: 1.8; max-width: 42ch; }

.tap-start {
  position: absolute; inset: 0; z-index: 5;
  display: grid; place-content: center; justify-items: center; gap: 12px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  color: #fff; cursor: pointer;
  font-size: 15px; font-weight: 700;
}
.tap-start .tap-btn {
  width: 74px; height: 74px; border-radius: 50%;
  background: linear-gradient(180deg, var(--amber), var(--amber-2));
  color: #241600; display: grid; place-items: center;
  font-size: 30px; padding-inline-start: 4px;
  box-shadow: 0 8px 26px rgba(246, 178, 58, 0.4);
}

.torrent-status {
  position: absolute; inset-inline: 0; bottom: 0;
  background: linear-gradient(0deg, rgba(0,0,0,0.9), transparent);
  color: var(--text); font-size: 12px;
  padding: 22px 14px 11px; display: none;
}
.torrent-status.on { display: block; }
.torrent-status .bar {
  height: 5px; border-radius: 999px; background: rgba(255,255,255,0.16);
  overflow: hidden; margin-top: 7px;
}
.torrent-status .bar > i {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--green), var(--amber));
  transition: width 0.4s;
}

/* شريط تحميل المصدر */
.loader {
  display: flex;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
}
.loader .input { flex: 1; }
.loader .btn-primary { width: auto; padding: 13px 22px; }
.loader .btn-ghost { padding: 13px 16px; }

.sync-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.sync-pill {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--green);
  background: rgba(69, 201, 138, 0.12);
  border: 1px solid rgba(69, 201, 138, 0.3);
  border-radius: 999px; padding: 6px 12px;
  font-weight: 700;
}
.sync-pill .live {
  width: 8px; height: 8px; border-radius: 50%; background: var(--green);
  animation: pulse 1.6s infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.35} }
.reactions { display: flex; gap: 6px; margin-inline-start: auto; }
.react-btn {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 17px;
  padding: 6px 11px;
  cursor: pointer;
  transition: transform 0.08s, background 0.15s;
  line-height: 1;
}
.react-btn:hover { transform: scale(1.14); background: var(--line); }

/* ===== الجانب: أعضاء + دردشة ===== */
.side { display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex; flex-direction: column;
  min-height: 0; overflow: hidden;
}
.card h3 {
  margin: 0; padding: 13px 15px;
  font-size: 13px; font-weight: 800;
  color: var(--muted); letter-spacing: 0.3px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 8px;
}
.members { padding: 11px 13px; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.member {
  display: flex; align-items: center; gap: 9px; font-size: 14px;
  padding: 5px 7px; border-radius: 10px;
}
.member:hover { background: var(--panel-2); }
.member .avatar { width: 27px; height: 27px; margin: 0; font-size: 12px; }
.member > span:nth-child(2) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member .you { color: var(--muted-2); font-size: 12px; flex: none; }
.badge-admin {
  font-size: 10.5px; font-weight: 800;
  color: var(--amber); background: rgba(246, 178, 58, 0.14);
  border: 1px solid rgba(246, 178, 58, 0.3);
  border-radius: 6px; padding: 2px 7px; flex: none;
}
.kick-btn {
  background: transparent; border: none; color: var(--muted-2);
  cursor: pointer; font-size: 14px; padding: 2px 6px; border-radius: 6px; flex: none;
  transition: color 0.15s, background 0.15s;
}
.kick-btn:hover { color: #fff; background: var(--red); }

.chat-card { flex: 1; }
.chat-log {
  flex: 1; overflow-y: auto;
  padding: 13px 15px;
  display: flex; flex-direction: column; gap: 10px;
  min-height: 120px;
}
.msg { font-size: 13.5px; line-height: 1.55; word-break: break-word; }
.msg .who { font-weight: 800; margin-inline-end: 6px; }
.msg.system {
  color: var(--muted-2); font-size: 12px; text-align: center;
  padding: 2px 0;
}
.chat-input {
  display: flex; gap: 8px; padding: 10px;
  border-top: 1px solid var(--line);
}
.chat-input .input { padding: 11px 13px; }
.chat-input .btn { padding: 11px 15px; }

/* التفاعلات الطائرة */
.float-layer { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 50; }
.floater { position: absolute; font-size: 36px; animation: floatUp 2.6s ease-out forwards; }
@keyframes floatUp {
  0% { transform: translateY(0) scale(0.6); opacity: 0; }
  15% { opacity: 1; transform: translateY(-12px) scale(1.15); }
  100% { transform: translateY(-230px) scale(1); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .floater { animation-duration: 0.6s; }
  .sync-pill .live { animation: none; }
}

/* ===== الأجهزة اللوحية والجوال ===== */
@media (max-width: 900px) {
  html, body { height: auto; }
  :root { --gutter: 12px; }
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    height: auto; min-height: 100%;
    gap: 12px; padding: 12px;
  }
  .topbar {
    position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
    padding: 10px 13px;
  }
  .side { flex-direction: column; }
  .chat-log { min-height: 200px; max-height: 46vh; }
  .loader { flex-wrap: wrap; }
  .loader .input { flex: 1 1 100%; }
  .loader .btn { flex: 1; }
}

@media (max-width: 560px) {
  .topbar .brand h1 { font-size: 16px; }
  .topbar .room-pill { display: none; }        /* توفير مساحة */
  .brand .dot { width: 11px; height: 11px; }
  .stage { border-radius: 13px; }
  .sync-row { gap: 8px; }
  .reactions { margin-inline-start: 0; width: 100%; justify-content: space-between; }
  .react-btn { flex: 1; text-align: center; }
  .members { max-height: 34vh; }
  .icon-btn { width: 38px; height: 38px; } /* لمس أسهل */
}
