@page {
  size: A4 landscape;
  margin: 1cm;
}

:root {
  --bg:       #1e1e1e;
  --surface:  #252526;
  --surf2:    #2d2d2d;
  --surf3:    #333333;
  --border:   #454545;
  --border2:  #3c3c3c;
  --text:     #d4d4d4;
  --muted:    #858585;
  --primary:  #007acc;
  --primary-h:#0068b0;
  --blue:     #4fc1ff;
  --accent:   #4ec9b0;
  --radius:   2px;
  --shadow:   0 2px 6px rgba(0,0,0,0.3);
  --ease:     ease;
}

*, *::before, *::after { box-sizing: border-box; }

button, a, input, [role="button"] { touch-action: manipulation; }

html, body {
  height: 100%;
  margin: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ── Sidebar ── */
.sidebar {
  background: var(--surf3);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand { display: flex; align-items: center; gap: 10px; }

.brand .logo {
  width: 30px; height: 30px;
  border-radius: 2px;
  background: var(--primary);
  flex-shrink: 0;
}

.brand .title {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
}

.toggle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 2px;
  padding: 5px 8px;
  cursor: pointer;
  display: none;
}

.toggle:hover { background: var(--surf2); }

.nav { display: flex; flex-direction: row; gap: 3px; }

.nav a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 2px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.1s, color 0.1s;
}

.nav a:hover  { background: var(--surf2); color: var(--text); }
.nav a.active { background: rgba(79,193,255,0.1); color: var(--blue); }

/* ── Topbar (pages j + voir-formation) ── */
.vf-topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surf3);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  height: 46px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.vf-brand {
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vf-brand span { color: var(--blue); }

.vf-nav {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  position: relative;
}

.vf-days-wrap { position: relative; }

.vf-days-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 2px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.1s;
}

.vf-days-toggle:hover { background: var(--surf2); }

.vf-days {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  position: absolute;
  left: 0;
  top: calc(100% + 5px);
  min-width: 110px;
  background: var(--surf2);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 4px;
  gap: 2px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  opacity: 0;
  transform: translateY(-4px);
  transform-origin: top left;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 120;
}

.vf-nav.open .vf-days {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.vf-day {
  display: flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 2px;
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  text-decoration: none;
  transition: background 0.1s, color 0.1s;
}

.vf-day:hover  { background: var(--surf3); color: var(--text); }
.vf-day.active { background: var(--primary); color: #fff; }

/* Bouton nav générique */
.vf-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 2px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  color: var(--muted);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
  white-space: nowrap;
}

.vf-nav-btn:hover    { background: var(--surf2); color: var(--text); }
.vf-nav-btn.active   { background: rgba(79,193,255,0.1); border-color: var(--primary); color: var(--blue); }
.vf-nav-btn.back     { color: var(--text); border-color: var(--border); }
.vf-nav-btn:disabled { opacity: .3; cursor: default; }

/* ── Contenu ── */
.content {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--bg);
  min-height: calc(100vh - 46px);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 16px;
}

h1 {
  margin: 0 0 16px 0;
  font-size: clamp(1.3rem, 2vw + 0.8rem, 2rem);
  color: var(--text);
}

.muted { color: var(--muted); }

/* ── Boutons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 600;
  font-family: inherit;
  font-size: 0.875rem;
  text-decoration: none;
  transition: background 0.1s, border-color 0.1s;
}
.btn + .btn { margin-left: 6px; }

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

.btn-primary:hover {
  background: var(--primary-h);
  border-color: var(--primary-h);
}

.btn-secondary {
  background: transparent;
  color: var(--accent);
  border-color: rgba(78,201,176,.35);
}
.btn-secondary:hover {
  background: rgba(78,201,176,.12);
  border-color: var(--accent);
}

/* ── Timeline sections ── */
.section {
  position: relative;
  padding-left: 114px;
  margin-bottom: 32px;
  content-visibility: auto;
  contain-intrinsic-size: 0 180px;
}

