/* =========================================================
   NovaERP — design system V1 (Lot L0)
   Direction : atelier technique clair (ardoise + émeraude)
   ========================================================= */

:root {
  --brand: #0f766e;
  --brand-ink: #134e4a;
  --ink: #15202b;
  --muted: #52606d;
  --paper: #f3f6f4;
  --paper-2: #e7eeea;
  --surface: #ffffff;
  --line: #c9d5cf;
  --accent: #c2410c;
  --danger: #b91c1c;
  --ok: #047857;
  --radius: 10px;
  --shadow: 0 18px 40px rgba(21, 32, 43, 0.08);
  --font-display: "Sora", "Segoe UI", sans-serif;
  --font-body: "Source Sans 3", "Segoe UI", sans-serif;
  --max: 1100px;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, #d9efe9 0%, transparent 55%),
    radial-gradient(900px 480px at 100% 0%, #e8f0ff 0%, transparent 50%),
    linear-gradient(180deg, var(--paper) 0%, var(--paper-2) 100%);
  line-height: 1.5;
}

a {
  color: var(--brand-ink);
}

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

img {
  max-width: 100%;
}

/* ---- Layout ---- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: var(--max);
  margin: 0 auto;
  padding: 1.25rem 1.5rem;
}

.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: -0.03em;
  color: var(--ink);
  text-decoration: none;
}

.brand span {
  color: var(--brand);
}

.site-footer {
  max-width: var(--max);
  margin: 3rem auto 0;
  padding: 1.5rem;
  color: var(--muted);
  font-size: 0.95rem;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.footer-links a {
  text-decoration: none;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 2.75rem;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn:focus-visible {
  outline: 3px solid #5eead4;
  outline-offset: 2px;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 10px 24px rgba(15, 118, 110, 0.28);
}

.btn-primary:hover {
  background: var(--brand-ink);
  color: #fff;
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.7);
}

.btn-block {
  width: 100%;
}

/* ---- Landing hero (une seule composition) ---- */
.hero {
  max-width: var(--max);
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
  min-height: calc(100vh - 8rem);
  display: grid;
  align-content: center;
  gap: 1.5rem;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  inset: 8% -10% auto auto;
  width: min(52vw, 520px);
  height: min(52vw, 520px);
  border-radius: 40% 60% 55% 45%;
  background:
    linear-gradient(145deg, rgba(15, 118, 110, 0.22), rgba(194, 65, 12, 0.12)),
    repeating-linear-gradient(
      -18deg,
      transparent,
      transparent 12px,
      rgba(19, 78, 74, 0.06) 12px,
      rgba(19, 78, 74, 0.06) 13px
    );
  animation: drift 14s ease-in-out infinite alternate;
  pointer-events: none;
  z-index: 0;
}

.hero > * {
  position: relative;
  z-index: 1;
}

@keyframes drift {
  from { transform: translate(0, 0) rotate(0deg); }
  to { transform: translate(-18px, 12px) rotate(4deg); }
}

.hero-brand {
  font-family: var(--font-display);
  font-size: clamp(2.8rem, 8vw, 5rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.05;
  margin: 0;
  animation: rise 0.7s ease both;
}

.hero-brand span {
  color: var(--brand);
}

.hero-tagline {
  max-width: 34rem;
  font-size: clamp(1.1rem, 2.4vw, 1.35rem);
  color: var(--muted);
  margin: 0;
  animation: rise 0.7s ease 0.1s both;
}

.hero-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.5rem;
  animation: rise 0.7s ease 0.2s both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.a11y-panel {
  max-width: var(--max);
  margin: 0 auto 2rem;
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.a11y-panel h2 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--ink);
  margin: 0 0 0.5rem;
}

.a11y-panel p {
  margin: 0 0 0.75rem;
  max-width: 62ch;
}

/* ---- Auth / content shells ---- */
.shell {
  max-width: 480px;
  margin: 2rem auto;
  padding: 0 1.5rem 3rem;
}

.shell-wide {
  max-width: 720px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
  padding: 1.75rem;
}

.panel h1 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  margin: 0 0 0.35rem;
  letter-spacing: -0.02em;
}

