/* =========================================================
   RESIDENCY JRMS - 1st Year
   Clean medical / academic style, RTL-aware
   ========================================================= */

:root {
  --primary: #0d5c63;
  --primary-dark: #1a3c40;
  --primary-light: #e8f4f4;
  --accent: #2a9d8f;
  --text: #14343a;
  --muted: #5a7377;
  --bg: #ffffff;
  --bg-soft: #f5faf9;
  --border: #d9e7e7;
  --shadow-sm: 0 1px 2px rgba(13, 92, 99, 0.06),
    0 2px 6px rgba(13, 92, 99, 0.04);
  --shadow-md: 0 4px 12px rgba(13, 92, 99, 0.08),
    0 8px 24px rgba(13, 92, 99, 0.06);
  --radius: 14px;
  --radius-sm: 10px;
  --font-ar: 'Cairo', 'Tajawal', system-ui, sans-serif;
  --font-en: 'Inter', system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-en), var(--font-ar);
  background: var(--bg-soft);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

[lang='ar'],
body[dir='rtl'] .hero-subtitle,
body[dir='rtl'] .hero-note {
  font-family: var(--font-ar);
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--primary-dark);
}

.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ============ TOP BAR ============ */
.topbar {
  background: var(--primary-dark);
  color: #fff;
  padding: 10px 0;
  font-size: 0.9rem;
}

.topbar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.topbar-label {
  opacity: 0.85;
  letter-spacing: 0.03em;
  font-weight: 500;
}

.social-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.social-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 500;
  transition: background 0.2s ease, transform 0.15s ease;
}

.social-btn:hover {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
  transform: translateY(-1px);
}

.social-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
  stroke: none;
}

.social-btn.tg { background: rgba(41, 161, 222, 0.85); }
.social-btn.tg:hover { background: #2aabee; }
.social-btn.wa { background: rgba(37, 211, 102, 0.9); }
.social-btn.wa:hover { background: #25d366; }
.social-btn.osce { background: rgba(41, 161, 222, 0.6); }
.social-btn.osce:hover { background: #1e88c9; }
.social-btn.mfds { background: rgba(255, 255, 255, 0.14); font-family: var(--font-ar); }
.social-btn.mfds:hover { background: rgba(255, 255, 255, 0.28); }

/* ============ HERO ============ */
.hero {
  background:
    radial-gradient(ellipse at top right, rgba(42, 157, 143, 0.15), transparent 60%),
    linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  padding: 60px 0 70px;
  position: relative;
  overflow: hidden;
}

.hero::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 40px;
  background: var(--bg-soft);
  clip-path: polygon(0 100%, 100% 100%, 100% 0, 0 100%);
}

.hero-inner {
  text-align: center;
  max-width: 780px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.hero-badge {
  display: inline-block;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  font-weight: 600;
  margin-bottom: 18px;
}

.hero-title {
  font-family: var(--font-en);
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 700;
  margin: 0 0 12px;
  letter-spacing: -0.02em;
}

.hero-subtitle {
  font-size: clamp(1rem, 2.2vw, 1.25rem);
  margin: 0 auto 28px;
  opacity: 0.95;
  font-weight: 500;
  max-width: 620px;
}

.hero-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 32px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.95rem;
  transition: transform 0.15s ease, background 0.2s ease, box-shadow 0.2s ease;
  border: 1px solid transparent;
  cursor: pointer;
}

.btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn-primary {
  background: #fff;
  color: var(--primary-dark);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.15);
}

.btn-primary:hover {
  transform: translateY(-2px);
  background: var(--primary-light);
  color: var(--primary-dark);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.2);
}

.btn-ghost {
  background: transparent;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.45);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  transform: translateY(-2px);
}

.hero-note {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  line-height: 1.75;
  margin: 0 auto 14px;
  max-width: 680px;
}

.hero-contact {
  font-size: 1.05rem;
  opacity: 0.95;
  margin: 0;
  font-weight: 500;
}

.hero-contact a {
  color: #fff;
  text-decoration: underline;
  text-underline-offset: 4px;
  font-weight: 700;
  font-size: 1.15rem;
}

.hero-contact .dot {
  margin: 0 8px;
  opacity: 0.6;
}

/* ============ SEARCH ============ */
.search-wrap {
  position: sticky;
  top: 0;
  z-index: 40;
  padding: 16px 0;
  background: rgba(245, 250, 249, 0.9);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
  margin-top: -20px;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 14px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.search-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(13, 92, 99, 0.12);
}

.search-icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

#searchInput {
  flex: 1;
  border: 0;
  outline: none;
  padding: 14px 12px;
  font-size: 1rem;
  font-family: inherit;
  background: transparent;
  color: var(--text);
  min-width: 0;
}

