/* ── Variables ──────────────────────────────────────────────────────────── */
:root {
  --primary:       #1A3A5C;
  --primary-light: #2A5A8C;
  --accent:        #C8932A;
  --accent-light:  #F0C96A;
  --success:       #198754;
  --danger:        #DC3545;
  --warning:       #FFC107;
  --bg-light:      #EAF0F7;
  --text-dark:     #212529;
  --text-muted:    #6C757D;
  --white:         #FFFFFF;
  --sidebar-width: 260px;
}

/* ── Reset / Base ───────────────────────────────────────────────────────── */
body {
  font-family: 'Inter', 'Helvetica Neue', Arial, sans-serif;
  background: #F8F9FA;
  color: var(--text-dark);
  margin: 0;
}

/* ── Sidebar ────────────────────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  height: 100dvh;
  background: var(--primary);
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.3s ease;
}

#sidebar .sidebar-brand {
  padding: 24px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
}

/* Zone de navigation défilante (barre de scroll discrète sur fond marine) */
#sidebar .overflow-auto {
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.25) transparent;
}
#sidebar .overflow-auto::-webkit-scrollbar {
  width: 6px;
}
#sidebar .overflow-auto::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.2);
  border-radius: 3px;
}
#sidebar .overflow-auto::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.35);
}

#sidebar .sidebar-brand .brand-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--white);
  margin: 0;
  line-height: 1.2;
}

#sidebar .sidebar-brand .brand-sub {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.6);
  margin: 2px 0 0;
}

#sidebar .sidebar-brand .brand-ville {
  font-size: 0.7rem;
  color: var(--accent-light);
}

#sidebar .nav-section {
  padding: 12px 0 4px;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.4);
  padding-left: 20px;
  margin-top: 8px;
}

#sidebar .nav-link {
  color: rgba(255,255,255,0.8);
  padding: 9px 20px;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  border-radius: 0;
  transition: all 0.2s;
  border-left: 3px solid transparent;
}

#sidebar .nav-link:hover,
#sidebar .nav-link.active {
  color: var(--white);
  background: rgba(255,255,255,0.08);
  border-left-color: var(--accent);
}

#sidebar .nav-link i {
  width: 18px;
  text-align: center;
  font-size: 1rem;
  color: var(--accent-light);
}

#sidebar .nav-link.active i {
  color: var(--accent);
}

/* ── Topbar ─────────────────────────────────────────────────────────────── */
#topbar {
  height: 60px;
  background: var(--white);
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
}

#topbar .page-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--primary);
  flex: 1;
}

/* ── Contenu principal ───────────────────────────────────────────────────── */
#main-content {
  margin-left: var(--sidebar-width);
  padding-top: 60px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.content-wrapper {
  padding: 24px;
  flex: 1 0 auto;
}

/* ── Footer ──────────────────────────────────────────────────────────────── */
.app-footer {
  flex-shrink: 0;
  margin-top: auto;
  padding: 14px 24px;
  border-top: 1px solid #e3e8ef;
  background: var(--white);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 10px;
  font-size: 0.8rem;
  color: #64748b;
}
.app-footer strong { color: var(--primary); }
.app-footer .footer-sep { color: #cbd5e1; }
.app-footer .footer-phone {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}
.app-footer .footer-phone:hover { text-decoration: underline; }

/* ── Cards KPI ──────────────────────────────────────────────────────────── */
.kpi-card {
  background: var(--white);
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: box-shadow 0.2s;
}

.kpi-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

.kpi-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.kpi-icon.primary  { background: rgba(26,58,92,0.1);  color: var(--primary); }
.kpi-icon.accent   { background: rgba(200,147,42,0.1); color: var(--accent);  }
.kpi-icon.success  { background: rgba(25,135,84,0.1);  color: var(--success); }
.kpi-icon.danger   { background: rgba(220,53,69,0.1);  color: var(--danger);  }
.kpi-icon.warning  { background: rgba(255,193,7,0.15); color: #856404; }

.kpi-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.kpi-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
}

.kpi-value.accent  { color: var(--accent); }
.kpi-value.danger  { color: var(--danger); }
.kpi-value.success { color: var(--success); }

/* ── Card générique ─────────────────────────────────────────────────────── */
.card {
  border: none;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}

.card-header {
  background: var(--white);
  border-bottom: 1px solid rgba(0,0,0,0.07);
  font-weight: 600;
  color: var(--primary);
  border-radius: 12px 12px 0 0 !important;
  padding: 14px 20px;
}

/* ── Tables ─────────────────────────────────────────────────────────────── */
.table thead th {
  background: var(--bg-light);
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 2px solid rgba(26,58,92,0.15);
  vertical-align: middle;
}

.table td { vertical-align: middle; font-size: 0.9rem; }

/* ── Boutons ─────────────────────────────────────────────────────────────── */
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-light); border-color: var(--primary-light); }

