
/* =========================================================
Thème / variables
========================================================= */
:root{
--panel-bg:#0b1222;
--panel-bd:#1f2937;
--text-title:#e5e7eb;
--text-muted:#9ca3af;
--text-dim:#6b7280;
--focus:#334155;
--primary:#2563eb;
--shadow:0 10px 24px rgba(0,0,0,.25);
--border:#1f2937;
}

/* =========================================================
Table responsive + 1ère colonne figée
========================================================= */
.table-responsive{ width:100%; overflow-x:auto; -webkit-overflow-scrolling:touch; padding-bottom:150px; padding-right:60px; box-sizing:border-box; }
.table-responsive table{ min-width:720px; }
.table-responsive table th:first-child,
.table-responsive table td:first-child{left:0; z-index:2;
}
.table-responsive table th:first-child{ z-index:3; }

/* Laisse les popovers passer devant le tableau et empêche qu'ils soient masqués */
.table-responsive { position: relative; overflow-y: visible; }
.inv-pop, .client-pop, .amount-pop, .due-pop, .status-pop { z-index: 2000; }

/* Un “spacer” optionnel que le JS créera si besoin (invisible) */
.table-spacer {
width: 100%;
height: 0;
pointer-events: none;
}

/* Le tableau peut déborder verticalement (utile aux popovers) */
.table-responsive {
overflow-y: visible;
}

/* Un espace auxiliaire créé par le JS sous la carte pour
permettre d'afficher entièrement les popovers si besoin */
.filter-pop-spacer {
height: 0;
width: 100%;
pointer-events: none;
}

