/* ==========================================================================
   FAMIVEST DESIGN SYSTEM — Components
   --------------------------------------------------------------------------
   All selectors are prefixed with `.fv-*` to avoid collision with the legacy
   codebase. Adapted from Famivest-Design-System-handoff.zip / ui_kits/app/app.css.
   Dynamic tone colors use [data-fv-tone="…"] from famivest-tokens.css
   (CSP-safe replacement for JSX style={{background, color}}).
   Requires famivest-tokens.css to be loaded first.
   ========================================================================== */

/* -------- APP SHELL (optional — opt-in via .fv-app on a wrapper) -------- */

.fv-app {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
  background: var(--fv-bg-1);
  color: var(--fv-fg-1);
  font-family: var(--fv-font-sans);
}

.fv-main {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.fv-content {
  padding: 28px 32px 48px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}

/* -------- SIDEBAR (.fv-sidebar) -------- */

.fv-sidebar {
  position: sticky;
  top: 0;
  width: 280px;
  height: 100vh;
  background: linear-gradient(170deg, var(--fv-night-800), var(--fv-night-900));
  color: #e6efef;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.fv-sb-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.fv-sb-header img {
  width: 36px;
  height: 36px;
  background: #fff;
  padding: 4px;
  border-radius: 9px;
}
.fv-sb-wordmark {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #fff;
}

.fv-sb-nav {
  flex: 1;
  overflow-y: auto;
  padding: 10px 0 20px;
}
.fv-sb-section { margin-bottom: 6px; }
.fv-sb-section-title {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(255, 255, 255, 0.38);
  font-weight: 600;
  padding: 14px 22px 6px;
}

.fv-sb-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 20px 9px 22px;
  margin-right: 10px;
  color: rgba(255, 255, 255, 0.78);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  border-left: 2px solid transparent;
  border-radius: 0 10px 10px 0;
  transition: all 140ms var(--fv-ease);
  cursor: pointer;
}
.fv-sb-item i {
  width: 17px;
  height: 17px;
  stroke-width: 1.75;
}
.fv-sb-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}
.fv-sb-item.active {
  background: rgba(68, 114, 64, 0.18);
  color: #fff;
  border-left-color: var(--fv-forest-400);
}

.fv-sb-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding: 14px 18px;
}
.fv-sb-user {
  display: flex;
  align-items: center;
  gap: 10px;
}
.fv-sb-name {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}
.fv-sb-plan {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
}

.fv-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--fv-forest-500), var(--fv-forest-700));
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.fv-avatar.sm {
  width: 26px;
  height: 26px;
  font-size: 11px;
}

/* -------- TOP BAR (.fv-topbar) -------- */

.fv-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 32px;
  background: #fff;
  border-bottom: 1px solid var(--fv-border-1);
  position: sticky;
  top: 0;
  z-index: 10;
}
.fv-crumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--fv-fg-3);
}
.fv-crumb-sep {
  margin: 0 6px;
  color: var(--fv-fg-4);
}
.fv-crumb.active {
  color: var(--fv-fg-1);
  font-weight: 600;
}
.fv-topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.fv-icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid var(--fv-border-1);
  background: #fff;
  cursor: pointer;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--fv-fg-2);
  transition: all 140ms var(--fv-ease);
}
.fv-icon-btn:hover {
  border-color: var(--fv-forest-500);
  color: var(--fv-forest-700);
}
.fv-icon-btn i {
  width: 16px;
  height: 16px;
  stroke-width: 1.75;
}
.fv-icon-btn.sm {
  width: 28px;
  height: 28px;
  border-color: transparent;
}
.fv-icon-btn.sm i {
  width: 14px;
  height: 14px;
}

.fv-dot {
  position: absolute;
  top: 7px;
  right: 8px;
  width: 7px;
  height: 7px;
  background: var(--fv-danger);
  border-radius: 50%;
  border: 1.5px solid #fff;
}

