/* ═══════════════════════════════════════════════════════════════════════
   CAMALARM CRM — T209I — t209i-invoice-editor-single-final.css
   ═══════════════════════════════════════════════════════════════════════
   
   UNIQUE COUCHE CSS pour l'éditeur facture.
   
   Remplace T209C, T209D, T209F (retirés du HTML).
   Travaille avec T209B (qui pose la grille canonique header+lignes
   via une <style> runtime). T209B utilise désormais la même grille
   que ce fichier (mise à jour T209I).
   
   STYLE :
   - Card discrète, fond blanc, border subtile
   - Accent gauche orange très léger
   - Inputs height 44px (+10% vs 40px)
   - Padding ligne 13px vertical (+10%)
   - Typographie Inter / JetBrains Mono (chiffres)
   - Pas de stepper, pas de labels internes desktop
   - Total HT en badge sobre orange pâle
   ═══════════════════════════════════════════════════════════════════════ */

:root {
  --t209i-text: #1E293B;
  --t209i-text-muted: #94A3B8;
  --t209i-text-header: #64748B;
  --t209i-border: #E2E8F0;
  --t209i-border-focus: #94A3B8;
  --t209i-bg: #FFFFFF;
  --t209i-bg-hover: #FAFBFD;
  --t209i-row-border: #EDF1F6;
  --t209i-accent: #E65100;
  --t209i-accent-light: #FFF7ED;
  --t209i-accent-text: #C2410C;
  --t209i-accent-border: #FED7AA;
  --t209i-input-h: 44px;
}

/* ─────────────────────────────────────────────────────────────────────
   CONTENEUR : pas d'overflow horizontal
   ───────────────────────────────────────────────────────────────────── */
#tab-fcr-scope .invoice-lines-final,
#tab-fcr-scope #fcrTable {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

#fcrTable {
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
}

/* ─────────────────────────────────────────────────────────────────────
   THEAD : style premium, alignement géré par T209B (même grid-template)
   ───────────────────────────────────────────────────────────────────── */
#fcrTable thead {
  background: #F8FAFC !important;
  border-bottom: 1px solid var(--t209i-border) !important;
}

#fcrTable thead tr.fcr-header-row {
  /* La grille est posée par T209B avec !important. Ce qui suit ne
     change PAS la grille, juste l'apparence. */
  padding: 14px 16px 12px 16px !important;
}

#fcrTable thead th {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;
  font-size: 10.5px !important;
  font-weight: 700 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.08em !important;
  color: var(--t209i-text-header) !important;
  min-width: 0 !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}

#fcrTable thead th.fcr-h-ref,
#fcrTable thead th.fcr-h-desc {
  text-align: left !important;
  padding-left: 2px !important;
}
#fcrTable thead th.fcr-h-qty { text-align: center !important; }
#fcrTable thead th.fcr-h-tva { text-align: center !important; }
#fcrTable thead th.fcr-h-price { text-align: right !important; padding-right: 14px !important; }
#fcrTable thead th.fcr-h-total { text-align: right !important; padding-right: 14px !important; }

/* ─────────────────────────────────────────────────────────────────────
   LIGNES : card discrète, accent gauche subtil
   ───────────────────────────────────────────────────────────────────── */
#fcrTB tr.fcr-line-v2 {
  display: block !important;
  margin: 8px 0 !important;
  padding: 0 !important;
  position: relative !important;
  overflow: hidden;
  box-sizing: border-box;
}

#fcrTB tr.fcr-line-v2::before {
  content: '';
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 2px;
  background: var(--t209i-accent);
  opacity: 0.35;
  z-index: 2;
  pointer-events: none;
  transition: opacity 0.18s ease;
  border-radius: 2px 0 0 2px;
}
#fcrTB tr.fcr-line-v2:hover::before {
  opacity: 0.7;
}

/* La grille interne (la classe est posée par invoice-lines-final.js et
   stylée par T209B avec grid-template-columns + padding). */
#fcrTB .fcr-line-grid {
  /* T209B applique : grid-template-columns, gap, padding, min-height
     Ici on ajoute le polish visuel sans toucher au layout */
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}

/* Hover : border-color géré par T209B, on renforce le shadow */
#fcrTB tr.fcr-line-v2:hover .fcr-line-grid {
  box-shadow: 0 3px 8px rgba(15, 23, 42, 0.05) !important;
}

/* ─────────────────────────────────────────────────────────────────────
   CELLULES : padding minimal, alignement
   ───────────────────────────────────────────────────────────────────── */
#fcrTB .fcr-cell {
  display: flex !important;
  align-items: center !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
  padding: 0 !important;
  margin: 0 !important;
  background: transparent !important;
  border: 0 !important;
}

