/* AI Doctor Suite — chat UI. Logical properties only, so RTL/LTR need no overrides. */
.aidoc {
	--ad-ink: #0d2b33;
	--ad-muted: #5b747b;
	--ad-paper: #ffffff;
	--ad-mist: #eef4f3;
	--ad-line: #d4e2e0;
	--ad-brand: #0b7a75;
	--ad-brand-ink: #ffffff;
	--ad-brand-soft: #d5eae6;
	--ad-warn: #c8372d;
	--ad-warn-soft: #fde9e6;
	--ad-amber: #f2b544;
	--ad-amber-soft: #fff4dc;
	--ad-radius: 18px;
	--ad-font: "Bricolage Grotesque", "Vazirmatn", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
	font-family: var(--ad-font);
	color: var(--ad-ink);
	font-size: 16px;
	line-height: 1.75;
	text-align: start;
	-webkit-text-size-adjust: 100%;
}
@media (prefers-color-scheme: dark) {
	.aidoc[data-dark="auto"] {
		--ad-ink: #e6f1f0; --ad-muted: #9db6b8; --ad-paper: #112a31; --ad-mist: #0b1f25; --ad-line: #25454d;
		--ad-brand: #3cc2b8; --ad-brand-ink: #062a2c; --ad-brand-soft: #14423f; --ad-warn-soft: #3a1b19; --ad-amber-soft: #3a2f13;
	}
}
.aidoc *, .aidoc *::before, .aidoc *::after { box-sizing: border-box; }

.aidoc__panel {
	display: flex; flex-direction: column;
	height: var(--aidoc-h, 640px); max-height: 92vh; min-height: 420px;
	background: var(--ad-paper);
	border: 1px solid var(--ad-line);
	border-radius: var(--ad-radius);
	overflow: hidden;
	box-shadow: 0 1px 0 var(--ad-line), 0 24px 48px -28px rgba(13, 43, 51, .35);
}
.aidoc__panel[hidden] { display: none; }

/* header */
.aidoc__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-block-end: 1px solid var(--ad-line); background: var(--ad-mist); }
.aidoc__id { display: flex; align-items: center; gap: 12px; min-width: 0; }
.aidoc__id strong { display: block; font-size: 1.02rem; line-height: 1.3; }
.aidoc__id small { display: block; color: var(--ad-muted); font-size: .78rem; line-height: 1.4; }
.aidoc__pulse { position: relative; inline-size: 12px; block-size: 12px; border-radius: 50%; background: var(--ad-brand); flex: none; }
.aidoc__pulse::after { content: ""; position: absolute; inset: -5px; border-radius: 50%; border: 2px solid var(--ad-brand); opacity: 0; animation: ad-pulse 2.8s ease-out infinite; }
@keyframes ad-pulse { 0% { transform: scale(.6); opacity: .7; } 70%, 100% { transform: scale(1.3); opacity: 0; } }
.aidoc__tools { display: flex; gap: 6px; }

.aidoc__ico { display: inline-grid; place-items: center; min-inline-size: 38px; block-size: 38px; padding: 0 8px; border: 1px solid transparent; border-radius: 12px; background: transparent; color: var(--ad-ink); font: 600 .8rem/1 var(--ad-font); cursor: pointer; transition: background .15s, color .15s, border-color .15s; }
.aidoc__ico:hover { background: var(--ad-brand-soft); }
.aidoc__ico.is-on, .aidoc__ico[aria-pressed="true"] { background: var(--ad-brand); color: var(--ad-brand-ink); }
.aidoc :focus-visible { outline: 3px solid var(--ad-amber); outline-offset: 2px; }

/* alert */
.aidoc__alert { padding: 12px 18px; background: var(--ad-warn-soft); border-block-end: 2px solid var(--ad-warn); font-size: .94rem; line-height: 1.65; }
.aidoc__alert[hidden] { display: none; }
.aidoc__alert strong { color: var(--ad-warn); }
.aidoc__alert--crisis { background: var(--ad-amber-soft); border-block-end-color: var(--ad-amber); }
.aidoc__alert--crisis strong { color: inherit; }

