/* ============================================================================
   RH Planète — Design System « Héritage tropical éditorial »
   Inspiré de l'architecture d'Abakoz HR & principes Emil Kowalski
   ----------------------------------------------------------------------------
   Papier crème, vert forêt profond, or impérial, terracotta latérite.
   Display : Fraunces · Corps : Hanken Grotesk · Mono : Geist Mono
   ========================================================================== */

:root {
  /* — Papier & surfaces — */
  --bg: #F2EEE3;              /* Fond général papier crème chaud */
  --surface: #FBF9F3;         /* Cartes et panneaux papier vanille */
  --wash: #ECE7D8;            /* Teinte discrète (th, barres d'outils) */
  --wash-2: #F7F4EB;          /* Survol doux de liste */
  --line: #E0DAC8;            /* Filets hairline chauds */
  --line-2: #CFC9B6;          /* Bordures de champs et contrôles */

  /* — Encres & typographie — */
  --ink: #1F2A23;             /* Encre principale vert-noir profond */
  --ink-2: #37453C;           /* Encre secondaire */
  --ink-3: #57655B;           /* Encre tertiaire / sous-titres */
  --muted: #78877D;           /* Mentions et libellés atténués */
  --muted-2: #A0ACA0;         /* Placeholders */

  /* — Marque & accents — */
  --accent: #0E6B52;          /* Vert émeraude signature */
  --accent-dark: #0A5340;
  --accent-soft: #DCEBE0;
  --gold: #B5893A;            /* Or de canne */
  --gold-soft: #F0E4C8;

  /* — Sémantique — */
  --ok: #25714B;              /* Vert sauge / succès */
  --ok-soft: #DDEDE0;
  --warn: #92650E;            /* Ocre doré / en attente */
  --warn-soft: #F2E5C6;
  --danger: #B04425;          /* Terracotta latérite / rejeté */
  --danger-soft: #F4E1D7;
  --info: #34618E;            /* Indigo ardoise / information */
  --info-soft: #E2E9F0;

  /* — Coque (sidebar & navigation sombre) — */
  --shell: #142720;           /* Vert forêt profond */
  --shell-2: #1B332A;         /* Surface sombre interne */
  --shell-ink: #EFE9D8;       /* Encre crème de coque */
  --shell-muted: #8DA294;     /* Libellés de navigation */
  --shell-line: rgba(239, 233, 216, 0.12);
  --shell-active: rgba(239, 233, 216, 0.08);
  --shell-gold: #D9A94F;      /* Or lumineux indicateur actif */

  /* — Typographies — */
  --ui-font: 'Hanken Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --display-font: 'Fraunces', Georgia, 'Times New Roman', serif;
  --mono-font: 'Geist Mono', 'Cascadia Mono', ui-monospace, monospace;

  /* — Rayons & ombres — */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --shadow-1: 0 1px 3px rgba(31, 42, 35, 0.05), 0 1px 2px rgba(31, 42, 35, 0.03);
  --shadow-2: 0 8px 24px rgba(31, 42, 35, 0.07), 0 2px 6px rgba(31, 42, 35, 0.04);
  --shadow-float: 0 16px 36px rgba(20, 39, 32, 0.14), 0 4px 10px rgba(20, 39, 32, 0.06);

  /* — Courbes de transition (Emil Kowalski) — */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);

  /* Overrides Bootstrap */
  --bs-primary: var(--accent);
  --bs-primary-rgb: 14, 107, 82;
  --bs-body-font-family: var(--ui-font);
  --bs-body-color: var(--ink);
  --bs-body-bg: var(--bg);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background-color: var(--bg);
  font-family: var(--ui-font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Texture de grain papier feutré quasi subliminale */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
@media print { body::after { display: none; } }

/* — Scrollbars personnalisées ton sur ton — */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: #CBC4AE;
  border-radius: 99px;
  border: 3px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: #B4AD95; }

/* — Typographie display — */
h1, h2, h3, .h1, .h2, .h3, .font-display, .display-6 {
  font-family: var(--display-font);
  font-optical-sizing: auto;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.eyebrow {
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.num-mono {
  font-family: var(--mono-font);
  font-variant-numeric: tabular-nums;
}

/* — Structure de l'application (Shell) — */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* — Sidebar sombre (Forêt & Or) — */
.sidebar {
  width: 268px;
  flex: 0 0 268px;
  display: flex;
  flex-direction: column;
  background-color: var(--shell);
  color: var(--shell-ink);
  background-image: radial-gradient(1200px 450px at -30% -10%, rgba(217, 169, 79, 0.08), transparent 60%);
  border-right: 1px solid var(--shell-line);
  padding: 22px 14px 16px;
  z-index: 50;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 18px;
  color: var(--shell-ink);
  text-decoration: none;
  font-family: var(--display-font);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: transform 160ms var(--ease-out);
}
.brand:hover { color: #ffffff; }
.brand:active { transform: scale(0.98); }

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--shell-2);
  border: 1px solid var(--shell-line);
  color: var(--shell-gold);
  font-family: var(--display-font);
  font-size: 1.3rem;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.brand-text small {
  color: var(--shell-muted);
  font-family: var(--ui-font);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-top: 3px;
}

.sidebar-divider {
  height: 1px;
  background: var(--shell-line);
  margin: 0 8px 14px;
}

.nav-caption {
  padding: 8px 12px 4px;
  color: var(--shell-muted);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.85;
}
.nav-caption-spaced { margin-top: 14px; }

.app-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.app-nav a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 38px;
  padding: 8px 12px;
  border-radius: var(--r-sm);
  color: var(--shell-muted);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: background-color 150ms var(--ease-out), color 150ms var(--ease-out), transform 150ms var(--ease-out);
}
.app-nav a:hover {
  background: rgba(239, 233, 216, 0.05);
  color: var(--shell-ink);
}
.app-nav a:active { transform: scale(0.98); }

.app-nav a.active {
  background: var(--shell-active);
  color: var(--shell-ink);
  font-weight: 600;
}
.app-nav a.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3.5px;
  border-radius: 99px;
  background: var(--shell-gold);
}

.nav-icon {
  display: inline-grid;
  place-items: center;
  width: 20px;
  color: var(--shell-muted);
  font-size: 1rem;
  transition: color 150ms var(--ease-out);
}
.app-nav a.active .nav-icon { color: var(--shell-gold); }
.app-nav a:hover .nav-icon { color: var(--shell-ink); }

/* Carte utilisateur dans la sidebar */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding: 11px 12px;
  border-radius: var(--r-md);
  background: var(--shell-2);
  border: 1px solid var(--shell-line);
}

.avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 50%;
  background: rgba(217, 169, 79, 0.15);
  color: var(--shell-gold);
  border: 1px solid rgba(217, 169, 79, 0.3);
  font-family: var(--display-font);
  font-size: 0.95rem;
  font-weight: 700;
}

.user-meta {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  line-height: 1.25;
}
.user-meta strong {
  overflow: hidden;
  color: var(--shell-ink);
  font-size: 0.8rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-meta small {
  color: var(--shell-muted);
  font-size: 0.68rem;
}

.logout-link {
  color: var(--shell-muted);
  font-size: 1.05rem;
  text-decoration: none;
  padding: 5px;
  border-radius: 6px;
  transition: transform 150ms var(--ease-out), color 150ms ease;
  line-height: 1;
}
.logout-link:hover { color: #E76F51; }
.logout-link:active { transform: scale(0.9); }

/* — Workspace & Topbar — */
.workspace {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
}

.topbar {
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  border-bottom: 1px solid var(--line);
  background: rgba(242, 238, 227, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar-label {
  color: var(--ink-2);
  font-size: 0.84rem;
  font-weight: 550;
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar-label span { color: var(--line-2); font-size: 0.9rem; }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px var(--ok-soft);
}

.page-wrap {
  width: 100%;
  max-width: 1680px;
  margin: 0 auto;
  padding: 30px 36px 56px;
  flex: 1;
}

/* — Animation d'apparition échelonnée (Emil Kowalski) — */
@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.page-wrap > * {
  animation: rise-in 0.38s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}
.page-wrap > *:nth-child(2) { animation-delay: 0.05s; }
.page-wrap > *:nth-child(3) { animation-delay: 0.1s; }
.page-wrap > *:nth-child(4) { animation-delay: 0.15s; }
.page-wrap > *:nth-child(n+5) { animation-delay: 0.2s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* — Cartes & Stat-Cards — */
.card {
  background-color: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  transition: border-color 180ms var(--ease-out), box-shadow 180ms var(--ease-out), transform 180ms var(--ease-out);
}

.card-header {
  background-color: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 18px 22px;
}

.stat-card {
  border: 1px solid var(--line);
  background-color: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}
.stat-card:hover {
  border-color: #D2CABA;
  box-shadow: var(--shadow-2);
  transform: translateY(-1.5px);
}
.stat-card .display-6 {
  font-family: var(--display-font);
  font-weight: 600;
  color: var(--ink);
  line-height: 1.1;
  font-size: 2.1rem;
}

/* — Tableaux de Données Éditoriaux — */
.table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--ink);
  --bs-table-hover-bg: var(--wash-2);
  --bs-table-border-color: var(--line);
  margin-bottom: 0;
}
.table > :not(caption) > * > * {
  padding: 0.85rem 1rem;
  border-bottom-color: var(--line);
}
.table thead th {
  background-color: var(--wash);
  color: var(--ink-3);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
}

/* — Badges Sémantiques Doux — */
.badge {
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 4px 9px;
  border-radius: 999px;
}
.badge.bg-light, .badge.text-bg-light {
  background-color: var(--wash) !important;
  color: var(--ink-2) !important;
  border: 1px solid var(--line) !important;
}
.badge.bg-success-subtle, .badge.text-bg-success {
  background-color: var(--ok-soft) !important;
  color: var(--ok) !important;
  border: 1px solid #C4DFC8 !important;
}
.badge.bg-warning-subtle, .badge.text-bg-warning {
  background-color: var(--warn-soft) !important;
  color: var(--warn) !important;
  border: 1px solid #E6D4AA !important;
}
.badge.bg-danger-subtle, .badge.text-bg-danger {
  background-color: var(--danger-soft) !important;
  color: var(--danger) !important;
  border: 1px solid #E4C5BA !important;
}
.badge.bg-primary-subtle, .badge.text-bg-primary {
  background-color: var(--accent-soft) !important;
  color: var(--accent) !important;
  border: 1px solid #B8D8C5 !important;
}

/* — Boutons & Actions (Tactile Emil Kowalski) — */
.btn {
  font-weight: 600;
  border-radius: var(--r-sm);
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
  transition: transform 140ms var(--ease-out), background-color 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}
.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background-color: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}
.btn-primary:hover, .btn-primary:focus {
  background-color: var(--accent-dark);
  border-color: var(--accent-dark);
  color: #ffffff;
}

.btn-outline-primary {
  color: var(--accent);
  border-color: var(--accent);
  background-color: transparent;
}
.btn-outline-primary:hover {
  background-color: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.btn-outline-secondary {
  color: var(--ink-2);
  border-color: var(--line-2);
  background-color: transparent;
}
.btn-outline-secondary:hover {
  background-color: var(--wash);
  border-color: var(--line-2);
  color: var(--ink);
}

.btn-success {
  background-color: var(--ok);
  border-color: var(--ok);
  color: #ffffff;
}
.btn-success:hover {
  background-color: #1D5B3C;
  border-color: #1D5B3C;
}

.btn-outline-danger {
  color: var(--danger);
  border-color: #DDA89A;
  background-color: transparent;
}
.btn-outline-danger:hover {
  background-color: var(--danger);
  border-color: var(--danger);
  color: #ffffff;
}

/* — Contrôles de Formulaire — */
.form-control, .form-select {
  background-color: var(--surface);
  border: 1px solid var(--line-2);
  color: var(--ink);
  border-radius: var(--r-sm);
  font-size: 0.875rem;
  transition: border-color 150ms var(--ease-out), box-shadow 150ms var(--ease-out);
}
.form-control:focus, .form-select:focus {
  background-color: #ffffff;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(181, 137, 58, 0.15);
  color: var(--ink);
}
.form-control::placeholder { color: var(--muted-2); }
.input-group-text {
  background-color: var(--wash);
  border-color: var(--line-2);
  color: var(--ink-3);
  font-weight: 600;
  font-size: 0.82rem;
}

/* — Alertes — */
.alert {
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font-size: 0.88rem;
}
.alert-info {
  background-color: var(--info-soft);
  border-color: #C2D3E3;
  color: var(--info);
}
.alert-primary {
  background-color: var(--gold-soft);
  border-color: #E2D1A8;
  color: #694C16;
}
.alert-success {
  background-color: var(--ok-soft);
  border-color: #C4DFC8;
  color: var(--ok);
}
.alert-danger {
  background-color: var(--danger-soft);
  border-color: #E4C5BA;
  color: var(--danger);
}

/* — Page Connexion — */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  background: radial-gradient(1000px 600px at 50% 10%, rgba(20, 39, 32, 0.12), transparent 75%), var(--bg);
}

.login-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-float);
}

