/* ============================================================
   LAYOUT V2 — Design system Moreen (patient mobile / pro tablette)
   Tokens : css/variables.css (chargé via reset.css)
   ============================================================ */

/* ============================================================
   LAYOUT COMMUN (landing, auth)
   ============================================================ */

.layout-centered {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.layout-centered .site-header {
  border-bottom: 1px solid var(--color-border);
  padding: var(--gap-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(6px);
}

.layout-centered .site-main {
  flex: 1;
  padding: var(--gap-lg) var(--gap-md);
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
  background: var(--gradient-page);
}

.layout-centered .site-footer {
  border-top: 1px solid var(--color-border);
  padding: var(--gap-md);
  text-align: center;
  font-size: 14px;
  color: var(--color-text-muted);
  background: rgba(255, 255, 255, 0.8);
}

/* ============================================================
   LAYOUT PATIENT — Mobile first (max 428px)
   ============================================================ */

.layout-patient {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: var(--max-patient);
  margin: 0 auto;
  position: relative;
  border-left: 1px solid var(--color-border-subtle);
  border-right: 1px solid var(--color-border-subtle);
  background: var(--gradient-page);
}

.layout-patient .page-header {
  position: sticky;
  top: 0;
  z-index: 10;
  height: var(--header-height);
  padding: 0 var(--gap-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--color-border);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(6px);
}

.layout-patient .page-header .header-title {
  font-size: 17px;
  font-weight: 600;
}

.layout-patient .page-header .header-back {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  font-size: 15px;
}

/* Cloche notifications — pastille « non lues » (prototype)
   Boîte 22×22 explicite : évite sur Safari iOS que la pastille reste en flux
   (affichée sous l’icône) faute de bloc de positionnement fiable sur <a>. */
.layout-patient .notification-bell-wrap {
  position: relative;
  display: inline-block;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  overflow: visible;
  color: var(--color-text);
  text-decoration: none;
  line-height: 0;
  vertical-align: middle;
}

.layout-patient .notification-bell-wrap svg {
  width: 22px;
  height: 22px;
  display: block;
}

.layout-patient .notification-bell-wrap:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: 4px;
}

.layout-patient .notification-badge {
  position: absolute;
  top: -5px;
  right: -7px;
  left: auto;
  bottom: auto;
  z-index: 1;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--color-primary);
  color: var(--color-white);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  border: 2px solid var(--color-white);
  box-sizing: border-box;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.layout-patient .page-content {
  flex: 1;
  padding: var(--gap-md);
  padding-bottom: calc(var(--bottom-nav-height) + var(--gap-md));
  overflow-y: auto;
}

/* Barre de navigation bas — patient */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--max-patient);
  height: var(--bottom-nav-height);
  display: flex;
  border-top: 2px solid var(--color-border);
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.97) 0%,
    rgba(246, 249, 238, 0.95) 100%
  );
  backdrop-filter: blur(8px);
  z-index: 100;
  box-shadow: 0 -6px 20px rgba(57, 79, 34, 0.08);
}

.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 0;
  font-size: 11px;
  gap: 3px;
  color: var(--color-text-muted);
  border-right: 1px solid var(--color-border-subtle);
}

.bottom-nav a:last-child {
  border-right: none;
}

.bottom-nav a.active {
  color: var(--color-primary);
  font-weight: 600;
  border-top: 2px solid var(--color-primary);
  margin-top: -2px;
}

/* ============================================================
   LAYOUT PRO — Tablette paysage : pleine largeur viewport
   ============================================================ */

.layout-pro {
  display: flex;
  min-height: 100vh;
  width: 100%;
  max-width: none;
  margin: 0;
  border-left: none;
  border-right: none;
  background: var(--gradient-page);
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(8px);
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed);
  overflow-x: hidden;
}

.sidebar-brand {
  height: var(--header-height);
  padding: 0 var(--gap-md);
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--color-border);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

.sidebar.collapsed .sidebar-brand {
  justify-content: center;
  font-size: 14px;
}

