/* ==========================================================================
   DESIGN SYSTEM & VARIABLES - VIBRANT MULTILINGUAL (FR / AR / EN)
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700;800;900&family=Inter:wght@400;500;600;700;800&family=Outfit:wght@600;700;800;900&display=swap');

:root {
  /* Default: VIBRANT LIGHT THEME */
  --bg-primary: #f0f4f8;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-input: #e2e8f0;
  
  --text-main: #0f172a;
  --text-muted: #334155;
  --text-dim: #64748b;
  
  --primary: #0284c7;
  --primary-gradient: linear-gradient(135deg, #0284c7 0%, #2563eb 100%);
  --accent-emerald: #059669;
  --accent-emerald-bg: #d1fae5;
  --accent-amber: #d97706;
  --accent-amber-bg: #fef3c7;
  --accent-rose: #e11d48;
  --accent-rose-bg: #ffe4e6;
  --accent-purple: #7c3aed;
  --accent-purple-bg: #ede9fe;
  
  --border-color: rgba(15, 23, 42, 0.12);
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 12px 30px -5px rgba(2, 132, 199, 0.15);
  --shadow-glow: 0 0 25px rgba(2, 132, 199, 0.35);
  
  --nav-height: 66px;
  --bottom-nav-height: 64px;
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 28px;
  --radius-full: 9999px;
  
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --bg-primary: #0b0f19;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.9);
  --bg-card-hover: rgba(31, 41, 55, 0.95);
  --bg-input: #1f2937;
  --text-main: #f9fafb;
  --text-muted: #cbd5e1;
  --text-dim: #94a3b8;
  
  --border-color: rgba(255, 255, 255, 0.12);
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(6, 182, 212, 0.3);
}

/* RTL ARABIC STYLES */
[dir="rtl"] {
  font-family: 'Cairo', 'Inter', sans-serif;
  text-align: right;
}

[dir="rtl"] .logo-container {
  flex-direction: row;
}

[dir="rtl"] .search-input {
  padding: 0.9rem 3rem 0.9rem 1.2rem;
}

[dir="rtl"] .search-icon {
  left: auto;
  right: 1.2rem;
}

[dir="rtl"] .reader-back-btn svg {
  transform: rotate(180deg);
}

/* RESET & BASE */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  scroll-behavior: smooth;
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-size: 16px;
}

body {
  min-height: 100vh;
  padding-bottom: calc(var(--bottom-nav-height) + 30px);
  overflow-x: hidden;
  line-height: 1.6;
}

h1, h2, h3, h4, h5 {
  font-family: 'Outfit', 'Cairo', sans-serif;
  font-weight: 800;
  line-height: 1.2;
}

a { color: inherit; text-decoration: none; }
button, input, select { font-family: inherit; font-size: inherit; border: none; outline: none; }
button { cursor: pointer; }

/* TOP HEADER & LOGO */
.top-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-height);
  background: var(--bg-secondary);
  box-shadow: var(--shadow-sm);
  border-bottom: 2px solid rgba(2, 132, 199, 0.2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.2rem;
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  font-weight: 900;
  font-size: 1.35rem;
  color: var(--text-main);
}

/* LOGO ICÔNE MÉDICALE */
.logo-icon {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, #0284c7 0%, #7c3aed 100%);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(124, 58, 237, 0.4);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* PWA INSTALL BUTTON & MODAL */
.pwa-install-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--primary-gradient);
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-full);
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.35);
  transition: var(--transition);
}

.pwa-install-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(2, 132, 199, 0.45);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(8px);
  z-index: 4000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: var(--bg-card);
  border: 2px solid var(--primary);
  box-shadow: var(--shadow-lg);
  max-width: 440px;
  width: 100%;
  position: relative;
}

.modal-close-btn {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  font-size: 1.8rem;
  color: var(--text-muted);
}
[dir="rtl"] .modal-close-btn {
  right: auto;
  left: 16px;
}

.lang-selector {
  display: flex;
  background: var(--bg-input);
  padding: 3px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
}

.lang-btn {
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--text-muted);
  transition: var(--transition);
}

.lang-btn.active {
  background: var(--primary-gradient);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.4);
}

.icon-btn {
  width: 40px; height: 40px; border-radius: var(--radius-full);
  background: var(--bg-input); color: var(--text-main);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; transition: var(--transition);
}

