/* ═══════════════════════════════════════════════════
   ADMIN — styles complémentaires à style.css
   Utilise les variables CSS définies dans style.css :
   --c-cream, --c-cream-dark, --c-sage, --c-sage-dark,
   --c-rose, --c-gold, --c-earth, --c-dark, --c-text,
   --c-muted, --c-white, --font-serif, --font-sans,
   --radius, --shadow
   ═══════════════════════════════════════════════════ */

/* ───────────────────────────────────────────────────
   PAGE BASE
   ─────────────────────────────────────────────────── */
.admin-page {
  background: var(--c-cream-dark);
  min-height: 100vh;
}

/* Utility: visually-hidden but accessible */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ───────────────────────────────────────────────────
   LOGIN SCREEN
   ─────────────────────────────────────────────────── */
.admin-login {
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(122,158,126,.18), transparent),
    var(--c-cream-dark);
}

.admin-login__card {
  background: var(--c-white);
  border: 1px solid rgba(122,158,126,.2);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  box-shadow: var(--shadow);
}
.admin-login__card[hidden] { display: none; }

.admin-login__brand {
  text-align: center;
  margin-bottom: .25rem;
}

.admin-login__brand-serif {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--c-sage-dark);
  letter-spacing: .04em;
}

.admin-login__title {
  font-family: var(--font-serif);
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--c-dark);
  text-align: center;
  margin-bottom: .25rem;
}

.admin-login__sub {
  color: var(--c-muted);
  font-size: .875rem;
  text-align: center;
  margin-top: -.75rem;
}

#login-form,
#forgot-form,
#reset-form {
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

.admin-login__link {
  background: none;
  border: none;
  color: var(--c-muted);
  font-size: .8rem;
  cursor: pointer;
  text-align: center;
  width: 100%;
  padding: 0;
  font-family: inherit;
  transition: color .2s;
}
.admin-login__link:hover { color: var(--c-sage-dark); }

.admin-login__success {
  background: rgba(122,158,126,.1);
  border: 1px solid rgba(122,158,126,.25);
  border-radius: 8px;
  padding: .9rem 1rem;
  color: var(--c-sage-dark);
  font-size: .875rem;
  line-height: 1.5;
}

/* ───────────────────────────────────────────────────
   HEADER (sticky)
   ─────────────────────────────────────────────────── */
.admin-dashboard {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}

.admin-header {
  background: var(--c-sage);
  padding: .875rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 8px rgba(44,36,22,.12);
}

