/* ============================================================
   Raduzi — app.css — الهيكل والهويّة والوضعان
   كلّ الألوان بأسماء قابلة للتبديل. المقاسات من عرض الشاشة وحده.
   ============================================================ */

:root {
  /* الهويّة الثابتة */
  --navy: #0B1F44;
  --navy-2: #13306B;
  --lime: #C8FF2E;
  --lime-on-white: #9BCF00;
  --blue: #1F5BFF;      /* المخمِّن */
  --orange: #FF7A1A;    /* صاحب الكلمة */
  --red: #E5243B;       /* مباشر */
  --green: #0F9F5F;
  --white: #FFFFFF;

  /* النهاريّ (الافتراضيّ) */
  --bg: #F3F5F9;
  --surface: #FFFFFF;
  --surface-2: #F8FAFC;
  --line: #E3E7EF;
  --line-2: #EEF1F6;
  --text: #0B1F44;
  --text-2: #5A6782;
  --text-3: #8A93A6;
  --topbar-bg: #0B1F44;
  --topbar-text: #FFFFFF;
  --hero-bg: #0B1F44;
  --hero-text: #FFFFFF;
  --hero-sub: #B9C4DA;
  --tab-active-bg: #0B1F44;
  --tab-active-text: #FFFFFF;
  --focus: #1F5BFF;
  --logo-dot: #C8FF2E;        /* داخل الشريط الكحليّ */
  --logo-dot-on-bg: #9BCF00;  /* على الخلفيّة الفاتحة */
  --logo-on-bg: #0B1F44;

  --font-ar: 'Cairo', 'Segoe UI', Tahoma, Arial, sans-serif;
  --font-brand: 'Barlow Condensed', 'Arial Narrow', Arial, sans-serif;

  /* مقياس من عرض الشاشة وحده */
  --pad: clamp(14px, 4vw, 56px);
  --radius: 16px;
  --radius-lg: 20px;

  color-scheme: light;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

:root[data-theme="dark"] {
  --bg: #07132B;
  --surface: #0F2650;
  --surface-2: #132E5E;
  --line: #23407A;
  --line-2: #1B3568;
  --text: #FFFFFF;
  --text-2: #B9C4DA;
  --text-3: #7F8DAE;
  --topbar-bg: #0B1F44;
  --topbar-text: #FFFFFF;
  --hero-bg: #13306B;
  --hero-text: #FFFFFF;
  --hero-sub: #B9C4DA;
  --tab-active-bg: #C8FF2E;
  --tab-active-text: #0B1F44;
  --logo-dot-on-bg: #C8FF2E;
  --logo-on-bg: #FFFFFF;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: inherit; }

html { scroll-padding-top: env(safe-area-inset-top, 0px); -webkit-text-size-adjust: 100%; }
html { height: 100%; }
body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ar);
  font-size: 16px;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  min-height: 100%;
  overflow-x: hidden;
  font-variant-numeric: lining-nums tabular-nums;
}

