/*
 * Notafacto Client — ponts d'intégration entre le design system porté de
 * notamicro (notafacto.css, classes nf-*) et le câblage Stimulus existant du
 * client (controllers sidebar / nav / company-selector / dashboard).
 *
 * Ce fichier ne contient QUE les écarts nécessaires ; tout le reste vient de
 * notafacto.css. À charger APRÈS notafacto.css.
 */

/* Le build injecte la classe `active` (et non `is-active` comme notamicro) sur
   le lien de navigation courant via le token {{nav-X}}. */
.nf-sidebar__section a.active {
  background: var(--bg);
  border-color: var(--border);
  color: var(--sidebar-text-active);
  font-weight: 500;
}

/* Le nav controller ouvre/ferme le menu avatar via l'attribut [hidden]
   (dropdownTarget.hidden = false), pas via .is-open. */
.nf-menu:not([hidden]) {
  display: block;
}

/* Sélecteur d'entreprise (topbar) — réutilise le style des champs nf. */
.company-selector {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.company-selector[hidden] {
  display: none;
}
.company-selector-label {
  font-size: 12px;
  color: var(--text-2);
  white-space: nowrap;
}

/* Lignes clé/valeur des cartes TVA du dashboard. */
.nf-kv-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 8px 0;
  font-size: 14px;
}
.nf-kv-row + .nf-kv-row {
  border-top: 1px solid var(--border);
}
.nf-kv-row__l {
  color: var(--text-2);
}
.nf-kv-row__v {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

/* Utilitaires d'espacement vertical (remplacent le CSS inline). */
.nf-mt-lg { margin-top: 24px; }
.nf-mt-md { margin-top: 16px; }
.nf-mb-lg { margin-bottom: 24px; }
.nf-mb-md { margin-bottom: 16px; }
.nf-mb-sm { margin-bottom: 8px; }

/* Ligne de tableau cliquable (listes factures). */
.nf-row-link { cursor: pointer; }

/* Champ « couleur d'accent » (paramètres). */
.nf-color-field { display: flex; align-items: center; gap: 8px; }
.nf-color-swatch {
  width: 48px;
  height: 40px;
  padding: 2px;
  border: 1px solid var(--border);
  background: none;
}
.nf-color-hex { max-width: 140px; }

/* Aperçu et actions du logo (paramètres). */
.nf-logo-preview {
  max-height: 80px;
  max-width: 240px;
  border: 1px solid var(--border);
  padding: 4px;
  background: #fff;
}
.nf-logo-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Variante « avertissement » du hint de champ (contraste couleur). */
.nf-field__hint--warning { color: var(--warning-text); }

/* Paragraphe explicatif (muted) dans/sous une carte. */
.nf-card__note {
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.55;
  margin: 0 0 16px;
}

/* Rangée de boutons (anciennement .form-actions). */
.nf-btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

/* Aperçu PDF (détail facture reçue). */
.nf-pdf-frame { width: 100%; height: 720px; border: 0; display: block; }

/* Valeur de détail en lecture seule (pages détail facture). */
.nf-detail-value {
  font-size: 14px;
  color: var(--text);
  white-space: pre-line;
}

/* Grille clé/valeur exhaustive (« Données reçues complètes »). */
.nf-detail-grid {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) 2fr;
  gap: 4px 24px;
  margin: 0;
}
.nf-detail-grid dt { color: var(--text-2); font-size: 13px; margin: 0; }
.nf-detail-grid dd { margin: 0; }

/* Sidebar d'aide : pas de sticky (le DS notafacto.css met .nf-help en
   position:sticky ; on le neutralise — l'aide suit le flux normal). */
.nf-help { position: static; }

/* Bloc éditable indépendant (nf-edit-block) : bascule view/édition.
   Le DS porté gère le bouton d'ouverture mais pas la visibilité form/résumé. */
.nf-edit-block:not([data-edit-state="editing"]) .nf-edit-block__form { display: none; }
.nf-edit-block[data-edit-state="editing"] .nf-edit-block__summary { display: none; }

/* En-tête de carte avec action à droite (titre + bouton). */
.nf-card__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.nf-card__head .nf-card__title { margin-bottom: 0; }