.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--white);
}
.btn-accent:hover { background: #a87820; border-color: #a87820; color: var(--white); }

/* ── Flash messages ─────────────────────────────────────────────────────── */
.alert { border-radius: 8px; font-size: 0.9rem; }

/* ── Login page ─────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
}

.login-card {
  background: var(--white);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  margin: auto;
}

.login-logo {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.8rem;
  color: var(--primary);
  font-weight: 700;
}

.login-footer {
  flex-shrink: 0;
  width: 100%;
  padding: 12px 8px 0;
  text-align: center;
  font-size: 0.8rem;
  color: rgba(255,255,255,0.75);
}
.login-footer strong { color: var(--white); }
.login-footer .login-footer-phone {
  color: var(--accent-light);
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
  margin-left: 4px;
}
.login-footer .login-footer-phone:hover { text-decoration: underline; }

/* ── Badges ─────────────────────────────────────────────────────────────── */
.badge { font-size: 0.75rem; font-weight: 500; border-radius: 6px; padding: 4px 8px; }

/* ── Formulaires ─────────────────────────────────────────────────────────── */
.form-control:focus, .form-select:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 0.2rem rgba(42,90,140,0.2);
}

.form-label { font-size: 0.85rem; font-weight: 500; color: var(--primary); }

/* ── Montant FCFA dans les inputs ───────────────────────────────────────── */
.input-group-text { background: var(--bg-light); color: var(--primary); font-size: 0.85rem; }