a { color: inherit; }
button { font-family: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1, h2, h3 { margin: 0; line-height: 1.3; }

/* ---------- الشريط العلويّ ---------- */
.topbar {
  flex-shrink: 0;
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 10;
  background: var(--topbar-bg);
  color: var(--topbar-text);
  padding: 12px var(--pad);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.logo {
  font-family: var(--font-brand);
  font-style: italic;
  font-weight: 800;
  font-size: clamp(30px, 7vw, 42px);
  line-height: 1;
  letter-spacing: 1px;
  text-decoration: none;
  color: var(--topbar-text);
  direction: ltr;
  unicode-bidi: isolate;
  padding: 4px 0;
}
.logo .dot { color: var(--logo-dot); }

.topbar-side { display: flex; align-items: center; gap: 8px; }

.theme-btn, .avatar {
  width: 44px; height: 44px;
  border-radius: 10px;
  border: none;
  background: rgba(255,255,255,0.12);
  color: var(--topbar-text);
  display: flex; align-items: center; justify-content: center;
  text-decoration: none;
  padding: 0;
}
.theme-btn:hover, .avatar:hover { background: rgba(255,255,255,0.2); }
.theme-btn .ico-moon { display: none; }
:root[data-theme="dark"] .theme-btn .ico-sun { display: none; }
:root[data-theme="dark"] .theme-btn .ico-moon { display: block; }
.avatar { border-radius: 50%; }

/* ---------- التبويبات (هيكل مؤقّت للتنقّل) ---------- */
.tabs {
  flex-shrink: 0;
  display: flex;
  gap: 8px;
  padding: 12px var(--pad) 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  flex-shrink: 0;
  height: 38px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
  display: flex; align-items: center;
}
.tabs a[aria-current="page"] {
  background: var(--tab-active-bg);
  color: var(--tab-active-text);
  border-color: var(--tab-active-bg);
}

/* ---------- المحتوى ---------- */
.app {
  flex: 1;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 18px var(--pad) 40px;
}
.page { display: flex; flex-direction: column; gap: 22px; }
.page[hidden] { display: none; }
.page-title { font-size: clamp(20px, 5vw, 26px); font-weight: 900; }

/* البطل */
.hero {
  background: var(--hero-bg);
  color: var(--hero-text);
  border-radius: var(--radius-lg);
  padding: clamp(18px, 4vw, 28px);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.hero h1 {
  font-size: clamp(22px, 5.5vw, 34px);
  font-weight: 900;
  line-height: 1.3;
}
.hero h1 em { font-style: normal; color: var(--lime); }
.btn-start {
  height: clamp(56px, 14vw, 62px);
  border: none;
  border-radius: 14px;
  background: var(--lime);
  color: var(--navy);
  font-size: clamp(22px, 6vw, 26px);
  font-weight: 900;
}
.btn-start:active { transform: translateY(1px); }
.hero-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.btn-ghost {
  height: 46px;
  border-radius: 12px;
  border: 1.5px solid rgba(255,255,255,0.4);
  background: transparent;
  color: var(--hero-text);
  font-size: 14px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}

/* الأعمدة */
.cols { display: flex; flex-direction: column; gap: 22px; }
.col { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.section-head { display: flex; align-items: center; gap: 8px; }
.section-head h2 { font-size: clamp(18px, 4.5vw, 24px); font-weight: 900; }
.live {
  background: var(--red); color: var(--white);
  font-size: 12px; font-weight: 800;
  border-radius: 4px; padding: 2px 8px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.empty { padding: 22px 16px; color: var(--text-2); font-weight: 600; font-size: 14px; text-align: center; }
.table-head {
  display: grid; grid-template-columns: 44px minmax(0,1fr) 88px;
  background: var(--navy); color: var(--white);
  font-size: 12px; font-weight: 700; padding: 10px 12px;
}
.ta-end { text-align: left; }

.placeholder { padding: 40px 16px; text-align: center; color: var(--text-2); }
.placeholder h2 { color: var(--text); font-size: 22px; font-weight: 900; margin-bottom: 6px; }
.placeholder p { margin: 0; font-weight: 600; }

/* الإعدادات */
.settings { display: flex; flex-direction: column; }
.setting-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 14px 16px; border-top: 1px solid var(--line-2);
}
.setting-row:first-child { border-top: none; }
.setting-name { font-weight: 800; }
.setting-sub { font-size: 13px; color: var(--text-2); font-weight: 600; }
.seg { display: flex; border: 1.5px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button {
  height: 40px; padding: 0 14px; border: none; background: var(--surface);
  color: var(--text); font-weight: 700; font-size: 14px;
}
.seg button + button { border-right: 1.5px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--navy); color: var(--white); }
:root[data-theme="dark"] .seg button[aria-pressed="true"] { background: var(--lime); color: var(--navy); }
.btn-small {
  height: 40px; padding: 0 18px; border-radius: 10px; border: 2px solid var(--text);
  background: transparent; color: var(--text); font-weight: 800; font-size: 14px;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
}

/* الفحص الذاتيّ */
.test-summary { padding: 14px 16px; font-weight: 800; border-bottom: 1px solid var(--line-2); }
.test-summary.pass { color: var(--green); }
.test-summary.fail { color: var(--red); }
.tests { list-style: none; margin: 0; padding: 0; }
.tests li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 16px; border-bottom: 1px solid var(--line-2); font-size: 14px; font-weight: 600; }
.tests li .mark { font-weight: 900; flex-shrink: 0; width: 22px; }
.tests li.pass .mark { color: var(--green); }
.tests li.fail .mark { color: var(--red); }
.tests li.skip .mark { color: var(--text-3); }
.tests li .detail { color: var(--text-2); font-size: 12px; display: block; }
#rerunTests { margin: 14px 16px; }

/* ---------- التذييل ---------- */
.footer {
  flex-shrink: 0;
  padding: 18px var(--pad);
  display: flex; align-items: center; justify-content: space-between;
  color: var(--text-2); font-size: 12px; font-weight: 600;
  border-top: 1px solid var(--line);
}
.logo-small {
  font-family: var(--font-brand); font-style: italic; font-weight: 800; font-size: 20px;
  color: var(--logo-on-bg); direction: ltr; unicode-bidi: isolate;
}
.logo-small .dot { color: var(--logo-dot-on-bg); }

/* ---------- الشاشات العريضة (من عرض الشاشة وحده) ---------- */
@media (min-width: 760px) {
  .hero { flex-direction: row; align-items: center; justify-content: space-between; gap: 24px; }
  .hero h1 { flex: 1; }
  .hero-row { display: flex; }
  .btn-start { padding: 0 46px; }
  .btn-ghost { padding: 0 18px; height: 54px; }
  .cols { flex-direction: row; align-items: flex-start; }
  .col { flex: 1; }
  .col-side { flex: 0 0 min(440px, 38%); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