.horaire {
  position: absolute;
  left: 0;
  top: 2px;
  width: 92px;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.4px;
  color: var(--blue);
  background: rgba(79,193,255,0.08);
  border: 1px solid rgba(79,193,255,0.22);
  border-radius: 2px;
  padding: 4px 8px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}

.horaire::after {
  content: '';
  position: absolute;
  left: 92px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 1px;
  background: rgba(79,193,255,0.28);
}

.section::before {
  content: '';
  position: absolute;
  left: 103px;
  top: 0;
  bottom: -32px;
  width: 1px;
  background: linear-gradient(180deg, rgba(79,193,255,0.3) 0%, rgba(79,193,255,0.04) 100%);
}

.section:last-child::before {
  background: linear-gradient(180deg, rgba(79,193,255,0.25) 0%, transparent 100%);
}

.section .important {
  background: rgba(78,201,176,0.08);
  border-left: 3px solid var(--accent);
  padding: 10px 14px;
  margin: 12px 0;
  border-radius: 2px;
  font-weight: 600;
  color: var(--text);
}

.section h2 {
  color: var(--blue);
  font-size: 1rem;
  margin-top: 14px;
  margin-bottom: 6px;
}

.section ul {
  margin: 6px 0;
  padding-left: 18px;
  color: var(--text);
}

.section li {
  margin-bottom: 5px;
  line-height: 1.5;
}

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

.section hr {
  border: none;
  height: 1px;
  background: var(--border2);
  margin: 20px 0;
}

/* ── Dropdown ── */
.dropdown { position: relative; display: inline-block; }

.dropdown-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  background: var(--primary);
  color: white;
  text-decoration: none;
  border-radius: var(--radius);
  font-weight: 600;
  margin-bottom: 10px;
  cursor: pointer;
  border: none;
  font-family: inherit;
  font-size: inherit;
}

.dropdown-btn:hover { background: var(--primary-h); }

.dropdown-content {
  display: none;
  position: absolute;
  background: var(--surf2);
  border: 1px solid var(--border);
  min-width: 200px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  border-radius: 2px;
  z-index: 1000;
  margin-top: 4px;
  overflow: hidden;
}

.dropdown-content a {
  color: var(--text);
  padding: 10px 14px;
  text-decoration: none;
  display: block;
  font-size: 0.875rem;
  transition: background 0.1s;
}

.dropdown-content a:hover { background: var(--surf3); }

.dropdown.active .dropdown-content { display: block; }

/* ── Tab system ── */
.tab-content        { display: none; }
.tab-content.active { display: block; }

/* ── Nav days bar ── */
.nav-days { margin-bottom: 12px; display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .toggle { display: block; }
  .brand .title { display: none; }
  .nav { gap: 3px; }
  .nav a { padding: 5px 10px; font-size: 0.8rem; }
}

/* Tablette */
@media (max-width: 900px) {
  .section         { padding-left: 90px; }
  .horaire         { width: 72px; font-size: 0.65rem; padding: 3px 6px; }
  .horaire::after  { left: 72px; width: 10px; }
  .section::before { left: 80px; }
}

/* Cibles de toucher min 44px */
@media (max-width: 768px) {
  .btn            { min-height: 44px; }
  .vf-nav-btn     { min-height: 44px; }
  .vf-days-toggle { min-height: 44px; }
  .vf-day         { min-height: 40px; }
}

