:root {
  --bg: #f7faf9;
  --surface: #ffffff;
  --surface-2: #eef5f2;
  --text: #0f1f1a;
  --muted: #55665f;
  --border: #dde7e3;
  --brand: #0a8f5f;
  --brand-strong: #067049;
  --brand-soft: #dff3ea;
  --accent: #e4572e;
  --warn: #b86e00;
  --danger: #c53030;
  --shadow: 0 10px 30px -12px rgba(10, 60, 40, .18);
  --radius: 16px;
  color-scheme: light;
}
/* Mode sombre : uniquement sur choix du visiteur (bouton 🌙), jamais automatique */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c1412; --surface: #121d1a; --surface-2: #17251f; --text: #e8f1ed;
  --muted: #9bb0a7; --border: #24352f; --brand: #2fc48a; --brand-strong: #5ad6a4;
  --brand-soft: #143528; --accent: #ff7a52; --warn: #f0b040; --danger: #ff6b6b;
  --shadow: 0 10px 30px -12px rgba(0,0,0,.6);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: "Plus Jakarta Sans", system-ui, sans-serif; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
.container { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 760px; }
.ar { font-family: "Noto Kufi Arabic", sans-serif; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* Header */
header {
  position: sticky; top: 0; z-index: 1000;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}
.nav { display: flex; align-items: center; justify-content: space-between; height: 68px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.35rem; }
.logo-mark { width: 36px; height: 36px; border-radius: 10px; display: block; object-fit: cover; }
.nav-links { display: flex; gap: 28px; font-weight: 500; color: var(--muted); }
.nav-links a:hover, .nav-links a.active { color: var(--text); }
.nav-right { display: flex; gap: 10px; align-items: center; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; border-radius: 12px; border: 0; cursor: pointer;
  font: inherit; font-weight: 600; transition: transform .15s, background .15s, opacity .15s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-strong); }
.btn-ghost { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--brand); }
.btn-sm { padding: 8px 14px; font-size: .92rem; border-radius: 10px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer; display: grid; place-items: center;
}
.menu-btn { display: none; }

/* Forms */
.field { display: flex; align-items: center; gap: 10px; padding: 0 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid transparent; }
.field:focus-within { border-color: var(--brand); }
.field svg { flex: none; color: var(--muted); }
.field input, .field select { border: 0; background: transparent; color: var(--text); font: inherit; width: 100%; padding: 13px 0; outline: none; }
label.lbl { display: block; font-weight: 600; font-size: .9rem; margin: 14px 0 6px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.error { color: var(--danger); font-size: .92rem; margin: 12px 0 0; min-height: 1.2em; }
.hint { color: var(--muted); font-size: .85rem; margin: 6px 0 0; }

/* Cards & sections */
.pill { display: inline-flex; gap: 8px; align-items: center; padding: 6px 14px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-strong); font-weight: 600; font-size: .9rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; }
.card h3 { margin: 0 0 8px; font-size: 1.15rem; }
.card p { margin: 0; color: var(--muted); }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 28px; box-shadow: var(--shadow); }
section { padding: 80px 0; }
.alt { background: var(--surface-2); }
.section-title { text-align: center; max-width: 640px; margin: 0 auto 48px; }
.section-title h2 { font-size: clamp(1.8rem, 3.5vw, 2.5rem); margin: 0 0 12px; letter-spacing: -.02em; line-height: 1.2; }
.section-title p { color: var(--muted); margin: 0; font-size: 1.05rem; }
.eyebrow { color: var(--brand); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; font-size: .8rem; }
h1 { font-size: clamp(2.1rem, 5vw, 3.4rem); line-height: 1.1; margin: 18px 0 16px; letter-spacing: -.02em; }
h1 em { font-style: normal; color: var(--brand); }
.lead { font-size: 1.12rem; color: var(--muted); max-width: 620px; margin: 0 0 28px; }
.page-head { padding: 48px 0 24px; }
.page-head h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); margin: 8px 0; }

