/* CPTS Clovis — interface claire et moderne */

@import url("https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap");

:root {
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-secondary: #475569;
  --muted: #64748b;
  --accent: #0d9488;
  --accent-hover: #0f766e;
  --accent-soft: rgba(13, 148, 136, 0.1);
  --accent-ring: rgba(13, 148, 136, 0.35);
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --ok: #059669;
  --ok-soft: #ecfdf5;
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.1);
  --radius: 12px;
  --radius-lg: 16px;
  --font: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
  --max: 1240px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.55;
  color: var(--text);
  background: var(--surface-2);
  -webkit-font-smoothing: antialiased;
}

/* ——— Accueil ——— */
.page-accueil {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.page-accueil .hero {
  background: linear-gradient(135deg, #f0fdfa 0%, #f8fafc 48%, #ecfeff 100%);
  border-bottom: 1px solid var(--border);
  padding: clamp(2rem, 5vw, 3.5rem) 1.25rem clamp(2rem, 4vw, 2.75rem);
}

.hero-inner {
  max-width: var(--max);
  margin: 0 auto;
  text-align: center;
}

.eyebrow {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 0.75rem;
}

.page-accueil h1 {
  font-size: clamp(1.85rem, 4.5vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin: 0 0 1rem;
  color: var(--text);
}

.lead {
  margin: 0 auto;
  max-width: 38rem;
  font-size: 1.0625rem;
  color: var(--text-secondary);
  line-height: 1.65;
}

.wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
  flex: 1;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: clamp(1.5rem, 3vw, 2rem);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
}

.prose h2 {
  margin: 0 0 0.75rem;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.prose p {
  margin: 0 0 1rem;
  color: var(--text-secondary);
  line-height: 1.65;
}

.prose p:last-child {
  margin-bottom: 0;
}

.ticks {
  margin: 1.25rem 0 0;
  padding-left: 1.35rem;
  color: var(--text-secondary);
  line-height: 1.75;
}

.ticks li::marker {
  color: var(--accent);
}

.tiles {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}

@media (min-width: 720px) {
  .tiles {
    grid-template-columns: repeat(2, 1fr);
  }
}

.tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 1.35rem 1.5rem;
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.tile-primary:hover {
  border-color: var(--accent-ring);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.tile-muted {
  opacity: 0.92;
  cursor: default;
  background: var(--surface-2);
}

.tile-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.tile-title {
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--text);
}

.tile-desc {
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.5;
}

.foot {
  text-align: center;
  padding: 1.5rem 1rem 2rem;
  font-size: 0.8125rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  margin-top: auto;
  background: var(--surface);
}

/* ——— Page adhérents ——— */
.page-adherents {
  min-height: 100vh;
  padding-bottom: 2rem;
}

.page-adherents .wrap {
  padding-top: 1.75rem;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.25rem;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.topbar-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.page-adherents h1 {
  margin: 0;
  font-size: clamp(1.35rem, 3vw, 1.65rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.intro {
  margin: 0 0 1.25rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.55;
  max-width: 52rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  min-height: 2.5rem;
  border-radius: 10px;
  border: none;
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
  color: #fff;
  background: var(--accent);
  box-shadow: var(--shadow-sm);
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover {
  background: var(--accent-hover);
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-ghost {
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border-strong);
  box-shadow: none;
}

.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #b91c1c;
}

.btn-sm {
  min-height: 2rem;
  padding: 0.3rem 0.65rem;
  font-size: 0.8125rem;
  font-weight: 500;
}

.table-wrap {
  overflow: auto;
  max-height: min(70vh, 720px);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.table-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  box-shadow: 0 1px 0 var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

th,
td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  background: var(--surface-2);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

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

tbody tr:hover td {
  background: #fafafa;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge-on {
  background: var(--ok-soft);
  color: var(--ok);
}

.badge-off {
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
}

.badge-admin {
  background: var(--warn-soft);
  color: var(--warn);
}

.row-actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.row-actions button {
  font-size: 0.8125rem;
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.row-actions button:hover {
  background: var(--surface-2);
  border-color: var(--muted);
}

.row-actions button.btn-danger {
  border-color: #fecaca;
  background: var(--danger-soft);
  color: var(--danger);
}

.row-actions button.btn-danger:hover {
  background: #fee2e2;
}

.row-actions button.btn-sm {
  min-height: 2rem;
  padding: 0.35rem 0.7rem;
  font-size: 0.8125rem;
}

.empty {
  padding: 2.5rem 1.5rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.9375rem;
}

/* ——— Modal ——— */
dialog {
  border: none;
  border-radius: var(--radius-lg);
  padding: 0;
  max-width: min(520px, 94vw);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1.15rem 1.35rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.dialog-head h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.dialog-body {
  padding: 1.35rem 1.35rem 0.5rem;
  max-height: min(70vh, 560px);
  overflow-y: auto;
}

.dialog-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  flex-wrap: wrap;
  padding: 1rem 1.35rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
  margin-top: 0.85rem;
}

label:first-of-type {
  margin-top: 0;
}

input[type="text"],
input[type="email"],
input[type="tel"],
select {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.9375rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input::placeholder {
  color: #94a3b8;
}

input:hover,
select:hover {
  border-color: var(--muted);
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.chk-row {
  display: flex;
  gap: 1.5rem;
  margin-top: 1.1rem;
  flex-wrap: wrap;
}

.chk-row label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
}

.chk-row input[type="checkbox"] {
  width: 1.05rem;
  height: 1.05rem;
  accent-color: var(--accent);
}

.msg {
  padding: 0.75rem 1rem;
  border-radius: 10px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  border: 1px solid transparent;
}

.msg-error {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

.msg-loading {
  color: var(--muted);
  background: var(--surface-2);
  border-color: var(--border);
}

/* ——— Modales larges : fiche détail + formulaire (même « masque ») ——— */
dialog.sheet-dialog,
dialog.detail-dialog {
  max-width: min(1200px, 98vw);
  width: 100%;
}

dialog.sheet-dialog form.sheet-form-body {
  display: block;
  margin: 0;
  padding: 0;
  max-height: min(82vh, 720px);
  overflow-y: auto;
}

dialog.sheet-dialog .dialog-actions {
  padding: 1rem 1.5rem 1.25rem;
}

/* Formulaire création / édition : même grille que la fiche lecture */
.sheet-form-body .detail-sheet-body {
  padding: 0 1.5rem 1.15rem;
}

.form-sheet-fields {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.form-sheet-row label {
  margin-top: 0;
  margin-bottom: 0.3rem;
}

.form-sheet-checks {
  margin-top: 0.35rem;
}

.form-sheet-checks .chk-row {
  margin-top: 0;
}

.form-sheet-muted {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding-top: 0.75rem;
  margin-top: 0.25rem;
  border-top: 1px solid var(--border);
}

.form-muted-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.form-muted-value {
  font-size: 0.85rem;
  color: var(--muted);
}

.form-photo-upload {
  margin-top: 1rem;
  width: 100%;
  max-width: min(300px, 100%);
}

.form-upload-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}

.form-photo-upload .file-hint {
  margin-top: 0.35rem;
}

.detail-id-photo-inner .form-photo-preview {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.detail-id-photo-inner .form-photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.detail-id-photo-inner .form-photo-preview img.photo-preview-default,
.detail-id-photo-inner .form-photo-preview img.detail-photo-default {
  object-fit: contain;
  padding: 0.35rem;
  background: var(--surface-2);
}

.detail-sheet-body {
  padding: 0 1.5rem 1.15rem;
  max-height: min(82vh, 720px);
  overflow-y: auto;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) min(300px, 28vw);
  gap: 1.75rem 2rem;
  align-items: start;
}

@media (max-width: 900px) {
  .detail-grid {
    grid-template-columns: 1fr min(280px, 72vw);
  }
}

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

  .detail-col-right {
    order: -1;
    justify-self: center;
    max-width: min(280px, 88vw);
  }
}

.detail-col-left {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}

.detail-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-sm);
  width: 100%;
  min-width: 0;
}

.detail-kicker {
  margin: 0 0 0.75rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.detail-dl {
  margin: 0;
}

.detail-dl-row {
  display: grid;
  grid-template-columns: minmax(5.5rem, 11rem) minmax(0, 1fr);
  gap: 0.5rem 1.25rem;
  align-items: start;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.detail-dl-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.detail-dl-block {
  grid-template-columns: 1fr;
}

.detail-dl-block dt {
  margin-bottom: 0.2rem;
}

.detail-dl-row dt {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.detail-dl-row dd {
  margin: 0;
  color: var(--text);
  font-weight: 500;
  word-break: break-word;
  overflow-wrap: anywhere;
  hyphens: auto;
  min-width: 0;
}

.detail-dl-muted dt,
.detail-dl-muted dd {
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--muted);
}

.detail-id-photo-frame {
  position: sticky;
  top: 0;
  border: 3px solid #1e293b;
  border-radius: 8px;
  padding: 0.45rem 0.5rem 0.65rem;
  background: linear-gradient(180deg, #f1f5f9 0%, #ffffff 45%);
  box-shadow: var(--shadow-md);
}

.detail-id-photo-label {
  display: block;
  text-align: center;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.detail-id-photo-inner {
  aspect-ratio: 35 / 45;
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  overflow: hidden;
}

.detail-id-photo-inner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.detail-id-photo-inner img.detail-photo-default {
  object-fit: contain;
  padding: 0.35rem;
  background: var(--surface-2);
}

tbody tr.row-adherent {
  cursor: pointer;
}

tbody tr.row-adherent:hover td {
  background: #f1f5f9;
}

tbody tr.row-adherent:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

tbody tr.row-adherent .row-actions,
tbody tr.row-adherent .row-actions button {
  cursor: pointer;
}

/* Tableau : e-mails moins contraints */
td.cell-mail {
  word-break: break-word;
  overflow-wrap: anywhere;
  min-width: 14rem;
  max-width: 28rem;
}

/* Civilité & photo */
.field-row {
  display: grid;
  gap: 1rem;
}

@media (min-width: 480px) {
  .field-row.two {
    grid-template-columns: 1fr 2fr;
  }
}

input[type="file"] {
  width: 100%;
  padding: 0.5rem 0;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.file-hint {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.photo-preview-wrap {
  margin-top: 0.75rem;
}

.photo-preview-wrap img {
  max-width: 120px;
  max-height: 120px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--border);
  display: block;
}

.photo-preview-wrap img.photo-preview-default {
  object-fit: contain;
  background: var(--surface-2);
}

.avatar-cell {
  width: 3rem;
  padding: 0.5rem 0.65rem !important;
}

.avatar-thumb {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--border);
  display: block;
  background: var(--surface-2);
}

.avatar-thumb.avatar-thumb-default {
  object-fit: contain;
  padding: 2px;
}

.avatar-placeholder {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
}

.civ-badge {
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
}
