/* ═══════════════════════════════════════════════════════════════════════════
   styles.css — Design System complet — Service Achats TPE/PME
   Stack : CSS custom, DM Sans, design bleu marine + or
   ═══════════════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=DM+Serif+Display&display=swap');

/* ── Variables ─────────────────────────────────────────────────────────────── */
:root {
  --navy:        #1C2333;
  --navy-dark:   #131929;
  --navy-mid:    #2a3349;
  --navy-light:  #3D4554;
  --gold:        #D4A843;
  --gold-light:  #e8c06a;
  --gold-dim:    rgba(212,168,67,0.15);
  --white:       #FFFFFF;
  --bg:          #F4F5F7;
  --bg-card:     #FFFFFF;
  --border:      #E2E4E9;
  --border-dark: #c8cbd3;
  --text:        #1a1a2e;
  --text-mid:    #4a4e6a;
  --text-light:  #8890a8;
  --green:       #16a34a;
  --green-bg:    #dcfce7;
  --red:         #dc2626;
  --red-bg:      #fee2e2;
  --orange:      #ea580c;
  --orange-bg:   #ffedd5;
  --blue:        #2563eb;
  --blue-bg:     #dbeafe;

  --sidebar-w:   240px;
  --topbar-h:    60px;
  --radius:      10px;
  --radius-sm:   6px;
  --radius-pill: 100px;
  --shadow:      0 2px 8px rgba(0,0,0,0.08);
  --shadow-md:   0 4px 16px rgba(0,0,0,0.12);
  --shadow-lg:   0 8px 32px rgba(0,0,0,0.16);

  --font: 'DM Sans', sans-serif;
  --font-serif: 'DM Serif Display', serif;

  --transition: 0.18s ease;
}

/* ── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button { font-family: var(--font); cursor: pointer; border: none; outline: none; }
input, textarea, select { font-family: var(--font); outline: none; }
ul, ol { list-style: none; }
img { display: block; max-width: 100%; }

/* ── Scrollbar ───────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-dark); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-light); }

/* ═══════════════════════════════════════════════════════════════════
   LAYOUT PRINCIPAL
   ═══════════════════════════════════════════════════════════════════ */

.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--navy);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logo .logo-name {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  color: var(--gold);
  letter-spacing: 0.02em;
  display: block;
}

.sidebar-logo .logo-sub {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.4);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 0;
  overflow-y: auto;
}

/* Label de section — NE PAS ajouter .nav-item ici */
.sidebar-section-label {
  padding: 12px 20px 4px;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.28);
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,0.65);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 0;
  transition: background var(--transition), color var(--transition);
  border-left: 3px solid transparent;
  position: relative;
}

.nav-item:hover {
  background: rgba(255,255,255,0.06);
  color: var(--white);
}

.nav-item.active {
  background: rgba(212,168,67,0.12);
  color: var(--gold);
  border-left-color: var(--gold);
}

.nav-item svg, .nav-item .nav-icon {
  width: 18px; height: 18px;
  flex-shrink: 0;
  opacity: 0.8;
}

.nav-item.active svg, .nav-item.active .nav-icon { opacity: 1; }

.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
}

.sidebar-user:hover { background: rgba(255,255,255,0.06); }

.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--gold-dim);
  border: 1.5px solid var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--gold);
  flex-shrink: 0;
}

.user-info { overflow: hidden; }

.user-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 0.68rem;
  color: rgba(255,255,255,0.4);
  text-transform: capitalize;
}

/* ── Topbar ───────────────────────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 32px;
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  z-index: 90;
  gap: 16px;
}

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

.topbar-date {
  font-size: 0.8rem;
  color: var(--text-light);
}

/* ── Zone de contenu ─────────────────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  margin-top: var(--topbar-h);
  flex: 1;
  min-height: calc(100vh - var(--topbar-h));
}

.page-section {
  display: none;
  padding: 32px 40px;
  animation: fadeIn 0.2s ease;
}

.page-section.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Page header ─────────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-header-left h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}

.page-header-left p {
  font-size: 0.875rem;
  color: var(--text-mid);
  margin-top: 4px;
}

/* ═══════════════════════════════════════════════════════════════════
   COMPOSANTS — CARTES
   ═══════════════════════════════════════════════════════════════════ */

