/* ===========================================================
   BIIIM Docs — stylesheet
   Deux thèmes : clair (défaut) + sombre (data-theme="dark")
   =========================================================== */

/* ---------- Thème clair (défaut) ---------- */
:root {
  --bg: #f7f8fa;
  --bg-2: #ffffff;
  --surface: #ffffff;
  --surface-2: #f2f3f6;
  --surface-3: #e5e7eb;
  --border: #e5e7eb;
  --border-2: #d1d5db;
  --text: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;
  --accent: #4f46e5; /* indigo-600 */
  --accent-2: #4338ca; /* indigo-700 — hover / actif */
  --accent-bg: rgba(79, 70, 229, 0.1);
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-pill: 999px;
  --shadow: 0 4px 20px rgba(15, 23, 42, 0.08);
  --font:
    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
}

/* ---------- Thème sombre ---------- */
:root[data-theme="dark"] {
  --bg: #0b0b0d;
  --bg-2: #0f1013;
  --surface: #151619;
  --surface-2: #1c1d21;
  --surface-3: #24262b;
  --border: #26272c;
  --border-2: #33353b;
  --text: #ffffff;
  --text-muted: #a1a3a8;
  --text-dim: #6f7178;
  --accent: #6366f1;
  --accent-2: #818cf8;
  --accent-bg: rgba(99, 102, 241, 0.14);
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}
html,
body,
.header,
.sidenav,
.shot,
.callout,
table,
.placeholder,
.steps li {
  transition:
    background-color 0.2s ease,
    color 0.2s ease,
    border-color 0.2s ease;
}
body {
  min-height: 100vh;
}
a {
  color: inherit;
  text-decoration: none;
}
img {
  max-width: 100%;
  display: block;
}

/* ----------- layout ----------- */
.app {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100vh;
}

/* ----------- header ----------- */
.header {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 240px;
}
.brand .logo {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 14px;
}
.brand .name {
  font-weight: 600;
  font-size: 16px;
  color: var(--text);
}
.brand .version {
  margin-left: 14px;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--accent-2);
  background: var(--accent-bg);
  border-radius: var(--radius-pill);
  border: 1px solid rgba(99, 102, 241, 0.25);
}

.header-spacer {
  flex: 1;
}

/* ----------- search trigger (command K button) ----------- */
.search-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 420px;
  max-width: 100%;
  height: 38px;
  padding: 0 10px 0 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-dim);
  cursor: text;
  font-family: var(--font);
  font-size: 14px;
  transition:
    background-color 0.15s,
    border-color 0.15s,
    color 0.15s;
}
.search-trigger:hover {
  background: var(--surface-3);
  color: var(--text-muted);
}
.search-trigger svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.search-trigger-text {
  flex: 1;
  text-align: left;
}
.search-trigger-kbd {
  display: inline-flex;
  gap: 3px;
}
.search-trigger-kbd kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  font-family: var(--font);
  font-size: 11px;
  color: var(--text-muted);
}

/* ----------- command palette ----------- */
.cmdk[hidden] {
  display: none !important;
}
.cmdk {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 8vh;
}
.cmdk-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  animation: cmdk-fade-in 0.18s ease-out;
}
:root[data-theme="dark"] .cmdk-backdrop {
  background: rgba(0, 0, 0, 0.65);
}
.cmdk-panel {
  position: relative;
  width: 640px;
  max-width: calc(100% - 32px);
  max-height: 70vh;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: top center;
  animation: cmdk-pop-in 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}
