/* ========================================================================
   Silex Local — Base, reset, body, scrollbar, focus
   ======================================================================== */

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  background: var(--bg);
  transition: background var(--t-base);
}

body {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  font-weight: var(--fw-regular);
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  transition: background var(--t-base), color var(--t-base);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

html[data-theme="light"] body {
  background-image: none;
}

/* Boutons reset */
button {
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

/* Liens */
a {
  color: inherit;
  text-decoration: none;
}

/* Inputs */
input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* Listes */
ul, ol {
  list-style: none;
}

/* Images */
img, svg {
  display: block;
  max-width: 100%;
  height: auto;
}

/* Tables */
table {
  border-collapse: collapse;
  width: 100%;
}

/* Focus visible accessible */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--r-2);
}

button:focus,
a:focus,
input:focus,
select:focus,
textarea:focus {
  outline: none;
}

/* Scrollbar custom */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg-2);
}

::-webkit-scrollbar-thumb {
  background: var(--border-2);
  border-radius: var(--r-3);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-3);
}

/* Typo helpers */
.h-display {
  font-family: var(--font-display);
  font-weight: var(--fw-extra);
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.h-mono {
  font-family: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

/* Texte secondaire */
.text-2 { color: var(--text-2); }
.text-3 { color: var(--text-3); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger  { color: var(--danger); }
.text-primary { color: var(--primary); }
.text-accent  { color: var(--accent); }

/* Layout root */
#app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* Mode embed : Silex Local utilisé comme module dans Le-Silex.
   Le menu gauche de Le-Silex est déjà présent, on cache le nôtre. */
body.is-embed #app {
  grid-template-columns: 1fr;
}
body.is-embed .sidebar {
  display: none;
}
body.is-embed .workspace-main {
  padding: var(--sp-5) var(--sp-6);
  max-width: 1280px;
  margin: 0 auto;
}

.workspace {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 100vh;
  position: relative;
}

.workspace.has-sidebar-2 {
  grid-template-columns: var(--sidebar-2-w) 1fr;
}

.workspace-main {
  padding: var(--sp-7) var(--sp-8);
  overflow-x: hidden;
  min-width: 0;
}

/* Loaders & utils */
.skeleton {
  background: linear-gradient(90deg, var(--bg-3) 0%, var(--surface) 50%, var(--bg-3) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.6s infinite;
  border-radius: var(--r-3);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Hidden utility */
.hidden { display: none !important; }
.invisible { visibility: hidden; }

/* Print : sidebar masquée, layout vertical */
@media print {
  #app {
    grid-template-columns: 1fr;
  }
  .sidebar, .sidebar-secondary, .header-tools, .ai-coach-fab {
    display: none !important;
  }
  .workspace-main {
    padding: 0;
  }
}
