/* Agenda Praticiens — page patient.
   Choix : polices système (chargement instantané sur réseau mobile, arabe et latin couverts),
   palette vert profond sur papier légèrement verdi, une seule pièce « signature » : la carte de rendez-vous. */

:root {
  --paper: #f7fafc;
  --card: #ffffff;
  --ink: #172b3a;
  --muted: #64748b;
  --line: #dde5ec;
  --accent: #12bfa3;
  --accent-ink: #ffffff;
  --accent-soft: #dcf5f0;
  --brand: #07549a;
  --brand-dark: #063b6b;
  --brand-light: #19a7e0;
  --brand-soft: #e4f0fa;
  --danger: #b3261e;
  --danger-soft: #fbe9e7;
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Arabic", "Noto Naskh Arabic", Tahoma, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body.ap-body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.55 var(--font);
}

.ap-wrap {
  max-width: 34rem;
  margin: 0 auto;
  padding: 1rem 1rem 3rem;
}

.ap-loading { color: var(--muted); }

/* ---------- En-tête ---------- */
.ap-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 0 1.25rem;
}
.ap-head h1 {
  margin: 0;
  font-size: 1.6rem;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.ap-head p { margin: 0.2rem 0 0; color: var(--muted); }
.ap-head-tel { display: inline-block; margin: 0.45rem 0 0; color: var(--brand); font-weight: 700; text-decoration: none; }
.ap-head-tel:hover, .ap-head-tel:focus-visible { text-decoration: underline; }
.ap-lang {
  flex: none;
  min-height: 44px;
  padding: 0 0.9rem;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 0.95rem;
  cursor: pointer;
}

/* ---------- Sections ---------- */
.ap-section { margin: 0 0 1.5rem; }
.ap-section h2 {
  margin: 0 0 0.6rem;
  font-size: 1.05rem;
  font-weight: 700;
}

/* Jours */
.ap-days {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.15rem 0.15rem 0.6rem;
  margin: 0 -0.15rem;
  scroll-snap-type: x proximity;
}
.ap-day {
  flex: none;
  min-width: 4.4rem;
  padding: 0.55rem 0.4rem;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  text-align: center;
  cursor: pointer;
  scroll-snap-align: start;
}
.ap-day .wd { display: block; font-size: 0.82rem; color: var(--muted); }
.ap-day .dn { display: block; font-size: 1.45rem; line-height: 1.15; font-weight: 700; font-variant-numeric: tabular-nums; }
.ap-day .mo { display: block; font-size: 0.82rem; color: var(--muted); }
.ap-day[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.ap-day[aria-pressed="true"] .wd,
.ap-day[aria-pressed="true"] .mo { color: #d6f5ee; }
.ap-more {
  margin-top: 0.25rem;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* Horaires */
.ap-times {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(4.6rem, 1fr));
  gap: 0.5rem;
}
.ap-time {
  min-height: 48px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.ap-time[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

/* Formulaire */
.ap-summary {
  margin: 0 0 0.9rem;
  padding: 0.7rem 0.9rem;
  border-radius: 12px;
  background: var(--accent-soft);
  font-weight: 600;
}
.ap-field { margin: 0 0 0.9rem; }
.ap-field label { display: block; margin: 0 0 0.25rem; font-weight: 600; }
.ap-field input[type="text"],
.ap-field input[type="tel"] {
  width: 100%;
  min-height: 50px;
  padding: 0 0.9rem;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
}
.ap-help { margin: 0.25rem 0 0; font-size: 0.88rem; color: var(--muted); }
.ap-hp { position: absolute; inset-inline-start: -9999px; width: 1px; height: 1px; overflow: hidden; }

.ap-btn {
  display: block;
  width: 100%;
  min-height: 54px;
  padding: 0 1rem;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  line-height: 54px;
  cursor: pointer;
}
.ap-btn[disabled] { opacity: 0.6; cursor: progress; }
.ap-btn-ghost {
  background: var(--card);
  color: var(--ink);
  border: 1.5px solid var(--line);
  line-height: 51px;
  font-weight: 600;
}
.ap-btn-danger { background: var(--danger); }

.ap-error {
  margin: 0 0 1rem;
  padding: 0.7rem 0.9rem;
  border-radius: 12px;
  background: var(--danger-soft);
  color: var(--danger);
  font-weight: 600;
}
.ap-empty {
  padding: 1rem;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
}
.ap-empty a { color: var(--accent); font-weight: 600; }

/* ---------- La carte de rendez-vous (pièce signature) ---------- */
.ap-card {
  --notch: 12px;
  position: relative;
  margin: 0.5rem 0 1.25rem;
  background: var(--card);
  border: 1.5px solid var(--ink);
  border-radius: var(--radius);
  overflow: hidden;
}
.ap-card-main { padding: 1.25rem 1.25rem 1.1rem; }
.ap-card-tag {
  margin: 0 0 0.9rem;
  color: var(--accent);
  font-weight: 700;
}
.ap-card-doc { margin: 0; font-size: 1.15rem; font-weight: 700; }
.ap-card-spec { margin: 0; color: var(--muted); }
.ap-card-date { margin: 1rem 0 0; font-size: 1.2rem; font-weight: 600; }
.ap-card-date::first-letter { text-transform: uppercase; }
.ap-card-time {
  margin: 0;
  font-size: 3.6rem;
  line-height: 1.05;
  font-weight: 800;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.ap-card-stub {
  position: relative;
  padding: 1rem 1.25rem 1.25rem;
  border-top: 2px dashed var(--ink);
  background: var(--paper);
}
.ap-card-stub::before,
.ap-card-stub::after {
  content: "";
  position: absolute;
  top: calc(var(--notch) / -2 - 1px);
  width: var(--notch);
  height: var(--notch);
  border-radius: 50%;
  background: var(--paper);
  border: 1.5px solid var(--ink);
}
.ap-card-stub::before { inset-inline-start: calc(var(--notch) / -2 - 1px); }
.ap-card-stub::after { inset-inline-end: calc(var(--notch) / -2 - 1px); }
.ap-card-patient { margin: 0 0 0.75rem; font-weight: 600; }
.ap-card-actions { display: grid; gap: 0.5rem; }
.ap-note { margin: 0 0 1rem; color: var(--muted); font-size: 0.92rem; }

/* ---------- Accessibilité ---------- */
button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 3px solid #0a9a83;
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

/* ---------- Arabe (droite à gauche) ---------- */
[dir="rtl"] .ap-head h1 { letter-spacing: 0; }
