/* =============================================================================
   css/repertoire/repertoire.css
   ─────────────────────────────────────────────────────────────────────────────
   OcuLearning — Clinical Repertoire Page Styles  (v2 — احترافي مُطوَّر)
   Scope: repertoire.html + standalone repertoire pages (all selectors .rep-*)

   Palette & tokens re-use the same CSS variables as index.html where available.
   Standalone pages define sane fallbacks so the page looks correct without shell.
   ============================================================================= */

/* ── Design Tokens ─────────────────────────────────────────────────────────── */
:root {
  --rep-font-sans:  'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --rep-font-serif: 'Fraunces', 'Georgia', 'Times New Roman', serif;
  --rep-font-mono:  'IBM Plex Mono', 'Courier New', monospace;

  /* Brand */
  --rep-brand:     #0d3b66;
  --rep-accent:    #1976d2;
  --rep-accent-lt: #e3f2fd;
  --rep-accent-dk: #0d47a1;

  /* Surfaces */
  --rep-bg:          #f4f6f9;
  --rep-surface:     #ffffff;
  --rep-surface-2:   #f8fafc;
  --rep-border:      #e1e8f0;
  --rep-border-soft: #edf1f7;

  /* Shadows */
  --rep-shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --rep-shadow-md: 0 4px 16px rgba(0,0,0,.08), 0 2px 6px rgba(0,0,0,.04);
  --rep-shadow-lg: 0 12px 40px rgba(0,0,0,.12), 0 4px 12px rgba(0,0,0,.06);

  /* Typography */
  --rep-text:       #1a2332;
  --rep-text-muted: #5f7284;
  --rep-text-faint: #8fa3b8;
  --rep-heading:    #0d2137;

  /* Section semantic colours */
  --rep-red:            #c62828;
  --rep-red-bg:         #fff5f5;
  --rep-red-border:     #ffcdd2;
  --rep-red-light:      #ffebee;

  --rep-amber:          #bf6000;
  --rep-amber-bg:       #fffbf0;
  --rep-amber-border:   #ffe082;
  --rep-amber-light:    #fff8e1;

  --rep-green:          #2e7d32;
  --rep-green-bg:       #f1f8f1;
  --rep-green-border:   #c8e6c9;
  --rep-green-light:    #e8f5e9;

  --rep-blue:           #01579b;
  --rep-blue-bg:        #e8f4fd;
  --rep-blue-border:    #bee3f8;

  --rep-gold:           #b08d00;
  --rep-gold-bg:        #fffef5;
  --rep-gold-border:    #f9e08c;

  --rep-purple:         #5c35a0;
  --rep-purple-bg:      #f5f0ff;
  --rep-purple-border:  #d9c8f5;

  /* Layout */
  --rep-sidebar-w: 260px;
  --rep-header-h:  64px;
  --rep-radius:    14px;
  --rep-radius-sm: 10px;
  --rep-radius-xs: 7px;
}

/* ── Reset + Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body.rep-page {
  font-family: var(--rep-font-sans);
  background: var(--rep-bg);
  color: var(--rep-text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================================
   READING PROGRESS BAR (يظهر أعلى الصفحة أثناء التمرير)
   ============================================================================ */
.rep-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 9999;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, #1976d2, #42a5f5, #1976d2);
  background-size: 200% 100%;
  animation: rep-progress-shimmer 2s linear infinite;
  transition: width 80ms linear;
  pointer-events: none;
  border-radius: 0 2px 2px 0;
}

@keyframes rep-progress-shimmer {
  0%   { background-position: 0% 0; }
  100% { background-position: 200% 0; }
}

/* ============================================================================
   SITE HEADER
   ============================================================================ */
.rep-header {
  position: sticky;
  top: 0;
  z-index: 200;
  height: var(--rep-header-h);
  background: var(--rep-brand);
  display: flex;
  align-items: center;
  padding: 0 2rem;
  gap: 2.5rem;
  box-shadow: 0 2px 12px rgba(0,0,0,.3);
}

.rep-header-brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  flex-shrink: 0;
}

.rep-header-brand img {
  width: 30px;
  height: 30px;
  border-radius: 6px;
}

.rep-header-brand-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.02em;
}

.rep-header-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex: 1;
}

.rep-header-nav a {
  padding: 0.45rem 0.9rem;
  border-radius: 7px;
  font-size: 0.9rem;
  font-weight: 500;
  color: rgba(255,255,255,.75);
  text-decoration: none;
  transition: background 150ms ease, color 150ms ease;
}

