/* Phase 0, version 2: footer, WhatsApp button and member messages.
   Loaded only when the Phase 0 switch is on for this visitor (includes/design_phases.php).
   It never styles the header, menus or page content.
   Brand rules: docs/brand/EDC_Hub_Brand_Playbook_v5.0.md (solid buttons, no gradients). */

:root {
  --p0-navy: #0B1F3A;
  --p0-obsidian: #0E171F;
  --p0-teal: #028090;
  --p0-gold: #C9A86A;
  --p0-cyan: #22D3EE;                 /* keyboard focus on dark surfaces only */
  --p0-cookie-h: 0px;                 /* set by phase0_shell.js while the notice is showing */
  --p0-page-bar: 0px;                 /* height of a page's own fixed bottom bar */
  --p0-safe: env(safe-area-inset-bottom, 0px);
  --p0-lift: var(--p0-cookie-h);      /* how far the notice pushes up the floating buttons */
  --p0-bottom: max(var(--p0-lift), var(--p0-safe));
  --p0-menu-notice: calc(var(--p0-cookie-h) + var(--p0-page-bar));  /* space the side menu leaves for the notice */
  --p0-float-w: 216px;                /* space beside the floating buttons */
  --p0-font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --p0-display: "Fraunces", Georgia, serif;
  --p0-surface: #FFFFFF;
  --p0-text: #0B1F3A;
  --p0-muted: #42526A;
  --p0-line: rgba(15, 23, 42, .12);
  --p0-field: #64748B;
  --p0-hover: rgba(2, 128, 144, .08);
  --p0-focus: #028090;
}
/* Desktop: the notice is in the opposite corner, so nothing on this side needs to move */
@media (min-width: 960px) { :root { --p0-lift: 0px; --p0-menu-notice: 0px; } }
html[data-theme="dark"] {
  --p0-surface: #0B1120;
  --p0-text: #F8FAFC;
  --p0-muted: #B6C2D2;
  --p0-line: rgba(255, 255, 255, .10);
  --p0-field: #8090A6;
  --p0-hover: rgba(255, 255, 255, .08);
  --p0-focus: #22D3EE;
}
.edc-p0-ftr[lang="ar"],
#edcChatDock[dir="rtl"],
html[lang="ar"] .edc-p0-wa {
  --p0-font: "IBM Plex Sans Arabic", system-ui, "Segoe UI", sans-serif;
  --p0-display: "Amiri", "Times New Roman", serif;
}
/* No letter spacing or italics on Arabic text */
.edc-p0-ftr[lang="ar"], .edc-p0-ftr[lang="ar"] *,
#edcChatDock[dir="rtl"], #edcChatDock[dir="rtl"] *,
html[lang="ar"] .edc-p0-wa, html[lang="ar"] .edc-p0-wa * { letter-spacing: 0 !important; font-style: normal !important; }

/* ---------- Footer ---------- */
body:has(> .edc-p0-ftr) { padding-bottom: 0 !important; }
.edc-p0-ftr, .edc-p0-ftr *, .edc-p0-wa, .edc-p0-wa * { box-sizing: border-box; }
/* On short pages, "sticky" with this "top" keeps the footer at the bottom of the screen.
   Longer pages aren't affected. */
