/* ===============================
   Variables & Thèmes
================================ */
:root{
  --bg:#0b1020;
  --panel:#101a33;
  --panel2:#0f1730;
  --text:#e7ecff;
  --muted:#aeb9e6;
  --border:rgba(255,255,255,.08);
  --accent:#6aa6ff;

  --bgLight:#f6f8ff;
  --panelLight:#ffffff;
  --panel2Light:#f0f3ff;
  --textLight:#0b1020;
  --mutedLight:#4a567a;
  --borderLight:rgba(10,16,32,.10);
}

/* ===============================
   Reset & Base
================================ */
*{box-sizing:border-box}
html,body{height:100%}

body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial;
  background: var(--bgLight);
  color: var(--textLight);
}

body[data-theme="dark"]{
  background: var(--bg);
  color: var(--text);
}

/* ===============================
   Topbar
================================ */
.topbar{
  position: sticky;
  top: 0;
  z-index: 10;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--borderLight);
  background: rgba(255,255,255,.75);
  backdrop-filter: blur(10px);
}

body[data-theme="dark"] .topbar{
  border-bottom: 1px solid var(--border);
  background: rgba(16,26,51,.75);
}

.brand{
  display:flex;
  align-items:center;
  gap:10px;
}

.logo{font-size:22px}
.title{font-weight:700}

.actions{
  display:flex;
  align-items:center;
  gap:10px;
}

/* ===============================
   Search & Buttons
================================ */
#search{
  width:min(420px, 58vw);
  padding:10px 12px;
  border-radius: 12px;
  border:1px solid var(--borderLight);
  background: var(--panelLight);
  color: inherit;
  outline:none;
}

body[data-theme="dark"] #search{
  border:1px solid var(--border);
  background: var(--panel);
}

.btn{
  border:1px solid var(--borderLight);
  background: var(--panelLight);
  padding:10px 12px;
  border-radius: 12px;
  cursor:pointer;
}

body[data-theme="dark"] .btn{
  border:1px solid var(--border);
  background: var(--panel);
  color: var(--text);
}

/* ===============================
   Layout
================================ */
.layout{
  display:grid;
  grid-template-columns: 280px 1fr;
  min-height: calc(100vh - 58px);
}

/* ===============================
   Sidebar
================================ */
.sidebar{
  border-right: 1px solid var(--borderLight);
  background: var(--panel2Light);
  padding: 14px;
}

body[data-theme="dark"] .sidebar{
  border-right: 1px solid var(--border);
  background: var(--panel2);
}

.nav-section{
  font-size:12px;
  letter-spacing:.08em;
  text-transform:uppercase;
  color: var(--mutedLight);
  margin: 10px 6px;
}

body[data-theme="dark"] .nav-section{
  color: var(--muted);
}

.nav-list{
  list-style:none;
  padding:0;
  margin:0;
}

.nav-list li{margin:6px 0}

.nav-list a{
  display:block;
  padding:10px;
  border-radius: 12px;
  text-decoration:none;
  color: inherit;
  border: 1px solid transparent;
}

.nav-list a:hover{
  border-color: var(--borderLight);
  background: rgba(255,255,255,.6);
}

body[data-theme="dark"] .nav-list a:hover{
  border-color: var(--border);
  background: rgba(255,255,255,.06);
}

.nav-list a.active{
  border-color: rgba(106,166,255,.35);
  background: rgba(106,166,255,.10);
}

/* ===============================
   Hint box
================================ */
.hint{
  margin-top: 16px;
  padding: 12px;
  border:1px solid var(--borderLight);
  border-radius: 14px;
  background: rgba(255,255,255,.6);
}

body[data-theme="dark"] .hint{
  border:1px solid var(--border);
  background: rgba(255,255,255,.05);
}

.hint-title{font-weight:700; margin-bottom:6px}
.hint-text{color: var(--mutedLight); font-size: 14px; line-height: 1.4}
body[data-theme="dark"] .hint-text{color: var(--muted)}

/* ===============================
   Content
================================ */
.content{
  padding: 18px 18px 40px;
}

.doc{
  max-width: 980px;
  margin: 0 auto;
  padding: 18px;
  border-radius: 18px;
  border: 1px solid var(--borderLight);
  background: var(--panelLight);
}

body[data-theme="dark"] .doc{
  border: 1px solid var(--border);
  background: var(--panel);
}

.doc h1,.doc h2,.doc h3{margin-top:0}
.doc p{line-height:1.55}

/* ===============================
   CODE BLOCKS (FIX IMPORTANT)
================================ */
pre{
  position: relative;       /* pour le bouton copier */
  max-width: 100%;
  overflow-x: auto;
  padding: 14px;
  border-radius: 14px;
  margin: 14px 0;
  background: rgba(0,0,0,0.05);
}

body[data-theme="dark"] pre{
  background: rgba(255,255,255,0.06);
}

pre code{
  display: block;
  white-space: pre-wrap;      /* autorise le retour à la ligne */
  word-break: break-word;     /* coupe les mots trop longs */
  overflow-wrap: anywhere;    /* sécurité max */
  line-height: 1.45;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.95em;
}

/* Scrollbar discrète */
pre::-webkit-scrollbar{ height: 8px; }
pre::-webkit-scrollbar-thumb{
  background: rgba(100,100,100,.3);
  border-radius: 10px;
}

/* ===============================
   Copy button for code blocks
================================ */
.copy-btn{
  position: absolute;
  top: 10px;
  right: 10px;
  border: 1px solid var(--borderLight);
  background: rgba(255,255,255,.85);
  color: inherit;
  padding: 6px 10px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  user-select: none;
}

.copy-btn:hover{
  background: rgba(255,255,255,1);
}

body[data-theme="dark"] .copy-btn{
  border: 1px solid var(--border);
  background: rgba(16,26,51,.92);
}

body[data-theme="dark"] .copy-btn:hover{
  background: rgba(16,26,51,1);
}

/* ===============================
   Inline Code
================================ */
code{
  font-family: ui-monospace, monospace;
  font-size: .95em;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(0,0,0,.06);
}

body[data-theme="dark"] code{
  background: rgba(255,255,255,.08);
}

/* ===============================
   Footer
================================ */
.footer{
  padding: 14px 16px;
  border-top: 1px solid var(--borderLight);
  color: var(--mutedLight);
}

body[data-theme="dark"] .footer{
  border-top: 1px solid var(--border);
  color: var(--muted);
}

/* ===============================
   Responsive
================================ */
@media (max-width: 900px){
  .layout{ grid-template-columns: 1fr; }
  .sidebar{ position: sticky; top: 58px; }
}