.rep-header-nav a:hover  { background: rgba(255,255,255,.1); color: #fff; }
.rep-header-nav a.active { background: rgba(255,255,255,.18); color: #fff; font-weight: 600; }

/* ============================================================================
   REPERTOIRE LIST VIEW
   ============================================================================ */
.rep-list-view  { display: block; background: #f4f7f9; min-height: 100vh; }
.rep-detail-view { display: none; }

/* ── Hero ── */
.rep-hero {
  position: relative;
  width: 100%;
  padding: 4rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 0%, #ffffff 0%, #f4f7f9 70%);
}

.rep-hero-watermark {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 800px;
  height: 800px;
  opacity: 0.7;
  pointer-events: none;
  z-index: 0;
}

.rep-hero-content {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 800px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.rep-search-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: #1976d2;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 1rem;
}

/* ── Search ── */
.rep-search-wrap {
  position: relative;
  width: 100%;
  margin-bottom: 1.5rem;
}

.rep-search-icon {
  position: absolute;
  left: 1.5rem;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  color: #8fa3b8;
  pointer-events: none;
}

.rep-search {
  width: 100%;
  padding: 1.2rem 1.5rem 1.2rem 3.5rem;
  border: 1.5px solid #d1d9e2;
  border-radius: 50px;
  font-family: var(--rep-font-sans);
  font-size: 1.05rem;
  color: var(--rep-text);
  background: #ffffff;
  outline: none;
  box-shadow: 0 4px 24px rgba(0,0,0,.06);
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

.rep-search:focus {
  border-color: #1976d2;
  box-shadow: 0 0 0 4px rgba(25,118,210,.1);
}

.rep-search::placeholder { color: #8fa3b8; }

/* ── Randomize Button ── */
.rep-btn-random {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  border-radius: 50px;
  border: 1px solid #cbe0fa;
  background: rgba(255,255,255,0.7);
  color: #1976d2;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  cursor: pointer;
  margin-bottom: 2rem;
  transition: background 150ms ease, border-color 150ms ease;
}

.rep-btn-random svg { width: 16px; height: 16px; }
.rep-btn-random:hover { background: #ffffff; border-color: #1976d2; }

/* ── Most Searched ── */
.rep-most-searched-title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: #1976d2;
  letter-spacing: 0.08em;
  margin-bottom: 0.75rem;
}

.rep-most-searched-title svg { width: 14px; height: 14px; }

.rep-most-searched-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 2rem;
}

.rep-ms-tag {
  background: #ffffff;
  border: 1px solid #e1e8f0;
  padding: 0.4rem 1rem;
  border-radius: 50px;
  font-size: 0.85rem;
  color: #5f7284;
  cursor: pointer;
  transition: border-color 150ms, color 150ms;
}
.rep-ms-tag:hover { border-color: #1976d2; color: #1976d2; }

/* ── Category filter pills ── */
.rep-filter-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}

.rep-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 1rem;
  border-radius: 50px;
  border: 1.5px solid #e1e8f0;
  background: #ffffff;
  font-size: 0.85rem;
  font-weight: 500;
  color: #5f7284;
  cursor: pointer;
  transition: all 180ms ease;
  user-select: none;
}

.rep-pill:hover           { border-color: #cbe0fa; background: #f4f9ff; }
.rep-pill.active          { border-color: var(--pill-color, #1976d2); background: color-mix(in srgb, var(--pill-color, #1976d2) 12%, transparent); color: var(--pill-color, #1976d2); font-weight: 600; }

.rep-pill-count           { font-size: 0.75rem; color: #8fa3b8; margin-left: 0.2rem; }
.rep-pill.active .rep-pill-count { color: currentColor; }

/* ── Grid Wrapper ── */
.rep-wrapper {
  max-width: 920px;
  margin: 0 auto;
  padding: 0 1.5rem 4rem;
}

/* ── Results bar ── */
#repResultsBar {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--rep-text-faint);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 1rem;
  padding-left: 0.25rem;
}

/* ── Conditions grid ── */
.rep-grid {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

/* ── Condition card ── */
.rep-card {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.8rem 1.25rem;
  background: #ffffff;
  border: 1.5px solid #edf1f7;
  border-radius: var(--rep-radius-sm);
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 1px 6px rgba(0,0,0,.04);
  transition:
    border-color 180ms ease,
    box-shadow   180ms ease,
    transform    120ms ease,
    opacity      200ms ease;
}

.rep-card:hover {
  border-color: #a8ccf5;
  box-shadow: 0 6px 20px rgba(25,118,210,.1);
  transform: translateY(-2px);
}

.rep-card:focus-visible {
  outline: 2px solid #1976d2;
  outline-offset: 2px;
}

/* Card thumbnail */
.rep-card-thumb {
  flex-shrink: 0;
  width: 50px;
  height: 50px;
  border-radius: 10px;
  overflow: hidden;
  background: #f8fafc;
  border: 1px solid #edf1f7;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rep-card-thumb img { width: 100%; height: 100%; object-fit: cover; }

.rep-card-thumb-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  background: linear-gradient(135deg, #eef3f8 0%, #dde6f0 100%);
  color: #8fa3b8;
}

/* Card text */
.rep-card-body { flex: 1; min-width: 0; }

.rep-card-title {
  font-size: 0.98rem;
  font-weight: 600;
  color: #1a2332;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rep-card-subtitle {
  font-size: 0.82rem;
  color: #8fa3b8;
  margin-top: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Category badge */
.rep-badge {
  flex-shrink: 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: #5f7284;
  background: #f0f4f8;
  padding: 0.2rem 0.65rem;
  border-radius: 50px;
  border: 1px solid #e1e8f0;
}

/* Card arrow */
.rep-card-arrow {
  flex-shrink: 0;
  color: #c5d3de;
  font-size: 1.3rem;
  margin-left: 0.25rem;
  transition: color 150ms, transform 150ms;
}
.rep-card:hover .rep-card-arrow { color: #1976d2; transform: translateX(3px); }

/* Empty state */
.rep-empty { text-align: center; padding: 3rem 1rem; color: var(--rep-text-muted); }
.rep-empty-icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.rep-empty p { font-size: 0.95rem; }


/* ============================================================================
   DETAIL VIEW
   ============================================================================ */

/* Back button */
.rep-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--rep-accent);
  background: var(--rep-accent-lt);
  border: 1px solid transparent;
  border-radius: 50px;
  cursor: pointer;
  padding: 0.5rem 1rem;
  margin-bottom: 1.5rem;
  transition: background 150ms ease, border-color 150ms;
}
.rep-back-btn:hover { background: #d1e9ff; border-color: #a8ccf5; }
.rep-back-btn svg   { width: 16px; height: 16px; }

/* Detail page layout */
.rep-detail-wrapper {
  max-width: 1160px;
  margin: 0 auto;
  padding: 2rem 1.5rem 6rem;
}

.rep-detail-layout {
  display: grid;
  grid-template-columns: var(--rep-sidebar-w) 1fr;
  gap: 2.25rem;
  align-items: flex-start;
}

/* ── Detail header card ── */
.rep-detail-header {
  background: linear-gradient(135deg, #ffffff 0%, #f8fafd 100%);
  border: 1.5px solid var(--rep-border);
  border-radius: var(--rep-radius);
  padding: 1.75rem 2rem;
  margin-bottom: 2rem;
  box-shadow: var(--rep-shadow-md);
  position: relative;
  overflow: hidden;
}

/* subtle decorative corner accent */
.rep-detail-header::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 200px; height: 200px;
  background: radial-gradient(circle at top right, rgba(25,118,210,.06), transparent 70%);
  pointer-events: none;
}

.rep-detail-header-top {
  display: flex;
  align-items: flex-start;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.rep-detail-title {
  font-family: var(--rep-font-serif);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--rep-heading);
  letter-spacing: -0.025em;
  line-height: 1.2;
  flex: 1;
}

.rep-detail-subtitle {
  font-size: 0.95rem;
  color: var(--rep-text-muted);
  margin-top: 0.4rem;
  font-style: italic;
}

.rep-detail-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}

/* Category badge (inside header) */
.rep-detail-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.9rem;
  border-radius: 50px;
  font-size: 0.82rem;
  font-weight: 600;
  border: 1.5px solid transparent;
  letter-spacing: 0.01em;
}

/* Reading time chip */
.rep-reading-time {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--rep-text-faint);
  background: var(--rep-surface-2);
  border: 1px solid var(--rep-border-soft);
  padding: 0.3rem 0.75rem;
  border-radius: 50px;
}
.rep-reading-time svg { width: 13px; height: 13px; }

/* ── Navigation sidebar (sticky) ── */
.rep-detail-nav {
  position: sticky;
  top: calc(var(--rep-header-h) + 1rem);
  background: var(--rep-surface);
  border: 1.5px solid var(--rep-border);
  border-radius: var(--rep-radius);
  padding: 1.25rem 1rem;
  box-shadow: var(--rep-shadow-sm);
  max-height: calc(100vh - var(--rep-header-h) - 2rem);
  overflow-y: auto;
}

.rep-detail-nav-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--rep-text-faint);
  margin-bottom: 0.85rem;
  padding: 0 0.5rem 0.6rem;
  border-bottom: 1px solid var(--rep-border-soft);
}

.rep-nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.rep-nav-list a {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--rep-radius-xs);
  font-size: 0.83rem;
  color: var(--rep-text-muted);
  text-decoration: none;
  transition: all 160ms ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  position: relative;
  border-left: 2.5px solid transparent;
}

.rep-nav-list a:hover {
  background: var(--rep-accent-lt);
  color: var(--rep-accent);
}

/* Active state with animated left indicator */
.rep-nav-list a.active {
  background: linear-gradient(90deg, #e3f2fd 0%, #f0f8ff 100%);
  color: var(--rep-accent-dk);
  font-weight: 600;
  border-left-color: var(--rep-accent);
}

.rep-nav-list a .rep-nav-icon { font-size: 0.9rem; flex-shrink: 0; opacity: 0.7; }
.rep-nav-list a.active .rep-nav-icon { opacity: 1; }

/* Section-specific nav colours */
.rep-nav-list a.nav-red-flags           { color: #c62828; }
.rep-nav-list a.nav-red-flags:hover,
.rep-nav-list a.nav-red-flags.active    { background: #fff0f0; color: #c62828; border-left-color: #c62828; }

.rep-nav-list a.nav-pearl               { color: #bf6000; }
.rep-nav-list a.nav-pearl:hover,
.rep-nav-list a.nav-pearl.active        { background: #fff8e1; color: #bf6000; border-left-color: #bf6000; }

/* Completion checkmark in nav */
.rep-nav-check {
  margin-left: auto;
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--rep-green);
  color: #fff;
  font-size: 0.55rem;
  display: none;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}
.rep-nav-list a.completed .rep-nav-check { display: flex; }

/* ── Detail content column ── */
.rep-detail-content {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

/* ── Images section ── */
.rep-images-section {
  background: var(--rep-surface);
  border: 1.5px solid var(--rep-border);
  border-radius: var(--rep-radius);
  overflow: hidden;
  box-shadow: var(--rep-shadow-sm);
}

.rep-images-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.9rem 1.5rem;
  border-bottom: 1px solid var(--rep-border-soft);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--rep-heading);
  background: var(--rep-surface-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Image placeholder */
.rep-image-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 2rem 1.5rem;
  background: linear-gradient(135deg, #f5f8fb 0%, #ebf0f7 100%);
  border: 2px dashed #c5d3de;
  border-radius: var(--rep-radius-sm);
  margin: 1rem 1.5rem 1.25rem;
  text-align: center;
  min-height: 140px;
}

.rep-image-placeholder-icon  { font-size: 2rem; opacity: 0.35; }
.rep-image-placeholder-label { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--rep-text-faint); }
.rep-image-placeholder-text  { font-size: 0.82rem; color: var(--rep-text-faint); line-height: 1.5; }

/* Gallery */
.rep-image-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
  padding: 1rem 1.5rem 1.25rem;
}

.rep-gallery-item { display: flex; flex-direction: column; gap: 0.4rem; }

.rep-gallery-item img {
  width: 100%;
  border-radius: var(--rep-radius-xs);
  border: 1px solid var(--rep-border);
  object-fit: cover;
  transition: transform 200ms ease;
}
.rep-gallery-item img:hover { transform: scale(1.02); }

.rep-gallery-caption {
  font-size: 0.78rem;
  color: var(--rep-text-faint);
  text-align: center;
  font-style: italic;
}

/* ============================================================================
   CLINICAL SECTION CARDS (main redesign)
   ============================================================================ */

.rep-section {
  background: var(--rep-surface);
  border: 1.5px solid var(--rep-border);
  border-radius: var(--rep-radius);
  overflow: hidden;
  box-shadow: var(--rep-shadow-sm);
  scroll-margin-top: calc(var(--rep-header-h) + 1.5rem);
  transition: box-shadow 200ms ease;
}

.rep-section:hover {
  box-shadow: var(--rep-shadow-md);
}

/* Section header bar */
.rep-section-header {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.85rem 1.5rem;
  border-bottom: 1px solid var(--rep-border-soft);
  background: linear-gradient(90deg, var(--rep-surface-2) 0%, var(--rep-surface) 100%);
}

.rep-section-icon {
  font-size: 1rem;
  line-height: 1;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--rep-accent-lt);
  display: flex;
  align-items: center;
  justify-content: center;
}

.rep-section-title {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--rep-heading);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  flex: 1;
}

/* Section body */
.rep-section-body {
  padding: 1.35rem 1.5rem;
}

/* ── Bullet list ── */
.rep-bullet-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.rep-bullet-list li {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  font-size: 0.915rem;
  line-height: 1.65;
  color: var(--rep-text);
}

.rep-bullet-list li::before {
  content: '';
  flex-shrink: 0;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--rep-accent);
  margin-top: 0.55em;
}

/* ── Signature Finding card ── */
.rep-signature-finding {
  background: linear-gradient(135deg, #fffef7 0%, #fef9e4 100%);
  border: 1.5px solid var(--rep-gold-border);
  border-left: 4px solid var(--rep-gold);
  border-radius: var(--rep-radius-xs);
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
  position: relative;
}

.rep-signature-label {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--rep-gold);
  margin-bottom: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.rep-signature-finding p {
  font-size: 0.915rem;
  line-height: 1.65;
  color: var(--rep-text);
  font-weight: 500;
}

/* ── RED FLAGS section ── */
.rep-section.section-red-flags {
  border-color: var(--rep-red-border);
  border-left: 4px solid var(--rep-red);
}

.rep-section.section-red-flags .rep-section-header {
  background: linear-gradient(90deg, var(--rep-red-light) 0%, var(--rep-surface) 100%);
  border-bottom-color: var(--rep-red-border);
}

.rep-section.section-red-flags .rep-section-icon {
  background: #ffcdd2;
}

.rep-section.section-red-flags .rep-section-title { color: var(--rep-red); }

/* Red flag alert box */
.rep-red-flag-alert {
  background: linear-gradient(135deg, #fff5f5 0%, #fff0f0 100%);
  border: 1.5px solid var(--rep-red-border);
  border-radius: var(--rep-radius-xs);
  padding: 1rem 1.1rem;
  margin-bottom: 0.5rem;
}

.rep-red-flag-alert-title {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--rep-red);
  margin-bottom: 0.65rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* Red flags bullet with ⚠ */
.rep-section.section-red-flags .rep-bullet-list li::before {
  content: '';
  width: 8px;
  height: 8px;
  background: var(--rep-red);
  border-radius: 2px;
  transform: rotate(45deg);
  margin-top: 0.5em;
}

/* ── CLINICAL PEARL section ── */
.rep-section.section-pearl {
  border-color: var(--rep-amber-border);
  border-left: 4px solid var(--rep-amber);
}

.rep-section.section-pearl .rep-section-header {
  background: linear-gradient(90deg, var(--rep-amber-light) 0%, var(--rep-surface) 100%);
  border-bottom-color: var(--rep-amber-border);
}

.rep-section.section-pearl .rep-section-icon { background: var(--rep-amber-border); }
.rep-section.section-pearl .rep-section-title { color: var(--rep-amber); }

.rep-pearl-card {
  background: linear-gradient(135deg, #fffdf5 0%, #fff9e6 100%);
  border: 1.5px solid var(--rep-amber-border);
  border-radius: var(--rep-radius-sm);
  padding: 1.25rem 1.35rem;
  position: relative;
}

.rep-pearl-card::before {
  content: '"';
  position: absolute;
  top: -0.5rem;
  left: 1rem;
  font-family: var(--rep-font-serif);
  font-size: 4rem;
  color: var(--rep-amber-border);
  line-height: 1;
  pointer-events: none;
}

.rep-pearl-text {
  font-family: var(--rep-font-serif);
  font-size: 1.05rem;
  line-height: 1.7;
  color: #3e2e00;
  font-style: italic;
  padding-top: 0.75rem;
}

/* ── First-Line Treatment highlight ── */
.rep-treatment-primary {
  background: linear-gradient(135deg, var(--rep-green-light) 0%, #edfaed 100%);
  border: 1.5px solid var(--rep-green-border);
  border-left: 4px solid var(--rep-green);
  border-radius: var(--rep-radius-xs);
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
  font-size: 0.915rem;
  line-height: 1.65;
  color: var(--rep-text);
}

.rep-treatment-primary-label {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--rep-green);
  margin-bottom: 0.35rem;
}

/* ── Management — numbered steps ── */
.rep-steps-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.rep-steps-list li {
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
  font-size: 0.915rem;
  line-height: 1.65;
  color: var(--rep-text);
}

.rep-step-num {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  background: linear-gradient(135deg, #1976d2, #42a5f5);
  color: #fff;
  border-radius: 50%;
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.15rem;
  box-shadow: 0 2px 6px rgba(25,118,210,.25);
}

/* ── Differential Diagnoses table ── */
.rep-ddx-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.rep-ddx-table th {
  text-align: left;
  padding: 0.65rem 1.25rem;
  background: var(--rep-surface-2);
  border-bottom: 2px solid var(--rep-border);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--rep-text-muted);
}

.rep-ddx-table td {
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--rep-border-soft);
  line-height: 1.6;
  vertical-align: top;
}

/* Alternating rows */
.rep-ddx-table tbody tr:nth-child(even) td { background: #fafbfd; }
.rep-ddx-table tr:last-child td             { border-bottom: none; }
.rep-ddx-table tbody tr:hover td            { background: var(--rep-accent-lt); }

.rep-ddx-condition {
  font-weight: 700;
  color: var(--rep-heading);
  width: 35%;
}

/* ── References section ── */
.rep-section.section-references { border-color: var(--rep-border-soft); }

.rep-ref-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  counter-reset: ref-counter;
}

.rep-ref-list li {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  font-size: 0.85rem;
  line-height: 1.55;
  color: var(--rep-text-muted);
  counter-increment: ref-counter;
}

.rep-ref-list li::before {
  content: counter(ref-counter) '.';
  flex-shrink: 0;
  font-weight: 700;
  color: var(--rep-text-faint);
  min-width: 20px;
  font-size: 0.78rem;
}

.rep-ref-list a {
  color: var(--rep-accent);
  text-decoration: none;
  word-break: break-all;
  transition: color 150ms ease;
}
.rep-ref-list a:hover { color: var(--rep-accent-dk); text-decoration: underline; }

/* ============================================================================
   PREV / NEXT NAVIGATION
   ============================================================================ */
.rep-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid var(--rep-border-soft);
}

.rep-pag-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.1rem;
  border-radius: var(--rep-radius-xs);
  border: 1.5px solid var(--rep-border);
  background: var(--rep-surface);
  color: var(--rep-text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 180ms ease;
  flex: 1;
  max-width: 220px;
}

.rep-pag-btn:hover {
  border-color: var(--rep-accent);
  color: var(--rep-accent);
  background: var(--rep-accent-lt);
}

.rep-pag-btn.next { justify-content: flex-end; margin-left: auto; }
.rep-pag-btn.prev { justify-content: flex-start; }
.rep-pag-btn svg  { width: 16px; height: 16px; flex-shrink: 0; }

.rep-pag-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  display: block;
  color: var(--rep-text-faint);
}
.rep-pag-name { font-size: 0.88rem; font-weight: 600; color: inherit; }

.rep-pag-center {
  font-size: 0.78rem;
  color: var(--rep-text-faint);
  text-align: center;
  white-space: nowrap;
}

/* ============================================================================
   JUMP-TO-TOP BUTTON
   ============================================================================ */
.rep-jump-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 500;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--rep-accent);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(25,118,210,.35);
  opacity: 0;
  transform: translateY(16px) scale(0.9);
  transition: opacity 250ms ease, transform 250ms ease;
  pointer-events: none;
}

.rep-jump-top.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.rep-jump-top:hover {
  background: var(--rep-accent-dk);
  box-shadow: 0 6px 20px rgba(25,118,210,.45);
  transform: translateY(-2px) scale(1.05);
}

.rep-jump-top svg { width: 20px; height: 20px; }

/* ============================================================================
   STANDALONE REPERTOIRE PAGE (inline overrides for *.html pages)
   ============================================================================ */

/* Override styles used in standalone pages */
.rep-page-wrapper {
  max-width: 1200px;
  margin: 0 auto;
  padding: 3rem 1.5rem 5rem;
  font-family: var(--rep-font-sans);
}

.rep-back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--rep-accent);
  background: var(--rep-accent-lt);
  padding: 0.4rem 1rem;
  border-radius: 50px;
  text-decoration: none;
  margin-bottom: 2rem;
  transition: background 150ms, color 150ms;
  border: 1px solid transparent;
}
.rep-back-link:hover { background: #d1e9ff; border-color: #a8ccf5; }
.rep-back-link svg   { width: 16px; height: 16px; }

/* ── Standalone header ── */
.rep-standalone-header {
  margin-bottom: 2.5rem;
  border-bottom: 1px solid var(--rep-border);
  padding-bottom: 2rem;
}

.rep-standalone-title {
  font-family: var(--rep-font-serif);
  font-size: 2.6rem;
  font-weight: 700;
  color: var(--rep-heading);
  margin-bottom: 0.4rem;
  line-height: 1.2;
}

.rep-standalone-subtitle {
  font-size: 1.15rem;
  color: var(--rep-text-muted);
  margin-bottom: 1.25rem;
  font-style: italic;
}

.rep-standalone-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.rep-standalone-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 1rem;
  border-radius: 50px;
  font-size: 0.82rem;
  font-weight: 700;
  background: var(--rep-accent-lt);
  color: var(--rep-accent-dk);
  border: 1.5px solid rgba(25,118,210,.15);
}