.sidebar-nav {
  flex: 1;
  padding: var(--gap-sm) 0;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px var(--gap-md);
  font-size: 14px;
  color: var(--color-text);
  border-left: 3px solid transparent;
}

.sidebar-nav a.active {
  font-weight: 600;
  color: var(--color-primary);
  border-left-color: var(--color-primary);
  background: linear-gradient(90deg, rgba(111, 140, 55, 0.16) 0%, rgba(237, 243, 223, 0.72) 100%);
  box-shadow: inset 0 0 0 1px rgba(95, 122, 47, 0.14);
}

/* Entrées non disponibles (prototype) */
.sidebar-nav a.sidebar-nav-soon {
  opacity: 0.72;
  cursor: help;
}

.sidebar.collapsed .sidebar-nav a span {
  display: none;
}

.sidebar.collapsed .sidebar-nav a {
  justify-content: center;
  padding: 11px 0;
}

.sidebar-toggle {
  padding: var(--gap-md);
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--color-text-muted);
  cursor: pointer;
  flex-shrink: 0;
}

/* Icônes réduire / agrandir : en mode réduit, pas de libellé (évite « Rédu » coupé) */
.sidebar-toggle-icon--expand {
  display: none;
}
.sidebar.collapsed .sidebar-toggle-icon--collapse {
  display: none;
}
.sidebar.collapsed .sidebar-toggle-icon--expand {
  display: block;
}
.sidebar.collapsed .sidebar-toggle-label {
  display: none;
}
.sidebar.collapsed .sidebar-toggle {
  justify-content: center;
  padding: 12px 6px;
  gap: 0;
}

.sidebar-footer {
  padding: var(--gap-md);
  border-top: 1px solid var(--color-border);
  font-size: 13px;
  flex-shrink: 0;
}

/* Pied sidebar réduit : masquer les textes longs, initiales + icône déconnexion */
.sidebar-footer-avatar {
  display: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-primary-soft);
  color: var(--color-primary);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 1;
}
.sidebar.collapsed .sidebar-footer-main {
  display: none;
}
.sidebar.collapsed .sidebar-footer-avatar {
  display: flex;
}
.sidebar.collapsed .sidebar-footer {
  padding: 10px 6px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}

.sidebar-footer-logout {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: var(--color-text-muted);
  font-size: 12px;
}
.sidebar-footer-logout:hover {
  color: var(--color-text);
}
.sidebar-footer-logout-icon {
  display: none;
  flex-shrink: 0;
}
.sidebar.collapsed .sidebar-footer-logout-icon {
  display: block;
}
.sidebar.collapsed .sidebar-footer-logout-text {
  border: 0;
  clip: rect(0 0 0 0);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 1px;
}
.sidebar.collapsed .sidebar-footer-logout {
  position: relative;
  justify-content: center;
  padding: 8px;
  border-radius: 10px;
  color: var(--color-text-muted);
  min-width: 36px;
  min-height: 36px;
  box-sizing: border-box;
}
.sidebar.collapsed .sidebar-footer-logout:hover {
  background: var(--color-surface-hover);
  color: var(--color-text);
}
.sidebar-footer-logout-wrap {
  margin-top: 8px;
}
.sidebar.collapsed .sidebar-footer-logout-wrap {
  margin-top: 0;
}