/* consent */
.aidoc__consent { padding: 14px 18px; background: var(--ad-amber-soft); border-block-end: 1px solid var(--ad-line); font-size: .9rem; }
.aidoc__consent[hidden] { display: none; }
.aidoc__consent p { margin: 0 0 10px; }
.aidoc__btn { padding: 9px 16px; border: 0; border-radius: 12px; background: var(--ad-brand); color: var(--ad-brand-ink); font: 600 .92rem/1.2 var(--ad-font); cursor: pointer; }

/* log */
.aidoc__log { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 14px; scroll-behavior: smooth; overscroll-behavior: contain; }
.aidoc__msg { display: flex; max-inline-size: 100%; }
.aidoc__msg--user { justify-content: flex-end; }
.aidoc__bubble { max-inline-size: min(100%, 640px); padding: 12px 16px; border-radius: 16px; word-wrap: break-word; overflow-wrap: anywhere; }
.aidoc__msg--bot .aidoc__bubble { background: var(--ad-mist); border: 1px solid var(--ad-line); border-start-start-radius: 4px; }
.aidoc__msg--user .aidoc__bubble { background: var(--ad-brand); color: var(--ad-brand-ink); border-start-end-radius: 4px; }
.aidoc__bubble p { margin: 0 0 .65em; }
.aidoc__bubble p:last-child { margin-block-end: 0; }
.aidoc__bubble ul, .aidoc__bubble ol { margin: 0 0 .65em; padding-inline-start: 1.3em; }
.aidoc__bubble li { margin-block-end: .25em; }
.aidoc__img { display: block; max-inline-size: 220px; max-block-size: 220px; border-radius: 10px; margin-block-end: 8px; }

.aidoc__cite a { color: var(--ad-brand); font-weight: 700; text-decoration: none; padding: 0 2px; }
.aidoc__cite a:hover { text-decoration: underline; }

/* pipeline steps */
.aidoc__steps { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; padding: 0; }
.aidoc__steps:empty { display: none; }
.aidoc__steps li { font-size: .72rem; line-height: 1; padding: 5px 9px; border-radius: 99px; border: 1px solid var(--ad-line); color: var(--ad-muted); background: var(--ad-paper); }
.aidoc__steps li.is-start { color: var(--ad-ink); border-color: var(--ad-brand); animation: ad-blink 1.1s ease-in-out infinite; }
.aidoc__steps li.is-done { color: var(--ad-brand); border-color: var(--ad-brand-soft); background: var(--ad-brand-soft); }
@keyframes ad-blink { 50% { opacity: .45; } }

.aidoc__typing { display: inline-flex; gap: 4px; padding-block: 4px; }
.aidoc__typing i { inline-size: 7px; block-size: 7px; border-radius: 50%; background: var(--ad-muted); animation: ad-dot 1.2s infinite ease-in-out; }
.aidoc__typing i:nth-child(2) { animation-delay: .15s; }
.aidoc__typing i:nth-child(3) { animation-delay: .3s; }
@keyframes ad-dot { 0%, 80%, 100% { transform: translateY(0); opacity: .4; } 40% { transform: translateY(-4px); opacity: 1; } }

/* meta, sources, review */
.aidoc__meta { display: flex; flex-wrap: wrap; gap: 6px; margin-block-start: 10px; }
.aidoc__pill { font-size: .72rem; line-height: 1; padding: 5px 9px; border-radius: 99px; background: var(--ad-paper); border: 1px solid var(--ad-line); color: var(--ad-muted); }
.aidoc__pill--high, .aidoc__pill--emergency { background: var(--ad-warn-soft); border-color: var(--ad-warn); color: var(--ad-warn); font-weight: 700; }
.aidoc__pill--moderate { background: var(--ad-amber-soft); border-color: var(--ad-amber); }
.aidoc__pill--cov-low { border-style: dashed; }
.aidoc__refs { margin-block-start: 10px; font-size: .84rem; }
.aidoc__refs summary { cursor: pointer; color: var(--ad-brand); font-weight: 600; }
.aidoc__refs ol { margin: 8px 0 0; padding-inline-start: 1.3em; }
.aidoc__refs a { color: var(--ad-ink); }
.aidoc__refs small { color: var(--ad-muted); }
.aidoc__review { margin-block-start: 10px; padding: 10px 12px; border-inline-start: 4px solid var(--ad-warn); background: var(--ad-warn-soft); border-radius: 8px; font-size: .9rem; }
.aidoc__err { color: var(--ad-warn); margin: 0; }