/* ── Layout grid ── */
.rep-layout {
  display: grid;
  grid-template-columns: 256px 1fr;
  gap: 3.5rem;
  align-items: start;
}

/* ── Sidebar TOC ── */
.rep-sidebar {
  position: sticky;
  top: calc(var(--rep-header-h) + 1rem);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  background: var(--rep-surface);
  padding: 1.25rem 1rem;
  border-radius: var(--rep-radius);
  border: 1.5px solid var(--rep-border);
  box-shadow: var(--rep-shadow-sm);
  max-height: calc(100vh - var(--rep-header-h) - 2rem);
  overflow-y: auto;
}

.rep-sidebar-title {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  color: var(--rep-text-faint);
  margin-bottom: 0.75rem;
  padding: 0 0.5rem 0.6rem;
  border-bottom: 1px solid var(--rep-border-soft);
}

.rep-toc-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--rep-radius-xs);
  color: var(--rep-text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 150ms ease;
  border-left: 2.5px solid transparent;
}

.rep-toc-link svg { width: 15px; height: 15px; opacity: 0.6; flex-shrink: 0; }

.rep-toc-link:hover {
  background: var(--rep-accent-lt);
  color: var(--rep-accent);
  border-left-color: var(--rep-accent);
}

.rep-toc-link.active {
  background: linear-gradient(90deg, var(--rep-accent-lt) 0%, #f5f9ff 100%);
  color: var(--rep-accent-dk);
  font-weight: 600;
  border-left-color: var(--rep-accent);
}
.rep-toc-link.active svg { opacity: 1; }

/* ── Standalone content ── */
.rep-standalone-content-wrap { min-width: 0; }

.rep-standalone-content {
  line-height: 1.75;
  color: var(--rep-text);
  font-size: 0.95rem;
}

.rep-standalone-content h3 {
  font-family: var(--rep-font-serif);
  font-size: 1.3rem;
  color: var(--rep-heading);
  margin: 0 0 1rem 0;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--rep-border-soft);
  font-weight: 700;
}