/* Contenu principal pro */
.layout-pro .main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.main-header {
  height: var(--header-height);
  padding: 0 var(--gap-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(6px);
}

/* En-tête pro : reste visible au scroll de la colonne .main-content */
.layout-pro .main-header {
  position: sticky;
  top: 0;
  z-index: 20;
}

/* Pro — recherche rapide patient (autocomplete, header) */
.pro-patient-quick-search {
  position: relative;
  flex: 0 1 200px;
  min-width: 0;
  max-width: min(220px, 100%);
}

.pro-patient-quick-search__label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.pro-patient-quick-search__input {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 10px;
  min-height: 34px;
  border: 1px solid var(--color-border-dark);
  border-radius: 10px;
  font-size: 13px;
  font-family: inherit;
  line-height: 1.25;
  background: var(--color-white);
  color: var(--color-text);
  -webkit-appearance: none;
  appearance: none;
}

.pro-patient-quick-search__input::-webkit-search-decoration,
.pro-patient-quick-search__input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.layout-pro .main-header select {
  padding: 6px 30px 6px 10px;
  min-height: 34px;
  max-width: min(280px, 100%);
  box-sizing: border-box;
  border: 1px solid var(--color-border-dark);
  border-radius: 10px;
  font-size: 13px;
  font-family: inherit;
  line-height: 1.25;
  color: var(--color-text);
  background-color: var(--color-white);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236a7663' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 14px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.btn-moreen-header {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  min-height: 34px;
  box-sizing: border-box;
  border: 1px solid var(--color-border-dark);
  border-radius: 10px;
  background: var(--color-white);
  color: var(--color-text);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  line-height: 1.2;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.btn-moreen-header:hover {
  background: var(--color-bg-light);
}

.pro-header-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  box-sizing: border-box;
  border: 1px solid var(--color-border-dark);
  border-radius: 10px;
  background: var(--color-white);
  color: var(--color-text);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.pro-header-icon-btn svg {
  display: block;
}

.pro-patient-quick-search__list {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  margin-top: 2px;
  max-height: 280px;
  overflow-y: auto;
  list-style: none;
  padding: 0;
  margin: 0;
  border: 1px solid var(--color-border);
  background: var(--color-white);
  z-index: 30;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.pro-patient-quick-search__option {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 6px;
  padding: 12px 10px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid var(--color-border-subtle);
}

.pro-patient-quick-search__option:last-child {
  border-bottom: none;
}

.pro-patient-quick-search__option:hover,
.pro-patient-quick-search__option--active {
  background: var(--color-surface-hover);
}

.pro-patient-quick-search__option-name {
  font-weight: 600;
  color: var(--color-text-strong);
}

.pro-patient-quick-search__option-meta {
  font-size: 12px;
  color: var(--color-text-muted);
}

/* Déconnexion : visible seulement en vue ≤768px (à côté de la cloche / actions) */
.header-logout-mobile {
  display: none;
}

.main-body {
  flex: 1;
  padding: var(--gap-lg);
}

/* ============================================================
   COMPOSANTS STRUCTURELS COMMUNS
   ============================================================ */

/* Section avec titre */
.section-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  margin-bottom: var(--gap-sm);
}

/* Carte */
.card {
  border: 1px solid var(--color-border);
  padding: var(--gap-md);
  margin-bottom: var(--gap-md);
  background: var(--gradient-surface-warm);
  border-radius: 14px;
  box-shadow: var(--shadow-card);
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
}

.card-body {
  font-size: 14px;
  color: var(--color-text);
}

/* Grille 2 colonnes */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap-md);
}

/* Grille bi-colonnes (pro) */
.col-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap-lg);
}

/* Boutons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--gap-sm);
  padding: 10px 20px;
  font-size: 15px;
  font-weight: 500;
  font-family: inherit;
  line-height: 1.25;
  color: var(--color-text);
  text-decoration: none;
  border: 1px solid var(--color-border-dark);
  cursor: pointer;
  background: var(--color-white);
  border-radius: 12px;
  -webkit-appearance: none;
  appearance: none;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

a.btn:link,
a.btn:visited {
  color: var(--color-text);
}

.btn:hover {
  background: var(--color-primary-soft);
  border-color: var(--color-primary);
}

.btn:active {
  transform: translateY(1px);
}

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

.btn-primary {
  background: var(--gradient-primary);
  color: var(--color-white);
  border-color: var(--color-primary);
  box-shadow: var(--shadow-soft);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #658232 0%, #557027 60%, #465f22 100%);
  border-color: var(--color-primary-hover);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-full {
  width: 100%;
}

/* Badge statut */
.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--color-border);
}

.badge-confirmed {
  border-color: var(--color-success);
  background: rgba(63, 138, 90, 0.14);
  color: var(--color-success-dark);
}
.badge-pending {
  border-color: var(--color-warning);
  color: var(--color-warning);
  background: rgba(176, 123, 44, 0.12);
}
.badge-cancelled {
  border-color: var(--color-border);
  color: var(--color-border-dark);
  background: var(--color-surface-subtle);
  text-decoration: line-through;
}

