/* =========================================================================
   Charte graphique — traduite de la maquette « Altis Conseil » (état studio).
   Registre éditorial : accent violet, titres serif (Cormorant Garamond),
   corps sans-serif moderne (Manrope), surfaces claires légèrement violacées,
   arrondis doux et ombres diffuses. Polices embarquées via fonts.css.
   ========================================================================= */

:root {
  color-scheme: light;

  /* Marque / accent (violet) */
  --accent: #7a48d8;
  --accent-soft: #5812f8;
  --accent-bg: rgba(122, 72, 216, 0.12);
  --accent-brd: rgba(122, 72, 216, 0.45);
  --grad: linear-gradient(135deg, #4a0cd6, #8b5cf6);

  /* Fonds & surfaces */
  --bg: #f5f3f9;
  --panel: #fcfcfd;
  --panel2: #f7f6fa;
  --panel-hi: #ebe7f4;

  /* Bordures */
  --border: #d8d3e4;
  --border2: #e3dfec;

  /* Texte */
  --text: #1d1434;
  --muted: #605676;
  --faint: #726b83;
  --nav: #473d5c;

  /* États */
  --ok: #3e7a0c;
  --ok-bg: rgba(101, 163, 13, 0.13);
  --warn: #a15c07;
  --warn-bg: rgba(217, 119, 6, 0.12);
  --error: #c02626;
  --error-bg: rgba(220, 38, 38, 0.10);

  /* En-tête sombre (barre de marque) */
  --header-bg: #1d1434;

  /* Ombres */
  --shadow: rgba(30, 25, 50, 0.12);
  --shadow-card: 0 8px 22px rgba(30, 25, 50, 0.10);

  /* Rythme */
  --radius: 12px;
  --radius-sm: 9px;
  --radius-pill: 999px;

  /* Typographie */
  --font-body: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Cormorant Garamond", Georgia, "Times New Roman", serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 1rem/1.55 var(--font-body);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: 0.01em;
  color: var(--text);
}

h1 {
  font-size: 2rem;
  margin: 0 0 0.25rem;
}

h2 {
  font-size: 1.5rem;
}

a {
  color: var(--accent-soft);
}

/* ---- En-tête du site --------------------------------------------------- */

.site-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.9rem 1.25rem;
  background: var(--header-bg);
  color: #fff;
  box-shadow: 0 2px 14px rgba(30, 25, 50, 0.25);
}

.site-header a {
  color: #fff;
  text-decoration: none;
}

