/* بنك الأسئلة الثقافية — متجاوب مع جميع الأجهزة */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* احترام خاصية hidden لعناصر المودال وغيرها */
[hidden] {
  display: none !important;
}

/* معاينة الداشبورد (?embed=1) — إخفاء تسجيل الخروج داخل الإطار */
html[data-embed="1"] #signOutBtn {
  display: none !important;
}

:root {
  --bg: #f0f4f3;
  --bg-card: #ffffff;
  --primary: #0d7377;
  --primary-dark: #095456;
  --accent: #ffb400;
  --accent-dark: #e6a200;
  --text: #1a1a1a;
  --text-muted: #555;
  --border: #e0e6e5;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(0,0,0,.08);
  --shadow-hover: 0 4px 20px rgba(0,0,0,.12);
  --font: "Tajawal", "Cairo", "Segoe UI", Arial, sans-serif;
  /* صعوبة */
  --easy: #2e7d32;
  --medium: #1565c0;
  --hard: #ef6c00;
  --extreme: #c62828;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* يمنع انضغاط المحتوى بعرض عمود ضيق */
#appScreen {
  width: 100%;
  max-width: 100%;
}

button { font-family: inherit; cursor: pointer; border: none; outline: none; }
input, select { font-family: inherit; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ========== الهيدر ========== */
.top-bar {
  background: var(--primary);
  color: #fff;
  padding: 1rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

.title-block h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.25rem; font-family:"Blabeloo",system-ui,sans-serif; }
.tagline { font-size: 0.875rem; opacity: .9; }

.top-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.search-input {
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,.3);
  background: rgba(255,255,255,.15);
  color: #fff;
  min-width: 180px;
  font-size: 0.9rem;
}
.search-input::placeholder { color: rgba(255,255,255,.7); }
.search-input:focus { background: rgba(255,255,255,.25); border-color: var(--accent); }

