/* ═══════════════════════════════════════════════════════════════════
   CAMALARM CRM — DEVIS v44
   Base propre pour les 4 pages : Express / Classique / IA / Facture.
   
   Principes :
   - Aucun override, aucun masquage
   - Composants explicites : .dv-page / .dv-section / .dv-line / ...
   - Typo Inter uniquement (pas de monospace)
   - Chiffres : tabular-nums pour alignement sans police fixed-width
   ═══════════════════════════════════════════════════════════════════ */

/* ─── Wrapper racine d'une page devis ───────────────────────────── */
.dv-page {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  font-family: var(--crm-font);
  color: var(--crm-text);
  font-size: 14px;
  line-height: 1.45;
}

/* ─── Cartes (structure commune) ────────────────────────────────── */
.dv-card {
  background: var(--crm-surface);
  border: 1px solid var(--crm-border);
  border-radius: 12px;
  box-shadow: var(--crm-sh-sm);
  overflow: hidden;
}
.dv-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  background: #fafbfc;
  border-bottom: 1px solid var(--crm-border);
}
.dv-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--crm-text);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin: 0;
}
.dv-card-title svg {
  width: 16px; height: 16px;
  stroke-width: 2;
  color: var(--crm-text-muted);
}
.dv-card-body { padding: 20px; }
.dv-card-body.compact { padding: 14px 20px; }

/* ─── Grid pour cartes côte à côte ───────────────────────────── */
.dv-grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 16px;
}

/* ═══════════════════════════════════════════════════════════════════
   BANDEAU CLIENT (en haut, sous le header)
   ═══════════════════════════════════════════════════════════════════ */
.dv-client-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  background: var(--crm-surface);
  border: 1px solid var(--crm-border);
  border-radius: 12px;
  box-shadow: var(--crm-sh-sm);
  flex-wrap: wrap;
}
.dv-client-left { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 220px; }
.dv-client-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--crm-bl-lt);
  display: flex; align-items: center; justify-content: center;
  color: var(--crm-bl);
  flex-shrink: 0;
}
.dv-client-avatar svg { width: 18px; height: 18px; stroke-width: 2; }
.dv-client-info { min-width: 0; }
.dv-client-name {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--crm-text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dv-client-meta {
  font-size: 12px;
  color: var(--crm-text-muted);
  margin-top: 2px;
  display: flex; gap: 12px; flex-wrap: wrap;
}
.dv-client-meta span { white-space: nowrap; }
.dv-client-empty {
  font-size: 13.5px;
  color: var(--crm-text-muted);
  font-style: italic;
}

/* Bouton "Ajouter un client" : état vide élégant (remplace le message permanent) */
.dv-client-addbtn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  background: transparent;
  border: 1px dashed var(--crm-border-hover);
  border-radius: 8px;
  color: var(--crm-text-muted);
  font-size: 13.5px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all .12s;
}
.dv-client-addbtn:hover {
  background: var(--crm-bl-lt);
  border-color: var(--crm-bl);
  border-style: solid;
  color: var(--crm-bl);
}
.dv-client-addbtn svg { color: inherit; }
.dv-client-actions { display: flex; gap: 8px; }

/* Champ "projet" au centre du bandeau */
.dv-client-project {
  flex: 2;
  min-width: 200px;
}
.dv-client-project input {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--crm-border);
  border-radius: 8px;
  font-size: 13.5px;
  font-family: inherit;
  background: #fff;
  color: var(--crm-text);
  transition: border-color .12s, box-shadow .12s;
}
.dv-client-project input:focus {
  outline: none;
  border-color: var(--crm-bl);
  box-shadow: 0 0 0 3px rgba(21,101,192,.1);
}

.dv-client-ref {
  font-size: 11.5px;
  color: var(--crm-text-muted);
  font-weight: 600;
  letter-spacing: 0.4px;
  padding: 6px 10px;
  background: #f1f5f9;
  border-radius: 6px;
  font-variant-numeric: tabular-nums;
}

/* ═══════════════════════════════════════════════════════════════════
   SECTIONS DE CONTENU (Technologie / Caméras / NVR / ...)
   ═══════════════════════════════════════════════════════════════════ */

