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

/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #0f3460;
  --secondary: #16213e;
  --accent: #e94560;
  --text-dark: #1a1a2e;
  --text-light: #f5f7fa;
  --bg-body: #f0f2f5;
  --card-bg: #ffffff;
  --border-color: #e2e8f0;
  --success: #22c55e;
  --error: #ef4444;
  --warning: #f59e0b;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

html { 
  font-size: 16px; 
  -webkit-text-size-adjust: 100%; 
  scroll-behavior: smooth;
}

body {
  font-family: 'Almarai', 'Segoe UI', Tahoma, sans-serif;
  background: var(--bg-body);
  color: var(--text-dark);
  direction: rtl;
  min-height: 100vh;
  padding-bottom: 4rem;
  line-height: 1.6;
}

/* ===== HEADER ===== */
.header {
  background: linear-gradient(135deg, var(--secondary) 0%, var(--primary) 100%);
  color: #fff;
  padding: 1.25rem 1rem;
  position: relative;
  overflow: hidden;
}

.header::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(233,69,96,0.05) 0%, transparent 70%);
  pointer-events: none;
}

.header-content {
  max-width: 1000px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
}

.header-text {
  flex: 1;
  text-align: right;
}

.header h1 { 
  font-size: 1.5rem; 
  font-weight: 800; 
  line-height: 1.2;
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header p { 
  font-size: 0.85rem; 
  opacity: 0.85; 
  margin-bottom: 0.75rem;
  font-weight: 400;
}

.header-badge {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.35rem 1rem;
  border-radius: 50px;
  box-shadow: 0 4px 10px rgba(233,69,96,0.3);
}

.logo-container {
  flex-shrink: 0;
}

.logo-img {
  max-width: 160px;
  height: auto;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.2));
}

/* ===== STICKY NAV ===== */
.nav-wrap {
  position: sticky;
  top: 0;
  z-index: 9999;
  background: rgba(15, 52, 96, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 0.6rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  white-space: nowrap;
  scrollbar-width: none;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.nav-wrap::-webkit-scrollbar { display: none; }

.nav-btn {
  display: inline-block;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.85);
  padding: 0.5rem 1.2rem;
  border-radius: 12px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  margin-left: 0.5rem;
  transition: var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.nav-btn:first-child { margin-left: 0; }

.nav-btn.active, .nav-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(233,69,96,0.4);
}

.nav-btn:active {
  transform: translateY(0);
}

/* ===== MAIN CONTENT ===== */
.content { 
  max-width: 800px; 
  margin: 0 auto; 
  padding: 1.5rem 1rem; 
}

/* ===== EXAM SECTION ===== */
.exam-sec { display: none; animation: fadeIn 0.4s ease-out; }
.exam-sec.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.exam-banner {
  background: linear-gradient(135deg, var(--secondary), var(--primary));
  border-radius: 16px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  color: #fff;
  box-shadow: var(--shadow-md);
}

.exam-year { font-size: 1.4rem; font-weight: 800; }
.exam-sub { font-size: 0.9rem; opacity: 0.85; margin-top: 0.3rem; }

/* ===== QUESTION BLOCK ===== */
.q-block {
  background: var(--card-bg);
  border-radius: 16px;
  margin-bottom: 1.5rem;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  transition: var(--transition);
}

.q-block:hover {
  box-shadow: var(--shadow-md);
}

.q-head {
  background: #f8fafc;
  color: var(--primary);
  padding: 1rem 1.25rem;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.4;
  border-bottom: 1px solid var(--border-color);
}

.q-body { padding: 1.25rem; }

/* ===== REF TAG ===== */
.ref-tag {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: #64748b;
  margin-top: 1rem;
  font-weight: 600;
}

/* ===== TRUE/FALSE ===== */
.tf-item {
  display: flex;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border-color);
  align-items: flex-start;
}

.tf-item:last-child { border-bottom: none; padding-bottom: 0; }
.tf-item:first-child { padding-top: 0; }

.tf-badge {
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 800;
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
  line-height: 1;
}

