/* ==========================================================================
   قناة الأبرار الفضائية — نظام التصميم
   أسود (هوية الشعار) + فضي/أبيض (النص) + أحمر (لون العلامة) + لمسة ذهبية خفيفة
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;800&display=swap');

:root {
  --bg: #0a0a0a;
  --surface: #141414;
  --surface-2: #1c1c1c;
  --border: #2a2a2a;

  --text: #f2f2f2;
  --muted: #98999b;

  --red: #d81f2a;
  --red-dark: #7a0f16;
  --red-glow: rgba(216, 31, 42, 0.45);

  --gold: #c9a227;

  --radius-sm: 6px;
  --radius-md: 10px;

  --tab-bar-h: 64px;
  --header-h: 56px;

  --safe-max-width: 560px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Cairo', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body {
  direction: rtl;
  min-height: 100vh;
  min-height: 100dvh;
}

a { color: inherit; }

button {
  font-family: inherit;
  border: none;
  background: none;
  color: inherit;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* ---------- App shell frame (keeps a phone-like column on wide screens) ---------- */

.app-shell {
  max-width: var(--safe-max-width);
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  position: relative;
  border-inline: 1px solid var(--border);
}

@media (min-width: 640px) {
  body { background: #000; }
}

/* ---------- Header ---------- */

.app-header {
  height: var(--header-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand img {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: block;
}

.brand-name {
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.2px;
}

.on-air {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.on-air .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 0 var(--red-glow);
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 var(--red-glow); }
  70%  { box-shadow: 0 0 0 8px rgba(216, 31, 42, 0); }
  100% { box-shadow: 0 0 0 0 rgba(216, 31, 42, 0); }
}

/* ---------- Main scroll area ---------- */

.app-main {
  flex: 1 1 auto;
  overflow-y: auto;
  padding-bottom: calc(var(--tab-bar-h) + 12px);
}

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

/* ---------- Live view ---------- */

.player-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
}

.player-wrap video {
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
}

.player-status {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  background: #000;
  pointer-events: none;
}

.player-status.hidden { display: none; }

.spinner {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--red);
  animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ticker — deliberately distinct from the broadcast's own on-screen ticker:
   thin, solid red, single-line marquee, sits directly under the player */

.ticker {
  background: var(--red);
  overflow: hidden;
  white-space: nowrap;
  height: 30px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--red-dark);
}

.ticker-track {
  display: inline-flex;
  gap: 64px;
  padding-inline-start: 100%;
  animation: ticker 22s linear infinite;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}

.ticker-track span { white-space: nowrap; }

@keyframes ticker {
  from { transform: translateX(0); }
  to   { transform: translateX(-100%); }
}

.channel-info {
  padding: 16px;
}

.channel-info h1 {
  font-size: 17px;
  font-weight: 800;
  margin: 0 0 4px;
}

.channel-info p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.9;
  max-width: 42ch;
}

.live-actions {
  display: flex;
  gap: 10px;
  padding: 0 16px 16px;
}

.pill-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.pill-btn.primary {
  background: var(--red);
  border-color: var(--red);
}

.pill-btn svg { width: 16px; height: 16px; flex: none; }

/* ---------- Programs view ---------- */

.section-title {
  padding: 18px 16px 8px;
  font-size: 16px;
  font-weight: 800;
}

.section-sub {
  padding: 0 16px 14px;
  margin-top: -6px;
  font-size: 12.5px;
  color: var(--muted);
}

.playlist-frame-wrap {
  padding: 0 16px 16px;
}

.playlist-frame-inner {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
}

.playlist-frame-inner iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.empty-state {
  margin: 8px 16px 20px;
  padding: 28px 18px;
  border-radius: var(--radius-md);
  border: 1px dashed var(--border);
  background: var(--surface);
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  line-height: 2;
}

.empty-state strong {
  display: block;
  color: var(--text);
  font-size: 14.5px;
  margin-bottom: 4px;
}

.youtube-cta {
  margin: 4px 16px 24px;
  display: flex;
  justify-content: center;
}

/* ---------- Programs grid ---------- */

.programs-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 0 16px 20px;
}

.program-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  text-align: right;
}

.program-card .thumb {
  width: 100%;
  aspect-ratio: 16/9;
  background: #000 center/cover no-repeat;
  position: relative;
}

.program-card .thumb::after {
  content: '▶';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 20px;
  background: rgba(0,0,0,0.15);
}

.program-card .info { padding: 10px; }
.program-card .info .title { font-size: 12.5px; font-weight: 700; line-height: 1.5; margin: 0 0 4px; }
.program-card .info .category { font-size: 11px; color: var(--gold); }

/* ---------- Video modal (programs playback) ---------- */

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.85);
  display: flex; align-items: center; justify-content: center;
  z-index: 60; padding: 16px;
}
.modal-backdrop.hidden { display: none; }

.video-modal-inner {
  width: 100%; max-width: 520px; position: relative;
}

.video-modal-frame {
  width: 100%; aspect-ratio: 16/9; background: #000; border-radius: var(--radius-md); overflow: hidden;
}
.video-modal-frame iframe, .video-modal-frame video {
  width: 100%; height: 100%; border: 0; display: block;
}

.video-modal-title {
  color: var(--text); font-size: 13px; font-weight: 700; margin-top: 10px; text-align: center;
}

.modal-close {
  position: absolute; top: -40px; left: 0;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); font-size: 16px;
}

/* ---------- More view ---------- */

.card {
  margin: 0 16px 14px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.card h2 {
  font-size: 14px;
  margin: 0 0 10px;
  font-weight: 800;
}

.card p {
  margin: 0 0 12px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.9;
}

.social-grid {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.social-icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.social-icon svg { width: 20px; height: 20px; }

.social-icon.disabled { opacity: 0.35; pointer-events: none; }

.notify-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.toggle {
  width: 46px;
  height: 26px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  position: relative;
  flex: none;
  transition: background 0.15s ease;
}

.toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.15s ease, background 0.15s ease;
}

.toggle.on {
  background: var(--red-dark);
  border-color: var(--red);
}

.toggle.on::after {
  transform: translateX(-20px);
  background: #fff;
}

.about-line {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--muted);
  padding: 8px 0;
  border-top: 1px solid var(--border);
}

.about-line:first-child { border-top: none; }

/* ---------- Bottom tab bar ---------- */

.tab-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--safe-max-width);
  height: var(--tab-bar-h);
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 30;
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
}

.tab-btn svg {
  width: 22px;
  height: 22px;
  stroke: var(--muted);
}

.tab-btn.active { color: var(--text); }
.tab-btn.active svg { stroke: var(--red); }

/* ---------- Install banner ---------- */

.install-banner {
  margin: 10px 16px 0;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--gold);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12.5px;
}

.install-banner.hidden { display: none; }

.install-banner button {
  font-weight: 800;
  color: var(--gold);
  white-space: nowrap;
}
