/* Structure : barre latérale, barre supérieure, zone de contenu. */
*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01";
}

a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
svg { display: block; }
::selection { background: var(--accent-soft); }

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
  /* Fond et bordure de la barre latérale prolongés sur toute la hauteur de la page. */
  background: linear-gradient(to right, var(--bg-sidebar) calc(var(--sidebar-w) - 1px), var(--border) calc(var(--sidebar-w) - 1px), var(--border) var(--sidebar-w), transparent var(--sidebar-w));
}

/* Barre latérale */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 10px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 16px;
}
.brand-mark { width: 26px; height: 26px; flex: none; }
.brand-name { font-weight: 650; letter-spacing: -0.01em; font-size: 15px; }
.brand-sub { color: var(--text-3); font-size: 12px; margin-top: -2px; }

.nav-label {
  padding: 14px 10px 6px;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 550;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 32px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-weight: 500;
  transition: background 120ms var(--ease), color 120ms var(--ease);
}
.nav-item svg { width: 16px; height: 16px; flex: none; opacity: 0.85; }
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item[aria-current="page"] { background: var(--active); color: var(--text); }
.nav-item[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  border-radius: 2px;
  background: var(--accent);
}
.nav-item .nav-count {
  margin-left: auto;
  min-width: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  line-height: 18px;
  font-variant-numeric: tabular-nums;
}
.nav-item .nav-count[data-tone="danger"] { background: var(--danger-soft); color: var(--danger); }
.nav-item .nav-count:empty { display: none; }

.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--border);
  color: var(--text-3);
  font-size: 12px;
}
.source-pill { display: inline-flex; align-items: center; gap: 8px; color: var(--text-2); }
.source-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--warning); }
.source-pill[data-mode="postgres"] .dot { background: var(--success); }
.source-pill[data-mode="actions"] svg { color: var(--accent-2); }

/* Barre supérieure */
.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--topbar-h);
  padding: 0 24px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.crumbs { display: flex; align-items: center; gap: 8px; color: var(--text-3); font-size: 13px; white-space: nowrap; }
.crumbs strong { color: var(--text); font-weight: 550; }
.crumbs svg { width: 14px; height: 14px; }
.topbar-spacer { flex: 1; }

.search {
  position: relative;
  display: flex;
  align-items: center;
  width: min(320px, 34vw);
}
.search svg { position: absolute; left: 10px; width: 15px; height: 15px; color: var(--text-3); pointer-events: none; }
.search input {
  width: 100%;
  height: 32px;
  padding: 0 34px 0 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  outline: none;
  transition: border-color 120ms, box-shadow 120ms;
}
.search input::placeholder { color: var(--text-3); }
.search input:focus { border-color: var(--accent-ring); box-shadow: 0 0 0 3px var(--accent-soft); }
.search kbd { position: absolute; right: 8px; }

.content {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px 32px 64px;
}

/* Tablette : barre latérale réduite aux icônes */
@media (max-width: 1100px) {
  :root { --sidebar-w: 64px; }
  .brand { justify-content: center; padding: 4px 0 16px; }
  .brand-text, .nav-label, .nav-item span, .sidebar-footer .source-text, .sidebar-footer .version { display: none; }
  .nav-item { justify-content: center; padding: 0; }
  .nav-item .nav-count { position: absolute; top: 2px; right: 4px; min-width: 16px; padding: 0 4px; line-height: 15px; font-size: 10px; }
  .sidebar-footer { align-items: center; padding: 10px 0; }
  .content { padding: 24px 20px 56px; }
}

@media (max-width: 720px) {
  .app { grid-template-columns: minmax(0, 1fr); background: none; }
  .sidebar { position: fixed; bottom: 0; top: auto; left: 0; right: 0; z-index: 30; height: 56px; flex-direction: row; justify-content: space-around; padding: 8px; border-right: 0; border-top: 1px solid var(--border); }
  .brand, .sidebar-footer, .nav-label { display: none; }
  .nav-item { width: 44px; height: 40px; }
  .nav-item[aria-current="page"]::before { display: none; }
  .topbar { padding: 0 16px; }
  .search { width: auto; flex: 1; }
  .content { padding: 20px 16px 88px; }
}
