/* Yannm dashboard — reset + typography + base layout */

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

html {
  background: var(--surface-0);
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  background: var(--surface-1);
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img,
svg,
video,
canvas {
  display: block;
  max-width: 100%;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--t-fast);
}

a:hover {
  color: var(--accent-hover);
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: none;
}

::selection {
  background: var(--accent-soft);
  color: var(--text-primary);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Scrollbar dark */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: var(--surface-1);
}
::-webkit-scrollbar-thumb {
  background: var(--surface-3);
  border-radius: var(--radius-full);
  border: 2px solid var(--surface-1);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--surface-4);
}

/* ── Typographie ─────────────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  letter-spacing: -0.01em;
}

h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }

p {
  color: var(--text-secondary);
}

code,
kbd,
samp,
pre {
  font-family: var(--font-mono);
  font-size: 0.875em;
}

/* ── Helpers ─────────────────────────────────────────────────────────── */
.container {
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--space-6);
}

.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger  { color: var(--danger); }
.text-accent  { color: var(--accent); }

.mono { font-family: var(--font-mono); }

.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }

.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;
}

/* ── App layout (avec sidebar) ───────────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
}

.app-main {
  display: flex;
  flex-direction: column;
  min-width: 0; /* permet au grid de réduire correctement */
}

.app-content {
  flex: 1;
  padding: var(--space-8);
  overflow-y: auto;
}

/* ── Burger button (caché desktop, visible mobile) ───────────────────── */
.topbar__burger {
  display: none;
  background: none;
  border: 0;
  padding: var(--space-2);
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-md);
}
.topbar__burger:hover {
  background: var(--surface-2);
  color: var(--text-primary);
}
.topbar__burger svg {
  width: 24px;
  height: 24px;
}

.sidebar-overlay {
  display: none;
}

/* ── Layout responsive ───────────────────────────────────────────────── */

/* Tablette + mobile (≤1024px) : sidebar drawer + paddings réduits. */
@media (max-width: 1024px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .app-content {
    padding: var(--space-4);
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 82%;
    max-width: 300px;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform var(--t-base);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.is-open {
    transform: translateX(0);
  }
  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: var(--overlay);
    z-index: 150;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--t-base);
  }
  .sidebar-overlay.is-visible {
    opacity: 1;
    pointer-events: auto;
  }
  .topbar__burger {
    display: inline-flex;
  }
  /* Tables : scroll horizontal pour préserver les colonnes. */
  .app-content table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
  .card {
    padding: var(--space-4);
  }
  /* Hit-targets touch confortables. */
  .btn {
    min-height: 40px;
  }
  /* Hero grids : laisse le auto-fit tomber à 1-2 colonnes. */
  h1 {
    font-size: var(--text-2xl);
  }
  h2 {
    font-size: var(--text-xl);
  }
}

/* Mobile (<768px) : layout 1 colonne, paddings encore plus serrés. */
@media (max-width: 768px) {
  body {
    font-size: var(--text-sm);
  }
  .app-content {
    padding: var(--space-3);
  }
  .topbar {
    padding: 0 var(--space-3);
  }
  .topbar__title {
    font-size: var(--text-sm);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  /* Cache le nom dans le pill, garde l'avatar. */
  .user-pill span {
    display: none;
  }
  .user-pill {
    padding: var(--space-1);
  }
  .card {
    padding: var(--space-3);
    border-radius: var(--radius-md);
  }
  h1 {
    font-size: var(--text-xl);
  }
  h2 {
    font-size: var(--text-lg);
  }
  h3 {
    font-size: var(--text-md);
  }
  .stat__value {
    font-size: var(--text-2xl);
  }
  /* Boutons : on remplit la largeur des form actions. */
  .btn {
    padding: var(--space-3) var(--space-4);
  }
  /* Safe-area iOS pour les éléments en bas (chat input par ex.). */
  .app-content {
    padding-bottom: calc(var(--space-3) + env(safe-area-inset-bottom));
  }
}

/* Très petit mobile (<400px) : stat cards en 2 colonnes max. */
@media (max-width: 400px) {
  .app-content {
    padding: var(--space-2);
  }
}

/* ── Layout centré (login, enroll) ───────────────────────────────────── */
.center-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--space-6);
  background:
    radial-gradient(circle at 20% 10%, rgba(255, 107, 26, 0.08), transparent 40%),
    radial-gradient(circle at 80% 90%, rgba(96, 165, 250, 0.05), transparent 40%),
    var(--surface-1);
}
