/* style.css : l'apparence de l'application (couleurs, tailles, disposition).
   Les propriétés "inline-start / inline-end" s'adaptent toutes seules
   au sens de lecture (gauche→droite en français, droite→gauche en arabe). */

/* Couleurs tirées du logo Gastro Clinic */
:root {
  --primary: #2c4874;        /* bleu marine du logo */
  --accent: #5792f1;         /* bleu clair du logo (l'estomac) */
  --primary-light: #e6eefc;
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e3e7ee;
  --danger: #b91c1c;
  --ok: #15803d;
  --sms: #5792f1;
  --wa: #16a34a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Arabic", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  padding-bottom: 0;
}

/* ---- Barre du haut ---- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px;
  background: var(--card); color: var(--primary);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 1.1rem; margin: 0; flex: 1; text-align: center; }
html[dir="rtl"] .topbar h1 { direction: rtl; }
.logo { width: 40px; height: 40px; border-radius: 10px; }
.chip {
  border: 1px solid var(--primary); background: transparent; color: var(--primary);
  border-radius: 999px; padding: 6px 12px; font-size: .85rem;
}
.lang-switch { display: flex; border: 1px solid var(--primary); border-radius: 999px; overflow: hidden; }
.lang-switch button {
  border: 0; background: none; color: var(--primary); padding: 6px 10px; font-size: .85rem;
}
.lang-switch button.active { background: var(--primary); color: white; }

main { padding: 12px 16px 90px; max-width: 900px; margin: 0 auto; } /* 90px : place pour le bouton + */

/* ---- Jour / Semaine / Mois ---- */
.segmented {
  display: flex; background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 3px; margin-bottom: 10px;
}
.segmented button {
  flex: 1; border: 0; background: none; padding: 8px; border-radius: 8px; color: var(--muted); font-weight: 600;
}
.segmented button.active { background: var(--primary); color: white; }

/* ---- Navigation entre les jours ---- */
.date-nav { display: flex; align-items: center; gap: 8px; margin: 4px 0 12px; }
.date-nav > button {
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--card); font-size: 1.5rem; line-height: 1; color: var(--primary);
}
[dir="rtl"] .date-nav > button { transform: scaleX(-1); }
.date-label { flex: 1; text-align: center; }
.date-label strong { display: block; }
.date-label strong::first-letter { text-transform: uppercase; }
.date-label .link {
  display: block; margin: 4px auto 0; border: 0; background: none;
  color: var(--accent); text-decoration: underline; font-size: .9rem;
}
.closed-note { text-align: center; color: var(--muted); margin: 0 0 8px; }