.rep-standalone-content h3 svg {
  width: 20px;
  height: 20px;
  color: var(--rep-accent);
  flex-shrink: 0;
}

.rep-standalone-content ul {
  list-style: none;
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.rep-standalone-content ul li {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  line-height: 1.65;
}

.rep-standalone-content ul li::before {
  content: '';
  flex-shrink: 0;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--rep-accent);
  margin-top: 0.6em;
}

/* Signature li inside content */
.rep-standalone-content ul li.rep-signature {
  background: linear-gradient(135deg, #fffef7, #fef9e4);
  border: 1.5px solid var(--rep-gold-border);
  border-left: 4px solid var(--rep-gold);
  border-radius: var(--rep-radius-xs);
  padding: 0.75rem 1rem 0.75rem 0.85rem;
  margin-bottom: 0.5rem;
}
.rep-standalone-content ul li.rep-signature::before { display: none; }

/* Red flag div */
.rep-flag {
  background: linear-gradient(135deg, #fff5f5 0%, #fff0f0 100%);
  border: 1.5px solid var(--rep-red-border);
  border-left: 4px solid var(--rep-red);
  border-radius: var(--rep-radius-xs);
  padding: 1rem 1.1rem;
}

.rep-flag-title {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--rep-red);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.rep-flag ul li::before { background: var(--rep-red); }

/* Pearl div */
.rep-pearl {
  background: linear-gradient(135deg, #fffdf5 0%, #fff9e6 100%);
  border: 1.5px solid var(--rep-amber-border);
  border-left: 4px solid var(--rep-amber);
  border-radius: var(--rep-radius-sm);
  padding: 1.25rem 1.35rem;
  position: relative;
}

.rep-pearl::before {
  content: '"';
  position: absolute;
  top: -0.5rem;
  left: 1rem;
  font-family: var(--rep-font-serif);
  font-size: 3.5rem;
  color: var(--rep-amber-border);
  line-height: 1;
  pointer-events: none;
}

.rep-pearl-title {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--rep-amber);
  margin-bottom: 0.5rem;
}

.rep-pearl p {
  font-family: var(--rep-font-serif);
  font-size: 1rem;
  line-height: 1.7;
  color: #3e2e00;
  font-style: italic;
  padding-top: 0.5rem;
}

/* Differential table inside standalone */
.rep-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  border-radius: var(--rep-radius-xs);
  overflow: hidden;
  border: 1px solid var(--rep-border);
}

.rep-table th {
  text-align: left;
  padding: 0.65rem 1.1rem;
  background: var(--rep-surface-2);
  border-bottom: 2px solid var(--rep-border);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--rep-text-muted);
}

