/* === Next Guard - Gestion de Chèques === */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

/* La zone d'impression est cachée à l'écran (visible uniquement à l'impression via print.css) */
#print-area { display: none; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: #1f2937;
  background: #f3f4f6;
  -webkit-font-smoothing: antialiased;
}

/* === Layout === */
#app-shell { display: flex; height: 100vh; }
.sidebar {
  width: 240px;
  background: linear-gradient(180deg, #1e3a5f 0%, #14253b 100%);
  color: #e5e7eb;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.brand {
  padding: 18px 16px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.brand .logo {
  width: 40px; height: 40px;
  background: #0ea5e9;
  color: white;
  font-weight: 700;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  letter-spacing: 0.5px;
}
.brand-title { font-weight: 600; font-size: 15px; }
.brand-sub { font-size: 11px; color: #94a3b8; }
.brand-logo-img {
  width: 160px;
  height: auto;
  display: block;
  filter: brightness(0) invert(1);
}

.nav { flex: 1; padding: 8px 0; overflow-y: auto; }
.nav-section {
  font-size: 10px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: #64748b;
  padding: 14px 16px 6px;
  font-weight: 600;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: #cbd5e1;
  text-decoration: none;
  font-size: 13.5px;
  border-left: 3px solid transparent;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
}
.nav-item:hover { background: rgba(255,255,255,0.05); color: white; }
.nav-item.active {
  background: rgba(14, 165, 233, 0.15);
  color: white;
  border-left-color: #0ea5e9;
}
.nav-item.nav-danger { color: #fca5a5; }
.nav-item.nav-danger:hover { background: rgba(239, 68, 68, 0.12); color: #fecaca; }
.nav-item .ic { font-size: 15px; width: 18px; text-align: center; }

.sidebar-footer {
  padding: 12px 16px;
  font-size: 11px;
  color: #64748b;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.sidebar-user {
  color: #e5e7eb;
  font-size: 12px;
  margin-bottom: 6px;
  font-weight: 500;
}

.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  height: 56px;
  background: white;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
}
.topbar-title { font-size: 17px; font-weight: 600; color: #0f172a; }
.topbar-actions { display: flex; gap: 8px; }
.content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* === Boutons === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #d1d5db;
  background: white;
  color: #1f2937;
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
  font-family: inherit;
}
.btn:hover { background: #f9fafb; border-color: #9ca3af; }
.btn-primary { background: #0ea5e9; color: white; border-color: #0ea5e9; }
.btn-primary:hover { background: #0284c7; border-color: #0284c7; }
.btn-success { background: #10b981; color: white; border-color: #10b981; }
.btn-success:hover { background: #059669; border-color: #059669; }
.btn-danger  { background: #ef4444; color: white; border-color: #ef4444; }
.btn-danger:hover  { background: #dc2626; border-color: #dc2626; }
.btn-warning { background: #f59e0b; color: white; border-color: #f59e0b; }
.btn-warning:hover { background: #d97706; border-color: #d97706; }
.btn-ghost { background: transparent; border-color: transparent; color: #64748b; }
.btn-ghost:hover { background: #f3f4f6; color: #1f2937; }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* === Cartes / widgets === */
.card {
  background: white;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  padding: 18px;
  margin-bottom: 16px;
}
.card-title { font-size: 15px; font-weight: 600; margin: 0 0 12px; color: #0f172a; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.kpi {
  background: white;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.kpi-ic {
  width: 44px; height: 44px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.kpi-ic.blue   { background: #dbeafe; color: #1d4ed8; }
.kpi-ic.green  { background: #d1fae5; color: #047857; }
.kpi-ic.orange { background: #fed7aa; color: #c2410c; }
.kpi-ic.red    { background: #fee2e2; color: #b91c1c; }
.kpi-ic.purple { background: #ede9fe; color: #6d28d9; }
.kpi-label { font-size: 11.5px; color: #64748b; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
.kpi-value { font-size: 22px; font-weight: 700; color: #0f172a; margin-top: 2px; }

/* === Formulaires === */
.form-row { display: flex; flex-direction: column; gap: 5px; }
.form-row label { font-size: 12px; font-weight: 600; color: #374151; }
.form-row input, .form-row select, .form-row textarea {
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13.5px;
  font-family: inherit;
  background: white;
  color: #1f2937;
  width: 100%;
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
  outline: none;
  border-color: #0ea5e9;
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
}
.form-row textarea { resize: vertical; min-height: 70px; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.form-grid .full { grid-column: 1 / -1; }
.field-hint { font-size: 11.5px; color: #6b7280; margin-top: 2px; }

/* === Tableaux === */
.table-wrap {
  background: white;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  overflow: hidden;
}
table.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
table.tbl th {
  text-align: left;
  padding: 10px 12px;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
  font-weight: 600;
  font-size: 12px;
  color: #374151;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}
table.tbl td {
  padding: 10px 12px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
table.tbl tr:last-child td { border-bottom: none; }
table.tbl tr:hover td { background: #f8fafc; }
table.tbl td.actions { text-align: right; white-space: nowrap; }
table.tbl td .btn { margin-left: 4px; }
.text-right { text-align: right; }
.text-muted { color: #6b7280; }
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: #6b7280;
}
.empty-state .ic { font-size: 36px; margin-bottom: 8px; opacity: 0.5; }

/* === Badges statut === */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.badge-emis      { background: #dbeafe; color: #1d4ed8; }
.badge-remis     { background: #fef3c7; color: #92400e; }
.badge-encaisse  { background: #d1fae5; color: #047857; }
.badge-annule    { background: #f3f4f6; color: #4b5563; }
.badge-impaye    { background: #fee2e2; color: #b91c1c; }
.badge-echu      { background: #fed7aa; color: #c2410c; }

/* === Filtres / barres de recherche === */
.filters {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
  align-items: center;
}
.filters input, .filters select {
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 13px;
  background: white;
  font-family: inherit;
}
.filters .grow { flex: 1; min-width: 200px; }

/* === Modal === */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.modal {
  background: white;
  border-radius: 10px;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}
.modal-lg { max-width: 920px; }
.modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-title { font-size: 15px; font-weight: 600; }
.modal-close {
  background: none; border: none; font-size: 22px; color: #6b7280;
  cursor: pointer; line-height: 1;
}
.modal-body { padding: 18px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 12px 18px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* === Toast === */
#toast-root {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: white;
  border-left: 4px solid #0ea5e9;
  border-radius: 6px;
  padding: 10px 16px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  min-width: 260px;
  font-size: 13.5px;
  animation: slideIn 0.2s;
}
.toast.success { border-left-color: #10b981; }
.toast.error   { border-left-color: #ef4444; }
.toast.warning { border-left-color: #f59e0b; }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* === Écran de connexion === */
.login-screen {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, #1e3a5f 0%, #0c1e35 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  z-index: 5000;
}
.login-card {
  background: white;
  border-radius: 12px;
  padding: 32px 30px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 25px 50px rgba(0,0,0,0.3);
}
.login-logo {
  width: 56px; height: 56px;
  background: #0ea5e9;
  color: white;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700;
  margin: 0 auto 16px;
}
.login-logo-img {
  display: block;
  width: 220px;
  height: auto;
  margin: 0 auto 18px;
}
.login-title { text-align: center; margin: 0 0 6px; font-size: 19px; color: #0f172a; }
.login-sub { text-align: center; color: #6b7280; margin: 0 0 22px; font-size: 13px; }
.login-error {
  color: #b91c1c; background: #fee2e2; border-radius: 6px;
  padding: 8px 10px; margin: 0 0 10px; font-size: 12.5px; min-height: 0;
}
.login-error:empty { display: none; }
.login-footer { text-align: center; margin-top: 18px; font-size: 11.5px; color: #94a3b8; }

/* === Aperçu chèque (dans la page de calibration) === */
.cheque-preview {
  position: relative;
  background: #fffef9;
  border: 1px solid #d4d4d4;
  margin: 0 auto;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  /* Dimensions et background définis dynamiquement en mm */
}
.cheque-preview .field {
  position: absolute;
  font-family: Arial, sans-serif;
  white-space: nowrap;
  overflow: visible;
  pointer-events: none;
  color: #1e3a8a;
}

/* Calibration : table des positions */
.pos-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr;
  gap: 10px;
  margin-bottom: 8px;
  align-items: center;
}
.pos-row label { font-size: 12.5px; font-weight: 500; color: #374151; }
.pos-row input { padding: 5px 8px; font-size: 12.5px; }
.pos-row-head {
  font-size: 11px; text-transform: uppercase; color: #64748b;
  font-weight: 600; letter-spacing: 0.5px;
}

/* === Badge navigation (alertes) === */
.nav-badge {
  background: #ef4444; color: white;
  border-radius: 10px; font-size: 10px; font-weight: 700;
  padding: 1px 6px; margin-left: 4px;
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px;
}

/* === Barre de progression (carnets) === */
.progress-bar {
  width: 80px; height: 8px;
  background: #e5e7eb; border-radius: 4px; overflow: hidden;
}
.progress-fill {
  height: 100%; background: #0ea5e9; border-radius: 4px;
  transition: width 0.3s;
}

/* === Cartes d'alertes === */
.alerte-card {
  border-left: 4px solid #fca5a5;
  background: #fef2f2;
  border-radius: 8px;
  padding: 16px 18px;
  margin-bottom: 16px;
}
.alerte-card-title {
  font-size: 15px; font-weight: 700;
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 6px;
}
.alerte-card-desc {
  font-size: 12.5px; color: #6b7280; margin-bottom: 12px;
}

/* === Impression Ordre de Virement / Bordereau === */
.ov-page, .bord-page {
  font-family: 'Segoe UI', Arial, sans-serif;
  padding: 20px 30px;
  max-width: 800px;
  margin: 0 auto;
  font-size: 13px;
  color: #1f2937;
}
.ov-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}
.ov-societe { font-size: 12px; color: #374151; line-height: 1.6; }
.ov-titre-box { text-align: right; }
.ov-titre {
  font-size: 17px; font-weight: 700;
  color: #1e3a5f; text-transform: uppercase;
  letter-spacing: 0.5px; line-height: 1.3;
}
.ov-ref  { font-size: 12px; color: #374151; margin-top: 4px; }
.ov-date { font-size: 12px; color: #374151; }
.ov-table { width: 100%; border-collapse: collapse; margin: 14px 0; }
.ov-table tr { border-bottom: 1px solid #e5e7eb; }
.ov-table td { padding: 8px 4px; font-size: 13px; }
.ov-lbl { font-weight: 600; color: #374151; width: 200px; }
.ov-montant-row td { font-size: 16px; padding: 12px 4px; background: #f9fafb; }
.ov-signatures {
  display: flex; gap: 20px; margin-top: 40px;
}
.ov-sig-box { flex: 1; }
.ov-sig-label { font-size: 11px; font-weight: 600; color: #64748b; margin-bottom: 30px; }
.ov-sig-line { border-bottom: 1px solid #9ca3af; }
.ov-footer {
  text-align: center; font-size: 10px; color: #94a3b8;
  margin-top: 30px; border-top: 1px solid #e5e7eb; padding-top: 8px;
}

/* Bénéficiaires : champs enrichis */
.bene-section-title {
  font-size: 12px; font-weight: 700; color: #374151;
  text-transform: uppercase; letter-spacing: 0.5px;
  margin: 14px 0 8px; grid-column: 1 / -1;
}