/* Formulaires */
.form-group {
  margin-bottom: var(--gap-md);
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 4px;
  color: var(--color-text);
}

.form-input {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  font-size: 15px;
  background: var(--color-white);
  border-radius: 10px;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.form-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(95, 122, 47, 0.14);
}

/* Tabs (structure) */
.tabs-header {
  display: flex;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--gap-md);
}

.tab-btn {
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  transition: color 160ms ease, border-color 160ms ease;
}

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

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* Accordéon */
.accordion-item {
  border: 1px solid var(--color-border);
  margin-bottom: var(--gap-sm);
  border-radius: 12px;
  overflow: hidden;
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
}

.accordion-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--gap-md);
  font-size: 15px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  background: var(--color-white);
  border: none;
}

.accordion-content {
  display: none;
  padding: 0 var(--gap-md) var(--gap-md);
  font-size: 14px;
  color: var(--color-text);
  border-top: 1px solid var(--color-border-subtle);
}

.accordion-item.open .accordion-content {
  display: block;
}

.accordion-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--color-text-muted);
  transition: transform 0.2s ease;
}

.accordion-chevron svg {
  display: block;
  width: 14px;
  height: 14px;
}

.accordion-item.open .accordion-chevron {
  transform: rotate(180deg);
}

/* Filtres chips */
.filter-chips {
  display: flex;
  gap: var(--gap-sm);
  overflow-x: auto;
  padding-bottom: var(--gap-sm);
  margin-bottom: var(--gap-md);
}

.chip {
  flex-shrink: 0;
  padding: 6px 14px;
  font-size: 13px;
  border: 1px solid var(--color-border);
  cursor: pointer;
  background: var(--color-white);
  white-space: nowrap;
  border-radius: 999px;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}

.chip:hover {
  background: var(--color-primary-soft);
  border-color: var(--color-primary);
}

.chip.active {
  background: var(--color-primary);
  color: var(--color-white);
  border-color: var(--color-primary);
}

/* Séparateur */
.divider {
  border: none;
  border-top: 1px solid var(--color-border-subtle);
  margin: var(--gap-md) 0;
}

/* Stat box */
.stat-box {
  border: 1px solid var(--color-border);
  padding: var(--gap-md);
  text-align: center;
  border-radius: 12px;
  background: var(--gradient-surface-warm);
  box-shadow: var(--shadow-card);
}

.stat-number {
  font-size: 28px;
  font-weight: 700;
  display: block;
}

.stat-label {
  font-size: 12px;
  color: var(--color-text-muted);
}

/* Agenda grid pro */
.agenda-grid {
  display: grid;
  grid-template-columns: 60px repeat(7, 1fr);
  border: 1px solid var(--color-border);
  overflow-x: auto;
}

.agenda-cell {
  border-right: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border-subtle);
  padding: 4px;
  min-height: 48px;
  font-size: 12px;
}

.agenda-cell:last-child {
  border-right: none;
}

.agenda-col-header {
  border-right: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  padding: 8px 4px;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  background: var(--color-bg-light);
}

.agenda-time-label {
  font-size: 11px;
  color: var(--color-border-dark);
  text-align: right;
  padding: 4px 8px;
  background: var(--color-bg-light);
}

.agenda-appt {
  border: 1px solid var(--color-border-dark);
  padding: 3px 5px;
  font-size: 11px;
  background: var(--color-border-subtle);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* Slots de créneau */
.slots-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--gap-sm);
  margin-bottom: var(--gap-md);
}

.slot-btn {
  padding: 10px;
  border: 1px solid var(--color-border);
  font-size: 14px;
  text-align: center;
  cursor: pointer;
  background: var(--color-white);
}

.slot-btn.selected {
  border-color: var(--color-primary);
  border-width: 2px;
  font-weight: 600;
}

.slot-btn:disabled {
  color: var(--color-border);
  cursor: not-allowed;
}

/* Liste items */
.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--gap-md) 0;
  border-bottom: 1px solid var(--color-border-subtle);
  font-size: 14px;
}