.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.card-body { padding: 20px; }

/* Stat cards */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition), transform var(--transition);
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.stat-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-light);
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.stat-sub {
  font-size: 0.78rem;
  color: var(--text-mid);
}

.stat-card.alert { border-color: var(--red); }
.stat-card.alert .stat-value { color: var(--red); }
.stat-card.success { border-color: var(--green); }
.stat-card.success .stat-value { color: var(--green); }

/* ═══════════════════════════════════════════════════════════════════
   COMPOSANTS — BOUTONS
   ═══════════════════════════════════════════════════════════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  transition: all var(--transition);
  white-space: nowrap;
  cursor: pointer;
}

.btn-primary {
  background: var(--navy);
  color: var(--white);
  border: 1.5px solid var(--navy);
}
.btn-primary:hover { background: var(--navy-mid); border-color: var(--navy-mid); }

.btn-gold {
  background: var(--gold);
  color: var(--navy);
  border: 1.5px solid var(--gold);
}
.btn-gold:hover { background: var(--gold-light); border-color: var(--gold-light); }

.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1.5px solid var(--border-dark);
}
.btn-outline:hover { background: var(--bg); border-color: var(--navy); color: var(--navy); }

.btn-danger {
  background: var(--red-bg);
  color: var(--red);
  border: 1.5px solid var(--red);
}
.btn-danger:hover { background: var(--red); color: white; }

.btn-success {
  background: var(--green-bg);
  color: var(--green);
  border: 1.5px solid var(--green);
}
.btn-success:hover { background: var(--green); color: white; }

.btn-sm {
  padding: 5px 12px;
  font-size: 0.8rem;
}

.btn-icon {
  padding: 7px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-mid);
  border: 1px solid var(--border);
  transition: all var(--transition);
}
.btn-icon:hover { background: var(--bg); color: var(--text); }

.btn[disabled], .btn:disabled {
  opacity: 0.45;
  pointer-events: none;
}

/* ═══════════════════════════════════════════════════════════════════
   COMPOSANTS — FORMULAIRES
   ═══════════════════════════════════════════════════════════════════ */

.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-mid);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  color: var(--text);
  background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus {
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(28,35,51,0.08);
}

.form-control::placeholder { color: var(--text-light); }

textarea.form-control {
  resize: vertical;
  min-height: 80px;
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238890a8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-light);
  margin-top: 4px;
}

.form-error {
  font-size: 0.75rem;
  color: var(--red);
  margin-top: 4px;
  display: none;
}

.form-error.visible { display: block; }

/* ── Inline edit (cellules tableau) ─────────────────────────────────────────── */
.inline-edit {
  padding: 4px 6px;
  border: 1.5px solid transparent;
  border-radius: 4px;
  background: transparent;
  font-size: 0.875rem;
  color: var(--text);
  width: 100%;
  transition: all var(--transition);
}

.inline-edit:hover {
  border-color: var(--border);
  background: var(--bg);
}

.inline-edit:focus {
  border-color: var(--gold);
  background: white;
  box-shadow: 0 0 0 2px var(--gold-dim);
  outline: none;
}

.inline-edit.saving { border-color: var(--gold); }
.inline-edit.saved  { border-color: var(--green); background: var(--green-bg); }
.inline-edit.error  { border-color: var(--red);   background: var(--red-bg); }

/* ═══════════════════════════════════════════════════════════════════
   COMPOSANTS — TABLEAUX
   ═══════════════════════════════════════════════════════════════════ */

.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
}