/* =========================================================
Dropdown WhatsApp + toast
========================================================= */
.dropdown{ position:relative; display:inline-block; }
.dropdown .dropdown-menu{
display:none; position:absolute; min-width:220px; z-index:1000;
background:var(--panel-bg); border:1px solid var(--panel-bd); border-radius:8px; padding:6px;
box-shadow:0 6px 18px rgba(0,0,0,.08);
}
.dropdown:hover .dropdown-menu{ display:block; }
.dropdown-menu a{
display:block; padding:8px 10px; text-decoration:none; color:var(--text-muted); border-radius:6px;
}
.dropdown-menu a:hover{ background:#0f172a; color:#93c5fd; }
.btn-wa{ padding:8px 12px; border-radius:8px; }

.wa-toast{
position:fixed; right:12px; bottom:12px; background:#222; color:#fff; padding:10px 12px; border-radius:8px; display:none;
}
.wa-toast.show{ display:block; }

/* =========================================================
Entêtes filtrables : base commune
========================================================= */
th[data-type]{ position:relative; white-space:nowrap; color:var(--text-title); font-weight:600; }
th[data-type] .inv-btn,
th[data-type] .client-btn,
th[data-type] .amount-btn,
th[data-type] .due-btn,
th[data-type] .status-btn{
margin-left:6px; padding:0; border:0; background:none; cursor:pointer; color:var(--text-muted);
font-size:.65rem; line-height:1; vertical-align:middle; transition:color .15s;
}
th[data-type] .inv-btn:hover,
th[data-type] .client-btn:hover,
th[data-type] .amount-btn:hover,
th[data-type] .due-btn:hover,
th[data-type] .status-btn:hover{ color:var(--text-title); }
th.is-open > .inv-btn,
th.is-open > .client-btn,
th.is-open > .amount-btn,
th.is-open > .due-btn,
th.is-open > .status-btn{ color:var(--text-title); }

/* Chips (petit rappel) — cachés quand vides, visibles sinon */
th .inv-chip, th .client-chip, th .amount-chip, th .due-chip, th .status-chip{
display:none; margin-left:8px; padding:2px 8px; font-size:.75rem; color:#d1d5db;
background:var(--panel-bg); border:1px solid var(--panel-bd); border-radius:999px;
}

/* =========================================================
Popovers — style commun
========================================================= */
.inv-pop, .client-pop, .amount-pop, .due-pop, .status-pop{
display:none; position:absolute; top:100%; left:0; margin-top:8px; min-width:260px; max-width:360px;
background:var(--panel-bg); border:1px solid var(--panel-bd); border-radius:10px; padding:10px; z-index:1020;
box-shadow:var(--shadow);
}
/* Structure en grille compacte (champs empilés) */
.inv-pop, .client-pop, .amount-pop, .due-pop, .status-pop{ display:none; }
.inv-pop.open, .client-pop.open, .amount-pop.open, .due-pop.open, .status-pop.open{ display:grid; gap:8px; }

/* Champs & selects */
.inv-pop input, .inv-pop select,
.client-pop input, .client-pop select,
.amount-pop input,
.due-pop select,
.status-pop select{
width:100%; box-sizing:border-box; margin:2px 0; padding:8px 10px;
background:var(--panel-bg); color:var(--text-title);
border:1px solid var(--panel-bd); border-radius:8px; font-size:.875rem;
}
.inv-pop input:focus, .inv-pop select:focus,
.client-pop input:focus, .client-pop select:focus,
.amount-pop input:focus,
.due-pop select:focus,
.status-pop select:focus{
outline:none; border-color:var(--focus); box-shadow:0 0 0 3px rgba(51,65,85,.35);
}

/* Échéance : placeholder cohérent */
.due-pop .dueBucket.is-placeholder{ color:var(--text-muted); background:#111827; }

/* Actions (Réinitialiser / Appliquer) — design d’origine */
.inv-actions, .client-actions, .amount-actions, .due-actions, .status-actions{
display:flex; gap:8px; justify-content:flex-end; margin-top:4px;
}
.inv-actions .inv-btn-reset,
.client-actions .client-btn-reset,
.amount-actions .amount-btn-reset,
.due-actions .due-btn-reset,
.status-actions .status-btn-reset{
background:var(--panel-bg); color:#d1d5db; border:1px solid var(--panel-bd);
border-radius:8px; padding:8px 10px; cursor:pointer; transition:.15s;
}
.inv-actions .inv-btn-reset:hover,
.client-actions .client-btn-reset:hover,
.amount-actions .amount-btn-reset:hover,
.due-actions .due-btn-reset:hover,
.status-actions .status-btn-reset:hover{
border-color:var(--focus); color:var(--text-title);
}
.inv-actions .inv-btn-apply,
.client-actions .client-btn-apply,
.amount-actions .amount-btn-apply,
.due-actions .due-btn-apply,
.status-actions .status-btn-apply{
background:var(--primary); color:#fff; border:1px solid var(--primary);
border-radius:8px; padding:8px 10px; cursor:pointer; transition:.15s;
}
.inv-actions .inv-btn-apply:hover,
.client-actions .client-btn-apply:hover,
.amount-actions .amount-btn-apply:hover,
.due-actions .due-btn-apply:hover,
.status-actions .status-btn-apply:hover{ filter:brightness(1.06); }

/* S'assure que les filtres s'affichent toujours au-dessus du tableau */
.inv-pop,
.client-pop,
.amount-pop,
.echeance
.due-pop,
.status-pop {
z-index: 2000 !important;
}

/* =========================================================
Pagination
========================================================= */
.pagination-bar{ margin-top:14px; display:flex; align-items:center; justify-content:space-between; }
.pagination-bar .muted{ color:#9ca3af; font-size:.9rem; }
.pagination-nav{ display:flex; align-items:center; gap:6px; }
.page-btn{
display:inline-flex; align-items:center; justify-content:center;
min-width:32px; height:32px; padding:0 8px; border-radius:8px;
border:1px solid #1f2937; background:var(--panel-bg); color:var(--text-title);
font-size:.9rem; text-decoration:none; box-shadow:0 6px 18px rgba(0,0,0,.08);
}
.page-btn:hover{ border-color:#334155; color:#fff; }
.page-btn.current{ background:var(--primary); border-color:var(--primary); color:#fff; cursor:default; }
.page-btn.disabled{ opacity:.45; pointer-events:none; }
.page-size-form{ display:inline-flex; align-items:center; gap:6px; margin-left:10px; border-left:1px solid #1f2937; padding-left:10px; }
.page-size-form label{ color:#9ca3af; font-size:.85rem; }
.page-size-form select{
background:var(--panel-bg); color:var(--text-title); border:1px solid var(--panel-bd); border-radius:8px; padding:6px 8px;
}
.page-size-form select:focus{ outline:none; border-color:var(--focus); box-shadow:0 0 0 3px rgba(51,65,85,.35); }

/* =========================================================
Responsive
========================================================= */
@media (max-width:1024px){
.grid.kpi{ display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; }
.inv-pop, .client-pop, .amount-pop, .due-pop, .status-pop{ right:0; left:auto; min-width:220px; max-width:90vw; }
#invoiceModal{ width:96vw !important; max-width:none !important; }
}
@media (max-width:768px){
.card>h3{ font-size:1rem; margin-bottom:8px; }
table thead th, table tbody td{ padding:8px 10px; font-size:.9rem; }
th.right, td.right{ text-align:right; }
.pagination-bar{ flex-direction:column; align-items:stretch; gap:10px; }
.pagination-left{ order:2; text-align:center; }
.pagination-nav{ order:1; justify-content:center; flex-wrap:wrap; }
.page-btn{ min-width:36px; height:36px; }
.page-size-form{ justify-content:center; border-left:0; padding-left:0; margin-left:0; }
}
@media (max-width:640px){
.grid.kpi{ grid-template-columns:1fr; }
.kpi .kpi-value{ font-size:1.6rem; }
/* Popovers en feuille en bas d’écran */
th .inv-pop, th .client-pop, th .amount-pop, th .due-pop, th .status-pop{
position:fixed; inset:auto 12px 12px 12px; top:auto; max-width:none; width:auto; border-radius:12px; z-index:9999;
}
th .inv-btn, th .client-btn, th .amount-btn, th .due-btn, th .status-btn{ font-size:.8rem; padding:2px 4px; }
.btn, .page-btn{ touch-action:manipulation; }
#invoiceModal{ width:100vw !important; max-width:100vw !important; border-radius:0 !important; }
#invoiceModal>div:first-child{ padding:10px; }
#invoiceModal [id="invoiceTitle"]{ font-size:1rem; }
}
@media (max-width:480px){ .pagination-nav .page-btn.current{ transform:scale(1.05); } }
@media (max-width:400px){
table tbody td:nth-child(6), table thead th:nth-child(6){ display:none; } /* cache "Visualisation" si très étroit */
}


/* ==========================================
CENTRAGE ET UNIFORMISATION DU TEXTE DANS LES BADGES
========================================== */

.badge {
text-align: center;   /* centre horizontalement */
justify-content: center; /* si c'est en flex (parfois dans certains frameworks) */
}

/* ===== Alert stack (bannières) ===== */
.alert-stack {
position: fixed;
top: 16px;
right: 16px;
display: grid;
gap: 10px;
z-index: 3000; /* au-dessus des popovers */
}

.alert {
display: flex;
align-items: flex-start;
gap: 10px;
max-width: 520px;
padding: 10px 12px;
border-radius: 10px;
border: 1px solid var(--panel-bd);
background: var(--panel-bg);
color: var(--text-title);
box-shadow: var(--shadow);
animation: alert-in .18s ease-out;
}
.alert .icon { font-size: 1.1rem; line-height: 1; }
.alert .content { flex: 1; }
.alert .title { font-weight: 700; margin: 0 0 2px; }
.alert .desc { color: var(--text-muted); margin: 0; }
.alert .close {
border: 0; background: transparent; color: var(--text-muted);
cursor: pointer; padding: 2px; margin-left: 6px;
}
.alert .close:hover { color: #fff; }

.alert.error   { border-color: #7f1d1d; background: #1f0b0b; }
.alert.success { border-color: #14532d; background: #0e1a14; }
.alert.warn    { border-color: #7c2d12; background: #1b130b; }
.alert.info    { border-color: #1e3a8a; background: #0b1322; }

@keyframes alert-in { from { transform: translateY(-6px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ===== Toast (tu en as déjà un, on uniformise légèrement) ===== */
.wa-toast{
position:fixed; right:12px; bottom:12px;
background:#222; color:#fff; padding:10px 12px; border-radius:8px; display:none;
box-shadow: var(--shadow);
}
.wa-toast.show{ display:block; }

/* --- Restauration du style "bleu nuit" fin pour le bouton WhatsApp --- */
.btn.btn-wa {
  background: var(--panel-bg);       /* bleu nuit : #0b1222 */
  color: var(--text-title);          /* #e5e7eb */
  border: 1px solid var(--panel-bd); /* #1f2937 */
  padding: 8px 12px;                /* plus fin */
  border-radius: 8px;
  font-weight: 500;
  line-height: 1.1;
  font-size: 0.8rem;
}

.btn.btn-wa:hover {
  background: #111827;               /* léger éclaircissement au survol */
  border-color: #334155;
}

.btn.btn-wa:focus {
  outline: 2px solid var(--focus);   /* #334155 */
  outline-offset: 2px;
}

.btn-wa { padding:8px 12px; border-radius:8px; }
