/* Diagnosis Decoder widget. Everything is scoped to .dd-widget so theme/Breakdance styles don't leak in or out. */
.dd-widget {
	--dd-navy: #00446d;
	--dd-text: #303030;
	--dd-teal: #0797b9;
	--dd-plum: #752d62;
	--dd-bot-bg: #eef5f9;
	--dd-tint: #e6f5f9;
	--dd-border: #d5e1e8;
	--dd-radius: 16px;

	color: var(--dd-text);
	font-size: 1rem;
	line-height: 1.5;
	max-width: 760px;
	margin: 0 auto;
	text-align: left;
}

.dd-widget *,
.dd-widget *::before,
.dd-widget *::after {
	box-sizing: border-box;
}

.dd-widget button {
	font: inherit;
	letter-spacing: normal;
	text-transform: none;
	text-shadow: none;
	box-shadow: none;
	margin: 0;
	cursor: pointer;
}

.dd-widget button:disabled {
	cursor: not-allowed;
}

.dd-widget button:focus-visible,
.dd-widget input:focus-visible {
	outline: 3px solid var(--dd-teal);
	outline-offset: 2px;
}

.dd-card {
	background: #fff;
	border: 1px solid var(--dd-border);
	border-radius: var(--dd-radius);
	box-shadow: 0 6px 24px rgba(0, 68, 109, 0.08);
	overflow: hidden;
}

/* Header */
.dd-header {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	padding: 0.875rem 1.25rem;
	border-bottom: 3px solid var(--dd-teal);
	background: #fff;
}

.dd-logo {
	height: 34px;
	width: auto;
	display: block;
}

.dd-title {
	color: var(--dd-navy);
	font-weight: 700;
	font-size: 1.0625rem;
	padding-left: 0.75rem;
	border-left: 1px solid var(--dd-border);
}

.dd-widget .dd-restart {
	margin-left: auto;
	background: none;
	border: 0;
	padding: 0.25rem 0.5rem;
	color: var(--dd-navy);
	font-size: 0.875rem;
	text-decoration: underline;
	text-underline-offset: 3px;
}

/* Conversation */
.dd-log {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
	padding: 1.25rem;
	height: min(72vh, 640px);
	overflow-y: auto;
	overscroll-behavior: contain;
	scroll-behavior: smooth;
}

.dd-msg {
	max-width: 85%;
	padding: 0.75rem 1rem;
	border-radius: var(--dd-radius);
	white-space: pre-line;
	overflow-wrap: anywhere;
	animation: dd-in 0.25s ease-out;
}

.dd-bot {
	align-self: flex-start;
	background: var(--dd-bot-bg);
	color: var(--dd-text);
	border-bottom-left-radius: 4px;
}

.dd-user {
	align-self: flex-end;
	background: var(--dd-navy);
	color: #fff;
	border-bottom-right-radius: 4px;
}

.dd-typing {
	display: flex;
	gap: 5px;
	padding: 0.9rem 1rem;
}

.dd-typing span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--dd-teal);
	opacity: 0.4;
	animation: dd-blink 1s infinite;
}

.dd-typing span:nth-child(2) { animation-delay: 0.15s; }
.dd-typing span:nth-child(3) { animation-delay: 0.3s; }

/* Choice buttons */
.dd-choices {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	animation: dd-in 0.25s ease-out;
}

.dd-widget .dd-choice {
	background: #fff;
	color: var(--dd-navy);
	border: 1.5px solid var(--dd-teal);
	border-radius: 999px;
	padding: 0.55rem 1.1rem;
	font-size: 0.9375rem;
	line-height: 1.35;
	text-align: left;
	transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}

.dd-widget .dd-choice:hover {
	background: var(--dd-tint);
}

/* Multi-select chips */
.dd-multi {
	flex-direction: column;
	align-items: stretch;
}

.dd-widget .dd-chip {
	border-radius: 12px;
	padding-left: 2.6rem;
	position: relative;
}

.dd-widget .dd-chip::before {
	content: "";
	position: absolute;
	left: 0.9rem;
	top: 50%;
	width: 1.1rem;
	height: 1.1rem;
	margin-top: -0.55rem;
	border: 1.5px solid var(--dd-teal);
	border-radius: 4px;
	background: #fff;
}

.dd-widget .dd-chip[aria-pressed="true"] {
	background: var(--dd-plum);
	border-color: var(--dd-plum);
	color: #fff;
}

.dd-widget .dd-chip[aria-pressed="true"]::before {
	border-color: #fff;
	background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.5l3 3 6-7' fill='none' stroke='%23752d62' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 85% no-repeat;
}

/* Primary action */
.dd-actions {
	display: flex;
	justify-content: flex-end;
	margin-top: 0.25rem;
}

.dd-widget .dd-primary {
	background: var(--dd-navy);
	color: #fff;
	border: 0;
	border-radius: 999px;
	padding: 0.7rem 1.5rem;
	font-weight: 600;
	font-size: 0.9375rem;
}

.dd-widget .dd-primary:hover:not(:disabled) {
	background: #003355;
}

.dd-widget .dd-primary:disabled {
	opacity: 0.45;
}

