/* ============================================
   CLIENT INVOICING MODULE STYLES
   ============================================ */

/* ---- Invoicing Header ---- */
.invoicing-header {
  margin-bottom: var(--space-6);
}

.invoicing-model-badge {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  background: var(--color-bg-subtle);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-5);
}

.invoicing-model-badge .model-icon {
  font-size: 24px;
}

.invoicing-model-badge strong {
  display: block;
  font-size: var(--text-sm);
}

.invoicing-model-badge .btn-ghost {
  margin-left: auto;
}

.invoicing-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
}

@media (max-width: 640px) {
  .invoicing-kpis {
    grid-template-columns: repeat(2, 1fr);
  }
}

.invoicing-kpi {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  text-align: center;
}

.invoicing-kpi-label {
  display: block;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-1);
}

.invoicing-kpi-value {
  display: block;
  font-size: var(--text-lg);
  font-weight: 700;
  font-family: var(--font-heading);
}

/* ---- Billing Setup ---- */
.billing-setup {
  padding: var(--space-8);
}

.billing-setup-header {
  text-align: center;
  margin-bottom: var(--space-8);
}

.billing-setup-header p {
  margin-top: var(--space-2);
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
}

.billing-model-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-5);
}

@media (max-width: 768px) {
  .billing-model-grid {
    grid-template-columns: 1fr;
  }
}

.billing-model-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--space-6);
  border: 2px solid var(--color-border-light);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.2s ease;
  gap: var(--space-3);
}

.billing-model-card:hover {
  border-color: var(--color-primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.billing-model-card.active {
  border-color: var(--color-primary);
  background: var(--color-primary-50);
}

.billing-model-icon {
  font-size: 32px;
}

.billing-model-card h4 {
  font-family: var(--font-heading);
  margin: 0;
}

/* ---- Billing Config Lines ---- */
.billing-config-lines {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.billing-config-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-2) 0;
}

.billing-config-line.billing-config-subtotal {
  border-top: 1px solid var(--color-border-light);
  padding-top: var(--space-3);
  margin-top: var(--space-2);
}

.billing-config-line.billing-config-total {
  border-top: 2px solid var(--color-border);
  padding-top: var(--space-3);
  margin-top: var(--space-1);
}

.billing-line-label {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

.billing-line-amount {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---- Payment Schedule Timeline ---- */
.schedule-timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative;
}

.schedule-step {
  display: flex;
  gap: var(--space-4);
  padding: var(--space-4) 0;
  position: relative;
}

.schedule-step:not(:last-child)::after {
  content: '';
  position: absolute;
  left: 15px;
  top: 44px;
  bottom: 0;
  width: 2px;
  background: var(--color-border-light);
}

.schedule-step.paid:not(:last-child)::after {
  background: var(--color-success);
}

.schedule-step-marker {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-bg-subtle);
  border: 2px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: 700;
  flex-shrink: 0;
  z-index: 1;
}

.schedule-step.paid .schedule-step-marker {
  background: var(--color-success);
  border-color: var(--color-success);
  color: white;
}

.schedule-step-content {
  flex: 1;
  min-width: 0;
}

.schedule-step-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-3);
}

.schedule-step-amount {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.schedule-step-details {
  margin-top: 2px;
}

/* Schedule progress bar */
.schedule-progress {
  height: 6px;
  background: var(--color-bg-subtle);
  border-radius: 3px;
  overflow: hidden;
  margin-top: var(--space-4);
}

.schedule-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--color-success), #66BB6A);
  border-radius: 3px;
  transition: width 0.5s ease;
}

/* ---- Schedule Form ---- */
.schedule-form-step {
  padding: var(--space-3);
  background: var(--color-bg-subtle);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-3);
}

/* ---- Document line rows ---- */
.doc-line-row {
  display: flex;
  gap: var(--space-3);
  align-items: center;
}

/* ---- Utility ---- */
.badge-sm {
  font-size: var(--text-xs);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}

.text-right {
  text-align: right;
}

.text-center {
  text-align: center;
}

.justify-end {
  justify-content: flex-end;
}

.justify-between {
  justify-content: space-between;
}

.align-center {
  align-items: center;
}

/* ============================================
   ACCOUNTING DASHBOARD
   ============================================ */

.accounting-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
}