.table-wrapper::-webkit-scrollbar { height: 4px; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead th {
  background: var(--navy);
  color: rgba(255,255,255,0.8);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 10px 14px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 2px solid var(--navy-mid);
}

thead th:first-child { border-radius: var(--radius) 0 0 0; }
thead th:last-child  { border-radius: 0 var(--radius) 0 0; }

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg); }

tbody td {
  padding: 10px 14px;
  color: var(--text);
  vertical-align: middle;
}

tfoot td {
  padding: 10px 14px;
  border-top: 2px solid var(--border);
  font-weight: 600;
  background: var(--bg);
  font-size: 0.85rem;
}

/* Ligne vide */
.table-empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-light);
  font-size: 0.9rem;
}

.table-empty .empty-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  opacity: 0.4;
  display: block;
}

/* ═══════════════════════════════════════════════════════════════════
   COMPOSANTS — PILLS / FILTRES
   ═══════════════════════════════════════════════════════════════════ */

.pills-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 14px;
  border-radius: var(--radius-pill);
  font-size: 0.8rem;
  font-weight: 500;
  border: 1.5px solid var(--border);
  background: var(--white);
  color: var(--text-mid);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.pill:hover {
  border-color: var(--navy);
  color: var(--navy);
}

.pill.active {
  background: var(--navy);
  color: var(--white);
  border-color: var(--navy);
}

.pill-count {
  background: rgba(255,255,255,0.2);
  border-radius: var(--radius-pill);
  padding: 1px 6px;
  font-size: 0.7rem;
}

.pill.active .pill-count { background: rgba(255,255,255,0.2); }
.pill:not(.active) .pill-count { background: var(--bg); color: var(--text-light); }

/* ═══════════════════════════════════════════════════════════════════
   COMPOSANTS — BADGES / STATUTS
   ═══════════════════════════════════════════════════════════════════ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.badge-green   { background: var(--green-bg);  color: var(--green); }
.badge-red     { background: var(--red-bg);    color: var(--red); }
.badge-orange  { background: var(--orange-bg); color: var(--orange); }
.badge-blue    { background: var(--blue-bg);   color: var(--blue); }
.badge-gray    { background: var(--bg);        color: var(--text-mid); border: 1px solid var(--border); }
.badge-gold    { background: var(--gold-dim);  color: var(--gold); }
.badge-navy    { background: var(--navy);      color: var(--white); }

/* Point indicateur colorblind-friendly : icône + couleur */
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════════
   COMPOSANTS — BARRE DE RECHERCHE
   ═══════════════════════════════════════════════════════════════════ */

.search-bar {
  position: relative;
  flex: 1;
  max-width: 400px;
}

.search-bar input {
  width: 100%;
  padding: 9px 12px 9px 38px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  background: var(--white);
  transition: border-color var(--transition);
}

.search-bar input:focus {
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(28,35,51,0.06);
}

.search-bar .search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--text-light);
  pointer-events: none;
}

/* ═══════════════════════════════════════════════════════════════════
   COMPOSANTS — TOASTS
   ═══════════════════════════════════════════════════════════════════ */

#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: var(--radius);
  background: var(--navy-dark);
  color: var(--white);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  min-width: 260px;
  max-width: 360px;
  animation: toastIn 0.25s ease;
  pointer-events: all;
  border-left: 4px solid var(--text-light);
}

.toast.success { border-left-color: var(--green); }
.toast.error   { border-left-color: var(--red); }
.toast.warning { border-left-color: var(--gold); }
.toast.info    { border-left-color: var(--blue); }

.toast-icon { font-size: 1rem; flex-shrink: 0; }
.toast-msg  { flex: 1; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); max-height: 80px; margin-bottom: 0; }
  to   { opacity: 0; transform: translateX(20px); max-height: 0; margin-bottom: -10px; }
}

.toast.removing {
  animation: toastOut 0.25s ease forwards;
}