/* Question checklist */
.dd-panel {
	border: 1px solid var(--dd-border);
	border-radius: var(--dd-radius);
	padding: 1rem 1.1rem 1.1rem;
	animation: dd-in 0.25s ease-out;
}

.dd-panel.dd-locked {
	opacity: 0.6;
}

.dd-panel-tools {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	align-items: center;
	gap: 0.5rem;
	font-size: 0.875rem;
	margin-bottom: 0.5rem;
}

.dd-count {
	font-weight: 600;
	color: var(--dd-navy);
}

.dd-tool-links {
	display: flex;
	gap: 1rem;
}

.dd-widget .dd-link {
	background: none;
	border: 0;
	padding: 0;
	color: var(--dd-navy);
	text-decoration: underline;
	text-underline-offset: 3px;
	font-size: 0.875rem;
}

.dd-group {
	border: 0;
	margin: 0.75rem 0 0;
	padding: 0;
	min-width: 0;
}

.dd-group legend {
	color: var(--dd-plum);
	font-weight: 700;
	font-size: 0.9375rem;
	padding: 0 0 0.35rem;
	margin: 0;
	width: 100%;
	border-bottom: 1px solid var(--dd-border);
}

.dd-qlist {
	list-style: none;
	margin: 0;
	padding: 0;
}

.dd-qlist li {
	display: flex;
	align-items: flex-start;
	gap: 0.65rem;
	margin: 0;
	padding: 0.5rem 0;
	border-bottom: 1px solid #eef2f5;
}

.dd-qlist li:last-child {
	border-bottom: 0;
}

.dd-qlist input[type="checkbox"] {
	flex: 0 0 auto;
	width: 1.15rem;
	height: 1.15rem;
	margin: 0.2rem 0 0;
	accent-color: var(--dd-plum);
	cursor: pointer;
}

.dd-qlist label {
	margin: 0;
	font-size: 0.9375rem;
	line-height: 1.45;
	cursor: pointer;
}

/* Visitor's own questions */
.dd-own-form {
	display: flex;
	gap: 0.5rem;
	margin: 0;
}

.dd-widget .dd-own-input {
	flex: 1 1 auto;
	min-width: 0;
	margin: 0;
	padding: 0.6rem 0.9rem;
	border: 1.5px solid var(--dd-border);
	border-radius: 10px;
	background: #fff;
	color: var(--dd-text);
	font: inherit;
	font-size: 0.9375rem;
	box-shadow: none;
}

.dd-widget .dd-own-input:focus {
	border-color: var(--dd-teal);
}

.dd-widget .dd-add {
	flex: 0 0 auto;
	background: #fff;
	color: var(--dd-navy);
	border: 1.5px solid var(--dd-teal);
	border-radius: 10px;
	padding: 0.55rem 1.1rem;
	font-weight: 600;
	font-size: 0.9375rem;
}

.dd-widget .dd-add:hover:not(:disabled) {
	background: var(--dd-tint);
}

.dd-own-list {
	margin: 0.75rem 0 0;
	padding: 0 0 0 1.4rem;
}

.dd-own-list[hidden] {
	display: none;
}

.dd-own-list li {
	padding: 0.45rem 0;
	border-bottom: 1px solid #eef2f5;
	font-size: 0.9375rem;
}

.dd-own-list li::marker {
	color: var(--dd-plum);
	font-weight: 700;
}

.dd-own-list li span {
	display: inline;
}

.dd-widget .dd-remove {
	float: right;
	margin-left: 0.75rem;
	background: none;
	border: 0;
	padding: 0 0.35rem;
	color: var(--dd-plum);
	font-size: 1.25rem;
	line-height: 1.2;
}

@keyframes dd-in {
	from { opacity: 0; transform: translateY(6px); }
	to { opacity: 1; transform: none; }
}

@keyframes dd-blink {
	0%, 100% { opacity: 0.3; }
	50% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
	.dd-widget *,
	.dd-log {
		animation: none !important;
		scroll-behavior: auto;
	}
}

@media (max-width: 560px) {
	.dd-header {
		padding: 0.75rem 1rem;
	}
	.dd-logo {
		height: 28px;
	}
	.dd-title {
		display: none;
	}
	.dd-log {
		padding: 1rem;
		height: min(78vh, 640px);
	}
	.dd-msg {
		max-width: 92%;
	}
}

/* Download page: [diagnosis_decoder_download] */
.dd-widget.dd-download {
	text-align: center;
}

.dd-download p {
	margin: 0 0 0.75rem;
}

.dd-download-summary {
	color: var(--dd-navy);
	font-weight: 600;
}

.dd-widget .dd-download-btn {
	font-size: 1.0625rem;
	padding: 0.85rem 1.9rem;
}

.dd-download-status:empty {
	display: none;
}

.dd-download-status {
	margin-top: 0.9rem !important;
	max-width: 34rem;
	margin-left: auto !important;
	margin-right: auto !important;
}

.dd-download-missing {
	border: 1px solid var(--dd-border);
	border-radius: var(--dd-radius);
	background: var(--dd-bot-bg);
	padding: 1rem 1.25rem;
	max-width: 34rem;
	margin: 0 auto;
}

.dd-download-missing p:last-child {
	margin-bottom: 0;
}

.dd-download-start {
	color: var(--dd-navy);
	font-weight: 600;
}