.list-item:last-child {
  border-bottom: none;
}

/* Responsive tablette vers mobile pour pro */
@media (max-width: 768px) {
  .layout-pro {
    flex-direction: column;
    max-width: 100%;
    margin: 0;
    border-left: none;
    border-right: none;
  }

  .sidebar {
    width: 100%;
    min-height: auto;
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
  }

  /*
   * Annuler le mode « réduit » : hors media, .sidebar.collapsed vaut 56px et masque les libellés,
   * ce qui casse la barre horizontale sur mobile.
   */
  .sidebar.collapsed {
    width: 100%;
  }

  .sidebar.collapsed .sidebar-brand {
    justify-content: flex-start;
    font-size: 18px;
    letter-spacing: 0.05em;
  }

  .sidebar.collapsed .sidebar-nav a span {
    display: inline;
  }

  .sidebar.collapsed .sidebar-nav a {
    justify-content: center;
    padding: 10px 12px;
  }

  .sidebar-nav {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    padding: var(--gap-sm) 0;
    gap: 0;
  }

  .sidebar-nav a {
    flex-shrink: 0;
    border-left: none;
    border-bottom: 2px solid transparent;
    padding: 10px 12px;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    font-size: 11px;
    line-height: 1.2;
    text-align: center;
    min-width: 72px;
    max-width: 96px;
  }

  .sidebar-nav a svg {
    flex-shrink: 0;
  }

  .sidebar-nav a.active {
    border-left: none;
    border-bottom-color: var(--color-primary);
    background: linear-gradient(180deg, rgba(111, 140, 55, 0.14) 0%, rgba(237, 243, 223, 0.8) 100%);
    box-shadow: inset 0 -1px 0 rgba(95, 122, 47, 0.18);
  }

  /* Réduire / agrandir la sidebar : sans objet en barre horizontale pleine largeur */
  .sidebar-toggle {
    display: none;
  }

  /* Nom / métier / déconnexion restent dans la sidebar en desktop ; en mobile la déconnexion est dans .main-header */
  .sidebar-footer {
    display: none;
  }

  .header-logout-mobile {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    border: 1px solid var(--color-border);
    background: var(--color-white);
    color: var(--color-text);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    min-height: 36px;
    box-sizing: border-box;
  }

  .header-logout-mobile:active {
    background: var(--color-bg-light);
  }

  /*
   * En-tête : une ligne — à gauche le titre ou « Bonjour » (+ date en dessous dans la colonne gauche),
   * à droite les actions (Moreen, cloche, déconnexion) alignées sur la même ligne que le premier texte.
   */
  .main-header {
    height: auto;
    min-height: var(--header-height);
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    padding: 12px var(--gap-md);
    gap: 8px 10px;
  }

  .main-header > div:first-child {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    min-width: 0;
    flex: 1 1 auto;
  }

  .main-header > div:first-child .text-muted {
    margin-left: 0 !important;
  }

  .main-header .flex-gap-sm {
    width: auto;
    max-width: 100%;
    justify-content: flex-end;
    flex-wrap: nowrap;
    flex-shrink: 0;
    gap: 6px;
    align-items: center;
    align-self: flex-start;
  }

  .main-header .flex-gap-sm > * {
    flex-shrink: 0;
  }

  .main-header .flex-gap-sm .pro-patient-quick-search {
    flex-shrink: 1;
    min-width: 100px;
    max-width: min(220px, 100%);
  }

  /* Titre Agenda / Patients : même ligne que le groupe de boutons */
  .main-header > span.text-bold:first-child {
    font-size: 17px;
    flex: 1 1 auto;
    min-width: 0;
    line-height: 1.25;
    padding-top: 2px;
    padding-right: 8px;
  }

  .main-header .flex-gap-sm .btn {
    max-width: none;
    white-space: nowrap;
  }

  /* Si vraiment trop étroit, les actions passent sous le bloc gauche tout en restant groupées */
  @media (max-width: 380px) {
    .main-header .flex-gap-sm {
      flex-basis: 100%;
      justify-content: flex-start;
      flex-wrap: wrap;
    }

    .main-header .flex-gap-sm .pro-patient-quick-search {
      flex: 1 1 100%;
      max-width: 100%;
    }
  }

  .main-body {
    padding: var(--gap-md);
  }

  .col-layout {
    grid-template-columns: 1fr;
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }
}