/* Téléphone */
@media (max-width: 600px) {
  .vf-topbar {
    height: auto;
    min-height: 46px;
    padding: 6px 10px;
    flex-wrap: wrap;
    row-gap: 4px;
    gap: 5px;
  }
  .vf-brand { font-size: 12px; }
  .vf-nav {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap;
    gap: 4px;
    padding-bottom: 2px;
  }
  .vf-nav::-webkit-scrollbar { display: none; }
  .vf-days    { padding: 3px; gap: 1px; }
  .vf-day     { padding: 5px 10px; font-size: 11px; }
  .vf-nav-btn { padding: 4px 9px; font-size: 11px; }

  .content { padding: 12px; gap: 8px; min-height: calc(100vh - 92px); }
  h1 { font-size: 1.3rem; margin-bottom: 12px; }

  .section         { padding-left: 72px; margin-bottom: 20px; }
  .horaire         { width: 58px; font-size: 0.6rem; padding: 3px 6px; }
  .horaire::after  { left: 58px; width: 7px; }
  .section::before { left: 64px; bottom: -20px; }

  .btn { font-size: 0.8rem; padding: 7px 11px; }
}

/* Très petit écran */
@media (max-width: 380px) {
  .section {
    padding-left: 0;
    padding-top: 34px;
    margin-bottom: 18px;
  }
  .section::before { display: none; }
  .horaire { width: auto; }
  .horaire::after { display: none; }
}

/* Réduire les animations sur petit écran */
@media (max-width: 600px), (prefers-reduced-motion: reduce) {
  .vf-days    { transition: none; }
  .btn        { transition: background 0.1s; }
  .vf-nav-btn { transition: background 0.1s; }
}

/* ── Modal aperçu simulaton (simu-preview) ── */
.sp-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.72);
  z-index: 9500;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 16px 12px;
  overflow-y: auto;
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease;
}
.sp-backdrop.open { opacity: 1; pointer-events: auto; }
.sp-modal {
  background: #252526;
  border: 1px solid #454545;
  border-radius: 6px;
  box-shadow: 0 12px 40px rgba(0,0,0,.7);
  width: min(820px, 94vw);
  flex-shrink: 0;
  display: flex; flex-direction: column;
  transform: translateY(18px);
  transition: transform .2s ease;
}
.sp-backdrop.open .sp-modal { transform: translateY(0); }
.sp-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px 12px;
  border-bottom: 1px solid #3c3c3c;
  gap: 12px;
}
.sp-title {
  font-size: .95rem; font-weight: 600;
  color: #4fc1ff; letter-spacing: .02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sp-close {
  flex-shrink: 0;
  background: none; border: 1px solid #454545; border-radius: 3px;
  color: #858585; cursor: pointer;
  padding: 3px 8px; font-size: .8rem;
  transition: background .15s, color .15s;
}
.sp-close:hover { background: rgba(239,68,68,.15); color: #f87171; border-color: rgba(239,68,68,.4); }
.sp-body {
  padding: 20px 18px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 560px) { .sp-body { grid-template-columns: 1fr; } }
.sp-section {
  background: #2d2d2d;
  border: 1px solid #3c3c3c;
  border-radius: 4px;
  padding: 14px 16px;
}
.sp-section-label {
  font-size: .7rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: #4ec9b0;
  margin-bottom: 10px;
}
.sp-content { font-size: .88rem; color: #d4d4d4; line-height: 1.6; }
.sp-content p { margin: 0 0 8px; }
.sp-content p:last-child { margin-bottom: 0; }
.sp-content strong { color: #4fc1ff; }
.sp-content .psis-section { font-weight: 700; color: #4ec9b0; }
.sp-content .psis-block { margin-bottom: 6px; }
.sp-content .psis-row { margin: 2px 0 2px 12px; }
.sp-content .gap-top { margin-top: 10px; }
.sp-content .good-luck { font-weight: 700; color: #f59e0b; margin-top: 12px; }
.sp-content .scenario-text { margin-bottom: 8px; }

/* ── Print ── */
@media print {
  body { background: #fff; color: #000; }

  .tab-content {
    display: block !important;
    page-break-before: always;
  }
  .tab-content:first-of-type { page-break-before: auto; }

  .sidebar {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 9999;
    background: #fff;
    border-bottom: 2px solid #007acc;
    page-break-after: avoid;
  }

  .content { margin-top: 80px; }
  .toggle  { display: none; }
}
