/* ============================================
   Type 2 Diabetes Subtypes - Main Stylesheet
   With RTL Support for Farsi/Arabic
   ============================================ */

/* ---------- CSS Variables ---------- */
:root {
  --bg: #f6f8ff;
  --text: #0b1220;
  --muted: #4b5563;
  --card: rgba(0,0,0,.04);
  --border: rgba(0,0,0,.12);
  --link: #1e5eff;
  --primary: #1B365D;
  --secondary: #2E5090;
  --danger: #dc3545;
  --dropdown-bg: #ffffff;
  --dropdown-shadow: 0 8px 24px rgba(0,0,0,0.15);
}

:root[data-theme="dark"] {
  --bg: #0b1220;
  --text: #e9eefc;
  --muted: #b8c4e6;
  --card: rgba(255,255,255,.04);
  --border: rgba(255,255,255,.12);
  --link: #9ec1ff;
  --dropdown-bg: #1a2640;
  --dropdown-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

:root[data-contrast="high"] {
  --border: rgba(255,255,255,.9);
}

/* ---------- Reset & Base ---------- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  line-height: 1.7;
  background: var(--bg);
  color: var(--text);
}

.wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 22px;
}

a {
  color: var(--link);
}

/* ---------- Site Header ---------- */
.siteHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--card);
}

.brandLeft {
  flex: 0 0 auto;
}

.brandCenter {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 72px;
}

.brandRight {
  flex: 0 0 auto;
  display: flex;
  gap: 10px;
  align-items: center;
}

.brandLogo {
  width: 86px;
  height: auto;
  display: block;
}

.brandTitle {
  font-size: 22px;
  font-weight: 900;
  line-height: 1.2;
}

.brandSubtitle {
  margin-top: 4px;
  font-size: 14px;
  color: var(--muted);
}

.iconBtn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
}

.iconBtn:focus {
  outline: 3px solid var(--link);
  outline-offset: 2px;
}

/* ---------- Language Bar ---------- */
.langBar {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  margin-top: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  flex-wrap: wrap;
  direction: ltr; /* Always LTR for language switcher */
}

.langBar a {
  color: var(--muted);
  text-decoration: none;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
}

.langBar a:hover {
  background: var(--border);
}

.langBar a.active {
  background: var(--secondary);
  color: #fff;
}

/* ---------- Main Menu with Dropdowns ---------- */
.mainMenu {
  margin-top: 10px;
  border-bottom: 1px solid var(--border);
}

.mainMenu > ul {
  list-style: none;
  display: flex;
  gap: 6px;
  padding: 8px 4px 10px;
  margin: 0;
  flex-wrap: wrap;
}

.mainMenu > ul > li {
  position: relative;
}

.mainMenu > ul > li > a {
  text-decoration: none;
  font-weight: 700;
  color: var(--text);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  border-radius: 8px;
  transition: background 0.2s;
}

.mainMenu > ul > li > a:hover {
  background: var(--card);
}

.mainMenu > ul > li > a.active {
  color: #c1121f;
}

.mainMenu > ul > li > a.active::after {
  content: "<<";
  margin-left: 4px;
  font-weight: 900;
  color: #c1121f;
}

/* Dropdown arrow indicator */
.mainMenu > ul > li.has-dropdown > a::after {
  content: "▼";
  font-size: 10px;
  margin-left: 4px;
  transition: transform 0.2s;
}

.mainMenu > ul > li.has-dropdown > a.active::after {
  content: "▼";
}

.mainMenu > ul > li.has-dropdown:hover > a::after,
.mainMenu > ul > li.has-dropdown:focus-within > a::after {
  transform: rotate(180deg);
}

/* Dropdown Menu */
.dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 220px;
  background: var(--dropdown-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--dropdown-shadow);
  padding: 8px 0;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s ease;
  z-index: 1000;
  list-style: none;
}

.mainMenu > ul > li:hover > .dropdown,
.mainMenu > ul > li:focus-within > .dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown li {
  margin: 0;
}

.dropdown a {
  display: block;
  padding: 10px 16px;
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
  transition: background 0.15s;
}

.dropdown a:hover,
.dropdown a:focus {
  background: var(--card);
  color: var(--primary);
}

.dropdown a .dropdown-icon {
  margin-right: 8px;
}

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px 24px;
  margin-top: 16px;
}

.card h2 {
  color: var(--primary);
  font-size: 1.4rem;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--secondary);
}

.card p {
  margin-bottom: 12px;
}

/* ---------- Statistics Grid ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.stat-box {
  background: var(--card);
  border-radius: 10px;
  padding: 16px;
  text-align: center;
  border-left: 4px solid var(--secondary);
}

.stat-number {
  font-size: 1.8rem;
  font-weight: bold;
  color: var(--primary);
  display: block;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 4px;
}

.stat-box.highlight {
  border-left-color: var(--danger);
}

.stat-box.highlight .stat-number {
  color: var(--danger);
}

/* ---------- Hook Box ---------- */
.hook-box {
  background: linear-gradient(135deg, rgba(46,80,144,0.1), rgba(30,94,255,0.05));
  border-left: 4px solid var(--secondary);
  padding: 16px 20px;
  border-radius: 10px;
  margin-top: 16px;
}