.admin-header__left {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.admin-header__back {
  color: rgba(255,255,255,.75);
  font-size: .82rem;
  text-decoration: none;
  transition: color .2s;
  white-space: nowrap;
}
.admin-header__back:hover { color: #fff; }

.admin-header__title {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 600;
  color: #fff;
  letter-spacing: .03em;
}

/* Override ghost button for dark header */
.admin-header .btn--ghost {
  color: rgba(255,255,255,.85);
  border-color: rgba(255,255,255,.4);
}
.admin-header .btn--ghost:hover {
  background: rgba(255,255,255,.15);
  color: #fff;
  border-color: rgba(255,255,255,.7);
}

/* ───────────────────────────────────────────────────
   TAB NAVIGATION
   ─────────────────────────────────────────────────── */
.admin-tabs {
  background: var(--c-white);
  border-bottom: 1px solid rgba(122,158,126,.2);
  display: flex;
  align-items: stretch;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.admin-tabs::-webkit-scrollbar { display: none; }

.admin-tab-btn {
  flex: none;
  padding: .9rem 1.4rem;
  font-family: var(--font-sans);
  font-size: .875rem;
  font-weight: 500;
  color: var(--c-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color .2s, border-color .2s;
  white-space: nowrap;
  letter-spacing: .02em;
}
.admin-tab-btn:hover { color: var(--c-sage-dark); }
.admin-tab-btn.active {
  color: var(--c-sage-dark);
  border-bottom-color: var(--c-sage);
  font-weight: 700;
}

/* ───────────────────────────────────────────────────
   TAB PANELS
   ─────────────────────────────────────────────────── */
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ───────────────────────────────────────────────────
   MAIN LAYOUT
   ─────────────────────────────────────────────────── */
.admin-main {
  max-width: 1140px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  flex: 1;
}

/* ───────────────────────────────────────────────────
   SECTION CARDS (white cards)
   ─────────────────────────────────────────────────── */
.admin-section {
  background: var(--c-white);
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: var(--shadow);
}

.admin-section--toolbar {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
  padding: 1rem 1.5rem;
}

.admin-section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.admin-section__title {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--c-dark);
  margin-bottom: 1.25rem;
}

.admin-section__header .admin-section__title {
  margin-bottom: 0;
}

.admin-section__actions {
  display: flex;
  align-items: center;
  gap: .5rem;
}

/* ───────────────────────────────────────────────────
   FORM HELPERS
   ─────────────────────────────────────────────────── */
.admin-form__grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}
@media (max-width: 640px) {
  .admin-form__grid { grid-template-columns: 1fr; }
}

.form-group--full { grid-column: 1 / -1; }

.admin-form__actions {
  margin-top: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1rem;
}

.settings-save-feedback {
  font-size: .85rem;
  color: var(--c-sage-dark);
  font-weight: 500;
}
.settings-save-feedback.error { color: #c0392b; }

.checkbox-label {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-size: .9rem;
  cursor: pointer;
  user-select: none;
}
.checkbox-label input { accent-color: var(--c-sage); width: 16px; height: 16px; }

/* ───────────────────────────────────────────────────
   FIELDSETS
   ─────────────────────────────────────────────────── */
.admin-fieldset {
  border: 1.5px solid rgba(122,158,126,.25);
  border-radius: var(--radius);
  padding: 1.25rem 1.25rem 1rem;
  margin-bottom: 1rem;
}

.admin-fieldset__legend {
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--c-sage-dark);
  padding: 0 .5rem;
}

/* ───────────────────────────────────────────────────
   RSVP STATS CHIPS
   ─────────────────────────────────────────────────── */
.rsvp-stats {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.stat-chip {
  flex: 1;
  min-width: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .25rem;
  padding: 1rem .75rem;
  border-radius: var(--radius);
  background: var(--c-cream);
  border: 1.5px solid var(--c-cream-dark);
  text-align: center;
}

.stat-chip__value {
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 600;
  line-height: 1;
  color: var(--c-dark);
}

.stat-chip__label {
  font-size: .75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--c-muted);
}

.stat-chip--present {
  border-color: rgba(122,158,126,.35);
  background: rgba(122,158,126,.07);
}
.stat-chip--present .stat-chip__value { color: var(--c-sage-dark); }

.stat-chip--absent {
  border-color: rgba(192,57,43,.25);
  background: rgba(192,57,43,.05);
}
.stat-chip--absent .stat-chip__value { color: #c0392b; }

.stat-chip--pending {
  border-color: rgba(201,149,106,.35);
  background: rgba(201,149,106,.07);
}
.stat-chip--pending .stat-chip__value { color: var(--c-earth); }

/* ───────────────────────────────────────────────────
   ADMIN TABLE
   ─────────────────────────────────────────────────── */
.admin-table-wrap {
  overflow-x: auto;
  border-radius: 8px;
}

.admin-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  color: var(--c-muted);
  padding: 3rem;
  font-size: .9rem;
}

.admin-empty {
  text-align: center;
  color: var(--c-muted);
  padding: 3rem;
  font-size: .9rem;
  font-style: italic;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

.admin-table th {
  text-align: left;
  padding: .7rem 1rem;
  color: var(--c-muted);
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .09em;
  font-weight: 700;
  border-bottom: 1.5px solid var(--c-cream-dark);
  white-space: nowrap;
  background: var(--c-cream);
}
.admin-table th:first-child { border-radius: 8px 0 0 0; }
.admin-table th:last-child  { border-radius: 0 8px 0 0; }

.admin-table td {
  padding: .85rem 1rem;
  border-bottom: 1px solid var(--c-cream-dark);
  vertical-align: middle;
}

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

.admin-table tbody tr:hover { background: rgba(122,158,126,.04); }

/* Expandable row */
.admin-table tbody tr.is-expanded { background: rgba(122,158,126,.06); }

.rsvp-detail-row td {
  background: var(--c-cream);
  padding: 0;
}
.rsvp-detail-inner {
  padding: 1rem 1.5rem 1.25rem 2.5rem;
  font-size: .85rem;
}
.rsvp-detail-inner table {
  font-size: .82rem;
  border-collapse: collapse;
}
.rsvp-detail-inner td {
  padding: .35rem .75rem;
  border-bottom: 1px solid rgba(122,158,126,.15);
}
.rsvp-detail-inner td:first-child { color: var(--c-muted); width: 120px; }
.rsvp-detail-inner tr:last-child td { border-bottom: none; }

.admin-table__name { font-weight: 600; color: var(--c-dark); }
.admin-table__muted { color: var(--c-muted); font-size: .82rem; }
.admin-table__actions-col { text-align: right; min-width: 90px; }
.admin-table__actions {
  display: flex;
  gap: .35rem;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* Presence badge */
.presence-badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  padding: .2rem .6rem;
  border-radius: 999px;
  white-space: nowrap;
}
.presence-badge--yes {
  background: rgba(122,158,126,.12);
  color: var(--c-sage-dark);
}
.presence-badge--no {
  background: rgba(192,57,43,.1);
  color: #c0392b;
}
.presence-badge--pending {
  background: rgba(201,149,106,.12);
  color: var(--c-earth);
}

/* Gift active badge */
.active-badge {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ccc;
}
.active-badge.is-active { background: var(--c-sage); }

/* Icon buttons */
.btn--icon {
  padding: .4rem;
  border: 1.5px solid var(--c-cream-dark);
  border-radius: 8px;
  color: var(--c-muted);
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color .2s, border-color .2s, background .2s;
  cursor: pointer;
}
.btn--icon:hover {
  color: var(--c-text);
  border-color: var(--c-sage);
  background: rgba(122,158,126,.07);
}
.btn--icon.btn--danger-icon:hover {
  color: #c0392b;
  border-color: rgba(192,57,43,.4);
  background: rgba(192,57,43,.06);
}
.btn--icon.btn--contributions:hover {
  color: var(--c-sage-dark);
  border-color: var(--c-sage);
}

/* ───────────────────────────────────────────────────
   INLINE RADIO GROUP VARIANT
   ─────────────────────────────────────────────────── */
.radio-group--inline {
  display: flex;
  flex-direction: row;
  gap: .75rem;
  flex-wrap: wrap;
}

/* ───────────────────────────────────────────────────
   UPLOAD ZONE (gifts image)
   ─────────────────────────────────────────────────── */
.upload-zone {
  position: relative;
}

.upload-zone__input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.upload-zone__label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: 1.5rem;
  border: 2px dashed rgba(122,158,126,.4);
  border-radius: var(--radius);
  color: var(--c-muted);
  text-align: center;
  transition: border-color .2s, color .2s, background .2s;
  min-height: 110px;
  background: var(--c-cream);
  cursor: pointer;
  font-size: .9rem;
}
.upload-zone:hover .upload-zone__label,
.upload-zone:focus-within .upload-zone__label {
  border-color: var(--c-sage);
  color: var(--c-sage-dark);
  background: rgba(122,158,126,.05);
}
.upload-zone__label small { font-size: .75rem; opacity: .65; }

.upload-zone__preview {
  width: 100%;
  max-height: 160px;
  object-fit: cover;
  border-radius: 8px;
  border: 1.5px solid var(--c-cream-dark);
  margin-top: .5rem;
}

/* ───────────────────────────────────────────────────
   PHOTOS ADMIN GRID
   ─────────────────────────────────────────────────── */
.photos-admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.photo-admin-item {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--c-cream-dark);
  box-shadow: 0 2px 8px rgba(44,36,22,.08);
  display: flex;
  flex-direction: column;
}

/* Drag handle */
.photo-admin-item__drag {
  position: absolute;
  top: .4rem;
  left: .4rem;
  z-index: 2;
  background: rgba(255,255,255,.85);
  border-radius: 6px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  color: var(--c-muted);
  transition: background .2s;
}
.photo-admin-item__drag:active { cursor: grabbing; }
.photo-admin-item__drag:hover { background: #fff; color: var(--c-text); }

/* Delete button */
.photo-admin-item__delete {
  position: absolute;
  top: .4rem;
  right: .4rem;
  z-index: 2;
  background: rgba(255,255,255,.85);
  border: none;
  border-radius: 6px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--c-muted);
  transition: background .2s, color .2s;
}
.photo-admin-item__delete:hover { background: #fff; color: #c0392b; }

.photo-admin-item__img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  display: block;
}

.photo-admin-item__caption {
  padding: .5rem .6rem;
  background: var(--c-white);
  border: none;
  border-top: 1px solid var(--c-cream-dark);
  font-family: var(--font-sans);
  font-size: .8rem;
  color: var(--c-text);
  width: 100%;
  resize: none;
  min-height: 2.5rem;
  transition: border-color .2s;
}
.photo-admin-item__caption:focus {
  outline: none;
  border-top-color: var(--c-sage);
}
.photo-admin-item__caption::placeholder { color: var(--c-muted); }

/* Dragging state */
.photo-admin-item.is-dragging {
  opacity: .4;
  outline: 2px dashed var(--c-sage);
}

/* ───────────────────────────────────────────────────
   UPLOAD PROGRESS BAR (photos)
   ─────────────────────────────────────────────────── */
.upload-progress {
  margin-bottom: 1rem;
}

.upload-progress__bar {
  height: 6px;
  background: var(--c-cream-dark);
  border-radius: 3px;
  overflow: hidden;
}

.upload-progress__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--c-sage), var(--c-sage-dark));
  border-radius: 3px;
  transition: width .3s ease;
}

