/* موقع مبارياتي — نفس ألوان التطبيق (ui/theme/Theme.kt) */
:root {
  --bg: #040a18;
  --panel: #0a1428;
  --card: #0d1a33;
  --card-hi: #12244a;
  --line: #1b2f57;
  --blue: #2e7dff;
  --glow: #00c2ff;
  --live: #ff3b4e;
  --win: #22c55e;
  --amber: #f59e0b;
  --text: #e8f0ff;
  --muted: #8ca0c4;
  --faint: #5b6e92;
  --radius: 16px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", sans-serif;
  background:
    radial-gradient(1200px 500px at 50% -200px, #0e2c63 0%, transparent 70%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-size: 15px;
  min-height: 100vh;
}
img { display: block; }
button { font: inherit; color: inherit; }
.wrap { max-width: 860px; margin: 0 auto; padding: 0 16px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

/* ── الترويسة ── */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: rgba(4, 10, 24, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 10px; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand img { width: 44px; height: 44px; object-fit: contain; }
.brand strong { display: block; font-size: 22px; font-weight: 700; line-height: 1.1; }
.brand small { color: var(--muted); font-size: 12px; }

.topbar-row { flex-wrap: wrap; row-gap: 8px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; margin-inline-start: auto; }
.lang-select {
  appearance: none; -webkit-appearance: none; cursor: pointer;
  padding: 8px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card);
  color: var(--text); font: inherit; font-size: 13px; font-weight: 600; max-width: 130px;
}
.lang-select:focus-visible { outline: 2px solid var(--glow); outline-offset: 2px; }

.live-toggle {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none;
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card);
  font-size: 13px; font-weight: 600; white-space: nowrap;
}
.live-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.live-toggle .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.live-toggle:has(input:checked) { border-color: var(--live); background: rgba(255, 59, 78, 0.12); }
.live-toggle:has(input:checked) .dot { background: var(--live); animation: pulse 1.2s infinite; }
.live-toggle:has(input:focus-visible) { outline: 2px solid var(--glow); outline-offset: 2px; }

/* ── شريط الأيام ── */
.days {
  display: flex; gap: 8px; overflow-x: auto; padding: 16px 0 10px;
  scrollbar-width: none;
}
.days::-webkit-scrollbar { display: none; }
.day {
  flex: 0 0 auto; min-width: 72px; padding: 8px 10px; border-radius: 14px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); text-align: center;
}
.day b { display: block; font-size: 14px; }
.day span { font-size: 12px; color: var(--muted); }
.day[aria-current="date"] {
  background: linear-gradient(180deg, #123a7a, #0b2352); border-color: var(--blue);
  box-shadow: 0 0 0 1px var(--blue), 0 6px 20px rgba(46, 125, 255, 0.25);
}
.day[aria-current="date"] span { color: var(--text); }

/* ── شريط البطولات ── */
.leagues-bar { margin-bottom: 6px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; }
.chip {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  padding: 6px 12px 6px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--card);
  font-size: 13px; white-space: nowrap;
}
.chip img { width: 18px; height: 18px; object-fit: contain; }
.chip .n { color: var(--muted); font-size: 12px; }
.chip[aria-selected="true"] { background: var(--blue); border-color: var(--blue); }
.chip[aria-selected="true"] .n { color: #dbe8ff; }

.summary { color: var(--muted); font-size: 13px; margin: 8px 2px 14px; }

/* ── مجموعة بطولة ── */
.group {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: 14px; overflow: hidden;
}
.group-head {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  background: linear-gradient(180deg, #13274f, #0a1730); border-bottom: 1px solid var(--line);
}
.group-head .logo {
  width: 30px; height: 30px; border-radius: 50%; background: rgba(255,255,255,.92);
  display: grid; place-items: center; flex: 0 0 auto;
}
.group-head .logo img { width: 21px; height: 21px; object-fit: contain; }
.group-head .logo.none { background: var(--card-hi); font-size: 15px; }
.group-head h2 { font-size: 15px; margin: 0; font-weight: 600; }
.group-head small { color: var(--muted); font-size: 12px; margin-inline-start: auto; }

/* ── صف المباراة ── */
.match {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px;
  width: 100%; padding: 12px 14px; background: none; border: 0; cursor: pointer; text-align: inherit;
  border-top: 1px solid rgba(27, 47, 87, 0.6);
}
.match:first-of-type { border-top: 0; }
.match:hover { background: rgba(46, 125, 255, 0.06); }
.match:focus-visible { outline: 2px solid var(--glow); outline-offset: -2px; }
.team { display: flex; align-items: center; gap: 8px; min-width: 0; }
.team.away { flex-direction: row-reverse; text-align: end; }
.team img, .team .ph { width: 30px; height: 30px; object-fit: contain; flex: 0 0 auto; }
.team .ph { border-radius: 50%; background: var(--card-hi); }
.team span { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team.winner span { color: #fff; }
.team.loser span { color: var(--muted); }

.mid { text-align: center; min-width: 86px; }
.score { font-size: 20px; font-weight: 700; letter-spacing: 1px; direction: ltr; }
.time { font-size: 17px; font-weight: 700; direction: ltr; }
.status { display: inline-block; font-size: 11px; font-weight: 600; margin-top: 2px; padding: 1px 8px; border-radius: 999px; }
.status.live { color: #fff; background: var(--live); }
.status.live::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #fff; margin-inline-end: 5px; vertical-align: middle; animation: pulse 1.2s infinite; }
.status.ft { color: var(--muted); background: var(--card-hi); }
.status.ns { color: var(--muted); }
.status.off { color: var(--amber); background: rgba(245, 158, 11, .12); }
.pens { font-size: 11px; color: var(--muted); direction: ltr; }

.channels {
  grid-column: 1 / -1; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: -2px;
}
.ch {
  font-size: 11px; color: var(--muted); padding: 2px 8px; border-radius: 6px;
  background: rgba(46, 125, 255, 0.08); border: 1px solid rgba(46, 125, 255, 0.18);
}
.ch::before { content: "📺 "; }
.ch.more::before { content: none; }

/* ── حالات ── */
.empty, .error {
  text-align: center; padding: 48px 16px; color: var(--muted);
  background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius);
}
.empty .big { font-size: 34px; margin-bottom: 8px; }
.error { color: #ffb4bc; border-color: rgba(255, 59, 78, .4); }
.skeleton { height: 64px; border-radius: 12px; margin: 10px 14px; background: linear-gradient(90deg, var(--card) 0%, var(--card-hi) 50%, var(--card) 100%); background-size: 200% 100%; animation: shimmer 1.3s infinite linear; }

.footer { color: var(--faint); font-size: 12px; text-align: center; padding: 28px 16px 40px; line-height: 1.8; }

/* ── نافذة التفاصيل ── */
dialog {
  border: 1px solid var(--line); border-radius: 20px; padding: 0; color: var(--text);
  background: var(--panel); width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 32px);
}
dialog::backdrop { background: rgba(2, 6, 16, 0.75); backdrop-filter: blur(3px); }
.dlg { position: relative; display: flex; flex-direction: column; max-height: calc(100vh - 34px); }
.dlg-close {
  position: absolute; top: 10px; inset-inline-start: 10px; z-index: 2; width: 34px; height: 34px;
  border-radius: 50%; border: 1px solid var(--line); background: var(--card); cursor: pointer;
}
.dlg-head { padding: 22px 16px 14px; text-align: center; background: linear-gradient(180deg, #13274f, #0a1730); }
.dlg-head .league { font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.dlg-teams { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.dlg-team img, .dlg-team .ph { width: 56px; height: 56px; margin: 0 auto 6px; object-fit: contain; }
.dlg-team .ph { border-radius: 50%; background: var(--card-hi); }
.dlg-team b { font-size: 14px; display: block; }
.dlg-score { font-size: 32px; font-weight: 700; direction: ltr; }
.tabs { display: flex; gap: 4px; padding: 8px 12px 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab {
  background: none; border: 0; padding: 10px 12px; cursor: pointer; color: var(--muted); font-weight: 600;
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.tab[aria-selected="true"] { color: var(--text); border-color: var(--blue); }
.dlg-body { padding: 14px 16px 20px; overflow-y: auto; }

.events { list-style: none; margin: 0; padding: 0; }
.events li { display: grid; grid-template-columns: 1fr 44px 1fr; align-items: center; padding: 7px 0; border-bottom: 1px solid rgba(27,47,87,.5); font-size: 14px; }
.events .min { text-align: center; color: var(--muted); font-size: 12px; direction: ltr; }
.events .away { text-align: end; }
.events .ic { margin-inline-end: 6px; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 7px 4px; text-align: center; border-bottom: 1px solid rgba(27,47,87,.5); }
.table th { color: var(--muted); font-weight: 500; font-size: 12px; }
.table td.name { text-align: start; }
.table td.name div { display: flex; align-items: center; gap: 6px; }
.table td.name img { width: 18px; height: 18px; object-fit: contain; }
.table tr.hl td { background: rgba(46, 125, 255, 0.14); }
.table td.pts { font-weight: 700; }
.table-group { font-size: 13px; color: var(--muted); margin: 14px 0 4px; }

.h2h-sum { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; text-align: center; }
.h2h-sum div { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 4px; }
.h2h-sum b { display: block; font-size: 20px; }
.h2h-sum span { font-size: 12px; color: var(--muted); }
.h2h-row { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; font-size: 13px; padding: 7px 0; border-bottom: 1px solid rgba(27,47,87,.5); }
.h2h-row .d { grid-column: 1 / -1; font-size: 11px; color: var(--faint); text-align: center; margin-bottom: -4px; }
.h2h-row .r { text-align: end; }
.h2h-row b { direction: ltr; }

@keyframes pulse { 50% { opacity: .35; } }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (max-width: 520px) {
  .brand small { display: none; }
  .team img, .team .ph { width: 24px; height: 24px; }
  .team span { font-size: 13px; }
  .mid { min-width: 70px; }
  .match { gap: 6px; padding: 11px 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before { animation: none !important; }
}

/* ================= الإعلانات ================= */
/* كل وحدة تحجز ارتفاعها مسبقاً حتى لا تقفز الصفحة حين يصل الإعلان. */

.ad {
  display: block;
  margin: 16px 0;
  background: rgba(255, 255, 255, .02);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  position: relative;
}
.ad-tag {
  position: absolute;
  inset-block-start: 6px;
  inset-inline-start: 10px;
  font-size: 10px;
  letter-spacing: .04em;
  color: var(--faint);
  background: rgba(4, 10, 24, .7);
  padding: 2px 7px;
  border-radius: 6px;
  z-index: 1;
}
.ad ins { display: block; width: 100%; }
.ad-details { margin: 18px 0 4px; }
.ad-footer { margin-bottom: 28px; }
/* الطباعة لا تحتاج إعلانات */
@media print { .ad, .consent { display: none !important; } }

/* شريط الموافقة — أسفل الشاشة، لا يغطّي المحتوى ولا يعيد نفسه بعد الاختيار */
.consent {
  position: fixed;
  inset-inline: 12px;
  inset-block-end: 12px;
  z-index: 50;
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 18px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .45);
}
.consent p { margin: 0; flex: 1; min-width: 240px; font-size: 13px; line-height: 1.7; color: var(--muted); }
.consent a { color: inherit; }
.consent-actions { display: flex; gap: 8px; }
.consent button {
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  border-radius: 10px;
  padding: 9px 16px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
}
.consent .btn-ok { background: #2e7dff; border-color: #2e7dff; color: #fff; font-weight: 600; }

/* ================= شريط المباشرة الآن ================= */

.live-strip { border: 1px solid rgba(239, 68, 68, .35); border-radius: 16px; padding: 4px 6px 6px; }
.live-strip .group-head h2 { color: #ff6b6b; }
.live-pulse { animation: pulse 1.6s ease-in-out infinite; }

/* ================= التذييل القانوني ================= */

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  justify-content: center;
  margin-bottom: 14px;
  font-size: 13px;
}
.footer-links a { color: var(--muted); text-decoration: none; }
.footer-links a:hover { color: var(--text); text-decoration: underline; }