/* — Mobile & Responsive — */
.sidebar-toggle, .mobile-nav { display: none; }

.skip-link { position: fixed; top: -100px; left: 16px; z-index: 1100; padding: 12px 18px; background: var(--surface); color: var(--accent); border: 2px solid var(--accent); border-radius: 8px; }
.skip-link:focus { top: 12px; }
a:focus-visible, button:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.table-search { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.table-search label { font-size: .82rem; font-weight: 600; }
.table-search input { flex: 1; min-width: 160px; max-width: 360px; }
.table-search span { margin-left: auto; }
.table-responsive { overscroll-behavior-x: contain; }
.table td { overflow-wrap: anywhere; }
.table td form { min-width: 270px; flex-wrap: wrap; }
.app-nav a { min-height: 44px; }
@media (max-width: 575.98px) {
  .topbar-label { font-size: .72rem; gap: 4px; }
  .topbar-right { display: none; }
  .card-body.p-md-5 { padding: 20px !important; }
  .table-search { padding: 12px; }
  .table-search label, .table-search span { width: 100%; margin-left: 0; }
  .btn-sm { min-height: 38px; }
  .table > :not(caption) > * > * { padding: .7rem; }
}

@media (max-width: 991.98px) {
  .sidebar { display: none; }
  .topbar { height: 56px; padding: 0 16px; }
  .sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--accent);
    cursor: pointer;
  }
  .page-wrap { padding: 20px 16px 40px; }
  .mobile-nav {
    display: block;
    width: 290px !important;
    background: var(--shell);
    color: var(--shell-ink);
    border-right: 1px solid var(--shell-line);
  }
  .mobile-nav .offcanvas-header {
    border-bottom: 1px solid var(--shell-line);
    padding: 18px 20px;
  }
  .mobile-links { padding: 12px 14px; }
  .mobile-links a {
    color: var(--shell-muted);
    padding: 8px 12px;
    border-radius: var(--r-sm);
    text-decoration: none;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
  }
  .mobile-links a:hover {
    color: var(--shell-ink);
    background: rgba(239, 233, 216, 0.05);
  }
}