#fcrTB .fcr-qty-cell { justify-content: center !important; }
#fcrTB .fcr-price-cell { justify-content: flex-end !important; }
#fcrTB .fcr-total-cell { justify-content: flex-end !important; }
#fcrTB .fcr-action-cell { justify-content: center !important; align-items: center !important; }

/* ─────────────────────────────────────────────────────────────────────
   GRIP : discret
   ───────────────────────────────────────────────────────────────────── */
#fcrTB .fcr-grip {
  width: 32px !important;
  height: var(--t209i-input-h) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  color: #CBD5E1 !important;
  opacity: 0.4 !important;
  cursor: grab !important;
  border-radius: 6px !important;
  transition: opacity 0.18s ease, color 0.18s ease, background 0.15s ease !important;
}
#fcrTB tr:hover .fcr-grip { opacity: 1 !important; color: #94A3B8 !important; }

/* ─────────────────────────────────────────────────────────────────────
   INPUTS COMMUNS : 44px, border 10px radius, focus state propre
   ───────────────────────────────────────────────────────────────────── */
#fcrTB .fcr-input,
#fcrTB input[data-fcr-ref],
#fcrTB input[data-fcr-qty],
#fcrTB input[data-fcr-price],
#fcrTB textarea[data-fcr-desc],
#fcrTB select[data-fcr-tva] {
  height: var(--t209i-input-h) !important;
  min-height: var(--t209i-input-h) !important;
  padding: 0 12px !important;
  border: 1px solid var(--t209i-border) !important;
  border-radius: 10px !important;
  background: var(--t209i-bg) !important;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;
  font-size: 14px !important;
  font-weight: 500 !important;
  color: var(--t209i-text) !important;
  outline: none !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
  transition: border-color 0.18s ease, box-shadow 0.18s ease !important;
  box-shadow: none !important;
  margin: 0 !important;
}

#fcrTB .fcr-input:hover,
#fcrTB input:hover,
#fcrTB textarea:hover,
#fcrTB select:hover {
  border-color: #CBD5E1 !important;
}

#fcrTB .fcr-input:focus,
#fcrTB input:focus,
#fcrTB textarea:focus,
#fcrTB select:focus {
  border-color: var(--t209i-border-focus) !important;
  box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.15) !important;
}

#fcrTB input::placeholder,
#fcrTB textarea::placeholder {
  color: var(--t209i-text-muted) !important;
  font-weight: 400 !important;
  font-style: normal !important;
  opacity: 1 !important;
}

/* ─────────────────────────────────────────────────────────────────────
   RÉF : monospace
   ───────────────────────────────────────────────────────────────────── */
#fcrTB input[data-fcr-ref] {
  font-family: 'JetBrains Mono', 'SF Mono', Menlo, monospace !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  text-transform: uppercase !important;
  color: #334155 !important;
  padding: 0 10px !important;
}

/* ─────────────────────────────────────────────────────────────────────
   DÉSIGNATION : textarea souple
   ───────────────────────────────────────────────────────────────────── */
#fcrTB textarea[data-fcr-desc] {
  resize: none !important;
  height: var(--t209i-input-h) !important;
  min-height: var(--t209i-input-h) !important;
  max-height: 88px !important;
  padding: 11px 12px !important;
  line-height: 1.4 !important;
  overflow-y: auto !important;
  white-space: pre-wrap !important;
}

/* ─────────────────────────────────────────────────────────────────────
   QTÉ : input simple centré, lisible (PAS DE STEPPER)
   ───────────────────────────────────────────────────────────────────── */
#fcrTB input[data-fcr-qty] {
  text-align: center !important;
  font-family: 'JetBrains Mono', 'SF Mono', Menlo, monospace !important;
  font-variant-numeric: tabular-nums !important;
  font-size: 15px !important;
  font-weight: 600 !important;
  color: var(--t209i-text) !important;
  background: var(--t209i-bg) !important;
  -moz-appearance: textfield !important;
  visibility: visible !important;
  opacity: 1 !important;
  padding: 0 8px !important;
}
#fcrTB input[data-fcr-qty]::-webkit-outer-spin-button,
#fcrTB input[data-fcr-qty]::-webkit-inner-spin-button {
  -webkit-appearance: none !important;
  margin: 0 !important;
}

/* MASQUER tout stepper résiduel (sessions ouvertes pré-T209I) */
#fcrTB .facture-ligne__stepper-btn,
#fcrTB .facture-ligne__stepper-btn--minus,
#fcrTB .facture-ligne__stepper-btn--plus {
  display: none !important;
}
#fcrTB .facture-ligne__stepper {
  /* display: contents permet à l'input enfant de prendre la place
     directement dans la grille parente sans wrapper visible */
  display: contents !important;
}

/* MASQUER labels internes par ligne (desktop) ajoutés par anciennes versions T209D */
@media (min-width: 761px) {
  #fcrTB .facture-ligne__label {
    display: none !important;
  }
}

