/* =========================================================
   LISTE DES COMMANDES DE VENTE + CARTE DU TABLEAU DE BORD
   Fichier : liste-commande-vente.css
   ========================================================= */

#section-liste-commandes-vente {
  --cmd-bleu: var(--bleu, #244d9b);
  --cmd-bleu-fonce: var(--bleu-fonce, #193b7a);
  --cmd-texte: var(--texte, #263247);
  --cmd-discret: var(--texte-clair, #718096);
  --cmd-bordure: var(--bordure, #e5eaf1);

  width: 100%;
  max-width: 1150px;
  margin: 0 auto;
  color: var(--cmd-texte);
  box-sizing: border-box;
}

#section-liste-commandes-vente *,
#section-liste-commandes-vente *::before,
#section-liste-commandes-vente *::after {
  box-sizing: border-box;
}

#section-liste-commandes-vente[hidden],
#section-liste-commandes-vente [hidden] {
  display: none !important;
}

/* ================= EN-TÊTE ================= */

#section-liste-commandes-vente .cmd-entete {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

#section-liste-commandes-vente h1 {
  margin: 0 0 6px;
  color: var(--cmd-bleu-fonce);
  font-size: 28px;
}

#section-liste-commandes-vente .cmd-ariane {
  color: var(--cmd-discret);
  font-size: 14px;
}

#section-liste-commandes-vente .cmd-ariane a {
  color: var(--cmd-bleu);
  text-decoration: none;
}

#section-liste-commandes-vente .cmd-ariane a:hover {
  text-decoration: underline;
}

#section-liste-commandes-vente .cmd-ariane span {
  margin: 0 4px;
}

/* ================= BOUTONS ================= */

#section-liste-commandes-vente .cmd-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 40px;
  padding: 9px 16px;
  border: 1px solid var(--cmd-bordure);
  border-radius: 6px;
  background: #fff;
  color: var(--cmd-texte);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

#section-liste-commandes-vente .cmd-btn:hover {
  border-color: var(--cmd-bleu);
}

#section-liste-commandes-vente .cmd-btn:disabled {
  opacity: .5;
  cursor: wait;
}

#section-liste-commandes-vente .cmd-btn-principal {
  border-color: var(--cmd-bleu);
  background: var(--cmd-bleu);
  color: #fff;
}

#section-liste-commandes-vente .cmd-btn-principal:hover {
  background: var(--cmd-bleu-fonce);
}

#section-liste-commandes-vente .cmd-btn-icone {
  width: 34px;
  min-height: 34px;
  padding: 0;
}

#section-liste-commandes-vente .cmd-btn-facturer {
  min-height: 34px;
  padding: 4px 10px;
  border-color: var(--cmd-bleu);
  color: var(--cmd-bleu);
  font-size: 13px;
}

#section-liste-commandes-vente .cmd-btn-facturer:hover {
  background: var(--cmd-bleu);
  color: #fff;
}

#section-liste-commandes-vente .cmd-btn:focus-visible,
#section-liste-commandes-vente select:focus-visible,
#section-liste-commandes-vente input:focus-visible,
#section-liste-commandes-vente .cmd-ligne:focus-visible {
  outline: 3px solid #93c5fd;
  outline-offset: 2px;
}

/* ================= MESSAGE ================= */

#section-liste-commandes-vente .cmd-message {
  margin: 0 0 14px;
  padding: 10px 14px;
  border-radius: 6px;
  background: #dcfce7;
  color: #166534;
  font-weight: 600;
}

#section-liste-commandes-vente .cmd-message.cmd-erreur {
  background: #fee2e2;
  color: #991b1b;
}

/* ================= TOTAUX ================= */

#section-liste-commandes-vente .cmd-resume {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

#section-liste-commandes-vente .cmd-resume button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 13px 14px;
  border: 1px solid var(--cmd-bordure);
  border-left: 4px solid var(--cmd-bleu);
  border-radius: 8px;
  background: #fff;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

#section-liste-commandes-vente .cmd-resume button:nth-child(1) { border-left-color: #f59e0b; }
#section-liste-commandes-vente .cmd-resume button:nth-child(2) { border-left-color: #ef4444; }
#section-liste-commandes-vente .cmd-resume button:nth-child(3) { border-left-color: #16a34a; }
#section-liste-commandes-vente .cmd-resume button:nth-child(4) { border-left-color: #94a3b8; }

#section-liste-commandes-vente .cmd-resume button:hover {
  box-shadow: 0 4px 14px rgba(15, 23, 42, .08);
}

#section-liste-commandes-vente .cmd-resume button.cmd-actif {
  background: #eef3fb;
  border-color: var(--cmd-bleu);
}

#section-liste-commandes-vente .cmd-resume span {
  color: var(--cmd-discret);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
}

#section-liste-commandes-vente .cmd-resume strong {
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

#section-liste-commandes-vente .cmd-resume small {
  color: var(--cmd-discret);
  font-size: 12px;
}

/* ================= FILTRES ================= */

#section-liste-commandes-vente .cmd-outils {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

#section-liste-commandes-vente .cmd-outils select,
#section-liste-commandes-vente .cmd-outils input {
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  color: var(--cmd-texte);
  font: inherit;
  font-size: 14px;
}

#section-liste-commandes-vente .cmd-outils input {
  flex: 1 1 220px;
}

/* ================= TABLEAU ================= */

#section-liste-commandes-vente .cmd-tableau-zone {
  overflow-x: auto;
  border: 1px solid var(--cmd-bordure);
  border-radius: 8px;
  background: #fff;
}

