/* ============================================================
   Mots doux — feuille de style principale
   Palette : crème #f7f3ec, vert forêt #3a6647 (marque),
             vert #2e8060 (interactif), terracotta #c25a3e (badge)
   ============================================================ */

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

:root {
  --bg:           #f7f3ec;
  --surface:      #ffffff;
  --green:        #2e8060;   /* couleur interactive principale */
  --green-dark:   #22614a;   /* hover / focus */
  --green-brand:  #3a6647;   /* logo, illustration login */
  --green-light:  #b0cbb8;   /* avatar lu */
  --green-pale:   #ddf2ea;   /* fond message non lu */
  --text:         #2a1f17;
  --text-muted:   #9a8e84;
  --badge:        #c25a3e;   /* pastille non-lus */
  --border:       #e5ddd3;
  --shadow:       rgba(42, 31, 23, 0.07);
  --r-sm:         8px;
  --r-md:         14px;
  --r-lg:         20px;
  --appbar-h:     60px;
  --nav-h:        62px;
}

/* ---- Base ---- */
html { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100%;
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select {
  font-family: inherit;
  font-size: inherit;
}
:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

/* ============================================================
   LAYOUT
   ============================================================ */

.appbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--appbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 6px var(--shadow);
}
.appbar-inner {
  max-width: 640px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
}
.appbar-brand { display: flex; align-items: center; gap: 10px; }
.appbar-icon {
  width: 36px; height: 36px;
  background: var(--green);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.appbar-icon svg { width: 20px; height: 20px; }
.appbar-name {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 18px;
  color: var(--text);
  letter-spacing: 0.01em;
}
.appbar-right { display: flex; align-items: center; gap: 10px; }

/* cloche notif */
.notif-btn {
  position: relative;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--green-pale);
  border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.notif-btn svg { width: 18px; height: 18px; stroke: var(--green); fill: none; }
.notif-badge {
  position: absolute;
  top: -2px; right: -2px;
  min-width: 17px; height: 17px;
  background: var(--badge);
  border: 2px solid var(--surface);
  border-radius: 999px;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px;
}

/* avatar utilisateur */
.avatar-btn {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-family: Georgia, serif;
  font-size: 15px;
  font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

/* zone de contenu */
.content {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 14px calc(var(--nav-h) + 76px);
}
/* pages sans nav (login) */
.content--full {
  max-width: 420px;
  margin: 0 auto;
  padding: 0 16px 40px;
}

/* navigation basse */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 100;
  height: var(--nav-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.bnav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-muted);
  font-size: 10px;
  letter-spacing: 0.03em;
  position: relative;
  cursor: pointer;
  padding-bottom: 2px;
}
.bnav-item.active { color: var(--green); }
.bnav-item svg { width: 20px; height: 20px; }
.bnav-badge {
  position: absolute;
  top: 8px; right: calc(50% - 18px);
  min-width: 16px; height: 16px;
  background: var(--badge);
  border-radius: 999px;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px;
}

/* bouton flottant écrire */
.fab {
  position: fixed;
  bottom: calc(var(--nav-h) + 14px);
  right: 18px;
  z-index: 101;
  width: 54px; height: 54px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-size: 28px;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 18px rgba(46, 128, 96, 0.40);
  border: none;
  cursor: pointer;
  text-decoration: none;
}
.fab:hover { background: var(--green-dark); }

/* ============================================================
   BOUTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 22px;
  border-radius: var(--r-sm);
  font-size: 15px;
  cursor: pointer;
  border: none;
  transition: background 0.15s, border-color 0.15s;
}
.btn-primary {
  background: var(--green);
  color: #fff;
  font-family: Georgia, serif;
  letter-spacing: 0.02em;
  box-shadow: 0 2px 10px rgba(46, 128, 96, 0.28);
}
.btn-primary:hover { background: var(--green-dark); }
.btn-secondary {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg); }
.btn-danger {
  background: #c0392b;
  color: #fff;
}
.btn-danger:hover { background: #a93226; }
.btn-full { width: 100%; }

/* ============================================================
   FORMULAIRES
   ============================================================ */
.field { margin-bottom: 18px; }
.field label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 7px;
}
.field-opt { text-transform: none !important; font-style: italic; font-size: 11px; }
.field input,
.field textarea,
.field select {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.18s;
  resize: none;
}
.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--green);
  background: #fff;
}
.field textarea.body-area {
  min-height: 200px;
  font-family: Georgia, serif;
  line-height: 1.75;
}
.field-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 5px;
  font-style: italic;
  text-align: right;
}