/* Titre de section dans une card */
.dv-section-title {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--crm-text-muted);
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.dv-section-title:not(:first-child) { margin-top: 20px; }
.dv-section-title svg {
  width: 14px; height: 14px;
  stroke-width: 2;
  color: var(--crm-text-subtle);
}

/* Sous-label */
.dv-sublabel {
  font-size: 12px;
  font-weight: 500;
  color: var(--crm-text-muted);
  margin-bottom: 6px;
  display: block;
}

/* ═══════════════════════════════════════════════════════════════════
   OPTIONS À COCHER / RADIOS (composant central du Devis Express)
   ═══════════════════════════════════════════════════════════════════ */
.dv-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

/* Une pill-option (radio ou checkbox) */
.dv-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: #fff;
  border: 1px solid var(--crm-border);
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--crm-text);
  cursor: pointer;
  transition: border-color .12s, background .12s, color .12s;
  user-select: none;
  line-height: 1;
  white-space: nowrap;
}
.dv-option:hover { border-color: var(--crm-border-hover); background: #fafbfc; }

/* Input réellement coché → état visuel */
.dv-option input[type="radio"],
.dv-option input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border: 1.5px solid var(--crm-border);
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  margin: 0;
  transition: all .12s;
}
.dv-option input[type="radio"] { border-radius: 50%; }

/* Cocher */
.dv-option input[type="checkbox"]:checked,
.dv-option input[type="radio"]:checked {
  background: var(--crm-bl);
  border-color: var(--crm-bl);
}
.dv-option input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  top: 1px; left: 4px;
  width: 5px; height: 9px;
  border-right: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(45deg);
}
.dv-option input[type="radio"]:checked::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 7px; height: 7px;
  background: #fff;
  border-radius: 50%;
}

/* État actif de la pill entière */
.dv-option:has(input:checked) {
  background: var(--crm-bl-lt);
  border-color: var(--crm-bl);
  color: var(--crm-bl);
  font-weight: 600;
}

/* Variante orange (pour options secondaires type "boîte de jonction") */
.dv-option.accent:has(input:checked) {
  background: var(--crm-or-lt);
  border-color: var(--crm-or);
  color: var(--crm-or);
}
.dv-option.accent input:checked {
  background: var(--crm-or);
  border-color: var(--crm-or);
}

/* ═══════════════════════════════════════════════════════════════════
   LIGNES DE CALCUL (produit : label | qty | prix | TVA | total)
   ═══════════════════════════════════════════════════════════════════ */
.dv-line {
  display: grid;
  grid-template-columns: 1fr 72px 96px 72px 100px;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--crm-border);
}
.dv-line:last-child { border-bottom: none; }
.dv-line-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--crm-text);
}
.dv-line-sub {
  font-size: 12px;
  font-weight: 400;
  color: var(--crm-text-muted);
  margin-top: 2px;
  line-height: 1.4;
}

/* Inputs dans les lignes */
.dv-input {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--crm-border);
  border-radius: 6px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--crm-text);
  background: #fff;
  transition: border-color .12s, box-shadow .12s;
  text-align: right;
  font-variant-numeric: tabular-nums;
  box-sizing: border-box;
}
.dv-input:focus {
  outline: none;
  border-color: var(--crm-bl);
  box-shadow: 0 0 0 3px rgba(21,101,192,.1);
}
.dv-input.tva {
  text-align: center;
  padding: 0 6px;
}

/* Total en bout de ligne */
.dv-line-total {
  text-align: right;
  font-size: 14px;
  font-weight: 600;
  color: var(--crm-text);
  font-variant-numeric: tabular-nums;
  padding-right: 4px;
}

/* Ligne accent (boîte jonction, option) */
.dv-line.accent {
  background: #fffaf4;
  margin: 0 -20px;
  padding-left: 20px;
  padding-right: 20px;
  border-bottom: 1px solid var(--crm-or-lt);
}
.dv-line.accent .dv-line-label { color: var(--crm-or); }

/* Ligne option à cocher */
.dv-line.option .dv-line-label { display: flex; align-items: center; }

/* ═══════════════════════════════════════════════════════════════════
   TABLE Produits / services supplémentaires
   ═══════════════════════════════════════════════════════════════════ */