.desktop-nav { display: none; gap: 1.6rem; align-items: center; }
.desktop-nav a { font-size: 0.95rem; font-weight: 600; color: var(--text-muted); }
.desktop-nav a:hover, .desktop-nav a.active { color: var(--primary); }

/* BOTTOM NAV */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--bottom-nav-height);
  background: var(--bg-secondary);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
  border-top: 2px solid var(--border-color);
  display: flex; justify-space-around; align-items: center;
  z-index: 1000;
}

.nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  color: var(--text-muted); font-size: 0.75rem; font-weight: 600;
  padding: 6px 14px; border-radius: 14px; transition: var(--transition);
}

.nav-item svg { width: 22px; height: 22px; fill: currentColor; }
.nav-item.active { color: #ffffff; background: var(--primary-gradient); box-shadow: 0 4px 10px rgba(2, 132, 199, 0.4); }

/* LAYOUT */
.container { max-width: 1200px; margin: 0 auto; padding: 1.2rem; }
.section { margin-bottom: 2.5rem; }
.section-header { margin-bottom: 1.4rem; }

.badge {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.45rem 1.1rem; border-radius: var(--radius-full);
  font-size: 0.82rem; font-weight: 800; text-transform: uppercase;
  background: linear-gradient(135deg, #0284c7 0%, #7c3aed 100%);
  color: #ffffff; box-shadow: 0 4px 12px rgba(2, 132, 199, 0.3); margin-bottom: 0.8rem;
}

.section-title { font-size: 1.7rem; color: var(--text-main); margin-bottom: 0.4rem; }
.section-subtitle { color: var(--text-muted); font-size: 1rem; }

/* HERO SECTION - CONTRASTE ULTRA CLAIR & NET */
.hero-card {
  position: relative; border-radius: var(--radius-lg); overflow: hidden;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  border: 2px solid rgba(2, 132, 199, 0.4);
  box-shadow: 0 15px 35px rgba(15, 23, 42, 0.3); margin-bottom: 1.8rem;
}
.hero-banner { position: relative; width: 100%; height: 250px; overflow: hidden; }
.hero-banner img { width: 100%; height: 100%; object-fit: cover; filter: brightness(0.9); }
.hero-overlay { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(15, 23, 42, 0.2) 0%, rgba(15, 23, 42, 0.95) 100%); }
.hero-content { padding: 1.8rem; position: relative; margin-top: -60px; }

/* TITRE HÉRO AVEC CONTRASTE NET ET LISIBILITÉ AMÉLIORÉE */
.hero-title {
  font-size: 2.1rem;
  font-weight: 900;
  color: #ffffff !important;
  margin-bottom: 0.8rem;
  line-height: 1.25;
  text-shadow: 0 3px 10px rgba(0, 0, 0, 0.9);
}

.hero-description {
  color: #f1f5f9 !important;
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.65;
  margin-bottom: 1.6rem;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.8);
}

.cta-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.8rem;
  width: 100%; padding: 1.1rem 1.6rem;
  background: linear-gradient(135deg, #0284c7 0%, #7c3aed 100%);
  color: #ffffff; font-weight: 800; border-radius: var(--radius-md);
  box-shadow: 0 8px 25px rgba(124, 58, 237, 0.4); font-size: 1.1rem;
  transition: var(--transition);
}

.cta-btn:hover, .cta-btn:active {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(124, 58, 237, 0.5);
}

/* VIGNETTES / PILLS EN BAS : CLIQUABLES AVEC EFFET HOVER */
.hero-pills {
  display: flex; gap: 0.8rem; overflow-x: auto; padding: 0.8rem 0; scrollbar-width: none;
}
.hero-pills::-webkit-scrollbar { display: none; }

.pill-item {
  white-space: nowrap;
  background: #ffffff;
  border: 2px solid var(--primary);
  padding: 0.7rem 1.2rem;
  border-radius: var(--radius-full);
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.15);
  cursor: pointer;
  transition: var(--transition);
}

.pill-item:hover, .pill-item:active {
  background: var(--primary-gradient);
  color: #ffffff;
  border-color: transparent;
  transform: translateY(-3px);
  box-shadow: 0 6px 18px rgba(2, 132, 199, 0.4);
}

