/* MedaZone v2 — "اسأل MedaZone": the AI search's floating launcher and chat panel (App\Pages\AiLauncher).
 *
 * Printed only while MEDAZONE_AI_SEARCH is on. Every colour comes from the product's --m-* tokens (light and dark
 * follow the site), with fallbacks for the few pages that do not load medazone.css. Logical properties
 * throughout: the launcher sits at the inline end — bottom-left in Arabic, bottom-right in English. It is lifted
 * above whatever else floats at the bottom of the page (the app's tab bar, a sticky booking bar…) by
 * ai-search.js through --mz-ai-lift.
 */
.mz-ai-root {
	/* The site's own palette (medazone.css, .medazone-scope), copied: the panel sits at the end of <body>,
	   outside the scope element that defines the tokens. ai-search.js mirrors the page's light/dark mode
	   (the theme switch) onto data-theme. Text on the brand blue is the site's dark ink, as on its buttons. */
	--ai-primary: oklch(0.70 0.160 258);
	--ai-primary-2: oklch(0.64 0.165 258);
	--ai-on-primary: oklch(0.18 0.030 255);
	--ai-bg: oklch(0.963 0.007 250);
	--ai-bg-2: oklch(0.928 0.011 250);
	--ai-text: oklch(0.20 0.025 255);
	--ai-muted: oklch(0.44 0.022 252);
	--ai-border: oklch(0.868 0.014 250);
	--ai-danger: oklch(0.55 0.190 25);
	--ai-danger-bg: oklch(0.95 0.030 25);
	--ai-safety-bg: oklch(0.95 0.050 80);
	--ai-success: oklch(0.52 0.130 148);
	--ai-chip-bg: oklch(0.70 0.160 258 / 0.16);
	--ai-link: oklch(0.50 0.175 258);
	--mz-ai-lift: 0px;
	--mz-ai-gap: 16px;
	font-family: "Cairo", system-ui, -apple-system, "Segoe UI", sans-serif;
	line-height: 1.6;
}
.mz-ai-root[data-theme="dark"] {
	--ai-bg: oklch(0.245 0.022 250);
	--ai-bg-2: oklch(0.20 0.018 250);
	--ai-text: oklch(0.96 0.008 250);
	--ai-muted: oklch(0.72 0.020 250);
	--ai-border: oklch(0.36 0.022 250);
	--ai-danger: oklch(0.70 0.170 25);
	--ai-danger-bg: oklch(0.31 0.055 25);
	--ai-safety-bg: oklch(0.31 0.050 70);
	--ai-success: oklch(0.80 0.125 148);
	--ai-chip-bg: oklch(0.70 0.160 258 / 0.22);
	--ai-link: oklch(0.78 0.120 258);
}
.mz-ai-root *, .mz-ai-root *::before, .mz-ai-root *::after { box-sizing: border-box; }
.mz-ai-root [hidden] { display: none !important; }

/* ---------------------------------------------------------------- the launcher */
.mz-ai-launch {
	position: fixed; z-index: 9985;
	inset-inline-end: calc(var(--mz-ai-gap) + env(safe-area-inset-right, 0px));
	bottom: calc(var(--mz-ai-gap) + var(--mz-ai-lift) + env(safe-area-inset-bottom, 0px));
	display: inline-flex; align-items: center; gap: 10px;
	height: 58px; min-width: 58px; padding: 0 18px; border: none; border-radius: 999px; cursor: pointer;
	background: var(--ai-primary); color: var(--ai-on-primary); font: inherit; font-size: 14.5px; font-weight: 800;
	box-shadow: 0 10px 28px oklch(0.45 0.15 258 / 0.38), 0 2px 6px oklch(0 0 0 / 0.18);
	transition: bottom .22s ease, transform .15s ease, background-color .15s ease, opacity .2s ease;
	-webkit-tap-highlight-color: transparent;
}
.mz-ai-launch:hover { background: var(--ai-primary-2); }
.mz-ai-launch:active { transform: scale(.96); }
.mz-ai-launch:focus-visible { outline: 3px solid var(--ai-primary); outline-offset: 3px; }
.mz-ai-launch svg { flex: none; }
.mz-ai-launch .mz-ai-spark { position: absolute; top: 9px; inset-inline-start: 34px; opacity: .9; }
.mz-ai-launch-label { white-space: nowrap; }
.mz-ai-root.is-open .mz-ai-launch { opacity: 0; pointer-events: none; transform: scale(.9); }
@media (max-width: 719px) {
	/* A round button on phones; the name is its tooltip and accessible label. */
	.mz-ai-launch { width: 58px; padding: 0; justify-content: center; }
	.mz-ai-launch-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
	.mz-ai-launch .mz-ai-spark { top: 11px; inset-inline-start: 36px; }
}