.rep-table td {
  padding: 0.75rem 1.1rem;
  border-bottom: 1px solid var(--rep-border-soft);
  line-height: 1.6;
  vertical-align: top;
}

.rep-table tbody tr:nth-child(even) td { background: #fafbfd; }
.rep-table tr:last-child td            { border-bottom: none; }
.rep-table tbody tr:hover td           { background: var(--rep-accent-lt); }

.rep-table td:first-child {
  font-weight: 700;
  color: var(--rep-heading);
  width: 35%;
}

/* References list inside standalone */
.rep-ref-list { /* already defined above — inherits */ }

/* ── Images gallery inside standalone ── */
.rep-standalone-images {
  margin-bottom: 3rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.25rem;
}

.rep-image-card {
  margin: 0;
  background: var(--rep-surface-2);
  border-radius: var(--rep-radius);
  overflow: hidden;
  border: 1.5px solid var(--rep-border);
  box-shadow: var(--rep-shadow-sm);
}

.rep-image-card img {
  width: 100%;
  height: 300px;
  object-fit: cover;
  display: block;
  transition: transform 250ms ease;
}
.rep-image-card:hover img { transform: scale(1.02); }

.rep-image-caption {
  padding: 0.85rem 1.1rem;
  font-size: 0.82rem;
  color: var(--rep-text-muted);
  text-align: center;
  border-top: 1px solid var(--rep-border-soft);
  font-style: italic;
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */

@media (max-width: 900px) {
  .rep-detail-layout,
  .rep-layout {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .rep-detail-nav,
  .rep-sidebar {
    position: static;
    max-height: none;
    overflow-y: visible;
    overflow-x: auto;
    flex-direction: row;
    padding: 0.85rem 1rem;
    -webkit-overflow-scrolling: touch;
  }

  .rep-nav-list,
  .rep-sidebar .rep-toc-link {
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 0.3rem;
  }

  .rep-nav-list a,
  .rep-toc-link {
    font-size: 0.78rem;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    white-space: nowrap;
    border-left: none !important;
    border: 1.5px solid transparent;
  }

  .rep-nav-list a.active,
  .rep-toc-link.active {
    border-left: none !important;
    border-color: var(--rep-accent) !important;
  }

  .rep-detail-nav-title,
  .rep-sidebar-title { display: none; }

  .rep-jump-top { bottom: 1.25rem; right: 1.25rem; }
}

@media (max-width: 640px) {
  .rep-header { padding: 0 1rem; gap: 1rem; }

  .rep-wrapper,
  .rep-detail-wrapper,
  .rep-page-wrapper { padding: 1.25rem 1rem 3.5rem; }

  .rep-standalone-title { font-size: 2rem; }
  .rep-standalone-subtitle { font-size: 1rem; }
  .rep-detail-title { font-size: 1.5rem; }
  .rep-header-nav { display: none; }
  .rep-card-subtitle { display: none; }
  .rep-section-body { padding: 1rem 1.1rem; }
  .rep-image-card img { height: 220px; }
  .rep-pag-name { display: none; }
}

/* ============================================================================
   PRINT STYLES (احترافية للطباعة)
   ============================================================================ */

@media print {
  .rep-back-link,
  .rep-back-btn,
  .rep-sidebar,
  .rep-detail-nav,
  .rep-jump-top,
  .rep-pagination,
  .rep-progress-bar,
  .site-header,
  .rep-header { display: none !important; }

  .rep-layout,
  .rep-detail-layout { display: block !important; }

  .rep-page-wrapper,
  .rep-detail-wrapper { padding: 0 !important; max-width: none !important; }

  .rep-section { page-break-inside: avoid; box-shadow: none; border: 1px solid #ccc; }
  .rep-section.section-red-flags { border-left: 4px solid #c62828 !important; }
  .rep-section.section-pearl     { border-left: 4px solid #bf6000 !important; }
  .rep-standalone-title          { font-size: 1.8rem; }

  body { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ============================================================================
   TRANSITION ANIMATIONS
   ============================================================================ */

.rep-list-view,
.rep-detail-view {
  animation: repFadeIn 280ms ease both;
}

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

/* Scroll-reveal for sections */
.rep-section {
  animation: repSectionIn 350ms ease both;
  animation-fill-mode: both;
}

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

/* Stagger sections */
.rep-section:nth-child(1) { animation-delay: 0ms; }
.rep-section:nth-child(2) { animation-delay: 40ms; }
.rep-section:nth-child(3) { animation-delay: 80ms; }
.rep-section:nth-child(4) { animation-delay: 120ms; }
.rep-section:nth-child(5) { animation-delay: 160ms; }
.rep-section:nth-child(6) { animation-delay: 200ms; }
.rep-section:nth-child(7) { animation-delay: 240ms; }
.rep-section:nth-child(8) { animation-delay: 280ms; }
.rep-section:nth-child(9) { animation-delay: 320ms; }

/* Card transitions */
.rep-card {
  transition:
    border-color 180ms ease,
    box-shadow   180ms ease,
    transform    120ms ease,
    opacity      200ms ease;
}

.rep-card[hidden] { display: none; }

/* Scrollbar for nav sidebars */
.rep-detail-nav::-webkit-scrollbar,
.rep-sidebar::-webkit-scrollbar { width: 4px; height: 4px; }
.rep-detail-nav::-webkit-scrollbar-track,
.rep-sidebar::-webkit-scrollbar-track { background: transparent; }
.rep-detail-nav::-webkit-scrollbar-thumb,
.rep-sidebar::-webkit-scrollbar-thumb { background: var(--rep-border); border-radius: 99px; }