/* CHAPTERS GRID */
.chapters-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.chapter-card {
  background: var(--bg-card); border: 2px solid var(--border-color);
  border-radius: var(--radius-md); overflow: hidden; display: flex; flex-direction: column;
  position: relative; box-shadow: var(--shadow-sm); transition: var(--transition); cursor: pointer;
}
.chapter-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--primary); }
.chapter-card-img { width: 100%; height: 110px; object-fit: cover; }
.chapter-card-overlay { position: absolute; top: 0; left: 0; right: 0; height: 110px; background: linear-gradient(180deg, rgba(0,0,0,0.1) 0%, rgba(0,0,0,0.6) 100%); }
.chapter-card-body { padding: 1rem; display: flex; flex-direction: column; gap: 0.4rem; flex: 1; }
.chapter-num {
  position: absolute; top: 10px; right: 10px; width: 30px; height: 30px;
  border-radius: var(--radius-full); background: var(--primary-gradient);
  color: #fff; font-weight: 900; font-size: 0.85rem; display: flex; align-items: center; justify-content: center; z-index: 2;
}
[dir="rtl"] .chapter-num { right: auto; left: 10px; }
.chapter-title { font-size: 1rem; font-weight: 800; color: var(--text-main); line-height: 1.3; }
.chapter-badge { font-size: 0.78rem; font-weight: 700; color: var(--primary); }