.clear-btn {
  background: var(--primary-light);
  color: var(--primary-dark);
  border: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s ease;
}

.clear-btn:hover {
  background: var(--primary);
  color: #fff;
}

.search-status {
  margin: 8px 4px 0;
  font-size: 0.85rem;
  color: var(--muted);
  min-height: 1em;
}

/* ============ MAIN / ACCORDIONS ============ */
.main-content {
  padding: 30px 20px 60px;
  display: grid;
  gap: 18px;
}

.accordion {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

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

.accordion.hidden {
  display: none;
}

.accordion-header {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 18px 22px;
  background: transparent;
  border: 0;
  cursor: pointer;
  text-align: start;
  font-family: inherit;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary-dark);
  transition: background 0.2s ease;
}

.accordion-header:hover {
  background: var(--primary-light);
}

.accordion-header:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
}

.accordion-header .ico {
  font-size: 1.4rem;
  line-height: 1;
}

.acc-title {
  flex: 1;
}

.acc-count {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-light);
  padding: 3px 10px;
  border-radius: 999px;
  min-width: 32px;
  text-align: center;
}

.chev {
  color: var(--muted);
  transition: transform 0.25s ease;
  font-size: 1rem;
}

.accordion-header[aria-expanded='false'] .chev {
  transform: rotate(-90deg);
}

.accordion-body {
  padding: 6px 22px 22px;
  border-top: 1px solid var(--border);
  animation: fadeIn 0.25s ease;
}

.accordion-header[aria-expanded='false'] + .accordion-body {
  display: none;
}

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

/* ============ LINK GRID ============ */
.link-grid {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
  /* Newest items are first in the DOM; force LTR flow so they render on the visual left */
  direction: ltr;
}

.link-grid li {
  display: flex;
}

.link-grid li.hidden {
  display: none;
}

.link-grid a {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.94rem;
  font-weight: 500;
  transition: all 0.18s ease;
  line-height: 1.35;
}

.link-grid a::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(42, 157, 143, 0.15);
}

.link-grid a:hover {
  background: #fff;
  border-color: var(--primary);
  color: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.link-grid a:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* "edited by Dr Afnan Ali" resources - red text only */
.link-grid li.afnan a {
  color: #d32f2f;
  font-weight: 700;
}
.link-grid li.afnan a::before {
  background: #d32f2f;
  box-shadow: 0 0 0 3px rgba(211, 47, 47, 0.15);
}
.link-grid li.afnan a:hover {
  color: #b71c1c;
}

/* highlight matches */
.link-grid a mark {
  background: #fff3a1;
  color: inherit;
  padding: 0 2px;
  border-radius: 3px;
}

.no-results {
  text-align: center;
  padding: 30px;
  background: #fff;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.95rem;
}

/* ============ FOOTER ============ */
.footer {
  background: var(--primary-dark);
  color: #cfe4e4;
  padding: 26px 0;
  text-align: center;
  font-size: 0.9rem;
}

.footer-inner p {
  margin: 4px 0;
}

.footer-sub {
  opacity: 0.75;
  font-size: 0.85rem;
}

.footer a {
  color: #fff;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ============ BACK TO TOP ============ */
.back-to-top {
  position: fixed;
  bottom: 24px;
  inset-inline-end: 24px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 0;
  background: var(--primary);
  color: #fff;
  font-size: 1.4rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: transform 0.2s ease, background 0.2s ease, opacity 0.2s ease;
  z-index: 50;
}

.back-to-top:hover {
  background: var(--primary-dark);
  transform: translateY(-3px);
}

.back-to-top:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 640px) {
  .hero {
    padding: 40px 0 55px;
  }
  .topbar-inner {
    justify-content: center;
  }
  .topbar-label {
    display: none;
  }
  .accordion-header {
    padding: 16px 16px;
    font-size: 1.05rem;
  }
  .accordion-body {
    padding: 6px 14px 18px;
  }
  .link-grid {
    grid-template-columns: 1fr;
  }
  .hero-note {
    font-size: 0.88rem;
  }
}

/* RTL small tweaks */
body[dir='rtl'] .btn svg {
  transform: scaleX(-1);
}

/* Print (in case a student wants to print the list) */
@media print {
  .topbar, .search-wrap, .back-to-top, .hero-actions, .footer { display: none; }
  .hero { background: none; color: #000; padding: 20px 0; }
  .accordion { break-inside: avoid; box-shadow: none; border-color: #000; }
  .accordion-header[aria-expanded='false'] + .accordion-body { display: block; }
}