.cmdk.closing .cmdk-backdrop {
  animation: cmdk-fade-out 0.14s ease-in forwards;
}
.cmdk.closing .cmdk-panel {
  animation: cmdk-pop-out 0.14s ease-in forwards;
}
@keyframes cmdk-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes cmdk-fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}
@keyframes cmdk-pop-in {
  from { opacity: 0; transform: translateY(-8px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes cmdk-pop-out {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(-6px) scale(0.97); }
}
.cmdk-input-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.cmdk-icon {
  width: 18px;
  height: 18px;
  color: var(--text-dim);
  flex-shrink: 0;
}
.cmdk-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
}
.cmdk-input::placeholder {
  color: var(--text-dim);
}
.cmdk-esc {
  font-size: 11px;
  color: var(--text-dim);
  padding: 3px 7px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface-2);
}
.cmdk-results {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}
.cmdk-group-label {
  padding: 10px 12px 6px 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.cmdk-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text);
  font-size: 14px;
  line-height: 1.3;
}
.cmdk-item .cmdk-item-title {
  flex: 1;
  min-width: 0;
}
.cmdk-item .cmdk-item-crumb {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}
.cmdk-item .cmdk-item-icon {
  color: var(--text-dim);
  display: inline-flex;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.cmdk-item .cmdk-item-icon svg {
  width: 16px;
  height: 16px;
}
.cmdk-item.selected,
.cmdk-item:hover {
  background: var(--surface-2);
}
.cmdk-item.selected .cmdk-item-crumb,
.cmdk-item.selected .cmdk-item-icon {
  color: var(--text-muted);
}
.cmdk-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--text-muted);
  font-size: 13px;
}
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  transition:
    background-color 0.15s,
    color 0.15s,
    border-color 0.15s;
}
.theme-toggle:hover {
  background: var(--surface-3);
  color: var(--text);
}
.theme-toggle svg {
  width: 18px;
  height: 18px;
}
/* Icon swap based on theme */
.theme-toggle .sun {
  display: none;
}
.theme-toggle .moon {
  display: block;
}
:root[data-theme="dark"] .theme-toggle .sun {
  display: block;
}
:root[data-theme="dark"] .theme-toggle .moon {
  display: none;
}

/* ----------- main content area ----------- */
.main {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 0;
  overflow: hidden;
}

/* ----------- side nav ----------- */
.sidenav {
  padding: 22px 14px 40px 20px;
  border-right: none;
  background: transparent;
  overflow-y: auto;
}
.sidenav .nav-group {
  margin-bottom: 36px;
}
.sidenav .nav-group-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 600;
  margin-bottom: 10px;
  padding: 0 14px;
}
.sidenav .nav-group-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  color: var(--text-dim);
}
.sidenav .nav-group-icon svg {
  width: 14px;
  height: 14px;
}
.sidenav .nav-group-items {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.sidenav .nav-link {
  display: block;
  padding: 10px 14px;
  font-size: 14px;
  color: var(--text);
  font-weight: 400;
  border-radius: 10px;
  cursor: pointer;
  transition:
    color 0.15s,
    background-color 0.15s;
}
.sidenav .nav-link:hover {
  background: var(--surface-2);
}
.sidenav .nav-link.active {
  color: var(--accent-2);
  font-weight: 500;
}

/* ----------- content ----------- */
.content {
  padding: 40px 56px 240px 56px;
  width: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.content > * {
  width: 100%;
  max-width: 752px;
}

.page-header {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 12px;
}
.page-header .squareicon {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  background: var(--accent-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-2);
}
.page-header h1 {
  margin: 0;
  font-size: 42px;
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.page-lede {
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1.6;
  max-width: 752px;
  margin: 16px 0 30px 0;
}

/* section block within page */
.section {
  margin: 40px 0;
  scroll-margin-top: 100px;
}
.section h2 {
  font-size: 26px;
  margin: 0 0 10px 0;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.section h3 {
  font-size: 18px;
  margin: 24px 0 8px 0;
  font-weight: 600;
  color: var(--text);
}
.section p,
.section li {
  color: var(--text-muted);
  line-height: 1.65;
  font-size: 15px;
}
.section p {
  margin: 0 0 12px 0;
}
.section ul,
.section ol {
  margin: 0 0 16px 0;
  padding-left: 22px;
}
.section ul li,
.section ol li {
  margin-bottom: 6px;
}
.section strong {
  color: var(--text);
  font-weight: 600;
}
.section code {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--accent-2);
}

/* procédure — liste numérotée stylée */
.steps {
  counter-reset: step;
  list-style: none;
  padding: 0;
  margin: 14px 0 22px 0;
}
.steps li {
  position: relative;
  counter-increment: step;
  padding: 4px 16px 10px 52px;
  background: transparent;
  border: none;
  border-radius: 0;
  margin-bottom: 0;
  color: var(--text);
  line-height: 1.55;
}
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #282828;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  z-index: 1;
}
.steps li{ margin-bottom: 0; }
.steps li::after {
  content: '';
  position: absolute;
  left: 13.5px;
  top: 26px;
  height: calc(100% - 20px);
  width: 1px;
  background: #282828;
}
.steps li:last-child::after {
  display: none;
}

/* note / tip blocks */
.callout {
  --callout-color: var(--accent);
  --callout-bg: color-mix(in srgb, var(--callout-color) 8%, transparent);
  --callout-border: color-mix(in srgb, var(--callout-color) 35%, transparent);
  border-radius: 16px;
  padding: 14px 18px;
  margin: 18px 0;
  background: var(--callout-bg);
  border: 1px solid var(--callout-border);
  color: var(--callout-color);
}
.callout.tip {
  --callout-color: var(--success);
}
.callout.warn {
  --callout-color: var(--warning);
}
.callout.danger {
  --callout-color: var(--danger);
}
.callout.info {
  --callout-color: var(--accent);
}
.callout .title {
  font-weight: 600;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--callout-color);
}
.callout p {
  margin: 0;
  color: var(--callout-color);
}
.callout .callout-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.callout .callout-icon svg {
  width: 18px;
  height: 18px;
}

/* screenshot frame */
.shot {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  margin: 22px 0;
  box-shadow: var(--shadow);
}
:root[data-theme="dark"] .shot {
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg-2) 100%);
}
.shot img {
  border-radius: 10px;
  display: block;
  width: 100%;
  border: 1px solid var(--border);
  cursor: zoom-in;
  transition: transform 0.15s ease;
}
.shot img:hover {
  transform: scale(1.005);
}