/* Espace collaborateur : navigation tactile sur téléphone. */
.staff-space { max-width: 720px; margin: 0 auto; }
.staff-mobile-nav { display: none; }
@media (max-width: 767.98px) {
  .page-wrap { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
  .staff-mobile-nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 1040; display: flex; background: var(--bg); border-top: 1px solid var(--line); padding: 8px 6px calc(8px + env(safe-area-inset-bottom)); box-shadow: 0 -4px 20px #0001; }
  .staff-mobile-nav a { flex: 1; display: flex; align-items: center; flex-direction: column; gap: 4px; text-decoration: none; color: var(--ink-3); font-size: 11px; min-height: 48px; justify-content: center; }
  .staff-mobile-nav a[aria-current="page"] { color: var(--gold, #b9954a); font-weight: 800; }
  .staff-mobile-nav svg { width: 22px; height: 22px; }
  .form-control, .form-select { min-height: 48px; font-size: 16px; }
  .btn { min-height: 44px; }
  .staff-space .btn { padding: 13px 16px; white-space: normal; }
}


.pwa-install[hidden] { display: none !important; }
.pwa-install { position: fixed; z-index: 1060; left: 16px; right: 16px; bottom: calc(88px + env(safe-area-inset-bottom)); max-width: 440px; margin: 0 auto; display: flex; gap: 12px; align-items: flex-start; padding: 16px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 8px 36px #0004; }
.pwa-install img { border-radius: 10px; }
.pwa-install p { font-size: 13px; margin: 6px 0 10px; }

.sidebar-nav form button, .sidebar-user form button, .offcanvas nav form button { font: inherit; border: 0; background: transparent; color: inherit; display: flex; align-items: center; gap: 12px; text-align: left; }