.dv-extras {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.dv-extras thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--crm-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--crm-border);
  background: #fafbfc;
}
.dv-extras tbody td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--crm-border);
}
.dv-extras tbody tr:last-child td { border-bottom: none; }
.dv-extras input,
.dv-extras select {
  width: 100%;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--crm-border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  font-variant-numeric: tabular-nums;
}
.dv-extras .rm-btn {
  background: transparent;
  border: none;
  color: var(--crm-text-subtle);
  cursor: pointer;
  font-size: 16px;
  padding: 4px 8px;
  border-radius: 4px;
}
.dv-extras .rm-btn:hover { color: var(--crm-rd); background: var(--crm-rd-lt); }

.dv-extras-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--crm-border);
}

/* ═══════════════════════════════════════════════════════════════════
   BLOC TOTAUX (TTC DOMINANT)
   ═══════════════════════════════════════════════════════════════════ */
.dv-totals {
  background: var(--crm-surface);
  border: 1px solid var(--crm-border);
  border-radius: 12px;
  overflow: hidden;
  max-width: 440px;
  margin-left: auto;
  box-shadow: var(--crm-sh-sm);
}
.dv-totals-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  font-size: 14px;
  color: var(--crm-text-muted);
  border-bottom: 1px solid var(--crm-border);
}
.dv-totals-row .label { color: var(--crm-text-muted); }
.dv-totals-row .value {
  font-weight: 600;
  color: var(--crm-text);
  font-variant-numeric: tabular-nums;
}
.dv-totals-row.discount .value { color: var(--crm-rd); }

/* TTC dominant */
.dv-totals-row.total {
  background: linear-gradient(135deg, #0f1729 0%, #1b2a4a 100%);
  color: rgba(255,255,255,.85);
  padding: 18px 20px;
  border: none;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 600;
  font-size: 13px;
}
.dv-totals-row.total .label { color: rgba(255,255,255,.85); }
.dv-totals-row.total .value {
  color: #fff;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.3px;
  font-variant-numeric: tabular-nums;
}

/* Acompte / Solde */
.dv-totals-row.accent { background: #fff7ed; border-bottom-color: var(--crm-or-lt); }
.dv-totals-row.accent .value { color: var(--crm-or); font-weight: 700; }
.dv-totals-row.accent input {
  width: 120px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--crm-or-lt);
  border-radius: 6px;
  text-align: right;
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  color: var(--crm-or);
  background: #fff;
  font-variant-numeric: tabular-nums;
}
.dv-totals-row.accent input:focus {
  outline: none;
  border-color: var(--crm-or);
  box-shadow: 0 0 0 3px rgba(230,81,0,.1);
}
.dv-totals-row:last-child { border-bottom: none; }

/* ═══════════════════════════════════════════════════════════════════
   BAS DE PAGE : Remise / Validité / Paiement
   ═══════════════════════════════════════════════════════════════════ */
.dv-field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}
.dv-field { display: flex; flex-direction: column; gap: 5px; }
.dv-field-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--crm-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.dv-field input,
.dv-field select,
.dv-field textarea {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--crm-border);
  border-radius: 8px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--crm-text);
  background: #fff;
  transition: border-color .12s, box-shadow .12s;
  box-sizing: border-box;
  font-variant-numeric: tabular-nums;
}
.dv-field textarea {
  height: auto;
  min-height: 80px;
  padding: 10px 12px;
  resize: vertical;
  font-variant-numeric: normal;
}
.dv-field input:focus,
.dv-field select:focus,
.dv-field textarea:focus {
  outline: none;
  border-color: var(--crm-bl);
  box-shadow: 0 0 0 3px rgba(21,101,192,.1);
}

/* ═══════════════════════════════════════════════════════════════════
   MOBILE
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .dv-line {
    grid-template-columns: 1fr 60px 80px;
    grid-template-rows: auto auto;
    gap: 6px;
  }
  .dv-line-label { grid-column: 1 / -1; }
  .dv-line-total { grid-column: 1 / -1; text-align: right; font-size: 15px; }
  .dv-totals { max-width: 100%; }
  .dv-totals-row.total .value { font-size: 20px; }
  .dv-client-bar { flex-direction: column; align-items: stretch; }
}