/* FULL-PAGE CHAPTER READER */
.fullpage-reader {
  position: fixed; inset: 0; width: 100vw; height: 100vh; background: var(--bg-primary);
  z-index: 3000; overflow-y: auto; display: none; flex-direction: column;
  animation: slideUp 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.fullpage-reader.active { display: flex; }
@keyframes slideUp { from { transform: translateY(100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.fullpage-header {
  position: sticky; top: 0; z-index: 10; height: 64px; background: var(--bg-secondary);
  border-bottom: 2px solid var(--border-color); display: flex; align-items: center; justify-content: space-between; padding: 0 1.2rem;
}
.reader-back-btn {
  display: flex; align-items: center; gap: 0.5rem; font-weight: 800; font-size: 1rem;
  color: var(--primary); background: var(--accent-emerald-bg); padding: 0.5rem 1rem; border-radius: var(--radius-full);
}
.fullpage-hero-img { width: 100%; max-height: 340px; object-fit: cover; }
.fullpage-body { max-width: 820px; margin: 0 auto; padding: 2rem 1.5rem; flex: 1; }
.fullpage-chapter-num { display: inline-block; padding: 0.4rem 1rem; border-radius: var(--radius-full); background: var(--primary-gradient); color: #fff; font-weight: 800; font-size: 0.9rem; margin-bottom: 1rem; }
.fullpage-title { font-size: 2.3rem; color: var(--text-main); margin-bottom: 1.2rem; line-height: 1.2; }
.fullpage-text { font-size: 1.25rem; line-height: 1.8; color: var(--text-muted); }
.fullpage-text p { margin-bottom: 1.5rem; }
.fullpage-text h3, .fullpage-text h4 { font-size: 1.55rem; color: var(--text-main); margin: 1.8rem 0 0.8rem 0; }

/* FASTING TIMELINE STYLES */
.fasting-timeline-box { display: flex; flex-direction: column; gap: 1.2rem; margin: 1.8rem 0; }
.fasting-phase { background: var(--bg-card); border: 2px solid var(--border-color); border-radius: var(--radius-md); padding: 1.2rem; box-shadow: var(--shadow-sm); }
.fasting-phase.highlight-18h { border-color: var(--accent-purple); background: linear-gradient(135deg, rgba(124, 58, 237, 0.08) 0%, rgba(2, 132, 199, 0.08) 100%); }
.phase-badge { display: inline-block; padding: 0.35rem 0.9rem; border-radius: var(--radius-full); font-weight: 800; font-size: 0.9rem; margin-bottom: 0.6rem; color: #fff; }
.phase-badge.p1 { background: #2563eb; }
.phase-badge.p2 { background: #0284c7; }
.phase-badge.p3 { background: #d97706; }
.phase-badge.p4 { background: #059669; }
.phase-badge.p5 { background: linear-gradient(135deg, #7c3aed 0%, #e11d48 100%); }

/* HEALTH CALCULATORS */
.tabs-container { background: var(--bg-card); border: 2px solid var(--border-color); border-radius: var(--radius-lg); padding: 1.4rem; box-shadow: var(--shadow-lg); }
.tabs-header { display: flex; gap: 0.6rem; overflow-x: auto; padding-bottom: 0.8rem; border-bottom: 2px solid var(--border-color); margin-bottom: 1.4rem; }
.tab-btn { padding: 0.6rem 1.2rem; border-radius: var(--radius-full); background: var(--bg-input); color: var(--text-muted); font-size: 0.9rem; font-weight: 700; white-space: nowrap; }
.tab-btn.active { background: var(--primary-gradient); color: #fff; box-shadow: 0 4px 12px rgba(2, 132, 199, 0.35); }
.calculator-panel { display: none; }
.calculator-panel.active { display: block; }
.form-group { margin-bottom: 1.2rem; }
.form-label { display: block; font-size: 0.95rem; font-weight: 700; color: var(--text-main); margin-bottom: 0.5rem; }
.form-input { width: 100%; padding: 0.9rem 1.1rem; background: var(--bg-input); border: 2px solid var(--border-color); border-radius: var(--radius-sm); color: var(--text-main); font-size: 1.1rem; font-weight: 600; }
.calc-result-box { margin-top: 1.4rem; padding: 1.2rem; border-radius: var(--radius-md); background: var(--bg-input); border: 2px solid var(--border-color); text-align: center; }
.result-value { font-size: 2.6rem; font-weight: 900; color: var(--primary); margin: 0.2rem 0; }
.result-status { display: inline-block; padding: 0.4rem 1rem; border-radius: var(--radius-full); font-size: 0.9rem; font-weight: 800; }

.spectrum-bar { height: 10px; border-radius: 5px; background: linear-gradient(90deg, #2563eb 0%, #059669 30%, #d97706 60%, #e11d48 100%); margin: 1.2rem 0 0.6rem 0; position: relative; }
.spectrum-pointer { position: absolute; top: -5px; width: 20px; height: 20px; border-radius: 50%; background: #ffffff; border: 4px solid var(--primary); transform: translateX(-50%); transition: left 0.4s ease-out; }

/* FOOD DATABASE */
.search-box { position: relative; margin-bottom: 1.2rem; }
.search-input { width: 100%; padding: 0.9rem 1.2rem 0.9rem 3rem; background: var(--bg-card); border: 2px solid var(--border-color); border-radius: var(--radius-full); color: var(--text-main); font-size: 1rem; }
.search-icon { position: absolute; left: 1.2rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 1.1rem; }

.food-filter-pills { display: flex; gap: 0.6rem; overflow-x: auto; padding-bottom: 0.8rem; margin-bottom: 1.2rem; }
.filter-btn { padding: 0.5rem 1.1rem; border-radius: var(--radius-full); background: var(--bg-card); border: 2px solid var(--border-color); color: var(--text-muted); font-size: 0.85rem; font-weight: 700; white-space: nowrap; }
.filter-btn.active { background: var(--primary-gradient); color: #ffffff; border-color: transparent; }

.food-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.food-card { background: var(--bg-card); border: 2px solid var(--border-color); border-radius: var(--radius-md); padding: 1.2rem; display: flex; flex-direction: column; gap: 0.7rem; box-shadow: var(--shadow-sm); }
.food-header { display: flex; justify-content: space-between; align-items: center; }
.food-name { font-size: 1.15rem; font-weight: 800; color: var(--text-main); }

.gi-badge { padding: 0.3rem 0.8rem; border-radius: var(--radius-full); font-size: 0.8rem; font-weight: 800; }
.gi-low { background: var(--accent-emerald-bg); color: var(--accent-emerald); }
.gi-medium { background: var(--accent-amber-bg); color: var(--accent-amber); }
.gi-high { background: var(--accent-rose-bg); color: var(--accent-rose); }

.food-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; text-align: center; background: var(--bg-input); padding: 0.8rem; border-radius: var(--radius-sm); }
.stat-val { font-weight: 800; font-size: 0.95rem; color: var(--text-main); }
.stat-lbl { font-size: 0.72rem; color: var(--text-dim); }

/* RESPONSIVE DESKTOP */
@media (min-width: 768px) {
  body { padding-bottom: 2.5rem; }
  .bottom-nav { display: none; }
  .desktop-nav { display: flex; }
  .hero-card { display: grid; grid-template-columns: 1.2fr 1fr; align-items: center; }
  .hero-banner { height: 100%; min-height: 350px; }
  .hero-content { margin-top: 0; padding: 3rem; }
  .hero-title { font-size: 2.6rem; }
  .chapters-grid { grid-template-columns: repeat(4, 1fr); }
  .food-grid { grid-template-columns: repeat(3, 1fr); }
}