/* ---------------------------------------------------------------- the panel */
.mz-ai-backdrop { position: fixed; inset: 0; z-index: 99988; background: oklch(0 0 0 / 0.45); }
.mz-ai-panel {
	position: fixed; z-index: 99989; display: flex; flex-direction: column; overflow: hidden;
	background: var(--ai-bg); color: var(--ai-text); border: 1px solid var(--ai-border);
	box-shadow: 0 24px 60px oklch(0 0 0 / 0.32);
	/* phones: a bottom sheet */
	inset-inline: 0; bottom: var(--mz-ai-kb, 0px); width: 100%;
	max-height: min(88vh, calc(var(--mz-ai-vh, 100vh) - 24px)); height: min(640px, calc(var(--mz-ai-vh, 100vh) - 24px));
	border-radius: 22px 22px 0 0; border-bottom: none;
	padding-bottom: env(safe-area-inset-bottom, 0px);
	animation: mz-ai-up .22s cubic-bezier(.2, .9, .3, 1) both;
}
@supports (height: 100dvh) {
	.mz-ai-panel { max-height: min(88dvh, calc(var(--mz-ai-vh, 100dvh) - 24px)); height: min(640px, calc(var(--mz-ai-vh, 100dvh) - 24px)); }
}
@media (min-width: 720px) {
	/* larger screens: a card above the launcher's corner; no backdrop */
	.mz-ai-backdrop { display: none; }
	.mz-ai-panel {
		inset-inline: auto; inset-inline-end: calc(var(--mz-ai-gap) + env(safe-area-inset-right, 0px));
		bottom: calc(var(--mz-ai-gap) + var(--mz-ai-lift)); width: 384px;
		height: min(620px, calc(100vh - 48px - var(--mz-ai-lift))); max-height: none;
		border-radius: 20px; border-bottom: 1px solid var(--ai-border); padding-bottom: 0;
	}
}
@keyframes mz-ai-up { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }

.mz-ai-head {
	display: flex; align-items: center; gap: 12px; padding: 14px 16px; flex: none;
	background: var(--ai-primary); color: var(--ai-on-primary);
}
.mz-ai-avatar { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: oklch(1 0 0 / 0.30); flex: none; }
.mz-ai-avatar svg { width: 20px; height: 20px; }
.mz-ai-titles { flex: 1; min-width: 0; }
.mz-ai-title { margin: 0; font-size: 16px; font-weight: 800; line-height: 1.3; color: inherit; }
.mz-ai-sub { margin: 0; font-size: 12.5px; opacity: .88; }
.mz-ai-x {
	display: grid; place-items: center; width: 40px; height: 40px; border: none; border-radius: 50%; cursor: pointer;
	background: oklch(1 0 0 / 0.30); color: inherit;
}
.mz-ai-x:hover { background: oklch(1 0 0 / 0.45); }
.mz-ai-x:focus-visible { outline: 2px solid var(--ai-on-primary); outline-offset: 2px; }

