/* ============================================================
   OFFICEA — Module Facturation (Espace Client)
   Palette : navy #1a2942 · ocre #b8843f · ivoire #f5f1e8
   ============================================================ */

/* ─── Onglet Factures principal ─── */
#tab-invoices.tab-panel {
  padding: 0 0 30px;
}

.billing-toolbar {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  padding: 0 18px 14px;
  align-items: center;
}
.billing-btn-new {
  flex: 1;
  min-width: 0;
}
.billing-icon-btn {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: 1px solid #b8843f;
  color: #b8843f;
  border-radius: 8px;
  cursor: pointer;
  padding: 0;
}
.billing-icon-btn:hover {
  background: #b8843f;
  color: #fff;
}

/* Choix Devis / Facture */
.billing-choice-sheet {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: #f5f1e8;
  border-radius: 16px 16px 0 0;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
}
@media (min-width: 720px) {
  .billing-choice-sheet {
    top: 50%; bottom: auto; left: 50%; right: auto;
    transform: translate(-50%, -50%);
    width: 90%; max-width: 380px;
    border-radius: 16px;
  }
}
.billing-choice-title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 22px; color: #1a2942; margin: 0 0 6px;
}
.billing-choice-opt {
  display: flex; align-items: center; gap: 14px;
  background: #fff; border: 1px solid #e8e0d0; border-radius: 12px;
  padding: 16px; cursor: pointer; text-align: left; font-family: inherit;
}
.billing-choice-opt:active { background: #faf6ec; }
.billing-choice-ico { font-size: 26px; flex-shrink: 0; }
.billing-choice-opt span:last-child { display: flex; flex-direction: column; }
.billing-choice-opt strong { font-size: 15px; color: #1a2942; }
.billing-choice-opt small { font-size: 12px; color: #8a8474; margin-top: 2px; }
.billing-choice-cancel {
  background: none; border: none; color: #8a8474; font-size: 14px;
  padding: 12px; cursor: pointer; font-family: inherit; margin-top: 4px;
}

/* ─── Stats (CA, en attente, en retard) ─── */
.billing-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 0 18px 14px;
}
.billing-stat {
  background: #fff;
  border: 1px solid #e8e0d0;
  border-radius: 10px;
  padding: 12px 14px;
  text-align: center;
}
.billing-stat.is-danger {
  background: #fff4f0;
  border-color: #f0c8b8;
}
.billing-stat-value {
  display: block;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 22px;
  font-weight: 600;
  color: #1a2942;
  line-height: 1.1;
}
.billing-stat.is-danger .billing-stat-value {
  color: #b8442e;
}
.billing-stat-label {
  display: block;
  font-size: 10.5px;
  color: #8a8474;
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ─── Filtres ─── */
.billing-filters {
  display: flex;
  gap: 8px;
  padding: 4px 18px 14px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  max-width: 100%;
  box-sizing: border-box;
}
.billing-filters::-webkit-scrollbar { display: none; }
/* dernier filtre : marge pour qu'il ne soit pas collé au bord en fin de scroll */
.billing-filters .billing-filter:last-child { margin-right: 18px; }
.billing-filter {
  background: #fff;
  border: 1px solid #e0d7c0;
  color: #6a6558;
  padding: 8px 14px;
  border-radius: 18px;
  font-family: inherit;
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.billing-filter:hover {
  border-color: #b8843f;
  color: #1a2942;
}
.billing-filter.active {
  background: #1a2942;
  color: #f5f1e8;
  border-color: #1a2942;
}

/* ─── Recherche ─── */
.billing-search-wrap {
  padding: 0 18px 12px;
}
#billing-search {
  width: 100%;
  background: #fff;
  border: 1px solid #e0d7c0;
  border-radius: 10px;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 14px;
  color: #1a2942;
  outline: none;
  box-sizing: border-box;
}
#billing-search:focus { border-color: #b8843f; }

/* ─── Liste devis/factures ─── */
.billing-list {
  padding: 0 16px;
}

/* Conteneur swipe : la zone "supprimer" est dessous, la carte glisse par-dessus */
.billing-swipe {
  position: relative;
  margin-bottom: 10px;
  border-radius: 12px;
  overflow: hidden;
}
.billing-swipe-action {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 96px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
}
.billing-swipe-delete {
  background: #b8442e;
}
.billing-swipe-delete span:first-child { font-size: 18px; }
.billing-swipe .billing-item {
  position: relative;
  margin-bottom: 0;
  will-change: transform;
  touch-action: pan-y;
}

.billing-item {
  background: #fff;
  border: 1px solid #e8e0d0;
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
  transition: box-shadow 0.15s, transform 0.15s;
  cursor: pointer;
}
.billing-item:hover {
  box-shadow: 0 4px 12px rgba(26,41,66,0.06);
}
.billing-item-chevron {
  margin-left: auto;
  color: #b8843f;
  font-size: 18px;
  font-weight: 600;
}
.billing-item-meta {
  display: flex;
  align-items: center;
  gap: 4px;
}
.billing-card-pay {
  margin-top: 10px;
  width: 100%;
  background: #e8f5e8;
  color: #1e6622;
  border: 1px solid #b8d8b8;
  border-radius: 8px;
  padding: 9px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.billing-card-pay:active { background: #d4edd4; }

/* ─── Aperçu détaillé ─── */
.billing-detail-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.billing-detail-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid #f0e9d8;
  font-size: 14px;
  color: #6a6558;
}
.billing-detail-row strong { color: #1a2942; text-align: right; }
.billing-detail-lines {
  background: #fff;
  border: 1px solid #e8e0d0;
  border-radius: 10px;
  padding: 6px 12px;
  margin-bottom: 14px;
}
.billing-detail-line {
  padding: 10px 0;
  border-bottom: 1px solid #f5f1e8;
}
.billing-detail-line:last-child { border-bottom: none; }
.billing-detail-line-desc {
  font-size: 14px;
  color: #1a2942;
  font-weight: 500;
}
.billing-detail-line-calc {
  font-size: 12px;
  color: #8a8474;
  margin-top: 2px;
}
.billing-detail-line-total {
  font-size: 14px;
  font-weight: 600;
  color: #1a2942;
  text-align: right;
  margin-top: 2px;
}
.billing-detail-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}
.billing-detail-actions button { width: 100%; }
.billing-item-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 6px;
}
.billing-item-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}
.billing-item-type {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 4px 10px;
  border-radius: 6px;
  flex-shrink: 0;
}
.billing-item-type.is-quote {
  background: #fff8e8;
  color: #8a5a00;
}
.billing-item-type.is-invoice {
  background: #1a2942;
  color: #f5f1e8;
}
.billing-item-number {
  font-size: 14px;
  font-weight: 600;
  color: #1a2942;
  margin: 0;
}
.billing-item-customer {
  font-size: 12.5px;
  color: #6a6558;
  margin: 2px 0 0;
}
.billing-item-right {
  text-align: right;
  flex-shrink: 0;
}
.billing-item-amount {
  display: block;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 18px;
  font-weight: 600;
  color: #1a2942;
  line-height: 1;
}
.billing-status {
  display: inline-block;
  margin-top: 5px;
  font-size: 10.5px;
  padding: 3px 9px;
  border-radius: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.billing-status.is-draft { background: #f0eadc; color: #6a6558; }
.billing-status.is-sent { background: #e8f0fa; color: #1a4470; }
.billing-status.is-accepted { background: #e8f5e8; color: #2e7d32; }
.billing-status.is-paid { background: #d4edd4; color: #1e6622; }
.billing-status.is-overdue { background: #fce4dc; color: #b8442e; }
.billing-status.is-cancelled { background: #ebebeb; color: #999; }

.billing-item-meta {
  font-size: 11.5px;
  color: #8a8474;
  margin-bottom: 8px;
}
.billing-item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.billing-action-btn {
  background: #faf6ec;
  border: 1px solid #e0d7c0;
  color: #1a2942;
  padding: 5px 11px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 11.5px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.billing-action-btn:hover {
  background: #b8843f;
  color: #fff;
  border-color: #b8843f;
}

.billing-empty {
  text-align: center;
  padding: 40px 20px;
  background: #fff;
  border: 1px dashed #e0d7c0;
  border-radius: 12px;
  margin: 0 16px;
}
.billing-empty-title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 18px;
  color: #1a2942;
  margin: 0 0 6px;
}
.billing-empty-sub {
  font-size: 13px;
  color: #6a6558;
  margin: 0;
}

/* ─── Boutons ─── */
.billing-btn-primary {
  background: #b8843f;
  color: #fff;
  border: none;
  padding: 11px 18px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.billing-btn-primary:hover { background: #9d6f30; }
.billing-btn-primary:disabled { opacity: 0.5; cursor: wait; }
.billing-btn-ghost {
  background: transparent;
  color: #1a2942;
  border: 1px solid #1a2942;
  padding: 11px 18px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
}
.billing-btn-ghost:hover { background: rgba(26,41,66,0.06); }
.billing-btn-ghost-sm {
  background: transparent;
  color: #b8843f;
  border: 1px solid #b8843f;
  padding: 7px 12px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
}
.billing-btn-ghost-sm:hover {
  background: #b8843f;
  color: #fff;
}

/* ═══════════════════════════════════════════════════════════
   MODAL (création, édition, settings, customers)
   ═══════════════════════════════════════════════════════════ */
#billing-modal-root {
  position: fixed;
  inset: 0;
  z-index: 9000;
}
.billing-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(26, 41, 66, 0.55);
  backdrop-filter: blur(2px);
}
.billing-modal {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  max-height: 92vh;
  background: #f5f1e8;
  border-radius: 16px 16px 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
@media (min-width: 720px) {
  .billing-modal {
    top: 50%;
    bottom: auto;
    left: 50%;
    right: auto;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 720px;
    max-height: 85vh;
    border-radius: 16px;
  }
  .billing-modal-editor {
    max-width: 820px;
  }
}
.billing-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: #1a2942;
  color: #f5f1e8;
  flex-shrink: 0;
}
.billing-modal-head h2 {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 20px;
  font-weight: 500;
  margin: 0;
}
.billing-modal-close {
  background: rgba(245,241,232,0.1);
  border: none;
  color: #f5f1e8;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
}
.billing-modal-close:hover { background: rgba(245,241,232,0.2); }
.billing-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px;
  -webkit-overflow-scrolling: touch;
}
.billing-modal-foot {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 14px 20px;
  border-top: 1px solid #e8e0d0;
  background: #fff;
  flex-shrink: 0;
}

/* ─── Champs ─── */
.billing-field {
  margin-bottom: 14px;
}
.billing-field label {
  display: block;
  font-size: 11.5px;
  color: #6a6558;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 5px;
}
.billing-input {
  width: 100%;
  background: #fff;
  border: 1px solid #e0d7c0;
  border-radius: 8px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  color: #1a2942;
  outline: none;
  box-sizing: border-box;
}
.billing-input:focus { border-color: #b8843f; }
.billing-field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
@media (max-width: 480px) {
  .billing-field-grid {
    grid-template-columns: 1fr;
  }
}
.billing-field-full {
  grid-column: 1 / -1;
}
.billing-section-title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 17px;
  color: #1a2942;
  margin: 18px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid #e8e0d0;
}
.billing-section-title:first-child { margin-top: 0; }

/* ─── Customer row dans éditeur ─── */
.billing-customer-row {
  display: flex;
  gap: 8px;
}
.billing-customer-row select {
  flex: 1;
}

/* ─── Lignes facture ─── */
.billing-lines {
  background: #fff;
  border: 1px solid #e8e0d0;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 14px;
}
.billing-lines-head {
  display: grid;
  grid-template-columns: 1fr 56px 84px 52px 92px 28px;
  gap: 6px;
  font-size: 10.5px;
  font-weight: 600;
  color: #8a8474;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0 4px 8px;
  border-bottom: 1px solid #f0e9d8;
}
@media (max-width: 600px) {
  .billing-lines-head { display: none; }
}
.billing-line-row {
  display: grid;
  grid-template-columns: 1fr 56px 84px 52px 92px 28px;
  gap: 6px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #f5f1e8;
}
.billing-line-row:last-child { border-bottom: none; }
.billing-line-row .billing-input {
  padding: 7px 8px;
  font-size: 13px;
}
/* Desktop : les wrappers disparaissent, leurs champs prennent place dans la grille */
@media (min-width: 601px) {
  .billing-line-fields,
  .billing-line-foot { display: contents; }
  .billing-line-cell { display: contents; }
  .billing-line-cell label { display: none; }
}
.billing-line-total {
  text-align: right;
  font-size: 13px;
  font-weight: 600;
  color: #1a2942;
  white-space: nowrap;
}
.billing-line-del {
  background: transparent;
  border: none;
  color: #b8442e;
  font-size: 15px;
  cursor: pointer;
  padding: 4px 6px;
  justify-self: center;
}
.billing-line-del:hover {
  background: #fce4dc;
  border-radius: 4px;
}

/* ─── Lignes facture : version mobile (carte par ligne) ─── */
@media (max-width: 600px) {
  .billing-line-row {
    display: block;
    padding: 12px;
    margin-bottom: 10px;
    border: 1px solid #ece5d5;
    border-radius: 10px;
    background: #fdfbf6;
    position: relative;
  }
  .billing-line-row:last-child { border-bottom: 1px solid #ece5d5; }

  /* Désignation pleine largeur */
  .billing-line-desc {
    width: 100%;
    margin-bottom: 10px;
  }

  /* Trio Qté / PU / TVA avec mini-labels */
  .billing-line-fields {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    margin-bottom: 10px;
  }
  .billing-line-cell { display: flex; flex-direction: column; gap: 3px; }
  .billing-line-cell label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #8a8474;
    font-weight: 600;
  }
  .billing-line-cell .billing-input { width: 100%; }

  /* Ligne du bas : total à gauche, supprimer à droite */
  .billing-line-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px dashed #ece5d5;
    padding-top: 8px;
  }
  .billing-line-total {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 17px;
  }
  .billing-line-total::before {
    content: "Total : ";
    font-family: inherit;
    font-size: 11px;
    color: #8a8474;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
  }
  .billing-line-del {
    font-size: 14px;
    color: #b8442e;
    padding: 6px 12px;
    border: 1px solid #f0c8b8;
    border-radius: 8px;
  }
}

/* ─── Totaux ─── */
.billing-totals {
  background: #faf6ec;
  border: 1px solid #e8e0d0;
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 14px;
}
.billing-total-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 14px;
  color: #6a6558;
}
.billing-total-row.is-big {
  border-top: 1px solid #e8e0d0;
  margin-top: 4px;
  padding-top: 10px;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 19px;
  font-weight: 600;
  color: #1a2942;
}

/* ─── Customers list ─── */
.billing-customers-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.billing-customer-row-item {
  background: #fff;
  border: 1px solid #e8e0d0;
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.billing-customer-name {
  font-size: 14px;
  font-weight: 600;
  color: #1a2942;
  margin: 0;
}
.billing-customer-meta {
  font-size: 11.5px;
  color: #6a6558;
  margin: 2px 0 0;
}
.billing-customer-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* ─── Logo preview ─── */
.billing-logo-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.billing-logo-preview {
  flex: 1;
  min-width: 120px;
  background: #fff;
  border: 1px dashed #b8843f;
  border-radius: 8px;
  padding: 14px;
  text-align: center;
  font-size: 12px;
  color: #6a6558;
  font-style: italic;
}

/* ─── Toast ─── */
.billing-toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1a2942;
  color: #f5f1e8;
  padding: 12px 22px;
  border-radius: 30px;
  font-size: 13.5px;
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  max-width: 90%;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}
.billing-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.billing-toast-success { background: #2e7d32; }
.billing-toast-error { background: #b8442e; }
.billing-toast-info { background: #1a2942; }

/* ─── Bandeau pré-remplissage profil ─── */
.billing-prefill-note {
  background: #fbf4e6;
  border: 1px solid #e7d3a8;
  color: #8a6a2a;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 12.5px;
  line-height: 1.5;
  margin-bottom: 16px;
}