#section-liste-commandes-vente .cmd-tableau {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

#section-liste-commandes-vente .cmd-tableau > thead th {
  padding: 11px 12px;
  border-bottom: 1px solid var(--cmd-bordure);
  background: #f8fafc;
  color: var(--cmd-discret);
  font-size: 12px;
  font-weight: 700;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

#section-liste-commandes-vente .cmd-tableau > tbody > tr > td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--cmd-bordure);
  vertical-align: middle;
}

#section-liste-commandes-vente .cmd-ligne {
  cursor: pointer;
}

#section-liste-commandes-vente .cmd-ligne:hover,
#section-liste-commandes-vente .cmd-ligne.cmd-ouverte {
  background: #f8fafc;
}

#section-liste-commandes-vente .cmd-num {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

#section-liste-commandes-vente .cmd-droite {
  text-align: right;
  white-space: nowrap;
}

#section-liste-commandes-vente .cmd-actions .cmd-btn + .cmd-btn {
  margin-left: 4px;
}

/* ================= DÉTAIL DES ARTICLES ================= */

#section-liste-commandes-vente .cmd-detail > td {
  padding: 4px 16px 14px !important;
  background: #f8fafc;
}

#section-liste-commandes-vente .cmd-articles {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

#section-liste-commandes-vente .cmd-articles th {
  padding: 6px 8px;
  color: var(--cmd-discret);
  font-size: 11px;
  text-align: left;
  text-transform: uppercase;
  border-bottom: 1px solid var(--cmd-bordure);
}

#section-liste-commandes-vente .cmd-articles td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--cmd-bordure);
}

#section-liste-commandes-vente .cmd-articles small {
  color: var(--cmd-discret);
}

#section-liste-commandes-vente .cmd-detail-pied {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin: 10px 0 0;
  color: var(--cmd-discret);
  font-size: 13px;
}

#section-liste-commandes-vente .cmd-livraison {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--cmd-texte);
  font-weight: 600;
}

#section-liste-commandes-vente .cmd-livraison input {
  min-height: 34px;
  padding: 4px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font: inherit;
}

#section-liste-commandes-vente .cmd-detail-pied strong {
  color: var(--cmd-texte);
}

/* ================= BADGES ================= */

#section-liste-commandes-vente .cmd-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

#section-liste-commandes-vente .cmd-badge-attente   { background: #fef3c7; color: #b45309; }
#section-liste-commandes-vente .cmd-badge-retard    { background: #fee2e2; color: #b91c1c; }
#section-liste-commandes-vente .cmd-badge-completee { background: #dcfce7; color: #15803d; }
#section-liste-commandes-vente .cmd-badge-annulee   { background: #eef1f5; color: #64748b; }

/* ================= ÉTAT VIDE ================= */

#section-liste-commandes-vente .cmd-vide {
  padding: 46px 20px;
  border: 1px dashed var(--cmd-bordure);
  border-radius: 8px;
  background: #fff;
  text-align: center;
}

#section-liste-commandes-vente .cmd-vide > div {
  margin-bottom: 8px;
  font-size: 40px;
}

#section-liste-commandes-vente .cmd-vide h2 {
  margin: 0 0 6px;
  font-size: 18px;
}

#section-liste-commandes-vente .cmd-vide p {
  margin: 0;
  color: var(--cmd-discret);
}

/* ================= CARTE DU TABLEAU DE BORD ================= */

.dashboard-panel.cmd-carte {
  cursor: pointer;
  transition: box-shadow .15s, border-color .15s;
}

.dashboard-panel.cmd-carte:hover {
  border-color: var(--bleu, #244d9b);
  box-shadow: 0 4px 14px rgba(15, 23, 42, .08);
}

.dashboard-panel.cmd-carte:focus-visible {
  outline: 3px solid #93c5fd;
  outline-offset: 2px;
}

.dashboard-panel.cmd-carte .cmd-carte-note {
  margin: 8px 0 0;
  color: #b91c1c;
  font-size: 11px;
}

/* ================= TÉLÉPHONE ================= */

@media (max-width: 900px) {
  #section-liste-commandes-vente .cmd-resume {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  #section-liste-commandes-vente h1 {
    font-size: 24px;
  }

  #section-liste-commandes-vente .cmd-resume {
    grid-template-columns: 1fr;
  }

  #section-liste-commandes-vente .cmd-tableau-zone {
    border: 0;
    background: transparent;
  }

  #section-liste-commandes-vente .cmd-tableau > thead {
    display: none;
  }

  #section-liste-commandes-vente .cmd-tableau,
  #section-liste-commandes-vente .cmd-tableau > tbody,
  #section-liste-commandes-vente .cmd-tableau > tbody > tr,
  #section-liste-commandes-vente .cmd-tableau > tbody > tr > td {
    display: block;
    width: 100%;
  }

  #section-liste-commandes-vente .cmd-tableau > tbody > tr.cmd-ligne {
    margin-top: 10px;
    padding: 8px 12px;
    border: 1px solid var(--cmd-bordure);
    border-radius: 8px;
    background: #fff;
  }

  #section-liste-commandes-vente .cmd-tableau > tbody > tr.cmd-ligne > td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 5px 0;
    border: 0;
    text-align: right;
  }

  #section-liste-commandes-vente .cmd-tableau > tbody > tr.cmd-ligne > td::before {
    content: attr(data-titre);
    color: var(--cmd-discret);
    font-size: 12px;
    text-align: left;
  }
}