/* ---- Grille horaire (Jour / Semaine) ---- */
.grid { background: var(--card); border-radius: 12px; padding: 8px 8px 8px 0; }
.grid-head, .grid-body { display: flex; }
.grid .gutter { width: 46px; flex: none; position: relative; }
.hour {
  position: absolute; inset-inline-end: 6px; transform: translateY(-50%);
  font-size: .75rem; color: var(--muted); direction: ltr;
}
.col {
  flex: 1; min-width: 0; position: relative;
  border-inline-start: 1px solid var(--border); cursor: copy;
}
.col.closed { background: repeating-linear-gradient(45deg, #f3f4f6 0 6px, #fafafa 6px 12px); }
.hline { position: absolute; left: 0; right: 0; border-top: 1px solid var(--border); }
.hline.half { border-top-style: dashed; opacity: .6; }
.now { position: absolute; left: 0; right: 0; border-top: 2px solid #ef4444; z-index: 2; }
.ev {
  position: absolute; z-index: 1; overflow: hidden; cursor: pointer;
  padding: 2px 6px; border-radius: 6px; font-size: .85rem; line-height: 1.25;
  background: var(--c);                                   /* couleur pastel du type */
  border-inline-start: 4px solid color-mix(in srgb, var(--c) 65%, black);
  box-shadow: 0 0 0 1px white;
}
.ev.notype { color: white; }                              /* sans type : bloc noir */
.ev.notype em { color: #d1d5db; }
.ev.inactive { color: var(--muted); }                     /* annulé / absent : bloc gris */
.ev.inactive span { text-decoration: line-through; }
.ev.noshow { color: #374151; }
.ev b { font-weight: 700; }
.ev em { display: block; font-style: normal; color: var(--muted); font-size: .78rem; }
.ev.sent::after { content: "✓"; position: absolute; top: 2px; inset-inline-end: 4px; color: var(--ok); font-weight: 700; }
.grid.week .ev { font-size: .7rem; padding: 1px 3px; }
.grid.week .ev b { display: block; }
.day-head {
  flex: 1; min-width: 0; border: 0; background: none; padding: 4px 0 8px;
  display: flex; flex-direction: column; align-items: center; color: var(--muted); font-size: .75rem;
}
.day-head strong { font-size: 1.05rem; color: var(--text); }
.day-head.today strong {
  background: var(--primary); color: white; border-radius: 50%; width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
}

/* ---- Vue Mois ---- */
.month {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px;
  background: var(--card); border-radius: 12px; padding: 8px;
}
.m-head { text-align: center; font-size: .75rem; color: var(--muted); padding-bottom: 4px; }
.m-cell {
  aspect-ratio: 1 / 1.1; border: 1px solid var(--border); border-radius: 8px; background: var(--card);
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 2px;
  padding: 4px 2px; min-width: 0;
}
.m-cell.other { opacity: .4; }
.m-cell.closed { background: #f3f4f6; }
.m-cell.today { border: 2px solid var(--primary); }
.m-num { font-weight: 600; font-size: .9rem; }
.m-count { font-size: .7rem; color: white; background: var(--accent); border-radius: 999px; padding: 0 6px; }
.m-dots { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px; }
.m-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--c); }

.view-title { margin: 4px 0; font-size: 1.1rem; color: var(--muted); text-align: center; }
.empty { text-align: center; color: var(--muted); margin-top: 40px; }
.help { color: var(--muted); font-size: .9rem; }
.counter { font-weight: 600; text-align: center; }

/* ---- Carte d'un rendez-vous (Rappels) ---- */
.card {
  background: var(--card); border-radius: 12px; padding: 12px;
  margin-bottom: 10px; box-shadow: 0 1px 2px rgba(0,0,0,.06);
  border-inline-start: 5px solid var(--c, var(--accent));
}
.card-head { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.time {
  font-weight: 700; font-size: 1.1rem; color: var(--primary);
  background: var(--primary-light); border-radius: 8px; padding: 6px 8px;
}
.who { flex: 1; display: flex; flex-direction: column; align-items: flex-start; }
.type-chip {
  font-size: .75rem; font-weight: 600; border-radius: 999px; padding: 1px 8px; margin: 2px 0;
  background: var(--c); color: var(--text);
}
.card.notype .type-chip { color: white; }
.card.inactive { opacity: .8; }
.card.inactive strong { text-decoration: line-through; color: var(--muted); }
.card-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.link.small { font-size: .8rem; color: var(--accent); margin-top: 8px; }
.hint { font-size: .85rem; color: #b45309; margin: -4px 0 12px; }
.confirm-box { padding: 16px; }
.confirm-box h2 { margin-top: 0; color: var(--ok); font-size: 1.15rem; }
.preview {
  background: var(--bg); border-radius: 10px; padding: 10px; font-size: .85rem;
  white-space: pre-wrap; word-break: break-word; max-height: 180px; overflow: auto;
}
#confirm-later { background: none; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-top: 10px; }
.phone { color: var(--muted); font-size: .9rem; }
.lang-tag {
  font-size: .75rem; border: 1px solid var(--border); border-radius: 6px; padding: 2px 6px; color: var(--muted);
}
.card-actions { display: flex; gap: 8px; margin-top: 10px; }
.badge { display: inline-block; margin-top: 8px; font-size: .8rem; color: var(--muted); }
.badge.ok { color: var(--ok); font-weight: 600; }

/* ---- Boutons ---- */
button, .btn { font: inherit; cursor: pointer; }
.btn {
  flex: 1; text-align: center; text-decoration: none;
  padding: 10px 6px; border-radius: 8px; border: 1px solid var(--border);
  color: var(--text); background: var(--card); font-weight: 600;
}
.btn.sms { background: var(--sms); color: white; border-color: var(--sms); }
.btn.wa  { background: var(--wa);  color: white; border-color: var(--wa); }
.primary { background: var(--primary); color: white; border: 0; border-radius: 8px; padding: 10px 16px; font-weight: 600; }
.danger  { background: none; color: var(--danger); border: 1px solid var(--danger); border-radius: 8px; padding: 10px 12px; }
.danger.small { padding: 6px 10px; font-size: .85rem; }
#f-cancel, #add-type { background: none; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }

.fab {
  position: fixed; bottom: 20px; right: 20px; z-index: 10;
  width: 60px; height: 60px; border-radius: 50%; border: 0;
  background: var(--accent); color: white; font-size: 2rem; line-height: 1;
  box-shadow: 0 4px 12px rgba(0,0,0,.25);
}
.fab[hidden] { display: none; }

/* ---- Onglets du bas ---- */
/* ---- Barre de navigation verticale, toujours à GAUCHE (même en arabe) ---- */
:root { --rail: 78px; }
.tabs {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 15; width: var(--rail);
  display: flex; flex-direction: column; gap: 4px;
  padding: 72px 6px 12px; /* 72px : on laisse la place à la barre du haut */
  background: var(--card); border-right: 1px solid var(--border);
}
.tabs button {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 12px 2px; border: 0; border-radius: 12px; background: none;
  color: var(--muted); font-weight: 600; font-size: .72rem; line-height: 1.15; text-align: center;
}
.tabs button .ico { font-size: 1.45rem; line-height: 1; }
.tabs button.active { color: var(--primary); background: var(--primary-light); box-shadow: inset 3px 0 0 var(--accent); }
/* La barre de gauche occupe --rail pixels : le contenu se centre dans l'espace restant.
   La barre du haut, elle, garde toute la largeur de l'écran. */
body.has-rail { padding-left: var(--rail); }
body.has-rail .topbar { margin-left: calc(-1 * var(--rail)); }
@media (max-width: 380px) { .topbar h1 { font-size: .95rem; } }

/* ---- Formulaires ---- */
dialog {
  border: 0; border-radius: 14px; padding: 0; width: min(520px, calc(100% - 24px));
}
dialog::backdrop { background: rgba(0,0,0,.4); }
form { padding: 16px; }
form h2 { margin-top: 0; font-size: 1.15rem; color: var(--primary); }
label { display: block; margin-bottom: 12px; }
label > span { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 4px; }
input:not([type="radio"]):not([type="checkbox"]):not([type="color"]), select {
  width: 100%; padding: 10px; font: inherit; border: 1px solid var(--border); border-radius: 8px; background: white;
}
input[type="color"] { width: 100%; height: 42px; border: 1px solid var(--border); border-radius: 8px; padding: 2px; background: white; }
.row { display: flex; gap: 10px; }
.row > label { flex: 1; min-width: 0; }
fieldset { border: 1px solid var(--border); border-radius: 8px; margin: 0 0 12px; }
legend { font-size: .85rem; color: var(--muted); }
label.radio { display: inline-flex; align-items: center; gap: 6px; margin: 4px 16px 4px 0; }
.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spacer { flex: 1; }
.error { color: var(--danger); }
.ok-msg { color: var(--ok); margin-inline-start: 10px; }
.warn { color: #b45309; }
.file-btn { flex: 0 1 auto; margin: 0; }

.panel { background: var(--card); border-radius: 12px; padding: 16px; margin-bottom: 14px; }
.panel h2 { margin-top: 0; font-size: 1.1rem; color: var(--primary); }
#settings-form { padding: 0; }
.type-row { border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-bottom: 10px; }
.save-bar {
  position: sticky; bottom: 0; z-index: 5; background: var(--bg); padding: 10px 0; margin-bottom: 14px;
}

/* ---- Jours fermés ---- */
.closed-label {
  position: absolute; top: 40%; left: 0; right: 0; text-align: center;
  color: var(--muted); font-weight: 700; font-size: .8rem; letter-spacing: .05em;
  transform: rotate(-90deg);
}
.grid.day .closed-label { transform: none; font-size: 1.2rem; }
.m-closed { font-size: .6rem; color: var(--muted); text-transform: uppercase; }

/* ---- Compteurs par type ---- */
.stats { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.stat {
  font-size: .8rem; padding: 3px 10px; border-radius: 999px;
  background: var(--c);
  border-inline-start: 4px solid color-mix(in srgb, var(--c) 65%, black);
}
.stat.notype { color: white; }
.stat.total { background: var(--primary); color: white; border: 0; }

/* ---- Coordonnées en bas de page ---- */
.contact {
  max-width: 900px; margin: 10px auto 0; padding: 16px;
  display: flex; gap: 14px; align-items: flex-start;
  background: var(--card); border-top: 3px solid var(--primary);
}
.contact-logo { width: 72px; height: 72px; object-fit: contain; flex: none; }
.contact-info { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; }
.contact-info strong { color: var(--primary); font-size: 1.1rem; }
.specialty { color: var(--accent); font-weight: 600; font-size: .85rem; }
.copy {
  border: 0; background: none; padding: 4px 0; text-align: start; color: var(--text);
  user-select: text; -webkit-user-select: text; font-size: .95rem; word-break: break-word;
}
.copy:active { color: var(--accent); }
.maps { color: var(--accent); font-size: .9rem; }

.toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%); z-index: 30;
  background: var(--primary); color: white; padding: 10px 16px; border-radius: 999px;
  font-size: .9rem; box-shadow: 0 4px 12px rgba(0,0,0,.25); max-width: calc(100% - 32px);
}
.toast[hidden] { display: none; }

/* ---- Formulaire : erreurs et suggestions ---- */
input.invalid, select.invalid { border: 2px solid var(--danger) !important; background: #fef2f2 !important; }
.error { font-weight: 600; }
.suggest {
  border: 1px solid var(--accent); border-radius: 10px; padding: 6px; margin: -4px 0 12px;
  background: var(--primary-light); display: flex; flex-direction: column; gap: 4px;
}
.suggest small { color: var(--muted); padding: 2px 4px; }
.suggest button {
  border: 0; background: white; border-radius: 8px; padding: 10px; text-align: start;
  display: flex; justify-content: space-between; gap: 10px;
}
.suggest button span { color: var(--muted); }
.suggest[hidden] { display: none; }

/* ---- Page patient (rdv.html) ---- */
body.patient { padding-bottom: 20px; }
.p-card {
  background: var(--card); border-radius: 16px; padding: 20px; margin-bottom: 14px; text-align: center;
  border-top: 8px solid var(--c); box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.p-card .type-chip { font-size: .9rem; padding: 4px 14px; }
.p-hello { margin: 0; font-size: 1.05rem; }
.p-label { margin: 2px 0 10px; color: var(--muted); }
.p-date { font-size: 1.35rem; font-weight: 700; color: var(--primary); margin: 12px 0 4px; }
.p-date::first-letter { text-transform: uppercase; }
.p-time { font-size: 1.1rem; margin: 0 0 6px; }
.p-time b { font-size: 1.8rem; color: var(--primary); }
.consigne { border-inline-start: 5px solid var(--accent); }
.consigne p { margin: 0; }
.p-actions { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.btn.wide { width: 100%; display: block; }
.primary-btn { background: var(--primary); color: white; border-color: var(--primary); }
.danger-btn { color: var(--danger); border-color: var(--danger); }
.privacy { text-align: center; padding: 0 8px; }

/* ---- Patient : Mes rappels (frise) ---- */
.timeline { list-style: none; padding: 0; margin: 0; }
.tl-item { display: flex; gap: 12px; position: relative; padding-bottom: 18px; }
.tl-item:not(:last-child)::before {
  content: ""; position: absolute; top: 34px; bottom: 0; inset-inline-start: 17px; width: 2px; background: var(--border);
}
.tl-dot {
  flex: none; width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: var(--card); border: 2px solid var(--border); font-size: 1.05rem;
}
.tl-item.done .tl-dot { border-color: var(--ok); }
.tl-body { flex: 1; min-width: 0; background: var(--card); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.tl-body .preview { margin: 6px 0 0; }

/* ---- Patient : agenda en lecture seule ---- */
.col.readonly { cursor: default; }
.ev.mine { box-shadow: 0 0 0 2px var(--primary); font-weight: 600; }
.legend { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.tl-body .preview { max-height: none; }

/* ---- Jours fériés / fermés ---- */
.col.holiday { background: repeating-linear-gradient(45deg, #eceff3 0 6px, #f7f8fa 6px 12px); }
.col.holiday-open { background: #f0fdf4; }
.closed-label.holiday { color: #6b7280; }
.closed-label.holiday-open { color: var(--ok); }
.grid.day .closed-label.holiday-open { top: 4px; }
.m-cell.holiday { background: #eceff3; }
.m-cell.holiday-open { background: #f0fdf4; border-color: #86efac; }
.m-closed.holiday-open { color: var(--ok); font-weight: 700; }
.banner {
  border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; font-weight: 600;
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between;
}
.banner .link, .banner-link .link { border: 0; background: none; color: var(--accent); text-decoration: underline; font: inherit; font-size: .85rem; font-weight: 500; padding: 0; }
.banner.holiday { background: #eceff3; color: var(--text); }
.banner.holiday-open { background: #dcfce7; color: #166534; }
.banner.closed { background: #f3f4f6; color: var(--muted); }
.banner-link { text-align: end; margin: -4px 0 6px; }

/* ---- Statistiques ---- */
main { position: relative; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-bottom: 14px; }
.kpi { background: var(--card); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.kpi-label { font-size: .78rem; color: var(--muted); }
.kpi-value { font-size: 1.5rem; color: var(--text); }
.kpi.accent .kpi-value { color: var(--primary); }
.kpi small { font-size: .7rem; color: var(--muted); }
.chart-panel h2 { font-size: 1rem; }
.chart { display: block; overflow: visible; }
.chart .gridline { stroke: #eef0f3; stroke-width: 1; }
.chart .axis { stroke: #c9ced6; stroke-width: 1; }
.chart .tick { font-size: 10px; fill: var(--muted); }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hit:hover { fill: rgba(44, 72, 116, .06); }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 8px; font-size: .8rem; color: var(--text); }
.chart-legend i, .chart-tip i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 5px; vertical-align: -1px; }
.chart-tip {
  position: absolute; z-index: 25; min-width: 160px; pointer-events: none;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px;
  box-shadow: 0 6px 18px rgba(0,0,0,.12); font-size: .8rem; display: flex; flex-direction: column; gap: 3px;
}
.chart-tip[hidden] { display: none; }
.hbars { display: flex; flex-direction: column; gap: 8px; }
.hbar-row { display: grid; grid-template-columns: minmax(70px, 30%) 1fr auto; gap: 8px; align-items: center; font-size: .85rem; }
.hbar-track { background: #f3f4f6; border-radius: 4px; height: 14px; overflow: hidden; }
.hbar { display: block; height: 100%; border-radius: 0 4px 4px 0; }
[dir="rtl"] .hbar { border-radius: 4px 0 0 4px; margin-inline-start: 0; }
.hbar-val { color: var(--muted); white-space: nowrap; }
.hbar-val b { color: var(--text); }
.table-wrap { overflow-x: auto; margin-top: 10px; background: var(--card); border-radius: 12px; }
.data-table { border-collapse: collapse; width: 100%; font-size: .8rem; }
.data-table th, .data-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); text-align: center; white-space: nowrap; }
.data-table th { color: var(--muted); font-weight: 600; }

/* =====================================================================
   ADAPTATION À LA TAILLE DE L'ÉCRAN ("responsive")
   - téléphone (par défaut, tout ce qui est au-dessus)
   - petit téléphone (≤ 360 px)
   - tablette / PC (≥ 900 px)
   ===================================================================== */

/* ---- Petits téléphones ---- */
@media (max-width: 360px) {
  :root { --rail: 62px; }
  .tabs { padding-left: 4px; padding-right: 4px; }
  .tabs button { font-size: .62rem; padding: 10px 1px; }
  .tabs button .ico { font-size: 1.25rem; }
  .lang-switch button { padding: 5px 7px; font-size: .75rem; }
  .topbar { gap: 6px; padding: 8px 10px; }
  .topbar h1 { font-size: .9rem; }
  .logo { width: 32px; height: 32px; }
  main { padding: 10px 10px 90px; }
  .grid .gutter { width: 38px; }
  .hour { font-size: .68rem; }
  .row { flex-direction: column; gap: 0; }           /* champs l'un sous l'autre */
  .card-actions { flex-wrap: wrap; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .p-date { font-size: 1.15rem; }
  .contact { padding: 12px 10px; gap: 10px; }
  .contact-logo { width: 48px; height: 48px; }
}
.contact-info { flex: 1; }
.contact-info strong, .specialty { overflow-wrap: anywhere; }

/* ---- Téléphone à l'horizontale / petite tablette ---- */
@media (min-width: 600px) {
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .grid.week .ev { font-size: .78rem; }
}

/* ---- Tablette et PC ---- */
@media (min-width: 900px) {
  :root { --rail: 190px; }
  body { font-size: 16.5px; }
  .topbar { padding: 10px 24px; }
  .topbar h1 { font-size: 1.3rem; }
  .logo { width: 46px; height: 46px; }

  /* Barre de gauche plus large : icône + texte sur une ligne */
  .tabs { padding: 84px 12px 16px; gap: 6px; }
  .tabs button {
    flex-direction: row; justify-content: flex-start; gap: 12px;
    font-size: .98rem; padding: 12px 14px; text-align: start;
  }
  .tabs button .ico { font-size: 1.3rem; }

  main { max-width: 1100px; padding: 20px 32px 100px; }
  body.patient main { max-width: 760px; }
  .contact { padding: 20px 32px; }

  .grid { padding: 12px 12px 12px 0; }
  .grid .gutter { width: 56px; }
  .ev { font-size: .9rem; padding: 4px 8px; }
  .grid.week .ev { font-size: .82rem; padding: 3px 6px; }
  .grid.week .ev b { display: inline; }
  .day-head { font-size: .85rem; }
  .month { gap: 6px; padding: 12px; }
  .m-cell { aspect-ratio: 1.35 / 1; }
  .m-num { font-size: 1rem; }

  .kpis { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
  .kpi { padding: 14px 16px; }
  .kpi-value { font-size: 1.8rem; }

  .card { padding: 14px 16px; }
  .card-actions .btn { padding: 12px 6px; }
  .p-actions { flex-direction: row; flex-wrap: wrap; }
  .p-actions .btn { flex: 1 1 200px; }

  dialog { width: min(560px, calc(100% - 48px)); }
  .fab { right: 32px; bottom: 32px; width: 64px; height: 64px; }
  .toast { bottom: 40px; }
  .save-bar { padding: 14px 0; }
}

/* ---- Grand écran ---- */
@media (min-width: 1400px) {
  main { max-width: 1280px; }
}

/* ---- Vérification douce : rosace de zellige (defi.js) ---- */
.defi {
  background: var(--card); border-radius: 18px; padding: 18px 16px 14px; text-align: center;
  max-width: 440px; margin: 0 auto; box-shadow: 0 2px 10px rgba(0,0,0,.06);
}
.defi h2 { margin: 0 0 4px; color: var(--primary); font-size: 1.15rem; }
.defi-prompt { margin: 0 0 12px; font-size: 1.05rem; }
.defi-stage { width: min(78vw, 300px); margin: 0 auto; }
.rosace { width: 100%; height: auto; display: block; }
.rosace .slot { fill: #fffdf7; stroke: #9a8a66; stroke-width: 2; stroke-dasharray: 4 3; animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 50% { fill: #f3e9cf; } }
.rosace .placed { animation: place .5s ease-out; transform-origin: center; transform-box: fill-box; }
@keyframes place { from { opacity: 0; transform: scale(1.4); } }
.rosace.done { animation: turn 6s ease-in-out; transform-origin: center; }
@keyframes turn { to { transform: rotate(45deg); } }
.defi-options { display: flex; justify-content: center; gap: 14px; margin: 14px 0 4px; }
.defi-opt {
  width: 88px; height: 88px; border-radius: 16px; border: 2px solid var(--border);
  background: #fbf8f1; padding: 10px; cursor: pointer; transition: transform .15s, border-color .15s;
}
.defi-opt:hover, .defi-opt:focus-visible { border-color: var(--accent); transform: translateY(-2px); outline: none; }
.defi-opt svg { width: 100%; height: 100%; }
.defi-opt.shake { animation: shake .4s; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.defi-msg { min-height: 1.4em; margin: 8px 0; font-weight: 600; color: #b45309; }
.defi.ok .defi-msg { color: var(--ok); font-size: 1.1rem; }
.defi-links { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: .9rem; }
.defi-links .link { border: 0; background: none; color: var(--accent); text-decoration: underline; padding: 4px 0; font: inherit; cursor: pointer; }
@media (prefers-reduced-motion: reduce) {
  .rosace .slot, .rosace .placed, .rosace.done, .defi-opt.shake { animation: none; }
}

/* ---- Réservation en ligne (Réglages) ---- */
.copy-link {
  display: block; width: 100%; text-align: start; margin: 0 0 12px; padding: 10px 12px;
  border: 1px dashed var(--accent); border-radius: 10px; background: var(--primary-light);
  color: var(--primary); font: inherit; font-size: .85rem; word-break: break-all; cursor: pointer;
}
.badge.online { color: var(--accent); font-weight: 600; }

/* ---- Page de réservation (reserver.html) ---- */
.steps { display: flex; justify-content: center; gap: 10px; list-style: none; padding: 0; margin: 0 0 12px; }
.steps li {
  width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: var(--card); border: 2px solid var(--border); color: var(--muted); font-weight: 700; font-size: .85rem;
}
.steps li.cur { border-color: var(--primary); background: var(--primary); color: #fff; }
.steps li.ok { border-color: var(--ok); color: var(--ok); }
.step-title { font-size: 1.1rem; color: var(--primary); margin: 4px 0 12px; }
.center { text-align: center; }
.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.type-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: start;
  background: var(--card); border: 2px solid var(--border); border-radius: 14px; padding: 14px;
  border-inline-start: 8px solid var(--c); cursor: pointer; font: inherit;
}
.type-card:hover, .type-card.sel { border-color: var(--primary); border-inline-start-color: var(--c); }
.type-card small { color: var(--muted); }
.type-dot { display: none; }
.ev.taken { opacity: .9; border-inline-start-width: 3px; padding: 0; }
.col.sel-day { background: #eef4ff; }
.day-head:disabled { opacity: .45; cursor: default; }
.day-head.sel strong { color: var(--accent); text-decoration: underline; }
button.day-head { cursor: pointer; }
.times { margin-top: 12px; }
.day-title { margin: 0 0 6px; color: var(--primary); font-size: 1rem; }
.day-title::first-letter { text-transform: uppercase; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.time-chip {
  border: 1px solid var(--border); background: var(--card); border-radius: 999px; padding: 9px 14px;
  font: inherit; font-weight: 600; cursor: pointer; min-width: 70px;
}
.time-chip.sel, .time-chip:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.summary { background: var(--primary-light); border-radius: 10px; padding: 10px 12px; }
.summary .link { border: 0; background: none; color: var(--accent); text-decoration: underline; font: inherit; cursor: pointer; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.done-title { color: var(--ok); font-size: 1.3rem; font-weight: 700; margin: 0 0 8px; }
.mine-card { display: block; text-decoration: none; color: inherit; }
.date-nav > button:disabled { opacity: .35; }
.tabs .tab-link {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 2px; border-radius: 12px;
  color: var(--accent); font-weight: 600; font-size: .72rem; line-height: 1.15; text-align: center; text-decoration: none;
}
.tabs .tab-link .ico { font-size: 1.45rem; line-height: 1; }
@media (min-width: 900px) {
  .tabs .tab-link { flex-direction: row; justify-content: flex-start; gap: 12px; font-size: .98rem; padding: 12px 14px; text-align: start; }
  .tabs .tab-link .ico { font-size: 1.3rem; }
}

/* =====================================================================
   COORDONNÉES DU CABINET dans la barre de gauche, sous les icônes
   - téléphone : icône + petit mot (Tél., E-mail, Adresse, Plan) ; toucher = copier
   - PC        : logo, nom, spécialité et coordonnées complètes
   ===================================================================== */
.tabs { overflow-y: auto; }
.rail-contact {
  margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 2px;
}
.rc-id { display: none; }
.rc-item {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  border: 0; background: none; padding: 8px 2px; border-radius: 10px; cursor: pointer;
  color: var(--primary); font: inherit; font-size: .64rem; font-weight: 600; text-decoration: none; text-align: center;
}
.rc-item .ico { font-size: 1.15rem; line-height: 1; }
.rc-item:hover { background: var(--primary-light); }
.rc-full { display: none; }

@media (min-width: 900px) {
  .rail-contact { margin-top: 22px; padding-top: 16px; gap: 4px; }
  .rc-id { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 0 8px 8px; }
  .rc-id img { width: 54px; height: 54px; object-fit: contain; margin-bottom: 4px; }
  .rc-id strong { color: var(--primary); font-size: .95rem; }
  .rc-id span { color: var(--accent); font-size: .75rem; font-weight: 600; line-height: 1.3; }
  :root { --rail: 220px; }
  .tabs .rc-item {
    flex-direction: row; align-items: flex-start; justify-content: flex-start; gap: 8px; padding: 7px 8px;
    font-size: .8rem; font-weight: 500; text-align: start; color: var(--text);
  }
  .tabs .rc-item .ico { font-size: .95rem; margin-top: 1px; flex: none; }
  .rc-short { display: none; }
  .rc-full { display: block; overflow-wrap: break-word; line-height: 1.35; }
  .tabs .rc-item.one-line .rc-full { white-space: nowrap; font-size: .76rem; }  /* téléphone et e-mail sur une ligne */
  a.rc-item .rc-full { color: var(--accent); font-weight: 600; }
}

/* Réservation : erreur après la rosace (on ne redemande pas la rosace) */
.b-fail { display: grid; gap: .8rem; margin-top: 1rem; }
.b-fail-actions { display: grid; gap: .5rem; }
.b-fail-actions .btn { text-align: center; text-decoration: none; }
.btn.ghost { background: transparent; color: var(--primary); border: 1.5px solid currentColor; }

/* RDV annulé / manqué côté patient : bien visible en rouge */
.p-card.cancelled {
  --c: var(--danger);
  border: 2px solid var(--danger);
  background: #fef2f2;
}
.p-card.cancelled .p-date, .p-card.cancelled .p-hello { color: #7f1d1d; }
.cancel-stamp {
  display: inline-block; margin: 0 0 .6rem;
  padding: 4px 14px; border-radius: 999px;
  background: var(--danger); color: #fff; font-weight: 700; letter-spacing: .02em;
}
.cancel-stamp.small { margin: 4px 0 0; padding: 2px 10px; font-size: .8rem; }
.cancel-note { color: var(--danger); font-weight: 600; }
.mine-card.cancelled { --c: var(--danger); border-color: var(--danger); background: #fef2f2; }
.mine-card.cancelled strong { text-decoration: line-through; color: #7f1d1d; }
.ev.mine.cancelled {
  --c: #fecaca; background: #fee2e2; color: #7f1d1d;
  box-shadow: 0 0 0 2px var(--danger);
  background-image: repeating-linear-gradient(135deg, transparent 0 6px, rgba(185, 28, 28, .18) 6px 8px);
}
.p-card.cancelled .type-chip, .mine-card.cancelled .type-chip { background: #fecaca; color: #7f1d1d; }