.edc-p0-ftr {
  position: sticky; top: 100vh;
  margin-top: 136px;
  background: var(--p0-navy);
  color: #FFFFFF;
  font: 400 1rem/1.6 var(--p0-font);
  text-align: start;
}
.edc-p0-ftr[lang="ar"] { line-height: 1.8; }
.edc-p0-ftr :focus-visible { outline: 3px solid var(--p0-cyan); outline-offset: 2px; border-radius: 8px; }
.edc-p0-ftr__arcs { position: absolute; bottom: calc(100% - 4px); left: 0; width: 100%; height: 72px; pointer-events: none; }
.edc-p0-ftr__arcs path { vector-effect: non-scaling-stroke; }
.edc-p0-ftr__wrap { width: min(1280px, 100% - 32px); margin-inline: auto; }
.edc-p0-ftr__top {
  display: grid;
  grid-template-columns: minmax(250px, 1.5fr) repeat(4, minmax(0, 1fr));
  gap: 40px 28px;
  padding-block: 64px 48px;
}
.edc-p0-ftr__brand { display: flex; flex-wrap: wrap; align-items: center; align-self: start; gap: 12px; min-width: 0; }
/* The logo file has about 9% empty space a side. The negative margins line up its visible edge. */
.edc-p0-ftr__brand img { display: block; flex: none; width: 88px; height: 88px; max-width: none; margin-block: -8px; margin-inline: -8px 0; }
.edc-p0-ftr__brand div { flex: 1 1 9rem; min-width: 0; }
.edc-p0-ftr__brand b { display: block; color: #FFFFFF; font: 600 1.1875rem/1.3 var(--p0-display); }
.edc-p0-ftr[lang="ar"] .edc-p0-ftr__brand b { font-weight: 700; font-size: 1.3125rem; line-height: 1.45; }
.edc-p0-ftr__brand p { max-width: 30ch; margin: 6px 0 0; text-wrap: balance; color: #C6D0DD; font-size: .9375rem; line-height: 1.55; }
.edc-p0-ftr h2 { margin: 0 0 6px; color: var(--p0-gold); font: 600 1rem/1.6 var(--p0-font); text-transform: none; }
.edc-p0-ftr ul { margin: 0; padding: 0; list-style: none; }
.edc-p0-ftr li { margin: 0; padding: 0; }
.edc-p0-ftr h2, .edc-p0-ftr a { overflow-wrap: break-word; }
.edc-p0-ftr a {
  display: inline-flex; align-items: center;
  min-width: 44px; min-height: 44px;
  color: #E4EAF2; font-size: .9375rem; line-height: 1.5; text-decoration: none;
}
.edc-p0-ftr a:hover { color: #FFFFFF; text-decoration: underline; text-decoration-color: var(--p0-gold); text-underline-offset: 5px; }
.edc-p0-ftr__mid { padding-block: 24px; border-top: 1px solid rgba(255, 255, 255, .16); }
.edc-p0-ftr__mid ul, .edc-p0-ftr__end ul { display: flex; flex-wrap: wrap; gap: 0 24px; }
/* The last row stays beside the floating buttons, so there is no empty space below it.
   Extra space is added only while the cookie notice or a page's own bottom bar is showing. */
.edc-p0-ftr__end {
  display: flex; flex-wrap: wrap; align-items: center; align-content: center; justify-content: flex-start; gap: 0 32px;
  min-height: 80px;
  padding-block: 8px calc(8px + max(var(--p0-cookie-h), var(--p0-safe)) + var(--p0-page-bar));
  padding-inline-end: var(--p0-float-w);
  border-top: 1px solid rgba(255, 255, 255, .16);
}
/* Logged in on smaller screens: room for the messages button above WhatsApp */
@media (max-width: 1199.98px) { body:has(#edcChatDock) .edc-p0-ftr__end { min-height: calc(144px + max(var(--p0-cookie-h), var(--p0-safe)) + var(--p0-page-bar)); } }
.edc-p0-ftr__end p { margin: 0; color: #C6D0DD; font-size: .875rem; }

/* Pages with their own fixed bottom bar: clinic pages and the new mobile directory */
@media (max-width: 959.98px) { html.cv2-on { --p0-page-bar: 92px; } }          /* Same width as clinic_v2.css */
@media (max-width: 767.98px) { html:has(body.dv3-m2) { --p0-page-bar: 92px; } }
/* The cookie notice sits above the booking bar. The directory bar appears after scrolling. */
@media (max-width: 959.98px) { html.cv2-on { --p0-notice-above: calc(94px + env(safe-area-inset-bottom, 0px)); } }
@media (max-width: 767.98px) { html.dmv2-bar-on { --p0-notice-above: calc(94px + env(safe-area-inset-bottom, 0px)); } }
/* The Specialists page has a Join button above WhatsApp, for visitors */
body:has(> a.fixed[href="/auth/register.php"]) .edc-p0-ftr__end { min-height: calc(152px + max(var(--p0-cookie-h), var(--p0-safe))); }

/* ---------- WhatsApp button ----------
   No ID in the selector, so the page rules that hide #edc-wa-fab still work. */
.edc-p0-wa {
  position: fixed; z-index: 60;
  bottom: calc(16px + var(--p0-bottom)); inset-inline-end: 16px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 8px 18px;
  border: 1px solid rgba(255, 255, 255, .28); border-radius: 10px;
  background: var(--p0-navy); color: #FFFFFF;
  box-shadow: 0 18px 44px rgba(2, 6, 23, .28);
  font: 600 .9375rem/1.3 var(--p0-font); text-decoration: none; white-space: nowrap;
}
.edc-p0-wa:hover { background: var(--p0-obsidian); color: #FFFFFF; }
.edc-p0-wa:focus-visible { outline: 3px solid var(--p0-focus); outline-offset: 2px; }
/* Pages with their own WhatsApp button keep it. It only moves up while the cookie notice is showing.
   "translate" is used so the buttons' own hover movement still works. */
a.edcv3-wa-fab, #edc-wa-fab:not(.edc-p0-wa) { translate: 0 calc(-1 * var(--p0-lift)); }
.pitch-counter { translate: 0 calc(-1 * var(--p0-cookie-h)); }
/* Dentist pitch: the language buttons sit above WhatsApp */
.pitch-lang-toggle { translate: 0 calc(-56px - var(--p0-lift)); }
/* Specialists: the Join button (with inline styles) sits above WhatsApp */
body > a.fixed[href="/auth/register.php"] { bottom: calc(80px + var(--p0-bottom)) !important; }
.edc-p0-wa svg { flex: none; width: 22px; height: 22px; fill: #25D366; }

/* ---------- Member messages ----------
   Same markup and script as the current panel. The button sits above WhatsApp. */
#edcChatDock, #edcChatDock * { box-sizing: border-box; }
#edcChatDock { inset-inline: auto 16px; bottom: calc(76px + var(--p0-bottom)); font-family: var(--p0-font); }
/* Above the page's own bottom bar, or the cookie notice if that's higher. "translate" would
   break the full-screen panel, so this uses "bottom". The bar heights match clinic_v2.css and
   directory_mobile_v2.css. */
@media (max-width: 959.98px) {
  html.cv2-on #edcChatDock { bottom: calc(102px + var(--p0-safe) + var(--p0-lift)) !important; }
}
html.dmv2-bar-on #edcChatDock { bottom: calc(112px + var(--p0-lift)) !important; }
/* Wide screens: Messages sits beside WhatsApp, so the footer needs only one row */
@media (min-width: 1200px) {
  body:has(.edc-p0-wa) #edcChatDock { inset-inline-end: 216px; bottom: 16px; }
  body:has(.edc-p0-wa):has(#edcChatDock) { --p0-float-w: 400px; }
}
#edcChatDock button, #edcChatDock input { font-family: inherit; }
#edcChatDock :focus-visible { outline: 3px solid var(--p0-focus); outline-offset: 2px; }
#edcChatDock .edc-cd-launch {
  justify-content: center;
  min-height: 48px; padding: 8px 18px;
  border: 1px solid rgba(255, 255, 255, .28); border-radius: 10px;
  background: var(--p0-navy); color: #FFFFFF;
  box-shadow: 0 18px 44px rgba(2, 6, 23, .28); font-weight: 600;
}
#edcChatDock .edc-cd-launch:hover { background: var(--p0-obsidian); }
#edcChatDock .edc-cd-launch-txt { font-size: .9375rem; }
#edcChatDock .edc-cd-badge { background: var(--p0-gold); color: var(--p0-navy); }
#edcChatDock .edc-cd-panel {
  inset-inline: auto 0;
  width: 360px; height: 480px;
  max-height: calc(100vh - 200px - var(--p0-bottom));
  max-height: calc(100dvh - 200px - var(--p0-bottom));
  border: 1px solid var(--p0-line); border-radius: 16px;
  background: var(--p0-surface); color: var(--p0-text);
  box-shadow: 0 18px 44px rgba(2, 6, 23, .28);
}
#edcChatDock .edc-cd-head { padding-block: 8px; padding-inline: 16px 8px; border: 0; background: var(--p0-navy); color: #FFFFFF; --p0-focus: var(--p0-cyan); }
#edcChatDock .edc-cd-title, #edcChatDock .edc-cd-peer { font-weight: 600; font-size: 1rem; }
#edcChatDock .edc-cd-x, #edcChatDock .edc-cd-back { min-width: 44px; height: 44px; padding: 0; border-radius: 10px; color: #FFFFFF; }
#edcChatDock .edc-cd-x:hover, #edcChatDock .edc-cd-back:hover { background: rgba(255, 255, 255, .12); }
/* The Back arrow (‹) already flips by itself in Arabic, so it needs no transform */
#edcChatDock .edc-cd-thread:hover { background: var(--p0-hover); }
#edcChatDock .edc-cd-av { background: var(--p0-hover); color: var(--p0-text); }
#edcChatDock .edc-cd-tname { font-size: .9375rem; }
#edcChatDock .edc-cd-tprev, #edcChatDock .edc-cd-ttime, #edcChatDock .edc-cd-empty { color: var(--p0-muted); font-size: .8125rem; }
#edcChatDock .edc-cd-tdot { background: var(--p0-teal); }
#edcChatDock .edc-cd-bubble { background: var(--p0-hover); color: var(--p0-text); }
#edcChatDock .edc-cd-bubble.is-mine { background: var(--p0-teal); color: #FFFFFF; }
#edcChatDock .edc-cd-btext { font-size: .9375rem; }
#edcChatDock .edc-cd-btime { font-size: .75rem; opacity: 1; text-align: end; }
#edcChatDock .edc-cd-form { padding: 12px; border-color: var(--p0-line); }
#edcChatDock .edc-cd-input { min-height: 48px; padding: 10px 14px; border: 1px solid var(--p0-field); border-radius: 10px; background: var(--p0-surface); color: var(--p0-text); font-size: 1rem; }
#edcChatDock .edc-cd-input:focus { border-color: var(--p0-focus); }
#edcChatDock .edc-cd-input::placeholder { color: var(--p0-muted); opacity: 1; }
#edcChatDock .edc-cd-send { width: 48px; min-width: 48px; height: 48px; border-radius: 10px; background: var(--p0-teal); }
#edcChatDock .edc-cd-send:hover { background: var(--p0-navy); }
html[data-theme="dark"] #edcChatDock .edc-cd-send:hover { background: #F8FAFC; color: var(--p0-navy); }
#edcChatDock[dir="rtl"] .edc-cd-send svg { transform: scaleX(-1); }

/* ---------- Smaller screens ---------- */
@media (max-width: 1279.98px) {
  .edc-p0-ftr__top { grid-template-columns: repeat(4, minmax(0, 1fr)); padding-block-start: 44px; }
  .edc-p0-ftr__brand { grid-column: 1 / -1; padding-bottom: 28px; border-bottom: 1px solid rgba(255, 255, 255, .16); }
}
@media (max-width: 900px) {
  .edc-p0-ftr__top { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  :root { --p0-float-w: 76px; }
  .edc-p0-ftr { margin-top: 96px; }
  .edc-p0-ftr__arcs { height: 40px; }
  .edc-p0-wa, #edcChatDock .edc-cd-launch { width: 52px; height: 52px; min-height: 52px; padding: 0; border-radius: 50%; }
  /* Icon only on phones. The button keeps its label for screen readers. */
  .edc-p0-wa span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
}
/* Small phones: two link columns, or one when the text is very large */
@media (max-width: 400px) {
  .edc-p0-ftr__top { grid-template-columns: repeat(auto-fit, minmax(min(100%, 8rem), 1fr)); }
}
/* Full-screen messages on phones, including sideways. Keep in step with FULL_SCREEN in phase0_shell.js. */
@media (max-width: 600px), (max-height: 500px) and (max-width: 950px) {
  #edcChatDock.is-open { z-index: 100002; }
  #edcChatDock .edc-cd-panel {
    position: fixed; inset: 0;
    width: 100%; max-width: 100%; height: auto; max-height: none;
    padding-bottom: max(var(--p0-menu-notice), var(--p0-safe));
    border: 0; border-radius: 0;
  }
  #edcChatDock .edc-cd-head { padding-top: calc(8px + env(safe-area-inset-top, 0px)); }
}
@media print {
  .edc-p0-wa, #edcChatDock { display: none !important; }
}