/* chips */
.aidoc__chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 18px 12px; }
.aidoc__chips:empty { display: none; }
.aidoc__chip { padding: 8px 12px; border-radius: 12px; border: 1px solid var(--ad-line); background: var(--ad-paper); color: var(--ad-ink); font: 500 .85rem/1.4 var(--ad-font); text-align: start; cursor: pointer; transition: border-color .15s, background .15s; }
.aidoc__chip:hover { border-color: var(--ad-brand); background: var(--ad-brand-soft); }

/* composer */
.aidoc__form { padding: 12px 14px 10px; border-block-start: 1px solid var(--ad-line); background: var(--ad-paper); }
.aidoc__form.is-locked { opacity: .55; pointer-events: none; }
.aidoc__preview { position: relative; display: inline-block; margin-block-end: 8px; }
.aidoc__preview[hidden] { display: none; }
.aidoc__preview img { display: block; block-size: 64px; inline-size: auto; border-radius: 10px; border: 1px solid var(--ad-line); }
.aidoc__preview .aidoc__ico { position: absolute; inset-block-start: -8px; inset-inline-end: -8px; min-inline-size: 24px; block-size: 24px; padding: 0; background: var(--ad-ink); color: var(--ad-paper); border-radius: 50%; }
.aidoc__row { display: flex; align-items: flex-end; gap: 6px; background: var(--ad-mist); border: 1px solid var(--ad-line); border-radius: 16px; padding: 6px; }
.aidoc__row:focus-within { border-color: var(--ad-brand); box-shadow: 0 0 0 3px var(--ad-brand-soft); }
.aidoc__row textarea { flex: 1; min-inline-size: 0; resize: none; border: 0; background: transparent; color: var(--ad-ink); font: inherit; line-height: 1.6; padding: 8px 6px; max-block-size: 150px; outline: 0; }
.aidoc__row textarea:focus-visible { outline: 0; }
.aidoc__send { display: inline-grid; place-items: center; inline-size: 40px; block-size: 40px; border: 0; border-radius: 12px; background: var(--ad-brand); color: var(--ad-brand-ink); cursor: pointer; flex: none; }
.aidoc__send[hidden] { display: none; }
.aidoc__send svg { transform: scaleX(var(--ad-flip, 1)); }
.aidoc[dir="rtl"] .aidoc__send svg { --ad-flip: -1; }
.aidoc__stop { background: var(--ad-warn); color: #fff; }
.aidoc__mic.is-on { animation: ad-blink 1s ease-in-out infinite; }
.aidoc__attach { cursor: pointer; }

.aidoc__foot { padding: 8px 16px 12px; font-size: .74rem; line-height: 1.6; color: var(--ad-muted); background: var(--ad-paper); }
.aidoc__nums { display: inline-block; color: var(--ad-warn); font-weight: 600; }
.aidoc__foot a { color: inherit; }

/* floating mode */
.aidoc--floating { position: fixed; inset-block-end: 20px; inset-inline-end: 20px; z-index: 99990; }
.aidoc--floating .aidoc__panel { position: absolute; inset-block-end: 70px; inset-inline-end: 0; inline-size: min(400px, calc(100vw - 32px)); block-size: min(680px, 78vh); }
.aidoc__launcher { inline-size: 58px; block-size: 58px; border-radius: 50%; border: 0; background: var(--ad-brand); color: var(--ad-brand-ink); cursor: pointer; display: grid; place-items: center; box-shadow: 0 10px 28px -10px rgba(11, 122, 117, .7); transition: transform .2s; }
.aidoc__launcher:hover { transform: scale(1.06); }

@media (max-width: 560px) {
	.aidoc__panel { border-radius: 14px; }
	.aidoc__log { padding: 14px; }
	.aidoc__bubble { padding: 10px 13px; }
}
@media (prefers-reduced-motion: reduce) {
	.aidoc *, .aidoc *::before, .aidoc *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
