/* ═══════════════════════════════════════════════
   CompSjid — Shared Stylesheet (Final)
   ═══════════════════════════════════════════════ */

/* ── CSS Variables ── */
:root {
  --navy: #0d1b2a;
  --blue: #1b4f8a;
  --mid: #2e6fc5;
  --sky: #4fa3e0;
  --accent: #7dd3fc;
  --light-bg: #f0f7ff;
  --card-bg: #ffffff;
  --text: #0d1b2a;
  --sub: #4a6080;
  --border: #c8dff5;
}

.dark {
  --navy: #070e1a;
  --blue: #7dd3fc;
  --mid: #4fa3e0;
  --sky: #2e6fc5;
  --accent: #1b4f8a;
  --light-bg: #070e1a;
  --card-bg: #0d1b2e;
  --text: #e2eeff;
  --sub: #8aafd4;
  --border: #1b3a5c;
}

/* ── Reset & Base ── */
*, *::before, *::after {
  box-sizing: border-box;
  transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}

body {
  font-family: 'Google Sans Flex', 'Google Sans', sans-serif;
  background: var(--light-bg);
  color: var(--text);
  margin: 0;
}

@media (min-width: 768px) {
  body { zoom: 1.1; }
}

h1, h2, h3, .font-display {
  font-family: 'Google Sans Flex', 'Google Sans', sans-serif;
}

/* ── Utility Classes ── */
.pi-logo {
  background: linear-gradient(135deg, #1b4f8a 0%, #2e6fc5 50%, #4fa3e0 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
}

.btn-primary {
  background: linear-gradient(135deg, #1b4f8a, #4fa3e0);
  color: white;
}
.btn-primary:hover { opacity: 0.9; transform: translateY(-2px); }

.btn-outline {
  border: 2px solid var(--mid);
  color: var(--mid);
}
.btn-outline:hover { background: var(--mid); color: white; }

.nav-link { color: var(--sub); }
.nav-link:hover { color: var(--mid); }

.section-title { color: var(--text); }

/* ── Navbar ── */
#navbar {
  background: var(--light-bg);
  border-bottom: 1px solid var(--border);
}
.scrolled-nav { box-shadow: 0 4px 30px rgba(13,27,42,0.08); }

/* ── Dropdown ── */
.dropdown { display: none; }
.dropdown-parent:hover .dropdown { display: block; }

/* ── Mobile Nav ── */
.mobile-menu { display: none; }
.mobile-menu.open { display: block; }
.mobile-toggle { display: none; }
.desktop-nav { display: flex; }

@media (max-width: 768px) {
  .desktop-nav { display: none !important; }
  .mobile-toggle { display: flex !important; align-items: center; justify-content: center; }
  .hide-mobile { display: none !important; }
  .btn-whatsapp { display: none !important; }
}

/* ── Page Hero ── */
.page-hero {
  background: linear-gradient(135deg, #0d1b2a 0%, #1b4f8a 50%, #2e6fc5 100%);
  padding: 80px 16px 56px;
  position: relative;
  overflow: hidden;
}
.page-hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
}

.breadcrumb a { color: rgba(255,255,255,0.6); font-size: 13px; text-decoration: none; }
.breadcrumb a:hover { color: white; }
.breadcrumb span { color: rgba(255,255,255,0.4); margin: 0 6px; font-size: 13px; }

/* ── Footer ── */
footer { background: var(--navy); }

/* ── Auth Modal ── */
#authOverlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(7,14,26,0.75);
  backdrop-filter: blur(8px);
  align-items: center;
  justify-content: center;
  padding: 20px;
}

#dashOverlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(7,14,26,0.75);
  backdrop-filter: blur(8px);
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
}