/* Wordmark texte (remplace les SVG — aucun asset externe requis) */
.brand-wordmark {
  font-family: var(--font-family);
  font-weight: 700;
  color: var(--color-primary);
  letter-spacing: 0.08em;
  line-height: 1.1;
  display: inline-block;
  text-decoration: none;
  text-transform: uppercase;
}
a.brand-wordmark:hover {
  color: var(--color-primary-hover);
}
.brand-wordmark--full {
  font-size: 1.5rem;
}
.brand-wordmark--compact {
  font-size: 1.125rem;
  font-weight: 700;
}
/* Monogramme sidebar (remplace l’icône logo) */
.brand-wordmark--sidebar {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0;
  color: var(--color-white);
  background: var(--gradient-primary);
  border-radius: 10px;
  box-shadow: var(--shadow-card);
}
.sidebar-brand .brand-wordmark--sidebar {
  margin: 0 auto;
}
.sidebar-brand {
  gap: var(--gap-sm);
}
.layout-centered .site-header .brand-wordmark--full {
  font-size: 1.35rem;
}
.brand-wordmark--invoice {
  font-size: 1rem;
  letter-spacing: 0.06em;
}

/* Utilitaires */
.text-sm   { font-size: 13px; }
.text-xs   { font-size: 12px; }
.text-muted { color: var(--color-text-muted); }
.text-bold  { font-weight: 600; }
.mb-sm { margin-bottom: var(--gap-sm); }
.mb-md { margin-bottom: var(--gap-md); }
.mb-lg { margin-bottom: var(--gap-lg); }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center  { display: flex; justify-content: center; align-items: center; }
.flex-gap-sm  { display: flex; gap: var(--gap-sm); align-items: center; }
.gap-sm { gap: var(--gap-sm); }

/* ============================================================
   V4 — États données mock (erreur chargement JSON)
   ============================================================ */
.proto-mock-error-banner {
  position: sticky;
  top: 0;
  z-index: 9999;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-white);
  background: #8b2942;
  border-bottom: 1px solid var(--color-border);
}