.fv-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 5px;
  background: var(--fv-stone-50);
  border: 1px solid var(--fv-border-1);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  color: var(--fv-fg-1);
}

/* -------- PAGE HEADER (.fv-pageheader) -------- */

.fv-pageheader {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 24px;
  gap: 24px;
  flex-wrap: wrap;
}
.fv-pagetitle {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 6px 0 4px;
  color: var(--fv-fg-1);
  line-height: 1.1;
}
.fv-pagesub {
  color: var(--fv-fg-2);
  font-size: 15px;
  margin: 0;
  max-width: 620px;
  line-height: 1.5;
}
.fv-pageheader-actions {
  display: flex;
  gap: 10px;
}

/* -------- BUTTONS (.fv-btn) -------- */

.fv-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 140ms var(--fv-ease);
  line-height: 1;
}
.fv-btn i {
  width: 15px;
  height: 15px;
  stroke-width: 1.9;
}
.fv-btn:focus-visible {
  outline: none;
  box-shadow: var(--fv-ring-focus);
}
.fv-btn[disabled],
.fv-btn.is-disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.fv-btn-primary {
  background: var(--fv-forest-700);
  color: #fff;
}
.fv-btn-primary:hover { background: var(--fv-forest-800); }

.fv-btn-secondary {
  background: #fff;
  color: var(--fv-fg-1);
  border-color: var(--fv-border-2);
}
.fv-btn-secondary:hover {
  border-color: var(--fv-forest-500);
  color: var(--fv-forest-700);
}

.fv-btn-ghost {
  background: transparent;
  color: var(--fv-forest-700);
}
.fv-btn-ghost:hover { background: var(--fv-forest-50); }

.fv-btn-sm {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 8px;
}

/* -------- KPI STRIP (.fv-kpi) -------- */

.fv-kpi-strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  margin-bottom: 28px;
}
.fv-kpi {
  background: #fff;
  border: 1px solid var(--fv-border-1);
  border-radius: 14px;
  padding: 16px 18px;
  box-shadow: var(--fv-shadow-sm);
}
.fv-kpi-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.fv-kpi-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  color: var(--fv-fg-3);
}
.fv-kpi-ic {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fv-kpi-ic i {
  width: 15px;
  height: 15px;
  stroke-width: 1.9;
}
.fv-kpi-val {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--fv-fg-1);
  font-feature-settings: 'tnum' 1, 'lnum' 1;
}
.fv-kpi-foot {
  margin-top: 4px;
  font-size: 12.5px;
  color: var(--fv-fg-3);
  display: flex;
  align-items: center;
  gap: 8px;
}
.fv-delta.pos { color: var(--fv-success); font-weight: 600; }
.fv-delta.neg { color: var(--fv-danger);  font-weight: 600; }
.fv-kpi-hint  { color: var(--fv-fg-3); }

@media (max-width: 1100px) {
  .fv-kpi-strip { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 700px) {
  .fv-kpi-strip { grid-template-columns: repeat(2, 1fr); }
}

/* -------- SECTION TITLE -------- */

.fv-section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 32px 0 14px;
}
.fv-section-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--fv-fg-1);
  letter-spacing: -0.01em;
}

/* -------- MODULE CARDS (.fv-modgrid, .fv-modcard) -------- */

.fv-modgrid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
@media (max-width: 900px) {
  .fv-modgrid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .fv-modgrid { grid-template-columns: 1fr; }
}