.tf-ok .tf-badge { background: #dcfce7; color: #15803d; }
.tf-err .tf-badge { background: #fee2e2; color: #b91c1c; }

.tf-body { flex: 1; min-width: 0; }
.tf-text { font-size: 1rem; line-height: 1.6; color: var(--text-dark); font-weight: 500; }

.tf-fix {
  background: #fffbeb;
  border-right: 4px solid var(--warning);
  padding: 0.75rem 1rem;
  margin-top: 0.75rem;
  font-size: 0.9rem;
  border-radius: 4px 12px 12px 4px;
  color: #92400e;
  line-height: 1.6;
}

.fix-label { font-weight: 800; margin-left: 0.3rem; color: #b45309; }

/* ===== COMPLETE ===== */
.comp-item {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border-color);
}

.comp-item:last-child { border-bottom: none; padding-bottom: 0; }
.comp-item:first-child { padding-top: 0; }

.comp-q { 
  font-size: 1rem; 
  font-weight: 700; 
  color: var(--text-dark); 
  margin-bottom: 0.75rem; 
  line-height: 1.6; 
}

.comp-blanks { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.blank-pill {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  padding: 0.4rem 1rem;
  font-size: 0.9rem;
  font-weight: 700;
  transition: var(--transition);
}

.blank-pill:hover {
  background: #dbeafe;
  transform: scale(1.02);
}

/* ===== MCQ ===== */
.mcq-item {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border-color);
}

.mcq-item:last-child { border-bottom: none; padding-bottom: 0; }
.mcq-item:first-child { padding-top: 0; }

.mcq-q { font-size: 1rem; font-weight: 700; margin-bottom: 0.75rem; line-height: 1.6; }
.mcq-opts { display: flex; flex-direction: column; gap: 0.5rem; }

.mcq-opt {
  background: #f8fafc;
  color: #475569;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  transition: var(--transition);
}

.mcq-correct {
  background: #dcfce7;
  color: #15803d;
  border-color: #86efac;
  font-weight: 800;
}

/* ===== ESSAY ===== */
.essay-item {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border-color);
}

.essay-item:last-child { border-bottom: none; padding-bottom: 0; }
.essay-item:first-child { padding-top: 0; }

.essay-q {
  background: #eff6ff;
  border-right: 4px solid #3b82f6;
  padding: 0.75rem 1.25rem;
  font-size: 1.05rem;
  font-weight: 800;
  color: #1d4ed8;
  border-radius: 4px 12px 12px 4px;
  margin-bottom: 0.75rem;
  line-height: 1.6;
}

.essay-a {
  font-size: 0.95rem;
  line-height: 1.8;
  color: #334155;
  background: #f1f5f9;
  border-radius: 12px;
  padding: 1rem 1.25rem;
}

/* ===== COMPARE TABLE ===== */
.compare-item { margin-bottom: 1.5rem; }
.compare-item:last-child { margin-bottom: 0; }

.compare-title {
  font-size: 1rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 0.75rem;
  line-height: 1.5;
}

.table-scroll { 
  overflow-x: auto; 
  -webkit-overflow-scrolling: touch; 
  border-radius: 12px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.cmp-table {
  width: 100%;
  min-width: 500px;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.cmp-table th {
  background: var(--primary);
  color: #fff;
  padding: 0.8rem 1rem;
  text-align: center;
  font-weight: 700;
  border: 1px solid rgba(255,255,255,0.1);
}

.cmp-table td {
  padding: 0.8rem 1rem;
  border: 1px solid var(--border-color);
  line-height: 1.6;
  vertical-align: top;
  background: #fff;
}

.cmp-table tr:nth-child(even) td { background: #f8fafc; }

/* ===== SCROLL TO TOP ===== */
.scroll-top {
  position: fixed;
  bottom: 1.5rem;
  left: 1.5rem;
  width: 50px;
  height: 50px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 16px;
  font-size: 1.5rem;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 25px rgba(233,69,96,0.4);
  z-index: 999;
  transition: var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.scroll-top:hover {
  transform: translateY(-5px);
  background: #d43d55;
}

.scroll-top.visible { display: flex; }

/* ===== MOBILE RESPONSIVENESS ===== */
@media (max-width: 600px) {
  html { font-size: 15px; }
  
  .header { padding: 1rem; }
  .header-content { flex-direction: column-reverse; text-align: center; gap: 0.75rem; }
  .header-text { text-align: center; }
  .header h1 { justify-content: center; font-size: 1.3rem; }
  .logo-img { max-width: 120px; }
  
  .content { padding: 1rem 0.75rem; }
  
  .nav-wrap { padding: 0.5rem; }
  .nav-btn { padding: 0.45rem 1rem; font-size: 0.8rem; }
  
  .q-head { padding: 0.85rem 1rem; font-size: 0.95rem; }
  .q-body { padding: 1rem; }
  
  .tf-item { gap: 0.75rem; }
  .tf-text { font-size: 0.95rem; }
  
  .essay-q { font-size: 1rem; padding: 0.6rem 1rem; }
  .essay-a { font-size: 0.9rem; padding: 0.85rem 1rem; }
  
  .scroll-top { bottom: 1rem; left: 1rem; width: 45px; height: 45px; }
}

@media (max-width: 400px) {
  .exam-year { font-size: 1.2rem; }
  .nav-btn { padding: 0.4rem 0.8rem; }
}
