﻿/* ===== Base commune aux 3 pages ===== */
#section-ajouter-agent,
#section-liste-agents,
#section-liste-commissions {
  width: 100%;
  margin: 0 auto;
  color: #263247;
}

#section-ajouter-agent { max-width: 960px; }
#section-liste-agents { max-width: 1200px; }
#section-liste-commissions { max-width: 1280px; }

#section-ajouter-agent[hidden],
#section-liste-agents[hidden],
#section-liste-commissions[hidden],
#section-liste-agents [hidden],
#section-liste-commissions [hidden] {
  display: none !important;
}

#section-ajouter-agent > header,
#section-liste-agents > header,
#section-liste-commissions > header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

#section-ajouter-agent h1,
#section-liste-agents h1,
#section-liste-commissions h1 {
  margin: 0;
  color: #193b7a;
  font-size: 28px;
}

#section-ajouter-agent header nav,
#section-liste-agents header nav,
#section-liste-commissions header nav {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 8px;
  color: #64748b;
  font-size: 14px;
}

#section-ajouter-agent header nav a,
#section-liste-agents header nav a,
#section-liste-commissions header nav a {
  color: #244d9b;
  text-decoration: none;
}

#section-ajouter-agent header nav a:hover,
#section-liste-agents header nav a:hover,
#section-liste-commissions header nav a:hover {
  text-decoration: underline;
}

#section-ajouter-agent header nav [aria-current="page"],
#section-liste-agents header nav [aria-current="page"],
#section-liste-commissions header nav [aria-current="page"] {
  color: #334155;
  font-weight: 600;
}

/* ===== Formulaire : ajouter / modifier un agent ===== */
#formulaire-agent {
  display: grid;
  grid-template-columns: minmax(180px, 240px) minmax(0, 1fr);
  align-items: center;
  gap: 14px 20px;
  padding: 28px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 24px rgb(25 59 122 / 6%);
}

#formulaire-agent label {
  color: #334155;
  font-size: 14px;
  font-weight: 600;
}

#formulaire-agent input:not([type="hidden"]),
#formulaire-agent textarea {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fbfcfe;
  color: #263247;
  font: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#formulaire-agent textarea {
  min-height: 96px;
  resize: vertical;
}

#formulaire-agent input:hover,
#formulaire-agent textarea:hover {
  border-color: #94a3b8;
}

#formulaire-agent input:focus,
#formulaire-agent textarea:focus {
  border-color: #244d9b;
  outline: none;
  box-shadow: 0 0 0 3px rgb(36 77 155 / 14%);
  background: #fff;
}

#formulaire-agent .actions-agent,
#message-agent {
  grid-column: 1 / -1;
}

#formulaire-agent .actions-agent {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 10px;
  padding-top: 20px;
  border-top: 1px solid #e8edf3;
}

#formulaire-agent button {
  min-height: 44px;
  padding: 10px 18px;
  border: 0;
  border-radius: 6px;
  background: #244d9b;
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}

#formulaire-agent button:hover {
  background: #193b7a;
  transform: translateY(-1px);
}

#formulaire-agent #btn-annuler-agent {
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #334155;
}

#formulaire-agent #btn-annuler-agent:hover {
  background: #f4f6fa;
  transform: none;
}

#message-agent {
  min-height: 1.5em;
  margin: 0;
  color: #b42318;
  font-size: 14px;
}

/* ===== Boutons d'en-tête (liste) ===== */
#btn-ajouter-agent-depuis-liste {
  min-height: 42px;
  padding: 10px 16px;
  border: 0;
  border-radius: 5px;
  background: #244d9b;
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

#btn-ajouter-agent-depuis-liste:hover {
  background: #193b7a;
}

/* ===== État vide ===== */
#section-liste-agents .etat-vide,
#section-liste-commissions .etat-vide {
  display: flex;
  min-height: 280px;
  max-width: 680px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 32px auto;
  padding: 36px 24px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #fff;
  text-align: center;
}

#section-liste-agents .etat-vide > div[aria-hidden="true"],
#section-liste-commissions .etat-vide > div[aria-hidden="true"] {
  margin-bottom: 12px;
  font-size: 40px;
}

#section-liste-agents .etat-vide h2,
#section-liste-commissions .etat-vide h2 {
  margin: 0 0 8px;
  color: #263247;
  font-size: 20px;
}

#section-liste-agents .etat-vide p,
#section-liste-commissions .etat-vide p {
  margin: 0;
  color: #64748b;
  line-height: 1.6;
}

/* ===== Tableaux ===== */
#liste-agents,
#liste-commissions {
  overflow-x: auto;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #fff;
}