.upload-progress__label {
  margin-top: .4rem;
  font-size: .8rem;
  color: var(--c-muted);
}

/* ───────────────────────────────────────────────────
   RIB SECTION
   ─────────────────────────────────────────────────── */
.rib-current {
  display: flex;
  align-items: center;
  gap: .75rem;
  font-size: .875rem;
  margin-bottom: .5rem;
}

.rib-current__label { color: var(--c-muted); }

.rib-current__link {
  color: var(--c-sage-dark);
  font-weight: 500;
  text-decoration: none;
}
.rib-current__link:hover { text-decoration: underline; }

.rib-filename {
  font-size: .8rem;
  color: var(--c-muted);
  margin-top: .4rem;
  display: block;
}

/* ───────────────────────────────────────────────────
   MODALS (complement style.css)
   ─────────────────────────────────────────────────── */
.modal--confirm .modal__inner {
  width: min(420px, 94vw);
}
.modal--confirm p {
  color: var(--c-muted);
  font-size: .9rem;
  margin-bottom: 1.5rem;
  line-height: 1.6;
}
.modal--confirm .modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: .75rem;
}

.modal--admin .modal__inner {
  width: min(640px, 94vw);
  max-height: 90vh;
  overflow-y: auto;
}

/* ───────────────────────────────────────────────────
   LOADING SPINNER
   ─────────────────────────────────────────────────── */