/* ── Stats Banner (boutique) ── */
.stats-bar {
  background: linear-gradient(135deg, #0d1b2a, #1b4f8a);
  border-radius: 20px;
  padding: 28px 32px;
  display: flex;
  gap: 0;
  flex-wrap: wrap;
  margin-bottom: 40px;
}
.stat-item { flex: 1; min-width: 120px; text-align: center; }
.stat-item + .stat-item { border-left: 1px solid rgba(255,255,255,0.1); }
@media (max-width: 600px) {
  .stat-item + .stat-item { border-left: none; border-top: 1px solid rgba(255,255,255,0.1); }
}

/* ── Filter / Niveau Tabs ── */
.filter-tab, .niveau-tab {
  padding: 10px 22px;
  border-radius: 50px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid var(--border);
  background: var(--card-bg);
  color: var(--sub);
  transition: all 0.2s;
  white-space: nowrap;
}
.filter-tab:hover, .niveau-tab:hover { border-color: var(--mid); color: var(--mid); }
.filter-tab.active, .niveau-tab.active {
  background: linear-gradient(135deg, #1b4f8a, #4fa3e0);
  color: white;
  border-color: transparent;
  box-shadow: 0 4px 16px rgba(46,111,197,0.3);
}

.filter-scroll, .niveau-tabs-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.filter-scroll::-webkit-scrollbar,
.niveau-tabs-scroll::-webkit-scrollbar { display: none; }

/* ── Book Cards (boutique) ── */
.book-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
  transition: transform 0.25s, box-shadow 0.25s, border-color 0.25s;
  display: flex;
  flex-direction: column;
  animation: fadeUp 0.4s ease both;
}
.book-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 48px rgba(30,80,160,0.15);
  border-color: var(--sky);
}

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

.book-cover {
  width: 100%;
  aspect-ratio: 3/4;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background: #e8f0fa;
}