/* --- Messagerie patient ↔ praticien --- */
.msg-layout-list { display: flex; flex-direction: column; gap: 0; }
.msg-thread-item {
  display: block;
  padding: 14px 0;
  border-bottom: 1px solid #ddd;
  text-decoration: none;
  color: inherit;
}
.msg-thread-item:last-child { border-bottom: none; }
.msg-thread-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 4px; }
.msg-thread-name { font-size: 15px; font-weight: 700; }
.msg-thread-consult-date { font-size: 12px; color: #6b7f6b; margin-bottom: 4px; }
.msg-thread-time { font-size: 11px; color: #888; flex-shrink: 0; }
.msg-thread-preview { font-size: 13px; color: #666; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-thread-chip {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid #ccc;
  padding: 2px 6px;
  margin-top: 6px;
  color: #666;
}
.msg-unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 10px;
  font-weight: 700;
  background: #333;
  color: #fff;
  border-radius: 9px;
}
.msg-disclaimer {
  font-size: 12px;
  color: #666;
  border: 1px solid #ddd;
  background: #f5f5f5;
  padding: 10px 12px;
  margin-bottom: var(--gap-md);
  line-height: 1.45;
}
.msg-consult-banner {
  border: 1px solid #ccc;
  background: #fafafa;
  padding: 10px 12px;
  margin-bottom: var(--gap-md);
  font-size: 13px;
}
.msg-consult-banner strong { display: block; font-size: 12px; margin-bottom: 4px; }
.msg-thread-view { display: flex; flex-direction: column; min-height: 50vh; }
.msg-bubbles { flex: 1; display: flex; flex-direction: column; gap: 10px; padding-bottom: var(--gap-md); }
.msg-bubble {
  max-width: 88%;
  padding: 10px 12px;
  border: 1px solid #ccc;
  font-size: 14px;
  line-height: 1.45;
  word-break: break-word;
}
.msg-bubble--patient { align-self: flex-end; background: #eee; border-color: #999; }
.msg-bubble--practitioner { align-self: flex-start; background: #fff; }
.msg-bubble-meta { font-size: 10px; color: #888; margin-top: 6px; }
.msg-typing-slot:not(:empty) { padding: 2px 4px 8px; }
.msg-typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #888;
  font-style: italic;
}
.msg-typing-dots {
  display: inline-flex;
  gap: 3px;
  align-items: center;
}
.msg-typing-dots span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.35;
  animation: msg-typing-dot 1.2s ease-in-out infinite;
}
.msg-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.msg-typing-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes msg-typing-dot {
  0%, 60%, 100% { opacity: 0.35; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-2px); }
}
.msg-audio-player {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 180px;
}
.msg-audio-player audio { flex: 1; min-width: 0; height: 32px; }
.msg-audio-duration { font-size: 12px; font-weight: 600; color: #444; white-space: nowrap; }
.msg-composer {
  border-top: 1px solid #ccc;
  padding-top: var(--gap-sm);
  margin-top: auto;
}
.msg-composer-row { display: flex; gap: 8px; align-items: flex-end; }
.msg-composer-input {
  flex: 1;
  min-height: 42px;
  max-height: 120px;
  padding: 10px 12px;
  border: 1px solid #ccc;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
}
.msg-composer-btn {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border: 1px solid #333;
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.msg-composer-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.msg-composer-btn--primary { background: #333; color: #fff; width: auto; padding: 0 14px; font-size: 13px; font-weight: 600; position: relative; min-width: 42px; }
.msg-composer-btn--loading .msg-send-btn-label { opacity: 0; }
.msg-send-btn-loader {
  position: absolute;
  inset: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.msg-send-btn-loader[hidden] { display: none !important; }
.msg-btn-spinner { animation: msg-spin 0.75s linear infinite; }
@keyframes msg-spin { to { transform: rotate(360deg); } }
.msg-composer-btn--recording { background: #444; color: #fff; animation: msg-rec-pulse 1.2s ease-in-out infinite; }
@keyframes msg-rec-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.65; }
}
.msg-rec-panel {
  border: 1px solid #999;
  background: #f5f5f5;
  padding: 12px;
  margin-bottom: 8px;
}
.msg-rec-timer { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.msg-rec-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.msg-empty { padding: 24px; text-align: center; color: #666; }
.msg-pro-split {
  display: grid;
  grid-template-columns: 280px 1fr 260px;
  gap: 0;
  min-height: calc(100vh - 120px);
  border: 1px solid #ccc;
}
.msg-pro-inbox { border-right: 1px solid #ccc; overflow-y: auto; padding: 0 12px; }
.msg-pro-conversation { display: flex; flex-direction: column; padding: 12px; min-height: 0; }
.msg-pro-context {
  border-left: 1px solid #ccc;
  background: #fafafa;
  padding: 12px;
  overflow-y: auto;
  font-size: 13px;
}
.msg-pro-context h3 { font-size: 13px; font-weight: 700; margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.05em; color: #666; }
.msg-pro-context-dl { margin-bottom: 12px; }
.msg-pro-context-dl dt { font-size: 10px; font-weight: 600; text-transform: uppercase; color: #888; margin-top: 8px; }
.msg-pro-context-dl dd { margin: 2px 0 0; color: #333; }
@media (max-width: 1024px) {
  .msg-pro-split { grid-template-columns: 220px 1fr; }
  .msg-pro-context { display: none; }
}
@media (max-width: 768px) {
  .msg-pro-split { grid-template-columns: 1fr; }
  .msg-pro-inbox { border-right: none; border-bottom: 1px solid #ccc; max-height: 220px; }
}
.header-messages-wrap { position: relative; display: inline-flex; color: inherit; }
.header-messages-wrap .msg-unread-badge { position: absolute; top: -4px; right: -6px; }