/* Tags & lists */
.tag { display: inline-block; font-size: .78rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; }
.tag.dispo { background: var(--brand-soft); color: var(--brand); }
.tag.commande { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.tag.indispo { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.tag.new { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.item {
  display: grid; grid-template-columns: 1fr auto; gap: 12px 16px; align-items: center;
  padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; margin-bottom: 10px;
}
.item h4 { margin: 0 0 2px; font-size: 1.08rem; }
.item p { margin: 0; color: var(--muted); font-size: .92rem; }
.item.flash { animation: flash 1.6s ease-out; }
@keyframes flash { from { box-shadow: 0 0 0 3px var(--accent); } to { box-shadow: 0 0 0 3px transparent; } }
.empty { padding: 28px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--border); border-radius: 14px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid var(--brand-soft); border-top-color: var(--brand); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.wa-box { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 20px; font-weight: 600; }
.wa-box .field { flex: 1; min-width: 180px; max-width: 260px; }
.btn-wa { background: #25d366; color: #fff; border: 0; }
.btn-wa:hover { background: #1ebe5b; }
.collect-tip { margin: 0 0 14px; padding: 12px 16px; border-radius: 12px; background: var(--brand-soft); color: var(--text); }
.alert-card { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 18px 20px; margin-bottom: 16px; border-radius: 16px; background: var(--surface); border: 2px solid var(--brand); box-shadow: var(--shadow); }
.alert-card p { margin: 4px 0 0; color: var(--muted); font-size: .95rem; }
.alert-card.on { border: 1px solid var(--border); box-shadow: none; background: var(--brand-soft); }
.alert-card.off { border: 1px dashed var(--border); box-shadow: none; }
.alert-icon { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: var(--brand-soft); font-size: 1.5rem; flex: none; }
.status-bar { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-radius: 14px; background: var(--brand-soft); color: var(--brand-strong); font-weight: 600; margin-bottom: 16px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.on { background: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }

.tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 12px; margin-bottom: 8px; }
.tabs button { flex: 1; padding: 10px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font: inherit; font-weight: 600; cursor: pointer; }
.tabs button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
#map { height: 240px; border-radius: 12px; border: 1px solid var(--border); margin-top: 6px; z-index: 0; }

footer { padding: 40px 0 28px; border-top: 1px solid var(--border); color: var(--muted); font-size: .92rem; margin-top: 40px; }
.copy { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }

@media (max-width: 860px) {
  .nav-links { display: none; }
  .nav-links.open {
    display: flex; flex-direction: column; position: absolute; top: 68px; left: 0; right: 0;
    background: var(--surface); padding: 20px 16px; border-bottom: 1px solid var(--border); gap: 16px;
  }
  .menu-btn { display: grid; }
  .nav-right .btn { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .item { grid-template-columns: 1fr; }
  .actions { justify-content: flex-start; }
  section { padding: 56px 0; }
  .panel { padding: 20px; }
}

/* Bouton "Se connecter en tant que pharmacien" : toujours visible, libellé court sur mobile */
.btn-pharma .short { display: none; }
@media (max-width: 860px) {
  .nav-right .btn-pharma { display: inline-flex; }
  .btn-pharma .long { display: none; }
  .btn-pharma .short { display: inline; }
}
@media (max-width: 1100px) {
  .nav-right .btn-primary { display: none; }
}

/* Langues ------------------------------------------------------------------ */
.i18n-pending body { visibility: hidden; }
.lang-wrap { position: relative; }
.lang-menu {
  position: absolute; top: calc(100% + 6px); inset-inline-end: 0; z-index: 1100; min-width: 160px;
  padding: 6px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow);
}
.lang-menu button {
  display: block; width: 100%; padding: 10px 12px; border: 0; border-radius: 8px; background: transparent;
  color: var(--text); font: inherit; font-weight: 500; text-align: start; cursor: pointer;
}
.lang-menu button:hover { background: var(--surface-2); }
.lang-menu button[aria-current="true"] { color: var(--brand); font-weight: 700; }
.lang-menu button[lang="ar"] { font-family: "Noto Sans Arabic", sans-serif; }
/* Arabe : police adaptée, pas d'espacement entre les lettres (il casse la liaison) */
html[lang="ar"] body { font-family: "Noto Sans Arabic", "Plus Jakarta Sans", system-ui, sans-serif; }
html[lang="ar"] h1, html[lang="ar"] h2, html[lang="ar"] .eyebrow { letter-spacing: 0; text-transform: none; }
html[lang="ar"] h1 { line-height: 1.35; }
/* E-mails, téléphones et mots de passe restent écrits de gauche à droite */
html[dir="rtl"] input[type="email"], html[dir="rtl"] input[type="tel"], html[dir="rtl"] input[type="password"] { direction: ltr; text-align: right; }
/* Petits téléphones : en-tête plus compact (bouton pharmacien en icône seule) */
@media (max-width: 440px) {
  .nav-right { gap: 6px; }
  .nav-right .btn-pharma { padding: 8px 10px; }
  .btn-pharma .short { display: none; }
  .icon-btn { width: 38px; height: 38px; }
}

/* Suggestions de médicaments --------------------------------------------- */
.field { position: relative; }
.ac-list {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 60; max-height: 320px; overflow-y: auto;
  padding: 6px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow);
}
.ac-item { padding: 10px 12px; border-radius: 8px; cursor: pointer; line-height: 1.4; }
.ac-item[aria-selected="true"], .ac-item:hover { background: var(--surface-2); }
.ac-sub { font-size: .85rem; }
.ac-item { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; }
.ac-main { min-width: 0; }
.ac-price { flex: none; font-weight: 700; color: var(--brand); white-space: nowrap; }
.ac-note { padding: 8px 12px 4px; font-size: .78rem; color: var(--muted); border-top: 1px solid var(--border); margin-top: 4px; }
.cat-switch { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.cat-switch label { display: flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 600; font-size: .92rem; }
.cat-switch label:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-strong); }
.cat-switch input { accent-color: var(--brand); margin: 0; }

/* Carte des établissements partenaires (accueil) ---------------------------- */
.map-section { padding-top: 24px; }
.map-card { position: relative; border-radius: 24px; overflow: hidden; border: 1px solid var(--border); box-shadow: var(--shadow); background: var(--surface); }
#homeMap { height: 420px; z-index: 0; }
.map-join { position: absolute; z-index: 500; inset-inline-start: 16px; bottom: 16px; padding: 10px 16px; border-radius: 999px; background: var(--surface); color: var(--brand-strong); font-weight: 700; font-size: .92rem; box-shadow: var(--shadow); border: 1px solid var(--border); }
.pin span { display: block; width: 26px; height: 26px; border-radius: 50%; background: var(--brand); border: 4px solid #fff; box-shadow: 0 0 0 6px color-mix(in srgb, var(--brand) 25%, transparent), 0 4px 10px rgba(0,0,0,.25); }
.leaflet-popup-content-wrapper { border-radius: 14px; font-family: inherit; }
.leaflet-popup-content { line-height: 1.6; }
.leaflet-popup-content .tag { margin-top: 6px; }
@media (max-width: 640px) { #homeMap { height: 320px; } .map-join { font-size: .85rem; bottom: 12px; inset-inline-start: 12px; } }
/* Teinte du fond de carte : douce en clair, inversée en sombre */
.map-card .leaflet-tile-pane { filter: grayscale(.55) saturate(.8) brightness(1.04); }
:root[data-theme="dark"] .map-card .leaflet-tile-pane { filter: grayscale(.6) invert(1) hue-rotate(180deg) brightness(.9) contrast(.9); }
.ac-free { color: var(--brand-strong); font-weight: 600; border-top: 1px solid var(--border); margin-top: 4px; }
.ac-list > .ac-free:first-child { border-top: 0; margin-top: 0; }

/* Ordonnance ---------------------------------------------------------------- */
.rx-box { margin-top: 12px; }
.rx-add { cursor: pointer; }
.rx-preview { display: flex; align-items: center; gap: 12px; }
.rx-preview img { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); }
.rx-view { margin-inline-start: 6px; }
.rx-overlay { position: fixed; inset: 0; z-index: 2000; background: rgba(0,0,0,.6); display: grid; place-items: center; padding: 16px; }
.rx-modal { background: var(--surface); border-radius: 16px; max-width: min(900px, 100%); max-height: 100%; display: flex; flex-direction: column; overflow: hidden; }
.rx-modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.rx-modal img { max-width: 100%; max-height: calc(100vh - 120px); object-fit: contain; background: #fff; }
.hero-rx { display: inline-flex; align-items: center; gap: 8px; margin-top: 14px; padding: 10px 16px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); color: var(--brand-strong); font-weight: 600; cursor: pointer; box-shadow: var(--shadow); }
.hero-rx:hover { border-color: var(--brand); }
