/* ============================================================
   style.css — تصميم داكن حديث، عربي RTL، متجاوب
   ============================================================ */

:root {
  --bg: #0b0f17;
  --bg-soft: #101624;
  --panel: #141b2b;
  --panel-2: #1a2236;
  --border: #26304a;
  --text: #e7eaf0;
  --muted: #98a2b8;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --live: #ef4444;
  --live-glow: rgba(239, 68, 68, 0.4);
  --ok: #22c55e;
  --warn: #f59e0b;
  --danger: #dc2626;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --font: 'Cairo', 'Segoe UI', Tahoma, 'Noto Sans Arabic', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(1200px 500px at 85% -10%, rgba(99, 102, 241, 0.12), transparent 60%),
    radial-gradient(900px 400px at 10% -10%, rgba(239, 68, 68, 0.07), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1 0 auto; width: 100%; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 1.6rem; margin: 0 0 4px; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }
h3 { margin: 0 0 10px; }
p { line-height: 1.8; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.hidden { display: none !important; }
.mt { margin-top: 28px; }

/* ---------------- Navbar ---------------- */
.navbar {
  background: rgba(11, 15, 23, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.navbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.navbar-links { display: flex; gap: 8px; flex-wrap: wrap; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
}
.brand:hover { text-decoration: none; }
.brand-icon { width: 26px; height: 26px; color: var(--primary); }
.brand-icon.big { width: 44px; height: 44px; }

/* ---------------- Container / sections ---------------- */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}
.page-head { margin-bottom: 22px; }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
  min-height: 42px;
  color: var(--text);
  background: var(--panel-2);
  text-decoration: none;
}
.btn:hover { text-decoration: none; filter: brightness(1.1); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); filter: none; }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover { background: var(--panel-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-live { background: var(--live); color: #fff; }
.btn-live:hover { background: #dc2626; filter: none; }
.btn-sm { padding: 6px 12px; min-height: 32px; font-size: 0.85rem; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0; }

/* ---------------- Badges ---------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  border: 1px solid var(--border);
  color: var(--muted);
  background: var(--panel);
}
.badge-live {
  color: #fff;
  background: var(--live);
  border-color: var(--live);
}
.badge-live::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
  animation: pulse 1.2s infinite;
}
.badge-offline { color: var(--muted); }
.badge-ok { color: var(--ok); border-color: rgba(34, 197, 94, 0.4); }
.badge-role { color: var(--warn); border-color: rgba(245, 158, 11, 0.4); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* ---------------- Cards / grids ---------------- */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}

.stream-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
  /* البطاقة كلها رابط: بدون زخرفة نصية وبمؤشر يد — قابلة للنقر من أي نقطة */
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}
.stream-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.35); }
.stream-card:hover .btn { filter: brightness(1.1); }
.stream-card * { pointer-events: none; } /* كل النقرات تذهب للبطاقة نفسها */

.stream-thumb {
  height: 150px;
  background:
    radial-gradient(400px 150px at 70% 0%, rgba(99, 102, 241, 0.25), transparent),
    linear-gradient(135deg, var(--panel-2), var(--bg-soft));
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.stream-thumb svg { width: 44px; height: 44px; color: var(--primary); opacity: 0.7; }

.stream-thumb .live-badge { position: absolute; top: 10px; right: 10px; }

.stream-card-body { padding: 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.stream-card-body h3 { margin: 0; font-size: 1.05rem; }
.stream-card-body .desc {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.6em;
}
.stream-card-body .btn { margin-top: auto; }

/* LIVE badge (عائم فوق الفيديو/الكروت) */
.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--live);
  color: #fff;
  font-weight: 700;
  font-size: 0.8rem;
  padding: 4px 12px;
  border-radius: 999px;
  box-shadow: 0 0 14px var(--live-glow);
}
.live-badge::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
  animation: pulse 1.2s infinite;
}

/* ---------------- State boxes ---------------- */
.state-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px 20px;
  color: var(--muted);
  flex-direction: column;
  text-align: center;
  background: var(--panel);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.state-icon { width: 44px; height: 44px; color: var(--muted); }

.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
.spinner-lg { width: 34px; height: 34px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- Alerts ---------------- */
.alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin: 12px 0;
  font-size: 0.92rem;
  line-height: 1.7;
  border: 1px solid var(--border);
  background: var(--panel-2);
  flex-wrap: wrap;
}
.alert-error { border-color: rgba(239, 68, 68, 0.45); background: rgba(239, 68, 68, 0.08); }
.alert-warn { border-color: rgba(245, 158, 11, 0.5); background: rgba(245, 158, 11, 0.08); display: block; }
.alert-warn code { background: rgba(0,0,0,0.3); padding: 2px 6px; border-radius: 6px; font-size: 0.85em; direction: ltr; display: inline-block; }
.alert-warn ol, .alert-warn ul { margin: 8px 18px 8px 0; padding: 0; }
.alert-warn li { margin-bottom: 6px; }
.alert-info { border-color: rgba(99, 102, 241, 0.4); background: rgba(99, 102, 241, 0.08); display: block; }

/* ---------------- Forms ---------------- */
.field { margin-bottom: 16px; }
.field label { display: block; margin-bottom: 6px; font-size: 0.9rem; color: var(--muted); }

.input {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-family: var(--font);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2); }
textarea.input { resize: vertical; min-height: 70px; }
select.input { cursor: pointer; }

.form-msg { padding: 10px 14px; border-radius: var(--radius-sm); font-size: 0.9rem; margin: 10px 0; }
.form-msg.ok { background: rgba(34, 197, 94, 0.1); color: var(--ok); border: 1px solid rgba(34, 197, 94, 0.35); }
.form-msg.err { background: rgba(239, 68, 68, 0.1); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.35); }