/* ═══════════════════════════════════════════════════════════════════
   COMPOSANTS — MODALES / POPUPS
   ═══════════════════════════════════════════════════════════════════ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13,17,28,0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.22s ease;
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95) translateY(8px);
  transition: transform 0.22s ease;
}

.modal-overlay.open .modal { transform: scale(1) translateY(0); }

.modal-lg { max-width: 800px; }
.modal-sm { max-width: 400px; }

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 1;
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

.modal-close {
  width: 30px; height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-light);
  font-size: 1.1rem;
  transition: all var(--transition);
}

.modal-close:hover { background: var(--bg); color: var(--text); }

.modal-body { padding: 20px 24px; }

.modal-footer {
  padding: 16px 24px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Popup PA/PV — critique */
.popup-pa-pv {
  border: 2px solid var(--gold);
}

.popup-pa-pv .modal-header {
  background: var(--gold-dim);
  border-bottom-color: var(--gold);
}

.popup-pa-pv .modal-title {
  color: var(--navy);
  display: flex;
  align-items: center;
  gap: 8px;
}

.popup-pa-pv .choice-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}

.popup-pa-pv .choice-btn {
  padding: 16px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
}

.popup-pa-pv .choice-btn:hover {
  border-color: var(--navy);
  background: var(--white);
}

.popup-pa-pv .choice-btn.selected {
  border-color: var(--gold);
  background: var(--gold-dim);
}

.popup-pa-pv .choice-btn strong {
  display: block;
  font-size: 0.95rem;
  color: var(--text);
  margin-bottom: 4px;
}

.popup-pa-pv .choice-btn span {
  font-size: 0.78rem;
  color: var(--text-mid);
}

/* ═══════════════════════════════════════════════════════════════════
   COMPOSANTS — LOADER / SKELETON
   ═══════════════════════════════════════════════════════════════════ */

.loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 48px;
  color: var(--text-light);
  font-size: 0.875rem;
}

.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--navy);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.spinner-gold { border-top-color: var(--gold); }
.spinner-sm { width: 18px; height: 18px; border-width: 2px; }

@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  background: linear-gradient(90deg, var(--bg) 25%, var(--border) 50%, var(--bg) 75%);
  background-size: 200% 100%;
  border-radius: 4px;
  animation: shimmer 1.4s infinite;
}

@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* ═══════════════════════════════════════════════════════════════════
   COMPOSANTS — ALERTES INLINE
   ═══════════════════════════════════════════════════════════════════ */

.alert-inline {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  margin-bottom: 16px;
}

.alert-inline.warning {
  background: var(--orange-bg);
  color: var(--orange);
  border: 1px solid var(--orange);
}

.alert-inline.error {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid var(--red);
}

.alert-inline.success {
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid var(--green);
}

.alert-inline.info {
  background: var(--blue-bg);
  color: var(--blue);
  border: 1px solid var(--blue);
}

/* ═══════════════════════════════════════════════════════════════════
   PAGE LOGIN
   ═══════════════════════════════════════════════════════════════════ */

.login-page {
  min-height: 100vh;
  display: flex;
  background: var(--navy-dark);
}

.login-brand {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 60px;
  background: var(--navy);
  border-right: 1px solid rgba(255,255,255,0.06);
}

.login-brand-logo {
  font-family: var(--font-serif);
  font-size: 2.2rem;
  color: var(--gold);
  margin-bottom: 12px;
}

.login-brand-tagline {
  font-size: 1rem;
  color: rgba(255,255,255,0.55);
  line-height: 1.6;
  max-width: 360px;
  margin-bottom: 40px;
}