/* ----------- page navigation (prev / next) ----------- */
.page-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 56px 0 0 0;
}
.page-nav-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition:
    border-color 0.15s,
    background-color 0.15s;
  min-height: 72px;
}
.page-nav-card:hover {
  border-color: var(--border-2);
  background: var(--surface-2);
}
.page-nav-empty {
  visibility: hidden;
  cursor: default;
  border-color: transparent;
}
.page-nav-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 400;
}
.page-nav-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.page-nav-chevron svg {
  width: 16px;
  height: 16px;
}
.page-nav-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
}
/* next card: align contents to the right */
.page-nav-card:last-child {
  align-items: flex-end;
  text-align: right;
}
.page-nav-card:last-child .page-nav-meta {
  flex-direction: row;
}

/* ----------- lightbox ----------- */
.lightbox[hidden] {
  display: none !important;
}
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(10px);
  animation: cmdk-fade-in 0.18s ease-out;
}
:root[data-theme="dark"] .lightbox-backdrop {
  background: rgba(0, 0, 0, 0.7);
}
.lightbox-content {
  position: relative;
  max-width: 95vw;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  animation: cmdk-pop-in 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.lightbox-content img {
  max-width: 95vw;
  max-height: 85vh;
  width: auto;
  height: auto;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  display: block;
}
.lightbox-caption {
  color: #fff;
  font-size: 14px;
  text-align: center;
  max-width: 80ch;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}
.lightbox-close {
  position: absolute;
  top: -48px;
  right: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.15s;
}
.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.22);
}
.lightbox-close svg {
  width: 20px;
  height: 20px;
}
.lightbox.closing .lightbox-backdrop {
  animation: cmdk-fade-out 0.14s ease-in forwards;
}
.lightbox.closing .lightbox-content {
  animation: cmdk-pop-out 0.14s ease-in forwards;
}
.shot .caption {
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-dim);
  text-align: center;
}

/* annotation legend (below screenshots) */
.legend {
  list-style: none;
  padding: 0;
  margin: 14px 0 0 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
.legend li {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 12px;
  align-items: baseline;
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
}
.legend li .num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  border: 2px solid #fff;
}
.legend li b {
  color: var(--text);
  font-weight: 600;
}

/* table */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0 22px 0;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  font-size: 14px;
}
table th,
table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
table th {
  background: var(--surface-2);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 13px;
  letter-spacing: 0.02em;
}
table tr:last-child td {
  border-bottom: none;
}
table tr:hover td {
  background: var(--surface-2);
}

/* placeholder block (sections non documentées) */
.placeholder {
  border: 1px dashed var(--border-2);
  border-radius: var(--radius);
  padding: 28px;
  color: var(--text-dim);
  text-align: center;
  background: var(--surface);
}
.placeholder .title {
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 600;
}

/* responsive */
@media (max-width: 1000px) {
  .main {
    grid-template-columns: 1fr;
  }
  .sidenav {
    border-right: none;
    border-bottom: 1px solid var(--border);
    min-height: auto;
  }
  .content {
    padding: 30px 22px 60px 22px;
  }
  .page-header h1 {
    font-size: 32px;
  }
}

/* util */
.hidden {
  display: none !important;
}