.panel .lead {
  color: var(--muted);
  margin: 0 0 1.5rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.form-group input,
.form-group select {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font: inherit;
  background: #fff;
}

.form-group input:focus-visible,
.form-group select:focus-visible {
  outline: 3px solid #5eead4;
  outline-offset: 1px;
  border-color: var(--brand);
}

.alert {
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

.alert-error {
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fecaca;
}

.alert-info {
  background: #ecfdf5;
  color: var(--ok);
  border: 1px solid #a7f3d0;
}

.access-list {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.access-list label {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}

.access-list label:hover,
.access-list input:focus-visible + .access-body {
  border-color: var(--brand);
}

.access-list input {
  margin-top: 0.25rem;
}

.access-body strong {
  display: block;
}

.access-body span {
  color: var(--muted);
  font-size: 0.95rem;
}

/* ---- App topbar ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.5rem;
  background: rgba(255, 255, 255, 0.85);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-meta {
  color: var(--muted);
  font-size: 0.95rem;
}

.app-main {
  max-width: var(--max);
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.app-main h1 {
  font-family: var(--font-display);
  letter-spacing: -0.02em;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
}

.skip-link:focus {
  left: 1rem;
  top: 1rem;
  z-index: 100;
  background: #fff;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  border: 2px solid var(--brand);
}

@media (max-width: 640px) {
  .site-header,
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ---- Studio + data tables (L1) ---- */
.studio-layout {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  gap: 1.25rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 3rem;
}

.studio-nav {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
}

.studio-nav ul {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
}

.studio-nav li {
  margin: 0.35rem 0;
}

.studio-main .lead {
  color: var(--muted);
}

.muted { color: var(--muted); font-size: 0.95rem; }

.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-draft { background: #ffedd5; color: #9a3412; }
.badge-published { background: #d1fae5; color: #065f46; }

.flash {
  max-width: 1200px;
  margin: 0.5rem auto;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius);
}
.flash-success, .flash-info { background: #ecfdf5; color: var(--ok); }
.flash-error { background: #fef2f2; color: var(--danger); }

.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.98rem;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--line);
}

.data-table th {
  font-family: var(--font-display);
  font-size: 0.85rem;
  color: var(--muted);
}

.form-inline-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem 1rem;
  align-items: end;
}

textarea {
  width: 100%;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font: inherit;
}

@media (max-width: 800px) {
  .studio-layout { grid-template-columns: 1fr; }
}

/* Bouton déconnexion (formulaire POST inline) */
.logout-form {
  display: inline;
  margin: 0;
}
.topbar nav,
.site-header nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

/* ---- ERP shell (layout type métier) ---- */
.erp-shell { min-height: 100vh; display: flex; flex-direction: column; }
.erp-topbar {
  display: grid;
  grid-template-columns: 1fr 1.2fr 1fr;
  gap: 1rem;
  align-items: center;
  padding: 0.65rem 1rem;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.erp-topbar-right { display: flex; gap: 0.5rem; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.erp-topbar-center { text-align: center; }
.context-chip {
  display: inline-block;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: #ecfdf5;
  color: var(--brand-ink);
  font-size: 0.9rem;
  font-weight: 600;
}
.erp-body { display: grid; grid-template-columns: 240px 1fr; flex: 1; min-height: 0; }
.erp-sidebar {
  background: #12352f;
  color: #e7eeea;
  padding: 1rem 0.5rem 2rem;
  min-height: calc(100vh - 58px);
}
.erp-nav-group {
  margin: 1rem 0.75rem 0.35rem;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #94b8b0;
  font-weight: 700;
}
.erp-nav-link {
  display: block;
  color: #e7eeea;
  text-decoration: none;
  padding: 0.55rem 0.85rem;
  border-radius: 8px;
  margin: 0.15rem 0.35rem;
}
.erp-nav-link:hover, .erp-nav-link.is-active {
  background: rgba(255,255,255,0.12);
  color: #fff;
}
.erp-content { padding: 1.25rem 1.5rem 2.5rem; }
.erp-page-header {
  display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start;
  margin-bottom: 1rem; flex-wrap: wrap;
}
.erp-page-header h1 { margin: 0.15rem 0 0; font-family: var(--font-display); letter-spacing: -0.02em; }
.breadcrumb { display: flex; gap: 0.4rem; color: var(--muted); font-size: 0.9rem; }
.breadcrumb a { text-decoration: none; }
.list-filters { display: flex; gap: 0.5rem; margin-bottom: 0.75rem; }
.list-filters input { min-width: min(100%, 280px); min-height: 2.5rem; padding: 0.45rem 0.7rem; border: 1px solid var(--line); border-radius: var(--radius); }
.erp-grid tbody tr.clickable-row { cursor: pointer; }
.erp-grid tbody tr.clickable-row:hover { background: #f0f7f4; }
.col-actions { width: 6rem; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
.form-grid .span-1 { grid-column: span 1; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-3 { grid-column: span 3; }
.field-help { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.9rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0.85rem; }
.tool-card {
  display: flex; flex-direction: column; gap: 0.35rem;
  padding: 1rem 1.1rem; background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); text-decoration: none; color: inherit;
  box-shadow: var(--shadow); transition: transform .15s ease;
}
.tool-card:hover { transform: translateY(-2px); border-color: var(--brand); }
.tool-card span { color: var(--muted); font-size: 0.92rem; }

.tab-rail { display: flex; flex-direction: column; gap: 0.25rem; margin-top: 1rem; }
.tab-rail-link {
  text-decoration: none; color: var(--ink); padding: 0.45rem 0.6rem; border-radius: 8px;
}
.tab-rail-link.is-active { background: #ecfdf5; color: var(--brand-ink); font-weight: 700; }
.checks { display: flex; flex-wrap: wrap; gap: 0.75rem 1.25rem; margin: 0.75rem 0 1rem; }
.meta-list { list-style: none; padding: 0; margin: 0 0 1rem; }
.meta-list li { margin: 0.3rem 0; font-size: 0.92rem; }
.stack-gap { margin-bottom: 0.5rem; }
.btn-icon {
  border: 1px solid var(--line); background: #fff; border-radius: 6px; cursor: pointer; min-width: 1.75rem;
}
.inline-forms { display: inline-flex; gap: 0.15rem; }
.mini-form { display: grid; gap: 0.35rem; margin: 0.5rem 0; padding: 0.5rem; background: #f8faf9; border-radius: 8px; }
.endpoint-list { list-style: none; padding: 0; }
.endpoint-list li { margin: 0.4rem 0; display: flex; gap: 0.5rem; align-items: center; }
.method { font-size: 0.72rem; font-weight: 800; padding: 0.15rem 0.4rem; border-radius: 4px; color: #fff; }
.method.get { background: #0369a1; }
.method.post { background: #047857; }
.method.patch { background: #b45309; }
.method.delete { background: #b91c1c; }
.code-block {
  max-height: 360px; overflow: auto; background: #0f172a; color: #e2e8f0;
  padding: 1rem; border-radius: 8px; font-size: 0.82rem;
}
.toolbar-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar-actions { display: flex; gap: 0.5rem; }

@media (max-width: 900px) {
  .erp-body { grid-template-columns: 1fr; }
  .erp-sidebar { min-height: auto; display: flex; flex-wrap: wrap; gap: 0.25rem; }
  .erp-nav-group { width: 100%; }
  .erp-topbar { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-1, .form-grid .span-2, .form-grid .span-3 { grid-column: span 1; }
}