@media (max-width: 768px) {
  .accounting-kpis {
    grid-template-columns: repeat(2, 1fr);
  }
}

.accounting-kpi-card {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  background: var(--color-bg-card);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}

.accounting-kpi-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.accounting-kpi-label {
  display: block;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}

.accounting-kpi-value {
  display: block;
  font-size: var(--text-xl);
  font-weight: 700;
  font-family: var(--font-heading);
  line-height: 1.2;
}

/* ---- Revenue Chart ---- */
.revenue-chart {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  height: 180px;
  gap: var(--space-3);
  padding: var(--space-4) 0;
}

.revenue-bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  height: 100%;
}

.revenue-bar-wrapper {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.revenue-bar {
  width: 60%;
  max-width: 50px;
  background: linear-gradient(180deg, var(--color-primary), var(--color-primary-light));
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  min-height: 4px;
  transition: height 0.5s ease;
}

.revenue-bar-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-secondary);
}

.revenue-bar-amount {
  font-size: 10px;
  color: var(--color-text-muted);
  white-space: nowrap;
}

/* ---- Document Lists ---- */
.accounting-doc-list {
  display: flex;
  flex-direction: column;
}

.accounting-doc-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3) var(--space-2);
  border-bottom: 1px solid var(--color-border-light);
  cursor: pointer;
  transition: background 0.15s;
  gap: var(--space-3);
}

.accounting-doc-item:last-child {
  border-bottom: none;
}

.accounting-doc-item:hover {
  background: var(--color-bg-subtle);
}

.accounting-doc-item strong {
  display: block;
  font-size: var(--text-sm);
}

/* ---- Company Logo Upload ---- */
.company-logo-upload {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-2);
}

/* ---- Grid helper ---- */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.gap-4 {
  gap: var(--space-4);
}

.gap-6 {
  gap: var(--space-6);
}

.mt-6 {
  margin-top: var(--space-6);
}