/* ─────────────────────────────────────────────────────────────────────
   PRIX UNIT : aligné droite, tabular
   ───────────────────────────────────────────────────────────────────── */
#fcrTB input[data-fcr-price] {
  text-align: right !important;
  font-family: 'JetBrains Mono', 'SF Mono', Menlo, monospace !important;
  font-variant-numeric: tabular-nums !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  color: var(--t209i-text) !important;
  padding: 0 12px !important;
  -moz-appearance: textfield !important;
}
#fcrTB input[data-fcr-price]::-webkit-outer-spin-button,
#fcrTB input[data-fcr-price]::-webkit-inner-spin-button {
  -webkit-appearance: none !important;
  margin: 0 !important;
}

/* ─────────────────────────────────────────────────────────────────────
   TVA : select propre
   ───────────────────────────────────────────────────────────────────── */
#fcrTB select[data-fcr-tva] {
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%2394A3B8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 11px center !important;
  padding: 0 28px 0 12px !important;
  text-align: center !important;
  text-align-last: center !important;
  font-weight: 600 !important;
  font-size: 14px !important;
  cursor: pointer !important;
}

/* ─────────────────────────────────────────────────────────────────────
   TOTAL HT : badge sobre orange pâle, jamais coupé
   ───────────────────────────────────────────────────────────────────── */
#fcrTB .fcr-total-cell .facture-ligne__total-badge,
#fcrTB .fcr-total-cell {
  /* Si présence d'un badge, le styler ; sinon styler le data-tot direct */
}

#fcrTB .facture-ligne__total-badge {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  height: var(--t209i-input-h) !important;
  padding: 0 12px !important;
  background: var(--t209i-accent-light) !important;
  border-radius: 10px !important;
  border: 1px solid var(--t209i-accent-border) !important;
  font-family: 'JetBrains Mono', 'SF Mono', Menlo, monospace !important;
  font-size: 14px !important;
  font-weight: 700 !important;
  color: var(--t209i-accent-text) !important;
  font-variant-numeric: tabular-nums !important;
  letter-spacing: 0 !important;
  white-space: nowrap !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  box-sizing: border-box !important;
}

#fcrTB .fcr-total-cell [data-tot]:not(.facture-ligne__total-amount) {
  /* Fallback : si pas de badge wrap, styler le data-tot directement */
  font-family: 'JetBrains Mono', 'SF Mono', Menlo, monospace !important;
  font-size: 14px !important;
  font-weight: 700 !important;
  color: var(--t209i-accent-text) !important;
  font-variant-numeric: tabular-nums !important;
  letter-spacing: 0 !important;
  text-align: right !important;
  width: 100% !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}

#fcrTB .facture-ligne__total-amount,
#fcrTB .facture-ligne__total-badge [data-tot] {
  font-family: 'JetBrains Mono', 'SF Mono', Menlo, monospace !important;
  font-size: 14px !important;
  font-weight: 700 !important;
  color: var(--t209i-accent-text) !important;
  font-variant-numeric: tabular-nums !important;
  letter-spacing: 0 !important;
}

/* ─────────────────────────────────────────────────────────────────────
   BOUTON SUPPRIMER
   ───────────────────────────────────────────────────────────────────── */
#fcrTB .fcr-remove,
#fcrTB .fcr-action-cell button {
  width: 38px !important;
  height: 38px !important;
  padding: 0 !important;
  background: transparent !important;
  border: 1px solid var(--t209i-border) !important;
  border-radius: 9px !important;
  color: var(--t209i-text-muted) !important;
  cursor: pointer !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: all 0.18s ease !important;
}
#fcrTB .fcr-remove:hover,
#fcrTB .fcr-action-cell button:hover {
  background: #FEE2E2 !important;
  border-color: #FECACA !important;
  color: #EF4444 !important;
}
#fcrTB .fcr-remove svg,
#fcrTB .fcr-action-cell button svg {
  width: 15px !important;
  height: 15px !important;
}

/* ─────────────────────────────────────────────────────────────────────
   RESPONSIVE
   ───────────────────────────────────────────────────────────────────── */
@media (max-width: 1280px) {
  #fcrTable thead tr.fcr-header-row,
  #fcrTB .fcr-line-grid {
    padding-left: 12px !important;
    padding-right: 12px !important;
    gap: 10px !important;
  }
}

@media (max-width: 760px) {
  #fcrTable thead { display: none !important; }
  #fcrTB .facture-ligne__label { display: block !important; }
}

@media (prefers-reduced-motion: reduce) {
  #fcrTB tr.fcr-line-v2,
  #fcrTB .fcr-input,
  #fcrTB input,
  #fcrTB textarea {
    transition: none !important;
  }
}