#liste-agents table,
#liste-commissions table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

#liste-agents th,
#liste-agents td,
#liste-commissions th,
#liste-commissions td {
  padding: 12px 14px;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
}

#liste-agents th,
#liste-commissions th {
  background: #f4f6fa;
  color: #334155;
  font-size: 13px;
  font-weight: 600;
}

#liste-agents tbody tr:hover,
#liste-commissions tbody tr:hover {
  background: #f8fafc;
}

#liste-agents tbody tr:last-child td,
#liste-commissions tbody tr:last-child td {
  border-bottom: 0;
}

#liste-agents td.cellule-montant,
#liste-commissions td.cellule-montant {
  font-weight: 600;
  text-align: right;
}

#liste-commissions th:nth-child(5),
#liste-commissions th:nth-child(7) {
  text-align: right;
}

#liste-commissions td:nth-child(5),
#liste-commissions td:nth-child(7) {
  text-align: right;
}

/* ===== Boutons d'action dans les tableaux ===== */
.cellule-actions {
  display: flex;
  gap: 8px;
}

.cellule-actions button {
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  background: #fff;
  color: #244d9b;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.cellule-actions button:hover {
  background: #eef3fb;
}

.cellule-actions button.bouton-danger {
  border-color: #f3c6c2;
  color: #b42318;
}

.cellule-actions button.bouton-danger:hover {
  background: #fdeceb;
}

/* ===== Pastilles de statut ===== */
.pastille-statut {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.pastille-statut.due {
  background: #fff4e0;
  color: #9a5b00;
}

.pastille-statut.payee {
  background: #e3f6ea;
  color: #1c7a43;
}

/* ===== Filtres et totaux des commissions ===== */
#section-liste-commissions .filtres-commissions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #fff;
}

#section-liste-commissions .filtres-commissions label {
  color: #334155;
  font-size: 13px;
  font-weight: 600;
}

#section-liste-commissions .filtres-commissions select,
#section-liste-commissions .filtres-commissions input {
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fbfcfe;
  color: #263247;
  font: inherit;
}

#section-liste-commissions .filtres-commissions select:focus,
#section-liste-commissions .filtres-commissions input:focus {
  border-color: #244d9b;
  outline: none;
  box-shadow: 0 0 0 3px rgb(36 77 155 / 14%);
}

#section-liste-commissions .totaux-commissions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

#section-liste-commissions .totaux-commissions > div {
  padding: 16px 18px;
  border: 1px solid #e2e8f0;
  border-left: 4px solid #244d9b;
  border-radius: 6px;
  background: #fff;
}

#section-liste-commissions .totaux-commissions > div:nth-child(2) {
  border-left-color: #e0a100;
}

#section-liste-commissions .totaux-commissions > div:nth-child(3) {
  border-left-color: #1c7a43;
}

#section-liste-commissions .totaux-commissions span {
  display: block;
  color: #64748b;
  font-size: 13px;
}

#section-liste-commissions .totaux-commissions strong {
  display: block;
  margin-top: 4px;
  color: #193b7a;
  font-size: 20px;
}

/* ===== Accessibilité ===== */
#section-ajouter-agent a:focus-visible,
#section-liste-agents a:focus-visible,
#section-liste-commissions a:focus-visible,
#formulaire-agent button:focus-visible,
#section-liste-agents button:focus-visible,
#section-liste-commissions button:focus-visible {
  outline: 3px solid #93c5fd;
  outline-offset: 3px;
}

/* ===== Champ Agent dans la facture ===== */
#agent-facture {
  width: 100%;
  min-height: 40px;
  margin-top: 6px;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fbfcfe;
  font: inherit;
}

/* ===== Mobile ===== */
@media (max-width: 650px) {
  #section-ajouter-agent h1,
  #section-liste-agents h1,
  #section-liste-commissions h1 {
    font-size: 24px;
  }

  #section-liste-agents > header,
  #section-liste-commissions > header {
    align-items: flex-start;
    flex-direction: column;
  }

  #btn-ajouter-agent-depuis-liste {
    width: 100%;
  }

  #formulaire-agent {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 20px 16px;
  }

  #formulaire-agent .actions-agent {
    flex-direction: column-reverse;
  }

  #formulaire-agent .actions-agent button {
    width: 100%;
  }

  #section-liste-agents .etat-vide,
  #section-liste-commissions .etat-vide {
    min-height: 240px;
    margin: 24px auto;
    padding: 28px 16px;
  }

  #liste-agents th,
  #liste-agents td,
  #liste-commissions th,
  #liste-commissions td {
    padding: 10px;
  }
}
