.admin-container {
  max-width: 1320px;
  margin: 3rem auto;
  padding: 0 1.5rem 4rem;
}

.nav-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  border-bottom: 2px solid var(--border-color);
  margin-bottom: 2rem;
}

.tab-btn {
  background: none;
  border: none;
  padding: 0.8rem 1.2rem;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.tab-btn:hover { color: var(--primary); }

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

.admin-container h3 { font-family: var(--font-serif); margin-bottom: 1rem; }
.admin-container h4 { font-family: var(--font-serif); margin-bottom: 0.5rem; }

.admin-container table { border-collapse: collapse; margin-top: 0.4rem; }
.admin-container table thead th { background: #faf7f4; }
.admin-container table th, .admin-container table td { vertical-align: top; border-bottom: 1px solid var(--border-color); }
.admin-container table tr:last-child td { border-bottom: none; }
.admin-container .form-group label { font-size: 0.85rem; }
.email-template-card code { background: #efe9e2; padding: 1px 5px; border-radius: 4px; font-size: 0.8rem; }

/* ===== Tableau des inscriptions (actives + archivées) ===== */
.reg-table-wrap {
  width: 100%;
  margin: 0.6rem auto 0.4rem;
  overflow-x: auto;
}

.reg-table {
  width: 100%;
  min-width: 1020px;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  overflow: hidden;
  font-size: 0.875rem;
  color: var(--text-dark);
}

.reg-table thead th {
  padding: 0.6rem 0.7rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: #faf7f4;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.reg-table tbody td {
  padding: 0.5rem 0.7rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
  overflow-wrap: anywhere;
}

.reg-table tbody tr:last-child td { border-bottom: none; }

/* Largeurs indicatives des colonnes */
.reg-table col.col-stage { width: 26%; }
.reg-table col.col-name { width: 10%; }
.reg-table col.col-birth { width: 8%; }
.reg-table col.col-created { width: 11%; }
.reg-table col.col-contact { width: 12%; }
.reg-table col.col-message { width: 15%; }
.reg-table col.col-status { width: 13%; }
.reg-table col.col-actions { width: 5%; }

/* Colonne Stage : titre sur 2 lignes max, date tronquée proprement */
.reg-table .c-stage .cell-title {
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: break-word;
}
.reg-table .c-stage .cell-sub {
  margin-top: 0.15rem;
  font-size: 0.76rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Colonne Message : max 2 lignes pour éviter les lignes géantes */
.reg-table .c-message .msg-clamp {
  font-size: 0.84rem;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

/* Contact */
.reg-table .c-contact { font-size: 0.84rem; }
.reg-table .c-contact .cell-email { overflow-wrap: anywhere; }
.reg-table .c-contact .cell-sub { font-size: 0.76rem; color: var(--text-muted); }

/* Dates / naissance */
.reg-table .c-birth, .reg-table .c-created {
  white-space: nowrap;
  font-size: 0.84rem;
}

/* Statut */
.reg-table .c-status .status-cell { display: flex; gap: 0.35rem; align-items: center; }
.reg-table .c-status select {
  width: 100%;
  min-width: 130px;
  max-width: 160px;
  padding: 0.35rem 0.4rem;
  font-size: 0.8rem;
}
.reg-table .c-status .btn-reg-status-apply {
  width: auto;
  padding: 0.25rem 0.5rem;
  font-size: 0.72rem;
  white-space: nowrap;
}

/* Actions */
.reg-table .c-actions { white-space: nowrap; text-align: right; }
.reg-table .c-actions .btn {
  width: auto;
  padding: 0.25rem 0.5rem;
  font-size: 0.72rem;
  margin-left: 0.25rem;
}

/* ===== Aperçus d'images (stages & personnalisation) ===== */
.hidden { display: none !important; }
.img-preview {
  display: block;
  max-width: 320px;
  max-height: 150px;
  width: auto;
  height: auto;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  margin-top: 0.6rem;
  background: #fff;
}
.img-current-note { display: block; color: var(--text-muted); font-size: 0.8rem; margin-top: 0.3rem; }

.thumb {
  width: 72px;
  height: 52px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  flex: none;
  background: #fff;
}
.thumb-empty {
  width: 72px;
  height: 52px;
  flex: none;
  background: #f3ede6;
  border: 1px dashed var(--border-color);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #b9afa3;
  font-size: 1.1rem;
}
/* ===== Connexion ===== */
.login-card {
  max-width: 400px;
  margin: 8rem auto;
  background: #fff;
  padding: 2.5rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-subtle);
}
.login-title { font-family: var(--font-serif); font-size: 2rem; margin-bottom: 1.5rem; text-align: center; }

/* ===== En-tête et éléments communs ===== */
.admin-header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 2rem; flex-wrap: wrap; }
.admin-header h1 { font-family: var(--font-serif); margin: 0; }
.btn-auto { width: auto; }
.btn-small { width: auto; padding: 0.4rem 1rem; font-size: 0.85rem; }
.btn-spaced { margin-bottom: 1rem; }
.btn-top { margin-top: 1rem; }
.muted { color: var(--text-muted); }
.help-block { font-size: 0.88rem; color: var(--text-muted); margin-bottom: 1rem; }
.help-text { display: block; margin-top: 0.3rem; color: var(--text-muted); font-size: 0.82rem; line-height: 1.4; }
.section-gap { margin-top: 3rem; }
.form-subtitle { margin-top: 1.5rem; }
.form-top { margin-top: 1rem; }
.modal-heading { font-family: var(--font-serif); margin-bottom: 1rem; }
.modal-wide { max-width: 640px; }
.input-readonly { background: #f4f1ec; color: var(--text-muted); }
.checkbox-label { display: flex; align-items: center; gap: 0.5rem; font-weight: 600; }
.checkbox-label input[type="checkbox"] { width: auto; flex: none; }

.panel { background: #faf7f4; padding: 1.5rem; border-radius: 8px; }
.panel-spaced { margin-bottom: 2rem; }
.panel-note { background: #fdf8f4; border: 1px solid var(--border-color); margin-top: 2rem; padding: 1.2rem; }

/* Grilles : deux colonnes sur grand écran, une seule sur mobile */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-2.grid-tight { gap: 0.8rem; }
.grid-2.grid-wide { gap: 2rem; }
.grid-full { grid-column: 1 / -1; }
.grid-rating { display: grid; grid-template-columns: 220px 1fr; gap: 1rem; }
.sig-layout { display: grid; grid-template-columns: minmax(320px, 420px) 1fr; gap: 2rem; align-items: start; }

.filter-bar { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; margin-bottom: 1.5rem; background: #faf7f4; padding: 1rem; border-radius: 8px; }
.filter-bar .form-group { margin: 0; }
.filter-bar .form-control { width: auto; min-width: 150px; }

.inline-form { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; }
.inline-form .grow { flex: 1; margin-bottom: 0; min-width: 220px; }

.users-list { margin: 1rem 0 2.5rem; }
.user-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.8rem 1rem; background: #fff; border: 1px solid var(--border-color); border-radius: 8px; margin-bottom: 0.6rem; }

/* ===== Avertissements et états ===== */
.banner-warning { background: #fff8e6; border: 1px solid #e6c96b; border-radius: 8px; padding: 0.9rem 1.2rem; margin-bottom: 1.5rem; font-size: 0.92rem; line-height: 1.5; }
.status-box { border-radius: 8px; padding: 0.9rem 1.2rem; margin-bottom: 1.5rem; font-size: 0.9rem; line-height: 1.5; border: 1px solid var(--border-color); background: #fdf8f4; }
.status-box ul { margin: 0.4rem 0 0; padding-left: 1.2rem; }
.status-box.status-ok { background: #eef7ee; border-color: #9fcf9f; }
.status-box.status-warn { background: #fff8e6; border-color: #e6c96b; }

.tab-badge { display: inline-block; min-width: 1.3rem; padding: 0 0.4rem; margin-left: 0.3rem; border-radius: 999px; background: #c62828; color: #fff; font-size: 0.72rem; line-height: 1.3rem; text-align: center; }

/* ===== Messages reçus ===== */
.contact-message { background: #fff; border: 1px solid var(--border-color); border-radius: 10px; padding: 1rem 1.2rem; margin-bottom: 1rem; }
.contact-message.is-unread { border-left: 4px solid var(--primary); background: #fffdf9; }
.contact-message-head {
  /* Sécurité : un `<header>` ne doit jamais hériter de la mise en page de
     l'en-tête du site (position fixe), sinon le nom, l'email et la date de
     chaque message remontent en haut de la page. */
  position: static;
  top: auto;
  width: auto;
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; align-items: baseline;
}
.contact-message-head a { color: var(--primary); overflow-wrap: anywhere; }
.contact-message-date { font-size: 0.82rem; color: var(--text-muted); white-space: nowrap; }
.contact-message-text { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0.7rem 0; }
.contact-message-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.badge-unread { display: inline-block; margin-left: 0.4rem; padding: 0.05rem 0.5rem; border-radius: 999px; background: var(--primary); color: #fff; font-size: 0.72rem; font-weight: 700; }
.msg-warning { color: #b3261e; font-size: 0.84rem; font-weight: 600; }

/* Fiche du message : informations explicites (nom, email, date et heure) */
.msg-identity { display: flex; flex-direction: column; gap: 0.15rem; }
.msg-label { display: inline-block; min-width: 3.4rem; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }

/* Formulaire de réponse */
.reply-form { margin-top: 1rem; padding-top: 0.9rem; border-top: 1px dashed var(--border-color); }
.reply-form textarea { width: 100%; font-family: inherit; resize: vertical; }
.reply-form-actions { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin-top: 0.6rem; }
.reply-form-msg { font-size: 0.86rem; }
.reply-form[hidden] { display: none; }

/* Historique de l'échange : réponses rattachées au message d'origine */
.msg-replies { margin-top: 1.1rem; padding-left: 1rem; border-left: 3px solid var(--accent); }
.msg-replies-title { font-size: 0.8rem; margin-bottom: 0.6rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.msg-reply { background: #faf7f4; border: 1px solid var(--border-color); border-radius: 8px; padding: 0.7rem 0.9rem; margin-bottom: 0.6rem; }
.msg-reply-head { display: flex; gap: 0.6rem; align-items: baseline; flex-wrap: wrap; font-size: 0.9rem; }
.msg-reply-date { color: var(--text-muted); font-size: 0.82rem; }
.msg-sent { color: #2e7d32; font-size: 0.8rem; font-weight: 600; }

/* Contenu réservé aux lecteurs d'écran */
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ===== Accessibilité : focus visible dans l'administration ===== */
.tab-btn:focus-visible, .admin-container .btn:focus-visible, .modal-card .btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ===== Écrans étroits (tablettes et mobiles) ===== */
@media (max-width: 900px) {
  .sig-layout { grid-template-columns: 1fr; }
  .grid-2.grid-wide { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .admin-container { margin: 1.5rem auto; padding: 0 1rem 3rem; }
  .login-card { margin: 3rem 1rem; padding: 1.5rem; }
  .nav-tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
  .tab-btn { white-space: nowrap; padding: 0.7rem 0.9rem; flex: none; }
  .grid-2, .grid-rating { grid-template-columns: 1fr; }
  .filter-bar .form-group, .filter-bar .form-control, .filter-bar .btn { width: 100%; }
  .panel { padding: 1.1rem; }
  .user-row { flex-wrap: wrap; }
  .contact-message-head { flex-direction: column; gap: 0.2rem; }
  .stage-actions { max-width: none; flex-basis: 100%; }
  .img-preview { max-width: 100%; }
}
