/* ============================================================================
   Styles — Module "Table" (Code / Nom / Prénom / Date de naissance)
   ============================================================================
   Ce fichier est AUTONOME : il ne dépend pas de style.css pour s'afficher
   correctement (au cas où table_gestion.php serait ouvert depuis un dossier
   où style.css n'est pas présent, ou n'a pas pu se charger). Les couleurs
   reprennent exactement la palette de l'application "gestion cabinet" ; si
   style.css est bien chargé également, il n'y a aucune différence visuelle
   (mêmes valeurs), les deux cohabitent sans conflit.
   ============================================================================ */

:root {
  --bleu: #7c5cff;
  --bleu-fonce: #5b3df0;
  --bleu-clair: #f1edff;
  --fond: #f7f6fb;
  --carte: #ffffff;
  --bordure: #e3dff2;
  --texte-principal: #1e1b2e;
  --texte-secondaire: #7a7690;
  --texte-lien: #4a4560;
  --rouge: #c0392b;
  --rouge-clair: #fdecec;
  --ombre: 0 1px 2px rgba(30, 20, 60, 0.05);
  --ombre-modale: 0 24px 60px rgba(16, 12, 40, 0.28);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", -apple-system, Roboto, Arial, sans-serif;
  background: var(--fond);
  color: var(--texte-principal);
  -webkit-font-smoothing: antialiased;
}

/* ----- Mise en page générale ----- */
.content {
  padding: 28px 32px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

.content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 22px;
}

.content-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.page-icon {
  width: 44px;
  height: 44px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  flex-shrink: 0;
}