/* ── Ligne de vente (tableau dynamique) ─────────────────────────────────── */
.ligne-article { background: #f8f9fa; border-radius: 8px; padding: 12px; margin-bottom: 8px; }

/* ── Modale de confirmation ─────────────────────────────────────────────── */
.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0);
  transition: background 0.2s ease;
}
.confirm-overlay.show { background: rgba(15, 23, 42, 0.55); }
.confirm-box {
  background: var(--white);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  width: 100%;
  max-width: 400px;
  padding: 28px 24px 22px;
  text-align: center;
  transform: scale(0.92) translateY(10px);
  opacity: 0;
  transition: transform 0.22s cubic-bezier(0.2,0.8,0.2,1), opacity 0.22s;
}
.confirm-overlay.show .confirm-box { transform: scale(1) translateY(0); opacity: 1; }
.confirm-icon {
  width: 56px; height: 56px;
  margin: 0 auto 14px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(217,119,6,0.12);
  color: #d97706;
  font-size: 1.7rem;
}
.confirm-title { color: var(--primary); font-weight: 700; margin: 0 0 8px; font-size: 1.1rem; }
.confirm-text  { color: #334155; font-size: 0.92rem; margin: 0 0 4px; }
.confirm-sub   { color: #94a3b8; font-size: 0.82rem; margin: 0 0 4px; }
.confirm-actions {
  display: flex; gap: 10px; justify-content: center; margin-top: 20px;
}
.confirm-actions .btn { min-width: 120px; padding: 8px 16px; }

/* ── Toasts (messages flash / notifications push) ───────────────────────── */
.toast-stack {
  position: fixed;
  top: 74px;
  right: 20px;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: calc(100% - 40px);
  max-width: 360px;
  pointer-events: none;
}
.app-toast {
  pointer-events: auto;
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--white);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.18);
  padding: 14px 14px 16px 16px;
  border-left: 4px solid var(--primary);
  overflow: hidden;
  animation: toastIn 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.app-toast.hiding { animation: toastOut 0.3s forwards; }
@keyframes toastIn  { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { to   { opacity: 0; transform: translateX(40px); } }

.app-toast-icon { font-size: 1.3rem; line-height: 1.3; flex-shrink: 0; }
.app-toast-body { flex: 1; font-size: 0.875rem; color: #1e293b; line-height: 1.45; padding-top: 1px; }
.app-toast-close {
  background: none; border: none; font-size: 1.3rem; line-height: 1;
  color: #94a3b8; cursor: pointer; padding: 0 2px; flex-shrink: 0;
}
.app-toast-close:hover { color: #475569; }
.app-toast-progress {
  position: absolute; bottom: 0; left: 0; height: 3px; width: 100%;
  background: currentColor; opacity: 0.45; transform-origin: left;
  animation: toastProgress 5s linear forwards;
}
@keyframes toastProgress { from { transform: scaleX(1); } to { transform: scaleX(0); } }

.app-toast-success { border-left-color: var(--success); }
.app-toast-success .app-toast-icon, .app-toast-success .app-toast-progress { color: var(--success); }
.app-toast-danger  { border-left-color: var(--danger); }
.app-toast-danger .app-toast-icon,  .app-toast-danger .app-toast-progress  { color: var(--danger); }
.app-toast-warning { border-left-color: #d97706; }
.app-toast-warning .app-toast-icon, .app-toast-warning .app-toast-progress { color: #d97706; }
.app-toast-info    { border-left-color: var(--primary); }
.app-toast-info .app-toast-icon,    .app-toast-info .app-toast-progress    { color: var(--primary); }

@media (max-width: 768px) {
  .toast-stack { top: auto; bottom: 16px; right: 16px; left: 16px; width: auto; max-width: none; }
  .app-toast { animation: toastInUp 0.35s cubic-bezier(0.2, 0.8, 0.2, 1); }
  @keyframes toastInUp { from { opacity: 0; transform: translateY(40px); } to { opacity: 1; transform: translateY(0); } }
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  #sidebar { transform: translateX(-100%); }
  #sidebar.show { transform: translateX(0); }
  #topbar, #main-content { left: 0; margin-left: 0; }
}

/* ── Filigrane (watermark) ───────────────────────────────────────────────── */
.document-wrapper {
  position: relative;
}
.document-wrapper::before {
  content: attr(data-watermark);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-35deg);
  font-size: 7rem;
  font-weight: 900;
  font-family: 'Playfair Display', serif;
  letter-spacing: 0.05em;
  opacity: 0.055;
  pointer-events: none;
  white-space: nowrap;
  z-index: 0;
  color: #000;
}
.document-wrapper.wm-proforma::before  { color: #C8932A; opacity: 0.09; }
.document-wrapper.wm-brouillon::before { color: #6C757D; opacity: 0.09; }
.document-wrapper.wm-annule::before    { color: #DC3545; opacity: 0.09; }
.document-wrapper.wm-original::before  { color: #198754; opacity: 0.07; }
.document-wrapper.wm-commande::before  { color: #0D6EFD; opacity: 0.07; }

/* ── Impression ──────────────────────────────────────────────────────────── */
.print-only { display: none !important; }

@media print {
  /* Masquer l'interface */
  #sidebar, #topbar, .no-print, .btn, .alert,
  .d-flex.gap-2.mb-3, nav.pagination, form[method="POST"] { display: none !important; }

  /* Afficher éléments print */
  .print-only { display: block !important; }

  /* Réinitialiser la mise en page */
  body { background: #fff !important; margin: 0; padding: 0; }
  #main-content { margin-left: 0 !important; padding: 0 !important; }
  .container-fluid { padding: 0 !important; }

  /* Filigrane plus visible à l'impression */
  .document-wrapper::before { opacity: 0.12 !important; }

  /* Mise en page document */
  .print-document {
    width: 210mm;
    min-height: 297mm;
    padding: 15mm 20mm;
    margin: 0 auto;
    box-shadow: none !important;
    border: none !important;
    page-break-after: always;
  }

  .print-footer {
    position: fixed;
    bottom: 10mm;
    left: 20mm;
    right: 20mm;
    border-top: 1px solid #ccc;
    padding-top: 4mm;
    font-size: 8pt;
    color: #666;
  }

  @page { size: A4; margin: 10mm; }
}