@media (max-width: 480px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

/* ---- Text link ---- */
.text-link {
  color: var(--color-primary);
  text-decoration: none;
}

.text-link:hover {
  text-decoration: underline;
}

/* ============================================
   Bloc Redevance Franchise (Comptabilité)
   ============================================ */
.franchise-block {
  background: linear-gradient(135deg, #fff8e6 0%, #fff3d0 100%);
  border: 1px solid color-mix(in srgb, #B8965A 25%, transparent);
  border-radius: 14px;
  padding: 20px 22px;
}
.franchise-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}
.franchise-head .eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 10px;
  color: #B8965A;
  font-weight: 700;
  margin-bottom: 4px;
}
.franchise-title {
  font-family: var(--font-heading, 'Cormorant Garamond', Georgia, serif);
  font-size: 22px;
  font-weight: 500;
  margin: 0 0 4px;
  color: #2a2520;
}
.franchise-network { color: #8a7f72; font-weight: 400; font-style: italic; }
.franchise-sub {
  margin: 0;
  font-size: 13px;
  color: #5a534a;
  line-height: 1.5;
}

.franchise-kpis {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}
@media (max-width: 900px) {
  .franchise-kpis { grid-template-columns: repeat(2, 1fr); }
}
.franchise-kpi {
  background: #fff;
  border: 1px solid color-mix(in srgb, #B8965A 18%, transparent);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.franchise-kpi-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #8a7f72;
}
.franchise-kpi-num {
  font-family: var(--font-heading, 'Cormorant Garamond', Georgia, serif);
  font-size: 22px;
  font-weight: 500;
  line-height: 1.15;
  color: #2a2520;
  margin-top: 2px;
}
.franchise-kpi-meta {
  font-size: 10px;
  color: #8a7f72;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.franchise-kpi-royalty { border-color: color-mix(in srgb, #B8965A 40%, transparent); background: color-mix(in srgb, #B8965A 4%, #fff); }
.franchise-kpi-royalty .franchise-kpi-num { color: #B8965A; }
.franchise-kpi-tva    .franchise-kpi-num { color: #c0392b; }
.franchise-kpi-total {
  background: #2a2520;
  border-color: #2a2520;
}
.franchise-kpi-total .franchise-kpi-label,
.franchise-kpi-total .franchise-kpi-meta { color: rgba(255,255,255,0.6); }
.franchise-kpi-total .franchise-kpi-num { color: #fff; }
.franchise-kpi-net {
  background: color-mix(in srgb, #6b8e7b 6%, #fff);
  border-color: color-mix(in srgb, #6b8e7b 30%, transparent);
}
.franchise-kpi-net .franchise-kpi-num { color: #6b8e7b; }

.franchise-detail {
  margin-top: 8px;
  border-top: 1px solid color-mix(in srgb, #B8965A 18%, transparent);
  padding-top: 12px;
}
.franchise-detail summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: #5a534a;
  padding: 4px 0;
  user-select: none;
}
.franchise-detail summary:hover { color: #2a2520; }
.franchise-table-wrap {
  margin-top: 10px;
  overflow-x: auto;
  background: #fff;
  border: 1px solid color-mix(in srgb, #B8965A 18%, transparent);
  border-radius: 8px;
}
.franchise-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.franchise-table th,
.franchise-table td {
  padding: 8px 12px;
  border-bottom: 1px solid color-mix(in srgb, #B8965A 10%, transparent);
}
.franchise-table th {
  background: color-mix(in srgb, #B8965A 8%, #fff);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #5a534a;
}
.franchise-table tr:last-child td { border-bottom: none; }
.franchise-table tbody tr:hover { background: color-mix(in srgb, #B8965A 5%, transparent); }

/* ============================================
   Historique complet — barre de recherche / filtres
   ============================================ */
.acct-hist-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.acct-hist-search {
  position: relative;
  flex: 1 1 260px;
  min-width: 220px;
  display: flex;
  align-items: center;
}
.acct-hist-search svg {
  position: absolute;
  left: 12px;
  color: #9a8f7d;
  pointer-events: none;
}
.acct-hist-search input {
  width: 100%;
  padding-left: 36px;
}
.acct-hist-filters select { flex: 0 1 180px; min-width: 150px; }
.acct-hist-dates {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.acct-hist-dates label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #5a534a;
}
.acct-hist-dates input[type="date"] { width: 150px; }
@media (max-width: 640px) {
  .acct-hist-filters { flex-direction: column; align-items: stretch; }
  .acct-hist-filters select,
  .acct-hist-search { flex-basis: auto; }
  .acct-hist-dates { justify-content: space-between; }
  .acct-hist-dates input[type="date"] { width: 100%; flex: 1; }
}

/* ============================================
   Dépenses & rentabilité (MVP)
   ============================================ */
.expense-regime-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 18px;
}
.expense-regime-banner .expense-regime-icon { font-size: 18px; line-height: 1.2; flex-shrink: 0; }
.expense-regime-micro {
  background: color-mix(in srgb, #B8965A 10%, #fff);
  border: 1px solid color-mix(in srgb, #B8965A 28%, transparent);
  color: #5a4a2a;
}
.expense-regime-reel {
  background: #EAF4EF;
  border: 1px solid #Bfe0cf;
  color: #2c5a44;
}
.expense-subhead {
  font-family: var(--font-heading, Georgia, serif);
  font-size: 0.95rem;
  margin: 20px 0 8px;
  color: #5a534a;
}
.expense-subhead:first-of-type { margin-top: 4px; }
.expense-cat-badge {
  display: inline-block;
  white-space: nowrap;
  font-size: 12px;
  color: #5a534a;
}
.expense-general-row td { font-style: italic; color: #8a8275; border-top: 1px dashed color-mix(in srgb, #B8965A 25%, transparent); }

.expense-vat-preview {
  font-size: 13px;
  color: #6b6257;
}
.expense-vat-preview strong { color: #4a4339; }

/* ============================================
   Justificatif de dépense (photo) + lightbox
   ============================================ */
.expense-receipt {
  display: flex;
  align-items: center;
  gap: 12px;
}
.expense-receipt-thumb {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, #B8965A 22%, transparent);
  cursor: zoom-in;
  background: #f6f1e9;
}
.expense-receipt-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.expense-image-overlay {
  position: fixed;
  inset: 0;
  z-index: 100001;
  background: rgba(20, 16, 12, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  cursor: zoom-out;
}
.expense-image-overlay img {
  max-width: 95vw;
  max-height: 92vh;
  border-radius: 8px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}
.expense-image-overlay-close {
  position: absolute;
  top: 16px;
  right: 22px;
  color: #fff;
  font-size: 34px;
  line-height: 1;
  cursor: pointer;
}

/* ============================================
   Vue facture (voir/modifier) — barre d'actions
   Fix débordement : wrap + tailles homogènes + responsive.
   ============================================ */
.doc-view-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  align-items: flex-start;
  margin-top: var(--space-6, 24px);
  padding-top: var(--space-4, 16px);
  border-top: 1px solid var(--color-border, #e7e0d6);
}
.doc-view-status,
.doc-view-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.doc-view-actions { justify-content: flex-end; }
.doc-view-status .form-select { width: auto; }
.doc-view-avoir-note { align-self: center; }
.doc-view-danger {
  color: var(--color-danger, #B4665C);
  border-color: var(--color-danger, #B4665C);
}
/* boutons d'action : empêche la troncature du libellé */
.doc-view-actions .btn { white-space: nowrap; }
@media (max-width: 680px) {
  .doc-view-footer { flex-direction: column; align-items: stretch; }
  .doc-view-status,
  .doc-view-actions { justify-content: stretch; }
  .doc-view-status .form-select { flex: 1; width: auto; }
  .doc-view-actions .btn { flex: 1 1 auto; justify-content: center; }
}

/* Tableau de la vue facture : défilement horizontal sur petits écrans
   au lieu de faire déborder la modale. */
.doc-view-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ============================================
   Infobulle au survol (réutilisable) — .wp-tip[data-tip]
   ============================================ */
.wp-tip { position: relative; }
/* display:none quand non survolé : un pseudo-élément positionné/dimensionné
   compte dans le scrollWidth même à opacity:0 et provoquerait un débordement
   horizontal de la modale. On ne le rend QUE au survol. */
.wp-tip::after {
  content: attr(data-tip);
  display: none;
  position: absolute;
  bottom: calc(100% + 9px);
  left: 50%;
  transform: translateX(-50%);
  background: #2a2520;
  color: #fff;
  padding: 8px 11px;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: 0;
  white-space: normal;
  width: max-content;
  max-width: 230px;
  text-align: center;
  pointer-events: none;
  z-index: 100;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
}
.wp-tip::before {
  content: '';
  display: none;
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #2a2520;
  pointer-events: none;
  z-index: 100;
}
.wp-tip:hover::after, .wp-tip:focus-visible::after,
.wp-tip:hover::before, .wp-tip:focus-visible::before {
  display: block;
  animation: wpTipIn .14s ease;
}
@keyframes wpTipIn { from { opacity: 0; transform: translateX(-50%) translateY(4px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* Modale relance & indemnité de retard */
.late-claim-b2b {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--color-border, #e7e0d6);
  border-radius: 10px;
  cursor: pointer;
  margin-bottom: 14px;
}
.late-claim-b2b input { margin-top: 3px; flex-shrink: 0; }
.late-claim-b2b span { display: flex; flex-direction: column; gap: 3px; }
.late-claim-b2b small { color: var(--color-text-muted, #8a8275); font-size: 11.5px; line-height: 1.45; }
.late-claim-rows { width: 100%; border-collapse: collapse; }
.late-claim-rows td { padding: 7px 4px; border-bottom: 1px solid var(--color-border-light, #efe9df); font-size: 13.5px; }
.late-claim-rows td:last-child { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.late-claim-rows tr.late-claim-total td {
  font-weight: 700;
  font-size: 15px;
  border-top: 2px solid var(--color-primary, #8B6F4E);
  border-bottom: none;
  color: var(--color-primary, #8B6F4E);
  padding-top: 9px;
}

/* ============================================
   Garde-fou : informations d'entreprise requises
   ============================================ */
.company-required-warn {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: #FFF6E9;
  border: 1px solid #F0D7A8;
  border-radius: 10px;
}
.company-required-warn p { margin: 0; font-size: 13.5px; line-height: 1.55; color: #5a4a2a; }
.company-required-icon { font-size: 20px; line-height: 1.2; flex-shrink: 0; }
.company-required-list {
  margin: 0;
  padding-left: 20px;
  line-height: 1.7;
  font-size: 13.5px;
  color: var(--color-text, #3a3530);
}
.company-required-list li { color: #B4665C; font-weight: 500; }