/* ---- Éditeur de facture (invoices-out-new) — pas d'équivalent notamicro ---- */
.nf-crumbs { display: flex; align-items: center; gap: 6px; font-size: 13px; margin-bottom: 16px; }
.nf-crumbs a { color: var(--text-2); text-decoration: none; }
.nf-crumbs a:hover { color: var(--accent); }
.nf-crumbs__sep { color: var(--text-3); }
.nf-crumbs__current { color: var(--text); font-weight: 500; }

.nf-editor-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0;
}
.nf-editor-actions__group { display: flex; align-items: center; gap: 8px; }

/* Layout éditeur : pas de sticky, pas d'overflow. Le panneau document garde
   une hauteur (pour que l'iframe s'affiche) mais défile avec la page comme le
   reste ; le formulaire suit le flux normal. */
.nf-editor { display: flex; gap: 24px; align-items: flex-start; }
.nf-editor__doc {
  flex: 1;
  min-width: 0;
  height: calc(100vh - 120px);
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}
.nf-editor__doc-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: var(--text-2);
  font-size: 14px;
}
.nf-editor__doc-icon { font-size: 4rem; opacity: 0.3; }
.nf-editor__doc-iframe { width: 100%; height: 100%; border: none; }
.nf-editor__form {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.nf-issue-number {
  margin: 4px 0 0;
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

@media (max-width: 1024px) {
  .nf-editor { flex-direction: column; }
  .nf-editor__doc { position: static; height: auto; min-height: 360px; }
}

/* Bannière « prochain numéro » (page Factures émises) : liste sans puces. */
.nf-next-number {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}

/* Sidebar mobile : le sidebar controller bascule la classe .open sur l'aside
   (target menu) et sur l'overlay (target overlay). */
.nf-sidebar__overlay {
  display: none;
}
@media (max-width: 1024px) {
  .nf-app {
    grid-template-columns: 1fr;
  }
  .nf-app__sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 60;
    width: var(--sidebar-w);
    transform: translateX(-100%);
    transition: transform 250ms ease;
  }
  .nf-app__sidebar.open {
    transform: translateX(0);
  }
  .nf-sidebar__overlay.open {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 55;
  }
}

/* ---------- Consommation & jetons : détail des cartes ---------- */
.nf-stat__breakdown {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-2);
}
.nf-stat__v.is-success { color: var(--success-text); }
.nf-stat__v.is-warning { color: var(--warning-text); }
.nf-stat__v.is-error { color: var(--error-text); }

/* ---------- Journal des événements (timeline, porté de notamicro) ---------- */
.nf-timeline {
  list-style: none;
  padding: 0;
  margin: 0;
}
.nf-timeline li {
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: 16px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
  font-size: 13px;
}
.nf-timeline li:last-child {
  border-bottom: 1px solid var(--border);
}
.nf-timeline__when {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: 0.04em;
}
.nf-timeline__what {
  color: var(--text);
}
.nf-timeline__who {
  display: block;
  color: var(--text-2);
  font-size: 12px;
  margin-top: 2px;
  font-style: italic;
  font-family: var(--serif);
}
.nf-timeline__empty {
  display: block;
  padding: 12px 0;
  font-size: 13px;
  color: var(--text-2);
}

/* ---------------------------------------------------------------------------
 * Branding revendeur runtime — EPIC-38.2
 *
 * Anti-flash : tant que le branding n'est pas résolu (`data-branding="pending"`,
 * posé par branding-boot.js), on masque le wordmark de la sidebar — l'espace
 * reste réservé (pas de layout shift), et « notafacto » n'apparaît jamais avant
 * que le contexte revendeur ne soit connu. `branding_controller` pose ensuite
 * `data-branding="ready"`.
 * --------------------------------------------------------------------------- */
[data-branding="pending"] .nf-logo {
  visibility: hidden;
}

/* Logo image (substitut du wordmark en marque blanche). */
.nf-logo__img {
  display: block;
  max-height: 28px;
  max-width: 160px;
  width: auto;
}
.nf-logo--sm .nf-logo__img {
  max-height: 24px;
}