/* ---------------- Auth page ---------------- */
.center-body { align-items: center; justify-content: center; }
.auth-card {
  width: min(420px, 92vw);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 34px 30px;
  box-shadow: var(--shadow);
  margin: 8vh auto;
}
.auth-head { text-align: center; margin-bottom: 20px; }
.auth-head h1 { margin: 10px 0 4px; }
.auth-hint { text-align: center; font-size: 0.85rem; margin-top: 18px; }

/* ---------------- Admin layout ---------------- */
.layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: var(--bg-soft);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand { padding: 4px 10px 18px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }

.sidebar-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-align: right;
  transition: background 0.15s, color 0.15s;
}
.nav-link svg { width: 19px; height: 19px; flex-shrink: 0; }
.nav-link:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.nav-link.active { background: rgba(99, 102, 241, 0.15); color: #c7d2fe; }

.sidebar-footer { border-top: 1px solid var(--border); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.sidebar-user { padding: 0 6px; line-height: 1.6; }
.sidebar-user .email { display: block; font-weight: 600; font-size: 0.9rem; word-break: break-all; }

.content {
  flex: 1;
  min-width: 0;
  padding: 26px 28px 60px;
  max-width: 1100px;
}

.section { display: none; }
.section.active { display: block; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

/* ---------------- Stats ---------------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 10px;
}
.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.stat-card .num { font-size: 1.9rem; font-weight: 700; color: #fff; line-height: 1.2; }
.stat-card .label { color: var(--muted); font-size: 0.85rem; margin-top: 2px; }

/* ---------------- Tables ---------------- */
.table-wrap {
  overflow-x: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.table { width: 100%; border-collapse: collapse; min-width: 640px; }
.table th, .table td {
  padding: 13px 16px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
  vertical-align: middle;
}
.table th { color: var(--muted); font-weight: 600; background: var(--bg-soft); white-space: nowrap; }
.table tr:last-child td { border-bottom: none; }
.table .actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------------- Player ---------------- */
.player-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}
.player-wrap video { width: 100%; height: 100%; object-fit: contain; background: #000; display: block; }

.player-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  background:
    radial-gradient(400px 200px at 50% 30%, rgba(99, 102, 241, 0.12), transparent),
    var(--bg-soft);
}

.player-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 8, 14, 0.82);
  backdrop-filter: blur(2px);
}
.player-overlay:empty { display: none; }
.overlay-content { text-align: center; color: var(--text); display: flex; flex-direction: column; gap: 12px; align-items: center; padding: 20px; }
.overlay-content p { margin: 0; font-size: 1.05rem; font-weight: 600; }

.player-wrap .live-badge { position: absolute; top: 14px; right: 14px; z-index: 5; }

.player-controls-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 4px;
  flex-wrap: wrap;
}

.watch-info { margin-top: 14px; }
.watch-title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.watch-title-row h1 { margin: 0; }

/* ---------------- Broadcast page ---------------- */
.broadcast-grid {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 18px;
  align-items: start;
}
.broadcast-status-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.hint-box {
  margin-top: 16px;
  padding: 14px 16px;
  background: var(--bg-soft);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.8;
}
.hint-box ul { margin: 8px 0 0; padding-right: 18px; }

/* ---------------- Modal ---------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 10, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 18px;
}
.modal {
  width: min(520px, 96vw);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.modal-head h2 { margin: 0; }
.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.8rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}
.modal-close:hover { color: var(--text); }
.modal-subtitle { color: var(--primary); }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.code-box {
  display: block;
  flex: 1;
  min-width: 0;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  font-size: 0.85rem;
  color: #c7d2fe;
  overflow-x: auto;
  white-space: nowrap;
  direction: ltr;
  text-align: left;
}
.copy-row { display: flex; gap: 8px; align-items: stretch; }

/* ---------------- Toast ---------------- */
#toast-container {
  position: fixed;
  bottom: 18px;
  right: 50%;
  transform: translateX(50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  align-items: center;
}
.toast {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 11px 20px;
  font-size: 0.92rem;
  box-shadow: var(--shadow);
  animation: toast-in 0.25s ease;
}
.toast.ok { border-color: rgba(34, 197, 94, 0.5); }
.toast.err { border-color: rgba(239, 68, 68, 0.5); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------------- Settings cards ---------------- */
.settings-card { max-width: 520px; margin-bottom: 18px; }

/* ---------------- Footer ---------------- */
.footer {
  border-top: 1px solid var(--border);
  color: var(--muted);
  text-align: center;
  padding: 18px;
  font-size: 0.85rem;
  flex-shrink: 0;
}

/* ---------------- Responsive ---------------- */
@media (max-width: 900px) {
  .layout { flex-direction: column; }

  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    border-left: none;
    border-bottom: 1px solid var(--border);
    padding: 12px;
  }
  .sidebar-brand { border-bottom: none; padding-bottom: 6px; margin-bottom: 6px; }
  .sidebar-nav { flex-direction: row; overflow-x: auto; padding-bottom: 6px; }
  .nav-link { white-space: nowrap; padding: 9px 12px; }
  .sidebar-footer { border-top: none; padding-top: 4px; flex-direction: row; align-items: center; justify-content: space-between; }
  .sidebar-footer .btn { width: auto; }
  .content { padding: 18px 14px 50px; }

  .broadcast-grid { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  h1 { font-size: 1.3rem; }
  .navbar-inner { padding: 10px 12px; }
  .container { padding: 16px 12px 40px; }
  .cards-grid { grid-template-columns: 1fr; }
}