/* message d'erreur */
.alert-error {
  background: #fdf0ee;
  border: 1px solid #e8b4aa;
  color: #8b3a2e;
  border-radius: var(--r-sm);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 18px;
}

/* ============================================================
   PAGE LOGIN
   ============================================================ */
.login-illustration {
  background: linear-gradient(150deg, #1e4f32 0%, var(--green-brand) 55%, #5a8a6a 100%);
  padding: 44px 32px 36px;
  text-align: center;
  position: relative;
  overflow: hidden;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}
.login-illustration::before {
  content: '';
  position: absolute;
  width: 220px; height: 220px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.10);
  top: -70px; right: -70px;
}
.login-illustration::after {
  content: '';
  position: absolute;
  width: 160px; height: 160px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.08);
  bottom: -50px; left: -40px;
}
.login-logo-box {
  width: 68px; height: 68px;
  background: rgba(255,255,255,0.15);
  border-radius: 20px;
  margin: 0 auto 16px;
  display: flex; align-items: center; justify-content: center;
  position: relative; z-index: 1;
}
.login-logo-box svg { width: 38px; height: 38px; }
.login-title {
  font-family: Georgia, serif;
  font-size: 28px;
  color: #fff;
  letter-spacing: 0.02em;
  margin-bottom: 6px;
  position: relative; z-index: 1;
}
.login-subtitle {
  font-size: 14px;
  color: rgba(255,255,255,0.68);
  font-style: italic;
  position: relative; z-index: 1;
}
.login-form {
  background: var(--surface);
  padding: 28px 28px 24px;
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  border: 1px solid var(--border);
  border-top: none;
}
.login-card {
  margin-top: 32px;
  border-radius: var(--r-lg);
  box-shadow: 0 6px 30px var(--shadow), 0 0 0 1px var(--border);
  overflow: hidden;
}

/* ============================================================
   CARTES DE MESSAGES (liste inbox / envoyés / recherche)
   ============================================================ */
.msg-list { display: flex; flex-direction: column; gap: 10px; }

.msg-card {
  background: var(--surface);
  border-radius: var(--r-md);
  box-shadow: 0 1px 6px var(--shadow);
  padding: 14px 16px;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
  position: relative;
  overflow: hidden;
  display: block;
  color: var(--text);
}
.msg-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 14px var(--shadow);
}
.msg-card.unread {
  background: var(--green-pale);
}
.msg-card.unread::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--green);
  border-radius: var(--r-md) 0 0 var(--r-md);
}

.msg-card-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 6px;
}
.msg-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--green-light);
  color: var(--green-brand);
  font-family: Georgia, serif;
  font-size: 14px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.msg-card.unread .msg-avatar {
  background: var(--green);
  color: #fff;
}
.msg-card-meta { flex: 1; min-width: 0; }
.msg-card-title {
  font-family: Georgia, serif;
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.msg-card.unread .msg-card-title {
  font-weight: 700;
  color: var(--green);
}
.msg-card-date {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
  white-space: nowrap;
  padding-top: 2px;
}
.msg-card-preview {
  font-size: 13px;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.5;
  padding-left: 42px;
}
.msg-card.unread .msg-card-preview { color: var(--text); }
.unread-pip {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--badge);
  flex-shrink: 0;
  margin-top: 6px;
}

/* actions sur cartes envoyées */
.msg-card-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.msg-card-actions a,
.msg-card-actions button {
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  text-decoration: none;
  transition: background 0.12s;
}
.msg-card-actions a:hover    { background: var(--bg); }
.msg-card-actions button:hover { background: #fdf0ee; color: #8b3a2e; border-color: #e8b4aa; }

/* badge direction (reçu/envoyé dans search) */
.direction-badge {
  display: inline-block;
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-radius: 4px;
  padding: 2px 7px;
  margin-left: 6px;
  vertical-align: middle;
}
.direction-badge.received { background: var(--green-pale);  color: var(--green); }
.direction-badge.sent     { background: #f5f0e8; color: var(--text-muted); }

/* ============================================================
   PAGE DE LECTURE D'UN MESSAGE
   ============================================================ */
.message-header {
  margin-bottom: 20px;
}
.message-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
  cursor: pointer;
}
.message-back:hover { color: var(--green); }
.message-title {
  font-family: Georgia, serif;
  font-size: 22px;
  color: var(--text);
  line-height: 1.3;
  margin-bottom: 8px;
}
.message-notitle {
  font-family: Georgia, serif;
  font-size: 22px;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 8px;
}
.message-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
}
.message-body {
  background: var(--surface);
  border-radius: var(--r-md);
  padding: 22px 20px;
  font-family: Georgia, serif;
  font-size: 16px;
  line-height: 1.8;
  color: var(--text);
  box-shadow: 0 1px 6px var(--shadow);
  word-break: break-word;
}