.cover-manuel     { background: linear-gradient(145deg, #0d3b72, #1b4f8a, #2e6fc5, #4fa3e0); }
.cover-exercices  { background: linear-gradient(145deg, #0a4a3a, #0d6e53, #10a077, #34d3a0); }
.cover-preparation{ background: linear-gradient(145deg, #5a1a6a, #8b2fa0, #b44fc5, #d47ae0); }

.cover-inner {
  width: 85%; height: 88%;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 10px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 14px; position: relative;
}
.cover-inner::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.05) 0%, transparent 60%);
  border-radius: 10px;
}
.cover-logo   { font-size: 13px; font-weight: 900; color: rgba(255,255,255,0.9); letter-spacing: 1px; text-transform: uppercase; margin-bottom: 8px; }
.cover-divider{ width: 40px; height: 2px; background: rgba(255,255,255,0.4); margin-bottom: 10px; }
.cover-title  { font-size: 11px; font-weight: 700; color: white; text-align: center; line-height: 1.4; margin-bottom: 10px; }
.cover-badge  { font-size: 9px; font-weight: 700; color: rgba(255,255,255,0.7); text-transform: uppercase; letter-spacing: 1.5px; border: 1px solid rgba(255,255,255,0.3); border-radius: 20px; padding: 3px 10px; }
.cover-deco   { position: absolute; font-size: 52px; font-family: serif; font-style: italic; opacity: 0.08; bottom: -6px; right: 4px; color: white; line-height: 1; }

.book-info { padding: 16px; flex: 1; display: flex; flex-direction: column; gap: 10px; }

.book-cat-badge { display: inline-flex; align-items: center; font-size: 10px; font-weight: 700; padding: 3px 10px; border-radius: 20px; text-transform: uppercase; letter-spacing: 0.8px; width: fit-content; }
.cat-manuel      { background: rgba(27,79,138,0.12); color: #1b4f8a; }
.cat-exercices   { background: rgba(16,160,119,0.12); color: #0a7a5a; }
.cat-preparation { background: rgba(139,47,160,0.12); color: #8b2fa0; }
.dark .cat-manuel      { background: rgba(125,211,252,0.15); color: #7dd3fc; }
.dark .cat-exercices   { background: rgba(52,211,160,0.15); color: #34d3a0; }
.dark .cat-preparation { background: rgba(212,122,224,0.15); color: #d47ae0; }

.book-title { font-size: 14px; font-weight: 700; color: var(--text); line-height: 1.4; flex: 1; }

.book-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; }

.btn-order {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 14px; border-radius: 12px; font-size: 13px; font-weight: 600;
  cursor: pointer; border: none;
  background: linear-gradient(135deg, #1b4f8a, #4fa3e0); color: white;
  transition: all 0.2s;
}
.btn-order:hover { opacity: 0.9; transform: translateY(-1px); box-shadow: 0 6px 20px rgba(46,111,197,0.35); }

.btn-whatsapp {
  width: 38px; height: 38px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: #25D366; border: none; cursor: pointer; flex-shrink: 0;
  transition: all 0.2s;
}
.btn-whatsapp:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-whatsapp svg { width: 18px; height: 18px; fill: white; }

/* ── Boutique Modal ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(7,14,26,0.7);
  backdrop-filter: blur(6px);
  z-index: 200; display: flex;
  align-items: center; justify-content: center;
  padding: 20px; opacity: 0; pointer-events: none;
  transition: opacity 0.25s;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal-box {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: 24px; max-width: 440px; width: 100%; padding: 32px;
  transform: translateY(20px) scale(0.97);
  transition: transform 0.25s; position: relative;
}
.modal-overlay.open .modal-box { transform: translateY(0) scale(1); }

/* ── Niveaux Page ── */
.num-badge {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, #1b4f8a, #4fa3e0);
  color: white; font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.lesson-done .num-badge { background: linear-gradient(135deg, #16a34a, #4ade80); }
.lesson-done .lesson-check { display: flex; }

.res-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 20px; border-radius: 14px;
  border: 1.5px solid var(--border); background: var(--card-bg);
  color: var(--text); cursor: pointer; font-size: 14px; font-weight: 600;
  transition: all 0.2s; width: 100%; text-align: left;
}
.res-btn:hover { border-color: var(--mid); background: rgba(46,111,197,0.06); color: var(--mid); }
.res-btn.active-res { border-color: var(--mid); background: rgba(46,111,197,0.1); color: var(--mid); }

@media (min-width: 1024px) {
  .lessons-sidebar { position: sticky; top: 80px; max-height: calc(100vh - 100px); overflow-y: auto; }
  .lessons-sidebar::-webkit-scrollbar { width: 4px; }
  .lessons-sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
}

.video-container {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 1rem;
  overflow: hidden;
  background: #000;
  box-shadow: 0 4px 24px rgba(13,27,42,0.15);
}
.video-container iframe {
  width: 100%;
  height: 100%;
  display: block;
  border: none;
}

.progress-bar-track { width: 100%; height: 8px; background: rgba(46,111,197,0.15); border-radius: 99px; overflow: hidden; }
.progress-bar-fill  { height: 100%; background: linear-gradient(90deg, #1b4f8a, #4fa3e0); border-radius: 99px; transition: width 0.5s ease; }

.lesson-check {
  display: none; width: 18px; height: 18px; background: #16a34a;
  border-radius: 50%; align-items: center; justify-content: center;
  flex-shrink: 0; margin-left: auto;
}
.lesson-check svg { width: 11px; height: 11px; color: white; }

.video-shield {
  position: absolute; inset: 0; z-index: 10;
  background: transparent; cursor: default; border-radius: 1rem;
  -webkit-user-select: none; user-select: none;
  pointer-events: none;
}

/* ── Index Hero ── */
.hero-bg {
  background:
    radial-gradient(ellipse at 60% 40%, rgba(79,163,224,0.18) 0%, transparent 60%),
    radial-gradient(ellipse at 10% 80%, rgba(27,79,138,0.15) 0%, transparent 50%),
    var(--light-bg);
}
.grid-pattern {
  background-image:
    linear-gradient(rgba(46,111,197,0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(46,111,197,0.07) 1px, transparent 1px);
  background-size: 40px 40px;
}

/* ── Index animations ── */
.fade-in { opacity: 0; transform: translateY(24px); transition: opacity 0.6s ease, transform 0.6s ease; }
.fade-in.visible { opacity: 1; transform: translateY(0); }

.math-float { animation: float 6s ease-in-out infinite; }
.math-float-2 { animation: float 8s ease-in-out infinite 2s; }
@keyframes float { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-14px)} }

.level-card:hover { transform: translateY(-6px); box-shadow: 0 20px 60px rgba(46,111,197,0.18); }
.star { color: #f59e0b; }

.avis-card { background: var(--card-bg); }
input, textarea, select { background: var(--card-bg); color: var(--text); border-color: var(--border); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--mid); }

/* ── Empty State ── */
#emptyState { display: none; }

/* ════════════════════════════════════════════════
   NEW FEATURES CSS
   ════════════════════════════════════════════════ */

/* ── Streak Widget ── */
#streakWidget { animation: slideInRight 0.4s ease; }
@keyframes slideInRight {
  from { transform: translateX(80px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* ── Exam Countdown ── */
#examCountdown { animation: fadeUp 0.5s ease 0.3s both; }

/* ── Quiz ── */
#quizContainer { animation: fadeUp 0.35s ease both; }
#optionsList button:hover {
  border-color: var(--mid) !important;
  background: rgba(46,111,197,0.06) !important;
}

/* ── Step-by-step ── */
#stepByStepWidget { animation: fadeUp 0.35s ease both; }

/* ── Past Exams ── */
#pastExamsPanel { animation: fadeUp 0.35s ease both; }

/* ── Social Actions ── */
#socialActions { animation: fadeUp 0.35s ease both; }

/* ── Lesson done state ── */
.lesson-done { background: rgba(22,163,74,0.04); }
.lesson-done .num-badge { background: linear-gradient(135deg, #16a34a, #4ade80) !important; }
.lesson-done .section-title {
  text-decoration: line-through;
  text-decoration-color: rgba(22,163,74,0.4);
  opacity: 0.7;
}

/* ── Lesson search ── */
#lessonSearch:focus {
  outline: none;
  border-color: var(--mid);
  box-shadow: 0 0 0 3px rgba(46,111,197,0.12);
}

/* ── Admin Dashboard ── */
#adminOverlay { animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* floating mark-done removed */

/* ── Mobile hero fixes ── */
@media (max-width: 767px) {
  #hero { overflow-x: hidden; min-height: 0 !important; }
  #hero h1 { font-size: clamp(1.8rem, 9vw, 3rem) !important; word-break: break-word; }
  #hero .absolute { display: none; } /* hide floating math symbols on mobile */

  /* Continue learning card */
  #hero [style*="border-radius: 16px"] {
    width: 100% !important;
    box-sizing: border-box !important;
    max-width: 100% !important;
  }

  /* Exam countdown */
  #examCountdown {
    margin: 16px 0 !important;
    border-radius: 12px !important;
  }
  #examCountdown #cdUnits > div {
    padding: 8px 0 !important;
  }

  /* Streak widget smaller on mobile */
  #streakWidget {
    bottom: 12px !important;
    right: 12px !important;
    padding: 8px 12px !important;
    min-width: 100px !important;
    font-size: 12px !important;
  }
}

/* ── Mobile tweaks ── */
@media (max-width: 768px) {
  /* Streak widget */
  #streakWidget { bottom: 16px; right: 16px; padding: 10px 14px; min-width: 120px; }

  /* Exam countdown */
  #examCountdown { padding: 16px; margin: 16px 0; border-radius: 16px; }
  #examCountdown #cdUnits { gap: 6px; }
  #examCountdown #cdUnits > div { min-width: 46px; padding: 8px 10px; border-radius: 8px; }
  #examCountdown #cdUnits #cd-days,
  #examCountdown #cdUnits #cd-hours,
  #examCountdown #cdUnits #cd-mins { font-size: 20px; }

  /* Hero section */
  #hero { padding-bottom: 40px; }
  #hero .pi-logo { word-break: break-word; }

  /* Continue learning card */
  #continueLearningCard { margin-top: 16px; padding: 12px 14px; }
  #continueLearningCard > div:first-of-type { min-width: 0; }
  #continueLearningCard div[style*="flex:1"] { min-width: 0; overflow: hidden; }

  /* Buttons in hero — stack on very small screens */
  #hero .flex.flex-wrap.gap-3 { gap: 8px; }
  #hero .btn-outline, #hero .btn-primary { width: 100%; justify-content: center; }
}

/* Prevent horizontal scroll globally */
body { overflow-x: hidden; }
html { overflow-x: hidden; }
#examCountdown { max-width: 100% !important; }