.btn {
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  transition: transform .15s, box-shadow .15s;
}
.btn:active { transform: scale(.98); }
.btn-accent { background: var(--accent); color: #1a1a1a; }
.btn-accent:hover { background: var(--accent-dark); color: #fff; }
.btn-outline { background: transparent; color: #fff; border: 2px solid rgba(255,255,255,.6); }
.btn-outline:hover { border-color: #fff; background: rgba(255,255,255,.1); }
/* زر الخروج في الهيدر: أوضح على الخلفية الداكنة */
.top-bar .btn-sign-out {
  background: rgba(255,255,255,.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,.5);
}
.top-bar .btn-sign-out:hover {
  background: rgba(255,255,255,.25);
  border-color: #fff;
}
.btn-ghost { background: transparent; color: var(--primary); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); }
.btn-small { padding: 0.35rem 0.75rem; font-size: 0.8rem; background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-small:hover { background: var(--border); }

/* ========== التخطيط الرئيسي (Grid + RTL: عمود يمين = شريط جانبي، يسار = المحتوى) ========== */
.layout {
  display: grid;
  width: 100%;
  max-width: 100%;
  grid-template-columns: 1fr;
  min-height: calc(100vh - 80px);
  align-items: stretch;
}
@media (min-width: 768px) {
  .layout {
    /* في RTL العمود الأول يُرسَم من يمين الشاشة */
    grid-template-columns: 280px minmax(0, 1fr);
  }
}

/* ========== الشريط الجانبي ========== */
.sidebar {
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  padding: 1rem;
  max-height: 70vh;
  overflow-y: auto;
}
@media (min-width: 768px) {
  .sidebar {
    max-height: none;
    min-height: calc(100vh - 80px);
  }
}

.stats-box h2, .filter-section h3 {
  font-size: 0.95rem;
  color: var(--primary);
  margin-bottom: 0.5rem;
  font-weight: 700;
}
.stats-box p { font-size: 0.875rem; margin-bottom: 0.25rem; color: var(--text-muted); }
.diff-bars { margin-top: 0.5rem; display: flex; flex-wrap: wrap; gap: 4px; }
.diff-bar {
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  color: #fff;
}
.diff-bar.easy { background: var(--easy); }
.diff-bar.medium { background: var(--medium); }
.diff-bar.hard { background: var(--hard); }
.diff-bar.extreme { background: var(--extreme); }

.filter-section { margin-top: 1.25rem; }
.stats-qna {
  font-size: 0.9rem;
  margin: 0.35rem 0 0;
  color: var(--medium, #475569);
}
.stats-qna strong {
  color: #4527a0;
}

.filter-hint {
  font-size: 0.75rem;
  color: var(--muted, #64748b);
  margin: 0 0 0.5rem;
  line-height: 1.35;
}

.filter-scroll { max-height: 200px; overflow-y: auto; }
.filter-scroll label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
  cursor: pointer;
}
.radio-group label { display: block; margin-bottom: 0.35rem; font-size: 0.9rem; cursor: pointer; }
.radio-group input { margin-left: 0.5rem; }
#resetFiltersBtn { width: 100%; margin-top: 1rem; padding: 0.6rem; }

/* ========== المحتوى الرئيسي ========== */
.main {
  padding: 1rem;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}
.toolbar-info { font-size: 0.9rem; color: var(--text-muted); }
.toolbar-check { font-size: 0.875rem; display: flex; align-items: center; gap: 0.5rem; cursor: pointer; }
.toolbar-check input { margin-left: 0.35rem; }
.per-page { font-size: 0.875rem; display: flex; align-items: center; gap: 0.5rem; }
.per-page select { padding: 0.35rem; border-radius: 6px; border: 1px solid var(--border); }

.loading, .error {
  text-align: center;
  padding: 2rem;
  font-size: 1.1rem;
}
.error { color: var(--extreme); }

.questions-grid {
  display: grid;
  gap: 1rem;
}
@media (min-width: 600px) {
  .questions-grid { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
}

/* ========== كرت السؤال ========== */
.question-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: box-shadow .2s;
}
.question-card:hover { box-shadow: var(--shadow-hover); }

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.badge {
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  font-weight: 600;
}
.badge.cat { background: #e3f2fd; color: var(--medium); }
.badge.easy { background: #e8f5e9; color: var(--easy); }
.badge.medium { background: #e3f2fd; color: var(--medium); }
.badge.hard { background: #fff3e0; color: var(--hard); }
.badge.extreme { background: #ffebee; color: var(--extreme); }
.badge.tf { background: #f3e5f5; color: #6a1b9a; }
.badge.mcq { background: #e0f2f1; color: #00695c; }
.badge.qna { background: #ede7f6; color: #4527a0; }
.badge.letter {
  background: #f1f5f9;
  color: var(--primary);
  border-radius: 999px;
}

/* علامة وناااسة في الفوتر */
@font-face {
  font-family: "Blabeloo";
  src: url("Blabeloo-font-v.1.0.ttf") format("truetype");
  font-display: swap;
}
.brand-mark {
  font-family: "Blabeloo", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0.03em;
  color: #f9d82e !important;
}
.brand-link {
  color: inherit;
  text-decoration: none;
  font-weight: 700;
}
.brand-link:hover {
  text-decoration: underline;
}

.card-q { font-size: 1rem; font-weight: 600; margin-bottom: 0.75rem; line-height: 1.5; }
.card-options { list-style: none; }
.card-options li {
  padding: 0.4rem 0.5rem;
  margin-bottom: 0.25rem;
  border-radius: 6px;
  font-size: 0.9rem;
  background: var(--bg);
}
.card-options li.correct { background: #e8f5e9; color: var(--easy); }
.card-source { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.5rem; }

/* ========== الترقيم ========== */
.pagination {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1.5rem;
  padding: 1rem 0;
}
.pagination button {
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.9rem;
}
.pagination button:hover { background: var(--bg); }
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination button:disabled { opacity: .5; cursor: not-allowed; }

/* ========== المودال (سؤال عشوائي) ========== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.5);
}
.modal-content {
  position: relative;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
}
.modal-close {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  width: 36px;
  height: 36px;
  font-size: 1.5rem;
  line-height: 1;
  background: var(--bg);
  border-radius: 50%;
  color: var(--text-muted);
}
.modal-close:hover { color: var(--text); background: var(--border); }

/* ========== أيباد / شاشات متوسطة ========== */
@media (min-width: 1024px) {
  .sidebar { width: 300px; }
  .main { padding: 1.5rem; }
}

/* ========== جوال: هيدر عمودي ========== */
@media (max-width: 767px) {
  .top-bar { flex-direction: column; align-items: stretch; text-align: center; }
  .top-actions { justify-content: center; }
  .search-input { min-width: 100%; }
}

/* ========== شاشة الدخول والحساب الموقوف ========== */
.auth-screen {
  min-height: 60vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}
.auth-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-hover);
  padding: 2rem;
  max-width: 400px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.auth-title { font-size: 1.5rem; color: var(--primary); margin-bottom: 0; }
.auth-subtitle { color: var(--text-muted); font-size: 0.95rem; margin: 0; }
.auth-error {
  color: #c62828;
  font-size: 0.9rem;
  padding: 0.5rem;
  background: rgba(198, 40, 40, 0.08);
  border-radius: 8px;
}
.auth-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
}
.auth-input:focus { outline: none; border-color: var(--primary); }
.auth-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.5rem;
}
/* أزرار شاشة الدخول: وضوح على خلفية بيضاء */
.auth-card .btn-outline {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
}
.auth-card .btn-outline:hover {
  background: rgba(13, 115, 119, 0.08);
  border-color: var(--primary-dark);
}
.auth-card--blocked .auth-title { color: #c62828; }
.auth-card--blocked .auth-subtitle { margin-bottom: 0.5rem; }
.auth-card--blocked .btn-outline {
  color: var(--text);
  border-color: var(--border);
}
.auth-card--blocked .btn-outline:hover {
  background: var(--bg);
  border-color: var(--text-muted);
}

/* ========== تذييل الحقوق ========== */
.credit-footer {
  text-align: center;
  padding: 14px 12px;
  font-size: 12px;
  color: var(--text-muted);
  opacity: 0.85;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.credit-footer .credit-by { font-weight: 600; }
.credit-footer .credit-rights { font-size: 11px; opacity: 0.9; }