/* the conversation */
.mz-ai-log {
	flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
	display: flex; flex-direction: column; gap: 10px; padding: 14px; background: var(--ai-bg-2);
}
.mz-ai-msg { max-width: 92%; font-size: 14px; }
.mz-ai-msg p { margin: 0; }
.mz-ai-msg.is-bot { align-self: flex-start; padding: 10px 12px; border-radius: 16px; border-start-start-radius: 6px; background: var(--ai-bg); border: 1px solid var(--ai-border); }
.mz-ai-msg.is-user {
	align-self: flex-end; padding: 9px 13px; border-radius: 16px; border-start-end-radius: 6px;
	background: var(--ai-primary); color: var(--ai-on-primary); font-weight: 600; white-space: pre-wrap; overflow-wrap: anywhere;
}
.mz-ai-msg.is-wide { max-width: 100%; width: 100%; }
.mz-ai-msg.is-typing { display: inline-flex; gap: 4px; padding: 12px 14px; }
.mz-ai-msg.is-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--ai-muted); animation: mz-ai-dot 1s infinite ease-in-out; }
.mz-ai-msg.is-typing i:nth-child(2) { animation-delay: .15s; }
.mz-ai-msg.is-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes mz-ai-dot { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.mz-ai-exs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.mz-ai-ex {
	font: inherit; font-size: 12.5px; font-weight: 700; padding: 6px 11px; border-radius: 999px; cursor: pointer;
	background: var(--ai-bg-2); color: var(--ai-link); border: 1px solid var(--ai-border);
}
.mz-ai-ex:hover { border-color: var(--ai-primary); }
.mz-ai-chips { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; font-size: 12px; color: var(--ai-muted); }
.mz-ai-chip { padding: 2px 9px; border-radius: 999px; background: var(--ai-chip-bg); color: var(--ai-text); font-weight: 700; }
.mz-ai-note { margin: 8px 0 0 !important; font-size: 13px; line-height: 1.75; color: var(--ai-muted); }
.mz-ai-note.is-safety { padding: 7px 10px; border-radius: 10px; background: var(--ai-safety-bg); color: var(--ai-text); }
.mz-ai-ask { margin-top: 8px !important; font-weight: 700; }

.mz-ai-emergency { margin: 0 0 10px; padding: 12px; border-radius: 14px; background: var(--ai-danger-bg); color: var(--ai-text); border: 1px solid var(--ai-danger); }
.mz-ai-emergency p { margin: 0; font-size: 14.5px; font-weight: 700; line-height: 1.8; }
p.mz-ai-emergency { font-size: 14.5px; font-weight: 700; line-height: 1.8; }

/* compact result cards */
.mz-ai-cards { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.mz-ai-doc { padding: 10px; border-radius: 14px; background: var(--ai-bg-2); border: 1px solid var(--ai-border); }
.mz-ai-doc-top { display: flex; gap: 10px; align-items: flex-start; }
.mz-ai-ph { flex: none; width: 42px; height: 42px; border-radius: 50%; object-fit: cover; display: grid; place-items: center; font-weight: 800; background: var(--ai-bg); color: var(--ai-link); border: 1px solid var(--ai-border); }
.mz-ai-doc-id { flex: 1; min-width: 0; }
.mz-ai-doc-name { display: block; font-size: 14px; font-weight: 800; color: var(--ai-text); text-decoration: none; line-height: 1.4; }
.mz-ai-doc-name:hover { color: var(--ai-link); }
.mz-ai-doc-line { font-size: 12px; color: var(--ai-muted); line-height: 1.6; overflow-wrap: anywhere; }
.mz-ai-doc-line b { color: var(--ai-text); font-weight: 700; }
.mz-ai-next { font-size: 12px; font-weight: 700; color: var(--ai-success); margin-top: 2px; }
.mz-ai-slots { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-top: 8px; }
.mz-ai-day { font-size: 11.5px; font-weight: 800; color: var(--ai-muted); margin-inline-end: 2px; }
.mz-ai-slot {
	font-size: 12.5px; font-weight: 700; padding: 4px 9px; border-radius: 8px; text-decoration: none;
	background: var(--ai-bg); color: var(--ai-link); border: 1px solid var(--ai-border);
}
.mz-ai-slot:hover { border-color: var(--ai-primary); }
.mz-ai-book {
	margin-inline-start: auto; font-size: 12.5px; font-weight: 800; padding: 5px 14px; border-radius: 9px; text-decoration: none;
	background: var(--ai-primary); color: var(--ai-on-primary) !important;
}
.mz-ai-place {
	display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 14px; text-decoration: none;
	background: var(--ai-bg-2); color: var(--ai-text); border: 1px solid var(--ai-border);
}
.mz-ai-place:hover { border-color: var(--ai-primary); }
.mz-ai-place .txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mz-ai-place .txt b { font-size: 14px; }
.mz-ai-place .txt small { font-size: 12px; color: var(--ai-muted); }
.mz-ai-more { display: inline-block; margin-top: 10px; font-size: 13px; font-weight: 800; color: var(--ai-link); text-decoration: none; }
.mz-ai-more:hover { text-decoration: underline; }

/* the composer */
.mz-ai-compose { flex: none; padding: 10px 12px 8px; background: var(--ai-bg); border-top: 1px solid var(--ai-border); }
.mz-ai-row { display: flex; align-items: center; gap: 8px; }
.mz-ai-q {
	flex: 1; min-width: 0; font: inherit; font-size: 16px; /* 16px: no zoom on focus in iOS */
	color: var(--ai-text); background: var(--ai-bg-2); border: 1px solid var(--ai-border); border-radius: 999px; padding: 10px 16px; outline: none;
}
.mz-ai-q:focus { border-color: var(--ai-primary); }
.mz-ai-q::placeholder { color: var(--ai-muted); }
.mz-ai-mic, .mz-ai-send {
	position: relative; flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; border: none; cursor: pointer;
	background: var(--ai-primary); color: var(--ai-on-primary);
}
.mz-ai-send { background: transparent; color: var(--ai-link); }
.mz-ai-send:hover { background: color-mix(in oklch, var(--ai-primary) 12%, transparent); }
.mz-ai-mic:focus-visible, .mz-ai-send:focus-visible { outline: 2px solid var(--ai-primary); outline-offset: 2px; }
.mz-ai-ring { position: absolute; inset: 0; border-radius: 50%; pointer-events: none; }
.mz-ai-root[data-state="listening"] .mz-ai-mic { background: var(--ai-danger); }
.mz-ai-root[data-state="listening"] .mz-ai-ring { animation: mz-ai-pulse 1.4s ease-out infinite; }
@keyframes mz-ai-pulse {
	from { box-shadow: 0 0 0 0 color-mix(in oklch, var(--ai-danger) 55%, transparent); }
	to { box-shadow: 0 0 0 14px transparent; }
}
.mz-ai-root[data-state="busy"] .mz-ai-send { opacity: .5; pointer-events: none; }
.mz-ai-meta { display: flex; align-items: center; gap: 10px; min-height: 18px; padding: 4px 6px 0; font-size: 12px; color: var(--ai-muted); }
.mz-ai-status:empty { display: none; }
.mz-ai-tts { display: inline-flex; gap: 5px; align-items: center; cursor: pointer; white-space: nowrap; margin-inline-start: auto; }
.mz-ai-privacy { margin: 2px 6px 0; font-size: 11px; line-height: 1.5; color: var(--ai-muted); }

html.mz-ai-lock, html.mz-ai-lock body { overflow: hidden !important; }
@media (min-width: 720px) { html.mz-ai-lock, html.mz-ai-lock body { overflow: auto !important; } }

@media (prefers-reduced-motion: reduce) {
	.mz-ai-panel, .mz-ai-msg.is-typing i { animation: none; }
	.mz-ai-launch { transition: none; }
	.mz-ai-root[data-state="listening"] .mz-ai-ring { animation: none; box-shadow: 0 0 0 4px color-mix(in oklch, var(--ai-danger) 40%, transparent); }
}

/* the play / stop button on each reply */
.mz-ai-msg.is-bot { position: relative; padding-inline-end: 44px; }
.mz-ai-say {
	position: absolute; top: 8px; inset-inline-end: 8px; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
	border: 1px solid var(--ai-border); background: var(--ai-bg-2); color: var(--ai-link); cursor: pointer;
}
.mz-ai-say:hover { border-color: var(--ai-link); }
.mz-ai-say:focus-visible { outline: 2px solid var(--ai-link); outline-offset: 2px; }
.mz-ai-say.is-on { background: var(--ai-primary); color: var(--ai-on-primary); border-color: transparent; }
.mz-ai-say.is-on .w1, .mz-ai-say.is-on .w2 { animation: mz-ai-wave 1s ease-in-out infinite; }
.mz-ai-say.is-on .w2 { animation-delay: .25s; }
@keyframes mz-ai-wave { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }
.mz-ai-msg.is-typing { padding-inline-end: 14px; }
@media (prefers-reduced-motion: reduce) { .mz-ai-say.is-on .w1, .mz-ai-say.is-on .w2 { animation: none; } }