.fv-modcard {
  background: #fff;
  border: 1px solid var(--fv-border-1);
  border-radius: 14px;
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--fv-shadow-sm);
  transition: all 220ms var(--fv-ease);
  position: relative;
}
.fv-modcard:hover {
  transform: translateY(-2px);
  box-shadow: var(--fv-shadow-md);
  border-color: var(--fv-border-2);
}
.fv-modcard-ic {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.fv-modcard-ic i {
  width: 20px;
  height: 20px;
  stroke-width: 1.75;
}
/* FontAwesome glyphs (pseudo-element-based) : annule la boîte 20x20 pour utiliser la taille de police. */
.fv-modcard-ic i.fas,
.fv-modcard-ic i.far,
.fv-modcard-ic i.fal,
.fv-modcard-ic i.fab,
.fv-modcard-ic i.fa {
  width: auto;
  height: auto;
  font-size: 18px;
  line-height: 1;
}
.fv-modcard-body { flex: 1; }
.fv-modcard-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--fv-fg-1);
}
.fv-modcard-desc {
  font-size: 12.5px;
  color: var(--fv-fg-3);
  margin-top: 3px;
  line-height: 1.45;
}
.fv-modcard-arrow {
  width: 16px;
  height: 16px;
  color: var(--fv-fg-4);
  flex-shrink: 0;
  transition: all 140ms;
}
.fv-modcard:hover .fv-modcard-arrow {
  color: var(--fv-forest-600);
  transform: translate(2px, -2px);
}

/* -------- CARD (.fv-card) -------- */

.fv-card {
  background: #fff;
  border: 1px solid var(--fv-border-1);
  border-radius: 14px;
  box-shadow: var(--fv-shadow-sm);
}
.fv-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 18px 20px 12px;
}
.fv-card-title {
  font-size: 17px;
  font-weight: 600;
  margin: 2px 0 0;
  letter-spacing: -0.01em;
}
.fv-card-actions {
  display: flex;
  gap: 8px;
}

/* -------- TABLE (.fv-table) -------- */

.fv-table-card {
  overflow: hidden;
}
.fv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.fv-table thead {
  background: var(--fv-stone-50);
  border-top: 1px solid var(--fv-border-1);
  border-bottom: 1px solid var(--fv-border-1);
}
.fv-table th {
  text-align: left;
  padding: 10px 18px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fv-fg-3);
}
.fv-table th.r,
.fv-table td.r { text-align: right; }
.fv-table tbody tr {
  border-top: 1px solid var(--fv-border-1);
  transition: background 120ms;
}
.fv-table tbody tr:first-child { border-top: 0; }
.fv-table tbody tr:hover       { background: var(--fv-stone-50); }
.fv-table td                   { padding: 14px 18px; }

.fv-row-main {
  display: flex;
  align-items: center;
  gap: 12px;
}
.fv-row-ic {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fv-row-ic i {
  width: 16px;
  height: 16px;
  stroke-width: 1.9;
}
.fv-row-name {
  font-weight: 600;
  color: var(--fv-fg-1);
  font-size: 14px;
}
.fv-row-sub {
  font-size: 12px;
  color: var(--fv-fg-3);
  margin-top: 2px;
}
.fv-row-loc {
  color: var(--fv-fg-2);
  font-size: 13px;
}
.fv-row-val {
  font-weight: 600;
  color: var(--fv-fg-1);
  font-feature-settings: 'tnum' 1, 'lnum' 1;
}

/* Kept scoped to .fv-table to avoid clobbering legacy .pos/.neg usage */
.fv-table .pos { color: var(--fv-success); font-weight: 600; }
.fv-table .neg { color: var(--fv-danger);  font-weight: 600; }

/* -------- BADGE (.fv-badge) -------- */

.fv-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--fv-forest-50);
  color: var(--fv-forest-700);
}

/* -------- AI CALLOUT (.fv-ai) -------- */