.login-brand-features {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-feature {
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgba(255,255,255,0.65);
  font-size: 0.875rem;
}

.login-feature-icon {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  background: var(--gold-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
  flex-shrink: 0;
  font-size: 1rem;
}

.login-form-wrapper {
  width: 440px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.login-form-box {
  width: 100%;
}

.login-form-box h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--white);
  margin-bottom: 6px;
}

.login-form-box p {
  font-size: 0.875rem;
  color: rgba(255,255,255,0.45);
  margin-bottom: 32px;
}

.login-form-box .form-label {
  color: rgba(255,255,255,0.55);
}

.login-form-box .form-control {
  background: rgba(255,255,255,0.07);
  border-color: rgba(255,255,255,0.12);
  color: var(--white);
}

.login-form-box .form-control:focus {
  border-color: var(--gold);
  background: rgba(255,255,255,0.1);
  box-shadow: 0 0 0 3px rgba(212,168,67,0.15);
}

.login-form-box .form-control::placeholder { color: rgba(255,255,255,0.25); }

.login-btn {
  width: 100%;
  padding: 12px;
  background: var(--gold);
  color: var(--navy);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  margin-top: 8px;
}

.login-btn:hover { background: var(--gold-light); }

.login-links {
  display: flex;
  justify-content: space-between;
  margin-top: 16px;
  font-size: 0.8rem;
}

.login-link {
  color: rgba(255,255,255,0.4);
  cursor: pointer;
  transition: color var(--transition);
}

.login-link:hover { color: var(--gold); }

.login-error {
  background: rgba(220,38,38,0.12);
  border: 1px solid var(--red);
  color: #fca5a5;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 16px;
  display: none;
}

.login-error.visible { display: block; }

/* ═══════════════════════════════════════════════════════════════════
   COMPOSANTS — DRAG & DROP UPLOAD
   ═══════════════════════════════════════════════════════════════════ */

.dropzone {
  border: 2px dashed var(--border-dark);
  border-radius: var(--radius);
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--bg);
  color: var(--text-mid);
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--gold);
  background: var(--gold-dim);
  color: var(--navy);
}

.dropzone .drop-icon {
  font-size: 2rem;
  margin-bottom: 8px;
  opacity: 0.5;
}

.dropzone p { font-size: 0.875rem; }
.dropzone strong { color: var(--gold); }

/* ═══════════════════════════════════════════════════════════════════
   COMPOSANTS — TABLEAU EXTRACTION IA
   ═══════════════════════════════════════════════════════════════════ */

.ia-result-table thead th {
  background: var(--navy-mid);
}

.ia-confidence {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
}

.ia-confidence-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
}

.ia-confidence.high .ia-confidence-dot   { background: var(--green); }
.ia-confidence.medium .ia-confidence-dot { background: var(--orange); }
.ia-confidence.low .ia-confidence-dot    { background: var(--red); }

/* ═══════════════════════════════════════════════════════════════════
   COMPOSANTS — WORKFLOW STEPS
   ═══════════════════════════════════════════════════════════════════ */

.workflow-steps {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 24px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.workflow-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.step-circle {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-light);
  transition: all var(--transition);
  position: relative;
  z-index: 1;
}

.step-line {
  width: 48px;
  height: 2px;
  background: var(--border);
  flex-shrink: 0;
  margin-top: -22px;
}

.workflow-step.done .step-circle {
  background: var(--green);
  border-color: var(--green);
  color: white;
}

.workflow-step.active .step-circle {
  background: var(--navy);
  border-color: var(--navy);
  color: white;
}

.workflow-step.done + .workflow-step .step-line { background: var(--green); }
.workflow-step.active + .workflow-step .step-line { background: var(--navy); }

.step-label {
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--text-light);
  text-align: center;
  max-width: 72px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.workflow-step.active .step-label { color: var(--navy); font-weight: 700; }
.workflow-step.done  .step-label  { color: var(--green); }