.hook-box p {
  margin: 0;
  font-size: 1.05rem;
}

/* ---------- Key Facts ---------- */
.key-facts {
  background: #fffbeb;
  border: 1px solid #f0e68c;
  border-radius: 10px;
  padding: 14px 18px;
  margin: 14px 0;
}

:root[data-theme="dark"] .key-facts {
  background: rgba(255,251,235,0.08);
  border-color: rgba(240,230,140,0.3);
}

.key-facts ul {
  margin: 8px 0 0 20px;
}

.key-facts li {
  margin: 6px 0;
}

/* ---------- Navigation Cards ---------- */
.nav-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.nav-card {
  display: block;
  background: var(--card);
  border: 2px solid var(--secondary);
  border-radius: 14px;
  padding: 20px;
  text-decoration: none;
  color: inherit;
  transition: all 0.3s ease;
}

.nav-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 25px rgba(46,80,144,0.15);
  border-color: var(--primary);
}

.nav-card-number {
  display: inline-block;
  background: var(--secondary);
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  text-align: center;
  line-height: 32px;
  font-weight: bold;
  margin-bottom: 10px;
}

.nav-card h3 {
  color: var(--primary);
  font-size: 1.15rem;
  margin-bottom: 8px;
}

.nav-card p {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0;
}

.nav-card .arrow {
  display: block;
  text-align: right;
  color: var(--secondary);
  font-size: 1.4rem;
  margin-top: 8px;
}

/* ---------- Footer ---------- */
.footer {
  margin-top: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 16px;
}

.footer p {
  margin: 4px 0;
}

/* ---------- Sources ---------- */
.sources {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.top-hero {
    width: 100%;
    background: #f4f6fb;
    padding: 12px 0 18px 0;
    overflow: hidden;
}

.top-hero-inner {
    max-width: 1200px;      /* matches medical site width */
    margin: 0 auto;
    padding: 0 20px;
}

.top-hero img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 12px;
    box-shadow: 0 12px 35px rgba(0,0,0,0.15);
}


/* ==========================================================================
   RTL SUPPORT (Farsi, Arabic, Hebrew)
   Applied when html has dir="rtl" or lang="fa"
   ========================================================================== */

[dir="rtl"] body,
[lang="fa"] body {
  direction: rtl;
  font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
}

/* RTL: Main Menu */
[dir="rtl"] .mainMenu > ul {
  flex-direction: row-reverse;
}

[dir="rtl"] .mainMenu > ul > li > a.active::after {
  content: ">>";
  margin-left: 0;
  margin-right: 4px;
}

[dir="rtl"] .mainMenu > ul > li.has-dropdown > a::after {
  margin-left: 0;
  margin-right: 4px;
}

/* RTL: Dropdown position */
[dir="rtl"] .dropdown {
  left: auto;
  right: 0;
}

[dir="rtl"] .dropdown a .dropdown-icon {
  margin-right: 0;
  margin-left: 8px;
}

/* RTL: Stat boxes - border on right side */
[dir="rtl"] .stat-box {
  border-left: none;
  border-right: 4px solid var(--secondary);
}

[dir="rtl"] .stat-box.highlight {
  border-left: none;
  border-right-color: var(--danger);
}

/* RTL: Hook box - border on right side */
[dir="rtl"] .hook-box {
  border-left: none;
  border-right: 4px solid var(--secondary);
}

/* RTL: Key facts list */
[dir="rtl"] .key-facts ul {
  margin: 8px 20px 0 0;
}

/* RTL: Nav card arrow */
[dir="rtl"] .nav-card .arrow {
  text-align: left;
}

/* RTL: Site header */
[dir="rtl"] .siteHeader {
  flex-direction: row-reverse;
}

[dir="rtl"] .brandRight {
  flex-direction: row-reverse;
}


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

@media (max-width: 700px) {
  .siteHeader {
    flex-direction: column;
    align-items: flex-start;
  }
  
  [dir="rtl"] .siteHeader {
    align-items: flex-end;
  }
  
  .brandRight {
    margin-top: 10px;
  }
  
  .brandLogo {
    width: 72px;
  }
  
  .brandTitle {
    font-size: 20px;
  }
  
  .nav-cards {
    grid-template-columns: 1fr;
  }
  
  /* Mobile dropdown adjustments */
  .mainMenu > ul {
    flex-direction: column;
    gap: 0;
  }
  
  [dir="rtl"] .mainMenu > ul {
    flex-direction: column;
  }
  
  .dropdown {
    position: static;
    box-shadow: none;
    border: none;
    border-radius: 0;
    padding-left: 20px;
    max-height: 0;
    overflow: hidden;
    opacity: 1;
    visibility: visible;
    transform: none;
    background: transparent;
  }
  
  [dir="rtl"] .dropdown {
    padding-left: 0;
    padding-right: 20px;
  }
  
  .mainMenu > ul > li:hover > .dropdown,
  .mainMenu > ul > li:focus-within > .dropdown {
    max-height: 500px;
  }
}