.fv-ai {
  display: flex;
  gap: 16px;
  padding: 18px 20px;
  background: linear-gradient(160deg, #f6f3ec, #faf8f3);
  border: 1px solid var(--fv-border-1);
  border-radius: 14px;
  box-shadow: var(--fv-shadow-sm);
  margin: 24px 0;
}
.fv-ai-bubble {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 11px;
  background: linear-gradient(155deg, #5b4aa8, #2e2474);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px -3px rgba(46, 36, 116, 0.45);
}
.fv-ai-bubble i {
  width: 18px;
  height: 18px;
  stroke-width: 1.8;
}
.fv-ai-body { flex: 1; }
.fv-ai-tag {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--fv-dom-ai);
  background: #ebe7f6;
  padding: 2px 10px;
  border-radius: 999px;
}
.fv-ai-title {
  font-size: 16px;
  font-weight: 600;
  margin: 6px 0 4px;
  color: var(--fv-fg-1);
}
.fv-ai-text {
  font-size: 13.5px;
  color: var(--fv-fg-2);
  line-height: 1.55;
  max-width: 720px;
}
.fv-ai-text b { color: var(--fv-fg-1); font-weight: 600; }
.fv-ai-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.fv-ai-disclaimer {
  font-size: 11px;
  color: var(--fv-fg-3);
  margin-top: 10px;
  font-style: italic;
}

/* -------- TWO-COL LAYOUT + SIDE CARD -------- */

.fv-two-col {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-top: 12px;
}
@media (max-width: 900px) {
  .fv-two-col { grid-template-columns: 1fr; }
}

.fv-side-card {
  background: #fff;
  border: 1px solid var(--fv-border-1);
  border-radius: 14px;
  padding: 18px 20px;
  box-shadow: var(--fv-shadow-sm);
}
.fv-side-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.fv-side-head i {
  width: 18px;
  height: 18px;
  color: var(--fv-forest-700);
  stroke-width: 1.75;
}
.fv-side-title {
  font-size: 15px;
  font-weight: 600;
}

/* -------- ALERT (.fv-alert) — no left-border accent (anti AI-slop) -------- */

.fv-alert {
  padding: 10px 12px;
  background: var(--fv-stone-50);
  border-radius: 10px;
  display: flex;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 13px;
  border: 1px solid var(--fv-border-1);
}
.fv-alert-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
}
.fv-alert-dot.warn { background: var(--fv-warning); }
.fv-alert-dot.info { background: var(--fv-info); }
.fv-alert-dot.ok   { background: var(--fv-success); }
.fv-alert-title {
  font-weight: 600;
  color: var(--fv-fg-1);
}
.fv-alert-sub {
  font-size: 12px;
  color: var(--fv-fg-3);
  margin-top: 2px;
}

/* -------- SPACING UTILITIES (replace inline margin/padding styles) -------- */

.fv-mt-0  { margin-top: 0; }
.fv-mt-1  { margin-top: var(--fv-s-1); }
.fv-mt-2  { margin-top: var(--fv-s-2); }
.fv-mt-3  { margin-top: var(--fv-s-3); }
.fv-mt-4  { margin-top: var(--fv-s-4); }
.fv-mt-5  { margin-top: var(--fv-s-5); }
.fv-mt-6  { margin-top: var(--fv-s-6); }
.fv-mt-8  { margin-top: var(--fv-s-8); }

.fv-mb-0  { margin-bottom: 0; }
.fv-mb-1  { margin-bottom: var(--fv-s-1); }
.fv-mb-2  { margin-bottom: var(--fv-s-2); }
.fv-mb-4  { margin-bottom: var(--fv-s-4); }
.fv-mb-6  { margin-bottom: var(--fv-s-6); }
.fv-mb-8  { margin-bottom: var(--fv-s-8); }

/* -------- ICON SPIN UTILITY (Lucide loaders) -------- */

@keyframes fv-icon-spin {
  to { transform: rotate(360deg); }
}

.icon-spin::before {
  display: inline-block;
  animation: fv-icon-spin 1s linear infinite;
}

/* -------- ICON SIZE UTILITIES (analogues à fa-2x / fa-3x) -------- */

.icon-2x { font-size: 2em; }
.icon-3x { font-size: 3em; }

/* -------- REDUCED MOTION -------- */

@media (prefers-reduced-motion: reduce) {
  .fv-modcard,
  .fv-btn,
  .fv-icon-btn,
  .fv-sb-item,
  .fv-modcard-arrow {
    transition: none;
  }
  .fv-modcard:hover { transform: none; }
  .icon-spin::before { animation: none; }
}