.brand {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.site-header nav {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.site-header nav a {
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.95rem;
  transition: background-color 0.15s ease;
}

.site-header nav a:hover {
  background: rgba(255, 255, 255, 0.12);
}

.site-header form {
  margin-left: auto;
}

.site-header button {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.22);
  color: #fff;
}

.site-header button:hover {
  background: rgba(255, 255, 255, 0.24);
}

/* ---- Contenu principal ------------------------------------------------- */

main {
  width: min(72rem, 100% - 2rem);
  margin: 2rem auto;
}

.page-heading {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: end;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.page-heading p {
  color: var(--faint);
  margin: 0;
  font-size: 0.9rem;
}

/* ---- Cartes & chronologie ---------------------------------------------- */

.timeline,
.day-group {
  display: grid;
  gap: 1rem;
}

.message {
  background: linear-gradient(165deg, var(--panel), var(--panel2));
  padding: 1.1rem 1.2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  overflow-wrap: anywhere;
}

.message header {
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
  flex-wrap: wrap;
  margin-bottom: 0.4rem;
}

.message header strong {
  font-weight: 700;
}

.message time {
  font-variant-numeric: tabular-nums;
  color: var(--faint);
  font-size: 0.9rem;
}

.badge {
  background: var(--accent-bg);
  color: var(--accent-soft);
  padding: 0.12rem 0.55rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--accent-brd);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.message small {
  color: var(--faint);
  font-size: 0.78rem;
}

/* ---- Carte d'authentification ------------------------------------------ */

.auth-card {
  max-width: 30rem;
  margin: 6vh auto;
  background: linear-gradient(165deg, var(--panel), var(--panel2));
  padding: 2.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}

/* ---- Formulaires ------------------------------------------------------- */

.auth-card form,
.search-form,
.compact-form {
  display: grid;
  gap: 0.75rem;
}

label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

input,
select,
button {
  font: inherit;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel2);
  color: var(--text);
}

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

button {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.15s ease;
}

button:hover {
  filter: brightness(1.08);
}

/* Boutons « fantômes » (aperçu) : contour accent sur fond clair */
.preview-button {
  background: var(--panel);
  color: var(--accent-soft);
  border: 1px solid var(--accent-brd);
}

.preview-button:hover {
  background: var(--accent-bg);
  filter: none;
}

/* ---- Pièces jointes ---------------------------------------------------- */

.attachment {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.attachment a {
  display: inline-block;
  padding: 0.5rem 0.8rem;
  border: 1px solid var(--accent-brd);
  border-radius: var(--radius-sm);
  color: var(--accent-soft);
  text-decoration: none;
  font-weight: 600;
}

.attachment a:hover {
  background: var(--accent-bg);
}

audio {
  width: 100%;
  margin: 0.5rem 0;
}

/* ---- États ------------------------------------------------------------- */

.error {
  color: var(--error);
  background: var(--error-bg);
  border: 1px solid rgba(220, 38, 38, 0.35);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

.notice {
  color: var(--warn);
  background: var(--warn-bg);
  border: 1px solid rgba(217, 119, 6, 0.35);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
}

/* ---- Navigation de pages ----------------------------------------------- */

.pagination,
.period-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin: 1.5rem 0;
}

.pagination a,
.period-nav a {
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--accent-soft);
  text-decoration: none;
  font-weight: 600;
}

.pagination a:hover,
.period-nav a:hover {
  border-color: var(--accent-brd);
  background: var(--accent-bg);
}

.summary-form {
  margin-top: 2rem;
}

/* ---- Synthèse ---------------------------------------------------------- */

main > section {
  background: linear-gradient(165deg, var(--panel), var(--panel2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  margin: 1rem 0;
  box-shadow: var(--shadow-card);
}

main > section h2 {
  margin-top: 0;
}

/* ---- Focus visible global ---------------------------------------------- */

a:focus-visible,
button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* ---- Modale d'aperçu --------------------------------------------------- */

dialog {
  width: min(64rem, calc(100% - 2rem));
  height: min(48rem, calc(100% - 2rem));
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 24px 60px rgba(30, 25, 50, 0.35);
}

dialog::backdrop {
  background: rgba(29, 20, 52, 0.55);
}

.preview-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.preview-heading h2 {
  margin: 0;
  font-size: 1.3rem;
}

.preview-heading button {
  background: var(--panel2);
  color: var(--muted);
  border: 1px solid var(--border);
}

.preview-heading button:hover {
  background: var(--panel-hi);
  filter: none;
}

#document-preview-frame {
  width: 100%;
  height: calc(100% - 7rem);
  margin-top: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
}

/* ---- Responsive (mobile-first descendant) ------------------------------ */

@media (max-width: 48rem) {
  main {
    width: min(72rem, 100% - 1.5rem);
    margin: 1.25rem auto;
  }

  .site-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.6rem;
  }

  .site-header form {
    margin-left: 0;
  }

  .site-header nav {
    width: 100%;
  }

  .page-heading {
    align-items: stretch;
  }

  .compact-form,
  .search-form {
    width: 100%;
  }

  h1 {
    font-size: 1.6rem;
  }
}

@media (max-width: 30rem) {
  main {
    width: calc(100% - 1rem);
    margin: 1rem 0.5rem;
  }

  .message {
    padding: 0.9rem 0.95rem;
  }

  .site-header nav a {
    padding: 0.5rem 0.6rem;
  }

  /* Cibles tactiles confortables sur les liens de pagination/pièces jointes */
  .pagination a,
  .period-nav a,
  .attachment a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
}