.page-icon-bleu-fonce { background: linear-gradient(135deg, #a78bfa, var(--bleu)); }

.content-header-left h1 {
  font-family: "Sora", "Inter", sans-serif;
  font-size: 22px;
  font-weight: 700;
  margin: 0;
  color: var(--texte-principal);
}

.content-header-left p {
  margin: 3px 0 0 0;
  font-size: 13px;
  color: var(--texte-secondaire);
}

/* ----- Boutons ----- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 9px;
  padding: 10px 16px;
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  transition: filter 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
  line-height: 1.2;
}
.btn:hover { filter: brightness(0.97); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.6; cursor: default; transform: none; }

.btn-primary {
  background: linear-gradient(135deg, var(--bleu), var(--bleu-fonce));
  color: #fff;
  box-shadow: 0 2px 8px rgba(124, 92, 255, 0.35);
}

.btn-ghost {
  background: #fff;
  color: var(--texte-lien);
  border-color: var(--bordure);
}
.btn-ghost:hover { background: #faf9fd; border-color: #d5cfef; }

/* ----- Statut de connexion ----- */
.tb-statut {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 13px;
  border-radius: 999px;
}
.tb-statut .point { width: 7px; height: 7px; border-radius: 50%; }

.tb-statut.ok { background: #e6f9f0; color: #17a874; }
.tb-statut.ok .point { background: #17a874; }

.tb-statut.erreur { background: var(--rouge-clair); color: var(--rouge); }
.tb-statut.erreur .point { background: var(--rouge); }

.tb-statut.chargement { background: var(--bleu-clair); color: var(--bleu-fonce); }
.tb-statut.chargement .point { background: var(--bleu-fonce); animation: tb-pulse 1s ease-in-out infinite; }

@keyframes tb-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

/* ----- Bandeaux d'erreur / avertissement ----- */
.tb-bandeau {
  display: none;
  align-items: flex-start;
  gap: 12px;
  border-radius: 12px;
  padding: 14px 18px;
  font-size: 13px;
  margin-bottom: 18px;
  line-height: 1.5;
}
.tb-bandeau.is-visible { display: flex; }

.tb-bandeau-erreur { background: var(--rouge-clair); border: 1px solid #f5c2c2; color: #8a2c22; }
.tb-bandeau-avertissement { background: #fff4e5; border: 1px solid #f7d9a8; color: #8a5a06; }

/* ----- Barre de recherche ----- */
.search-bar { position: relative; margin-bottom: 20px; }

.search-icon {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  opacity: 0.5;
  pointer-events: none;
}

.search-bar input {
  width: 100%;
  padding: 12px 14px 12px 40px;
  border-radius: 10px;
  border: 1px solid var(--bordure);
  background: var(--carte);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  color: var(--texte-principal);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.search-bar input:focus {
  border-color: var(--bleu);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.15);
}
.search-bar input::placeholder { color: #a8a3c0; }

/* ----- Table des enregistrements ----- */
.tb-table-wrapper {
  background: var(--carte);
  border: 1px solid var(--bordure);
  border-radius: 13px;
  overflow-x: auto;
  box-shadow: var(--ombre);
}

.tb-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

.tb-table th, .tb-table td { padding: 13px 20px; border-bottom: 1px solid var(--bordure); text-align: left; }

.tb-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  color: var(--texte-secondaire);
  background: #fbfafd;
}

.tb-table td.code {
  font-weight: 700;
  color: var(--bleu-fonce);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.tb-table td.nom { font-weight: 600; }

.tb-table tbody tr { cursor: pointer; transition: background 0.1s ease; }
.tb-table tbody tr:hover { background: #f8f7fc; }
.tb-table tbody tr:last-child td { border-bottom: none; }

.tb-table td.col-actions { text-align: right; white-space: nowrap; }
.tb-table th.col-actions { text-align: right; }

.btn-supprimer-ligne {
  flex-shrink: 0;
  border: 1px solid var(--bordure);
  background: #fff;
  color: var(--rouge);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease;
}
.tb-table tbody tr:hover .btn-supprimer-ligne { opacity: 1; }
.btn-supprimer-ligne:hover { background: var(--rouge-clair); border-color: #f5c2c2; }

/* ----- État vide ----- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 64px 20px;
}
.empty-icon {
  width: 54px;
  height: 54px;
  border-radius: 13px;
  background: var(--bleu-clair);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin-bottom: 16px;
}
.empty-state h2 { margin: 0 0 6px 0; font-size: 16.5px; font-family: "Sora", "Inter", sans-serif; }
.empty-state p { margin: 0 0 18px 0; font-size: 13px; color: var(--texte-secondaire); }

/* ============================================================================
   MODALE — fenêtre "Nouvelle fiche" / "Modifier la fiche"
   ============================================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 16, 36, 0.55);
  backdrop-filter: blur(1.5px);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 6vh 20px;
  overflow-y: auto;
  z-index: 100;
}
.modal-overlay.is-open { display: flex; }

.modal {
  background: var(--carte);
  width: 100%;
  max-width: 560px;
  border-radius: 16px;
  box-shadow: var(--ombre-modale);
  overflow: hidden;
  animation: tb-apparition 0.15s ease-out;
}

@keyframes tb-apparition {
  from { opacity: 0; transform: translateY(-6px) scale(0.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 22px 26px;
  border-bottom: 1px solid var(--bordure);
}

.modal-header h2 {
  margin: 0;
  font-family: "Sora", "Inter", sans-serif;
  font-size: 19px;
  font-weight: 700;
  color: var(--texte-principal);
}

.modal-header p {
  margin: 5px 0 0 0;
  font-size: 13px;
  color: var(--texte-secondaire);
}

.modal-close {
  border: none;
  background: #f2f0f9;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 14px;
  color: var(--texte-lien);
  flex-shrink: 0;
  transition: background 0.15s ease;
}
.modal-close:hover { background: #e7e3f5; }

.modal-body { padding: 24px 26px; max-height: 68vh; overflow-y: auto; }

.modal-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 26px;
  border-top: 1px solid var(--bordure);
  background: #fbfafd;
}

/* ----- Champs du formulaire ----- */
.conteneur { display: flex; flex-wrap: wrap; gap: 16px; }

.groupe3 {
  flex: 1 1 100%;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px 18px;
}

.champ { display: flex; flex-direction: column; gap: 6px; }

.champ label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--texte-lien);
  letter-spacing: 0.01em;
}

.champ label .requis { color: var(--rouge); margin-left: 2px; }

.champ input,
.champ select {
  padding: 10px 12px;
  border: 1px solid var(--bordure);
  border-radius: 9px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  background: #fff;
  color: var(--texte-principal);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.champ input::placeholder { color: #b3aecb; }

.champ input:hover, .champ select:hover { border-color: #cfc7e8; }

.champ input:focus, .champ select:focus {
  border-color: var(--bleu);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.15);
}

.champ input:disabled {
  background: #f7f6fb;
  color: var(--texte-secondaire);
  cursor: not-allowed;
}

.champ input[type="date"] { color: var(--texte-principal); }

/* Champ mis en évidence en cas d'erreur (ex. code en double) */
.tb-champ-erreur {
  border-color: var(--rouge) !important;
  background: #fffafa;
  box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.12) !important;
}

@media (max-width: 620px) {
  .groupe3 { grid-template-columns: 1fr; }
}

/* ----- Message de validation dans la modale ----- */
.form-message {
  font-size: 13px;
  margin-top: 14px;
  min-height: 0;
}
.form-message:empty { margin-top: 0; }
.form-message.erreur {
  color: #8a2c22;
  background: var(--rouge-clair);
  border: 1px solid #f5c2c2;
  border-radius: 9px;
  padding: 10px 14px;
}