@keyframes spin {
  to { transform: rotate(360deg); }
}

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2.5px solid var(--c-cream-dark);
  border-top-color: var(--c-sage);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}

.spinner--sm {
  width: 14px;
  height: 14px;
  border-width: 2px;
}

/* Button loading state */
.btn.is-loading {
  pointer-events: none;
  opacity: .75;
  position: relative;
}
.btn.is-loading > span { opacity: 0; }
.btn.is-loading::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
/* Ghost button loading */
.btn--ghost.is-loading::after {
  border-color: rgba(74,113,80,.3);
  border-top-color: var(--c-sage-dark);
}

/* ───────────────────────────────────────────────────
   TOAST / NOTIFICATION
   ─────────────────────────────────────────────────── */
.admin-toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  pointer-events: none;
}

.admin-toast__item {
  background: var(--c-dark);
  color: var(--c-white);
  font-size: .875rem;
  padding: .75rem 1.25rem;
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(44,36,22,.18);
  pointer-events: auto;
  animation: toast-in .25s ease;
  max-width: 320px;
  line-height: 1.5;
}
.admin-toast__item.is-success { border-left: 3px solid var(--c-sage); }
.admin-toast__item.is-error   { border-left: 3px solid #c0392b; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ───────────────────────────────────────────────────
   RESPONSIVE
   ─────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .admin-main { padding: 1rem 1rem 3rem; gap: 1rem; }
  .admin-section { padding: 1.25rem; }
  .admin-header { padding: .75rem 1rem; }
  .admin-header__left { gap: .75rem; }
  .admin-header__title { font-size: 1rem; }
  .rsvp-stats { gap: .5rem; }
  .stat-chip { padding: .75rem .5rem; }
  .stat-chip__value { font-size: 1.6rem; }
  .photos-admin-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .photo-admin-item__img { height: 120px; }
}

@media (max-width: 480px) {
  .admin-tabs { gap: 0; }
  .admin-tab-btn { padding: .75rem .9rem; font-size: .8rem; }
  .admin-login__card { padding: 2rem 1.25rem; }
  .admin-section--toolbar { padding: .75rem 1rem; }
}

/* ───────────────────────────────────────────────────
   RESPONSIVE MOBILE — tableau & overflow
   ─────────────────────────────────────────────────── */

/* Empêche le tableau de faire déborder toute la page */
.admin-page,
.admin-dashboard { overflow-x: hidden; }

.admin-section { min-width: 0; overflow: hidden; }

.admin-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  /* Arrondi conservé même avec scroll */
  border-radius: 8px;
}

@media (max-width: 600px) {
  .admin-section { padding: .875rem; }
  .admin-section--toolbar { flex-wrap: wrap; gap: .5rem; }

  /* RSVP : masquer Email, Téléphone, Date (peu utiles dans le tableau) */
  #rsvp-table th:nth-child(2),
  #rsvp-table td:nth-child(2),
  #rsvp-table th:nth-child(3),
  #rsvp-table td:nth-child(3),
  #rsvp-table th:nth-child(7),
  #rsvp-table td:nth-child(7) { display: none; }

  /* Cadeaux : masquer Prix cible, Contributions */
  #gifts-table th:nth-child(2),
  #gifts-table td:nth-child(2),
  #gifts-table th:nth-child(4),
  #gifts-table td:nth-child(4) { display: none; }

  /* Réduire le padding des cellules */
  .admin-table th,
  .admin-table td { padding: .6rem .6rem; font-size: .8rem; }

  /* Boutons d'action : icônes seulement */
  .admin-table__actions { gap: .25rem; }

  /* Toolbar RSVP : boutons empilés */
  .admin-section--toolbar .btn { font-size: .8rem; padding: .45rem .8rem; }
}