/* ============================================================
   PAGE ÉCRITURE / ÉDITION
   ============================================================ */
.compose-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.compose-back {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text);
  font-size: 18px;
  flex-shrink: 0;
  text-decoration: none;
}
.compose-header-info h1 {
  font-family: Georgia, serif;
  font-size: 18px;
  color: var(--green);
  margin-bottom: 2px;
}
.compose-header-info p { font-size: 12px; color: var(--text-muted); }
.recipient-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--green-pale);
  color: var(--green);
  border: 1px solid rgba(46,128,96,0.28);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  margin-left: auto;
  flex-shrink: 0;
}
.recipient-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--green);
}
.compose-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 4px;
}

/* ============================================================
   RECHERCHE
   ============================================================ */
.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}
.search-bar input {
  flex: 1;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  font-size: 15px;
  outline: none;
  transition: border-color 0.18s;
}
.search-bar input:focus { border-color: var(--green); }
.search-bar button {
  padding: 11px 18px;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 14px;
}
.search-bar button:hover { background: var(--green-dark); }
.search-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-style: italic;
  font-size: 14px;
}

/* ============================================================
   EXPORT
   ============================================================ */
.export-card {
  background: var(--surface);
  border-radius: var(--r-md);
  box-shadow: 0 1px 6px var(--shadow);
  padding: 24px 20px 20px;
}
.export-card h2 {
  font-family: Georgia, serif;
  font-size: 17px;
  color: var(--text);
  margin-bottom: 4px;
}
.export-card .sub { font-size: 13px; color: var(--text-muted); margin-bottom: 22px; }
.radio-group { display: flex; flex-direction: column; gap: 10px; margin-bottom: 4px; }
.radio-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  cursor: pointer;
}
.radio-label input[type="radio"] { width: 16px; height: 16px; accent-color: var(--green); }
.date-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.date-row .field { margin-bottom: 0; }
.section-title {
  font-size: 11px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 20px 0 10px;
}

/* ============================================================
   PAGE PROFIL / DÉCONNEXION
   ============================================================ */
.profile-card {
  background: var(--surface);
  border-radius: var(--r-md);
  box-shadow: 0 1px 6px var(--shadow);
  padding: 28px 20px 24px;
  text-align: center;
}
.profile-avatar {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-family: Georgia, serif;
  font-size: 28px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 14px;
}
.profile-username {
  font-family: Georgia, serif;
  font-size: 20px;
  margin-bottom: 4px;
}
.profile-sub { font-size: 13px; color: var(--text-muted); margin-bottom: 24px; }

/* ============================================================
   CONFIRMATION SUPPRESSION
   ============================================================ */
.confirm-card {
  background: var(--surface);
  border-radius: var(--r-md);
  box-shadow: 0 1px 6px var(--shadow);
  padding: 28px 20px 24px;
}
.confirm-card h2 {
  font-family: Georgia, serif;
  font-size: 18px;
  margin-bottom: 8px;
  color: var(--text);
}
.confirm-card p { font-size: 14px; color: var(--text-muted); margin-bottom: 20px; }
.confirm-preview {
  background: var(--bg);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  font-family: Georgia, serif;
  font-size: 14px;
  font-style: italic;
  color: var(--text-muted);
  margin-bottom: 24px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}
.confirm-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ============================================================
   PAGE VIDE / 404
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 52px 20px;
  color: var(--text-muted);
}
.empty-state svg {
  width: 48px; height: 48px;
  margin-bottom: 14px;
  opacity: 0.4;
}
.empty-state p { font-size: 14px; font-style: italic; }

/* ============================================================
   EN-TÊTES DE SECTION
   ============================================================ */
.page-heading {
  font-family: Georgia, serif;
  font-size: 18px;
  color: var(--text);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.page-heading .badge-count {
  background: var(--badge);
  color: #fff;
  font-family: system-ui, sans-serif;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  padding: 2px 8px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (min-width: 520px) {
  .content { padding: 20px 24px calc(var(--nav-h) + 80px); }
  .date-row { grid-template-columns: 1fr 1fr; }
}