/* ═══════════════════════════════════════════════════════════════════
   RESPONSIVE — TABLETTE
   ═══════════════════════════════════════════════════════════════════ */

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open { transform: translateX(0); }

  .main-content {
    margin-left: 0;
  }

  .topbar {
    left: 0;
  }

  .topbar-menu-btn {
    display: flex;
  }

  .page-section {
    padding: 20px 16px;
  }

  .login-brand { display: none; }
  .login-form-wrapper { width: 100%; }

  .stat-cards {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .stat-cards {
    grid-template-columns: 1fr;
  }

  .page-header {
    flex-direction: column;
  }

  .form-row {
    grid-template-columns: 1fr;
  }
}

/* ── Bouton menu mobile ───────────────────────────────────────────────────────── */
.topbar-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  margin-right: 8px;
}

/* ── Overlay mobile sidebar ───────────────────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 99;
}

.sidebar-overlay.open { display: block; }

/* ═══════════════════════════════════════════════════════════════════
   UTILITAIRES
   ═══════════════════════════════════════════════════════════════════ */

.hidden   { display: none !important; }
.flex     { display: flex; }
.gap-8    { gap: 8px; }
.gap-12   { gap: 12px; }
.gap-16   { gap: 16px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1   { flex: 1; }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.text-sm  { font-size: 0.8rem; }
.text-xs  { font-size: 0.72rem; }
.text-mid { color: var(--text-mid); }
.text-light { color: var(--text-light); }
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.text-gold   { color: var(--gold); }
.font-bold { font-weight: 700; }
.font-semi { font-weight: 600; }
.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.w-full { width: 100%; }
.divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

/* ═══════════════════════════════════════════════════════════════════
   EXTENSION PHASE 6 — Utilitaires manquants + micro-composants
   ═══════════════════════════════════════════════════════════════════ */

/* ── Spacing utilitaires ──────────────────────────────────────────── */
.mb-8  { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-24 { margin-bottom: 24px; }
.mt-4  { margin-top: 4px; }
.mt-12 { margin-top: 12px; }
.pt-8  { padding-top: 8px; }
.pb-8  { padding-bottom: 8px; }
.gap-4  { gap: 4px; }
.gap-24 { gap: 24px; }

/* ── Texte utilitaires ────────────────────────────────────────────── */
.text-red   { color: var(--red)   !important; }
.text-green { color: var(--green) !important; }
.text-gold  { color: var(--gold)  !important; }
.text-navy  { color: var(--navy)  !important; }

/* ── Sidebar overlay mobile ───────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 99;
}
.sidebar-overlay.open { display: block; }

/* ── Sidebar open mobile ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 100;
  }
  .sidebar.open { transform: translateX(0); }
}

/* ── Topbar menu btn (déjà présent mais assuré) ────────────────────── */
.topbar-menu-btn {
  display: none;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text);
  padding: 6px;
  border-radius: var(--radius-sm);
}
@media (max-width: 768px) {
  .topbar-menu-btn { display: flex; align-items: center; }
}

/* ── Login page compléments ───────────────────────────────────────── */
.login-error {
  display: none;
  background: rgba(220,38,38,.1);
  border: 1px solid var(--red);
  border-radius: var(--radius-sm);
  color: #fca5a5;
  font-size: .82rem;
  padding: 10px 14px;
  margin-bottom: 14px;
}
.login-error.visible { display: block; }

.login-links {
  display: flex;
  justify-content: space-between;
  margin-top: 16px;
}
.login-link {
  font-size: .8rem;
  color: var(--text-mid);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.login-link:hover { color: var(--text); }

.login-brand-features {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 32px;
}
.login-feature {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  font-size: .9rem;
  opacity: .85;
}
.login-feature-icon {
  font-size: 1.2rem;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 1px;
}

/* ── Stats inline dans la fiche fournisseur ───────────────────────── */
.fiche-stat-row {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: .875rem;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.fiche-stat-row:last-child { border-bottom: none; }

/* ── Workflow steps ───────────────────────────────────────────────── */
.workflow-steps {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 24px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.workflow-step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-light);
  background: var(--bg);
  border: 1px solid var(--border);
  border-right: none;
  white-space: nowrap;
  cursor: default;
}
.workflow-step:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.workflow-step:last-child  { border-right: 1px solid var(--border); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.workflow-step.active  { background: var(--navy); color: #fff; border-color: var(--navy); }
.workflow-step.done    { background: rgba(22,163,74,.1); color: var(--green); border-color: rgba(22,163,74,.2); }
.workflow-step-num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: currentColor;
  color: var(--navy);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .7rem;
  font-weight: 700;
  flex-shrink: 0;
}
.workflow-step.active .workflow-step-num { background: #fff; }

/* ── Modale inline mini (confirmation urgente) ────────────────────── */
.modal.modal-xs { max-width: 320px; }

/* ── Table IA résultat (déjà partiellement présent) ──────────────── */
.ia-result-table { width: 100%; }
.ia-result-table .inline-edit {
  padding: 4px 6px;
  font-size: .82rem;
}

/* ── Badge urgence ────────────────────────────────────────────────── */
.badge-urgent {
  background: rgba(220,38,38,.12);
  color: var(--red);
  border: 1px solid rgba(220,38,38,.25);
  font-size: .65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 20px;
  letter-spacing: .04em;
  text-transform: uppercase;
  vertical-align: middle;
}

/* ── Pill all/filter actif ────────────────────────────────────────── */
.pills-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

/* ── Page section (transitions) ──────────────────────────────────── */
.page-section {
  display: none;
  animation: fadeIn .15s ease;
}
.page-section.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Alert inline compléments ─────────────────────────────────────── */
.alert-inline {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: .82rem;
  border: 1px solid transparent;
  flex-wrap: wrap;
}
.alert-inline.info {
  background: rgba(59,130,246,.08);
  border-color: rgba(59,130,246,.2);
  color: #93c5fd;
}
.alert-inline.warning {
  background: rgba(245,158,11,.08);
  border-color: rgba(245,158,11,.2);
  color: #fcd34d;
}
.alert-inline.success {
  background: rgba(22,163,74,.08);
  border-color: rgba(22,163,74,.2);
  color: #86efac;
}
.alert-inline.error {
  background: rgba(220,38,38,.08);
  border-color: rgba(220,38,38,.2);
  color: #fca5a5;
}

/* ── Toast compléments ────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 500;
  min-width: 240px;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toastIn .2s ease;
}
.toast.removing { animation: toastOut .25s ease forwards; }
.toast.success { border-left: 4px solid var(--green); }
.toast.error   { border-left: 4px solid var(--red); }
.toast.warning { border-left: 4px solid var(--gold); }
.toast.info    { border-left: 4px solid #3b82f6; }
.toast-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  flex-shrink: 0;
}
.toast.success .toast-icon { background: rgba(22,163,74,.15);  color: var(--green); }
.toast.error   .toast-icon { background: rgba(220,38,38,.15);  color: var(--red); }
.toast.warning .toast-icon { background: rgba(212,168,67,.15); color: var(--gold); }
.toast.info    .toast-icon { background: rgba(59,130,246,.15); color: #60a5fa; }
.toast-msg { flex: 1; }
@keyframes toastIn  { from { opacity: 0; transform: translateX(20px); } to { opacity:1; transform:translateX(0); } }
@keyframes toastOut { to   { opacity: 0; transform: translateX(20px); } }

/* ── Spinner sm ───────────────────────────────────────────────────── */
.spinner-sm {
  width: 14px !important;
  height: 14px !important;
  border-width: 2px !important;
}

/* ── Btn icon (actions tableau) ───────────────────────────────────── */
.btn-icon {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  color: var(--text-mid);
  font-size: .95rem;
  line-height: 1;
  transition: background .15s;
}
.btn-icon:hover {
  background: var(--bg);
  color: var(--text);
}

/* ── Table actions col ────────────────────────────────────────────── */
thead th:last-child,
tbody td:last-child {
  text-align: center;
}

/* ── Modal overlay blur ───────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(2px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}
.modal-overlay.open {
  display: flex;
}

/* ── Sidebar section label (jamais cliquable) ─────────────────────── */
.sidebar-section-label {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: rgba(255,255,255,.35);
  padding: 16px 16px 6px;
  pointer-events: none;
  user-select: none;
}

/* ── Sidebar footer ───────────────────────────────────────────────── */
.sidebar-footer {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .15s;
}
.sidebar-user:hover { background: rgba(255,255,255,.06); }
.user-info { flex: 1; min-width: 0; }
.user-name {
  font-size: .82rem;
  font-weight: 600;
  color: rgba(255,255,255,.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role {
  font-size: .7rem;
  color: rgba(255,255,255,.4);
  margin-top: 1px;
}
.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--navy);
  font-size: .75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ── Responsive : masquer sidebar ────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar         { position: fixed; top: 0; left: 0; height: 100vh; }
  .main-content    { margin-left: 0 !important; }
  .topbar-date     { display: none; }
  .stat-cards      { grid-template-columns: 1fr 1fr; }
}


/* ═══════════════════════════════════════════════════════════════════
   COMPARAISON FOURNISSEURS — Phase 9
═══════════════════════════════════════════════════════════════════ */
.compare-table tbody tr.best-row td { background: rgba(22,163,74,.05); }
.compare-table tbody tr.best-row td:first-child { border-left: 3px solid var(--green); }
.compare-winner {
  display: inline-flex; align-items: center; gap: 4px;
  background: rgba(22,163,74,.1); color: var(--green);
  font-size: .68rem; font-weight: 700; padding: 2px 7px; border-radius: 20px;
}

/* Cellules inline dans la vue globale */
.comp-cell {
  display: flex; flex-direction: column; align-items: center;
  padding: 6px 10px; border-radius: var(--radius-sm);
  background: var(--bg2); border: 1px solid var(--border);
  min-width: 90px; text-align: center;
}
.comp-cell.best {
  background: rgba(22,163,74,.08); border-color: rgba(22,163,74,.25);
}
.comp-fourn { font-size: .68rem; color: var(--text-light); margin-bottom: 2px; white-space: nowrap; overflow: hidden; max-width: 100px; text-overflow: ellipsis; }
.comp-prix  { font-size: .82rem; font-weight: 700; font-family: 'DM Mono', monospace; }
.comp-tag   { font-size: .65rem; margin-top: 2px; }

/* Modal XL */
.modal.modal-xl { max-width: 1100px; }


/* ═══════════════════════════════════════════════════════════════════
   FINANCE / BUDGETS
═══════════════════════════════════════════════════════════════════ */
.badge.b-gold { background:rgba(200,150,42,.12); color:var(--gold); }
.badge.b-blue { background:rgba(37,99,235,.1);   color:#2563eb; }
.badge.b-orange { background:rgba(217,119,6,.1); color:var(--orange); }

.kpi-row { display:grid; grid-template-columns:repeat(4,1fr); gap:12px; }
.kpi-card {
  background:var(--surface); border:1px solid var(--border);
  border-radius:var(--radius); padding:16px 18px;
}
.kpi-label { font-size:.7rem; font-weight:700; text-transform:uppercase;
  letter-spacing:.07em; color:var(--text-light); margin-bottom:6px; }
.kpi-value { font-size:1.35rem; font-weight:700; line-height:1.2; }
.kpi-sub   { font-size:.72rem; color:var(--text-light); margin-top:4px; }

.grid-2col { display:grid; grid-template-columns:1fr 1fr; gap:14px; }
.td-sm { font-size:.75rem; }

/* TABLE TOOLBAR */
.table-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.table-toolbar .ml-auto { margin-left: auto; }
.form-input-sm {
  padding: 5px 10px;
  font-size: .8rem;
  height: 32px;
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
