/**
 * Cooldelo AI Studio — scoped styles.
 * Mirrors the Design Vault tokens: charcoal surfaces + amber accent.
 */

.cd-ai {
	--ai-bg: #0b0b0e;
	--ai-surface: #101015;
	--ai-surface-2: #16161d;
	--ai-line: #24242c;
	--ai-text: #fafafa;
	--ai-muted: #9ca3af;
	--ai-accent: #f5a524;
	--ai-accent-soft: rgba(245, 165, 36, 0.14);
	--ai-paper: #f4efe4;
	position: relative;
	isolation: isolate;
	padding: 84px 24px 12px;
	color: var(--ai-text);
	font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	font-size: 16px;
	line-height: 1.6;
	-webkit-font-smoothing: antialiased;
}

.cd-ai *,
.cd-ai *::before,
.cd-ai *::after {
	box-sizing: border-box;
}

.cd-ai__aura {
	position: absolute;
	inset: -40px 0 auto;
	height: 340px;
	z-index: -1;
	pointer-events: none;
	background:
		radial-gradient(42% 60% at 18% 0%, rgba(245, 165, 36, 0.12) 0%, rgba(245, 165, 36, 0) 70%),
		radial-gradient(36% 54% at 82% 4%, rgba(124, 92, 255, 0.09) 0%, rgba(124, 92, 255, 0) 72%);
}

.cd-ai__head {
	max-width: 720px;
	margin: 0 auto;
	text-align: center;
}

.cd-ai__eyebrow {
	display: inline-flex;
	align-items: center;
	gap: 9px;
	margin: 0 0 14px;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.18em;
	text-transform: uppercase;
	color: var(--ai-accent);
}

.cd-ai__eyebrow span {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--ai-accent);
	box-shadow: 0 0 0 4px var(--ai-accent-soft);
}

.cd-ai__title {
	margin: 0;
	font-size: clamp(30px, 4.2vw, 46px);
	line-height: 1.12;
	letter-spacing: -0.02em;
	font-weight: 700;
}

.cd-ai__lead {
	margin: 16px auto 0;
	max-width: 580px;
	font-size: 15px;
	line-height: 1.65;
	color: var(--ai-muted);
}

.cd-ai__shell {
	max-width: 940px;
	margin: 34px auto 0;
	border: 1px solid var(--ai-line);
	border-radius: 24px;
	background:
		linear-gradient(180deg, rgba(255, 255, 255, 0.035) 0%, rgba(255, 255, 255, 0) 38%),
		var(--ai-surface);
	box-shadow: 0 50px 90px -60px rgba(0, 0, 0, 0.95);
	overflow: hidden;
}

/* ---------- Log ---------- */

.cd-ai__log {
	display: flex;
	flex-direction: column;
	gap: 16px;
	min-height: 210px;
	max-height: 620px;
	padding: 24px;
	overflow-y: auto;
	scrollbar-width: thin;
	scrollbar-color: #34343f transparent;
}

.cd-ai__intro-title {
	margin: 2px 0 12px;
	font-size: 14px;
	color: var(--ai-muted);
}

.cd-ai__examples {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.cd-ai__example {
	padding: 8px 13px;
	border: 1px solid var(--ai-line);
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.03);
	color: #d8d8de;
	font: inherit;
	font-size: 12.5px;
	line-height: 1.35;
	text-align: left;
	cursor: pointer;
	transition: border-color 0.25s ease, color 0.25s ease, background 0.25s ease;
}

.cd-ai__example:hover,
.cd-ai__example:focus-visible {
	border-color: rgba(245, 165, 36, 0.55);
	color: #fff;
	background: var(--ai-accent-soft);
	outline: none;
}

.cd-ai__msg {
	max-width: 86%;
	animation: cd-ai-in 0.35s ease both;
}

.cd-ai__msg--user {
	align-self: flex-end;
}

.cd-ai__msg--bot {
	align-self: flex-start;
	width: 100%;
	max-width: 100%;
}

.cd-ai__bubble {
	padding: 11px 15px;
	border-radius: 16px 16px 5px 16px;
	background: #1d1d25;
	border: 1px solid #2a2a34;
	color: #ececf1;
	font-size: 14px;
	word-break: break-word;
}

.cd-ai__botcard {
	padding: 14px;
	border: 1px solid var(--ai-line);
	border-radius: 18px;
	background: var(--ai-surface-2);
}

.cd-ai__bothead {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 0 0 10px;
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: var(--ai-muted);
}

.cd-ai__bothead::before {
	content: "";
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--ai-accent);
}

.cd-ai__sheet {
	display: grid;
	place-items: center;
	padding: 18px;
	border-radius: 14px;
	background:
		radial-gradient(120% 120% at 50% 0%, #fffdf8 0%, var(--ai-paper) 70%);
}

.cd-ai__sheet svg {
	display: block;
	width: 100%;
	height: auto;
	max-width: 360px;
	max-height: 360px;
}

.cd-ai__sheet img {
	display: block;
	width: 100%;
	height: auto;
	max-width: 520px;
	border-radius: 10px;
}

.cd-ai__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: 12px;
}

.cd-ai__action {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 8px 13px;
	border: 1px solid var(--ai-line);
	border-radius: 10px;
	background: rgba(255, 255, 255, 0.04);
	color: var(--ai-text);
	font: inherit;
	font-size: 12.5px;
	font-weight: 500;
	text-decoration: none;
	cursor: pointer;
	transition: border-color 0.2s ease, background 0.2s ease;
}

.cd-ai__action:hover,
.cd-ai__action:focus-visible {
	border-color: rgba(245, 165, 36, 0.5);
	background: var(--ai-accent-soft);
	outline: none;
}

.cd-ai__action--primary {
	background: var(--ai-accent);
	border-color: var(--ai-accent);
	color: #14100a;
	font-weight: 600;
}

.cd-ai__action--primary:hover,
.cd-ai__action--primary:focus-visible {
	background: #ffb63c;
	border-color: #ffb63c;
	color: #14100a;
}

.cd-ai__meta {
	margin: 10px 0 0;
	font-size: 11.5px;
	line-height: 1.5;
	color: var(--ai-muted);
}

/* ---------- loading ---------- */

.cd-ai__loading {
	display: flex;
	align-items: center;
	gap: 10px;
	font-size: 13px;
	color: var(--ai-muted);
}

.cd-ai__dots {
	display: inline-flex;
	gap: 4px;
}

.cd-ai__dots i {
	width: 5px;
	height: 5px;
	border-radius: 50%;
	background: var(--ai-accent);
	animation: cd-ai-bounce 1.1s infinite ease-in-out;
}

.cd-ai__dots i:nth-child(2) {
	animation-delay: 0.15s;
}

.cd-ai__dots i:nth-child(3) {
	animation-delay: 0.3s;
}

/* ---------- composer ---------- */

.cd-ai__composer {
	padding: 16px 18px 18px;
	border-top: 1px solid var(--ai-line);
	background: rgba(0, 0, 0, 0.18);
}

.cd-ai__row {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 12px;
}

.cd-ai__modes {
	display: inline-flex;
	padding: 3px;
	border: 1px solid var(--ai-line);
	border-radius: 999px;
	background: rgba(0, 0, 0, 0.35);
}

.cd-ai__mode {
	min-height: 38px;
	padding: 7px 14px;
	border: 0;
	border-radius: 999px;
	background: transparent;
	color: var(--ai-muted);
	font: inherit;
	font-size: 12.5px;
	font-weight: 500;
	cursor: pointer;
	transition: color 0.2s ease, background 0.2s ease;
}

.cd-ai__mode span {
	margin-left: 5px;
	font-size: 10.5px;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: #7f8694;
}

.cd-ai__mode.is-active {
	background: var(--ai-surface-2);
	color: var(--ai-text);
	box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset;
}

.cd-ai__mode.is-active span {
	color: var(--ai-accent);
}

.cd-ai__select {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	font-size: 12px;
	color: var(--ai-muted);
}

.cd-ai__select select {
	padding: 7px 28px 7px 10px;
	border: 1px solid var(--ai-line);
	border-radius: 9px;
	background: #121218 url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%239ca3af' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 10px center;
	color: #e6e6ea;
	font: inherit;
	font-size: 12.5px;
	appearance: none;
	cursor: pointer;
}

.cd-ai__inputrow {
	display: grid;
	grid-template-columns: 1fr auto;
	align-items: end;
	gap: 10px;
}

.cd-ai__label {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

.cd-ai__input {
	width: 100%;
	min-height: 58px;
	max-height: 160px;
	padding: 15px 16px;
	border: 1px solid var(--ai-line);
	border-radius: 14px;
	background: #0e0e13;
	color: var(--ai-text);
	font: inherit;
	font-size: 14.5px;
	line-height: 1.5;
	resize: vertical;
	transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.cd-ai__input::placeholder {
	color: #6b7280;
}

.cd-ai__input:focus {
	outline: none;
	border-color: rgba(245, 165, 36, 0.6);
	box-shadow: 0 0 0 3px rgba(245, 165, 36, 0.14);
}

.cd-ai__send {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 56px;
	padding: 0 22px;
	border: 1px solid var(--ai-accent);
	border-radius: 14px;
	background: linear-gradient(180deg, #ffb63c 0%, var(--ai-accent) 100%);
	color: #171106;
	font: inherit;
	font-size: 14px;
	font-weight: 700;
	cursor: pointer;
	transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.cd-ai__send:hover {
	box-shadow: 0 12px 26px -14px rgba(245, 165, 36, 0.85);
	transform: translateY(-1px);
}

.cd-ai__send:disabled {
	opacity: 0.65;
	cursor: progress;
	transform: none;
	box-shadow: none;
}

.cd-ai__spinner {
	display: none;
	width: 16px;
	height: 16px;
	border: 2px solid rgba(0, 0, 0, 0.25);
	border-top-color: #171106;
	border-radius: 50%;
	animation: cd-ai-spin 0.8s linear infinite;
}

.cd-ai__send.is-busy .cd-ai__send-label {
	display: none;
}

.cd-ai__send.is-busy .cd-ai__spinner {
	display: block;
}

.cd-ai__note {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	gap: 6px 16px;
	margin: 10px 0 0;
	font-size: 11.5px;
	line-height: 1.5;
	color: var(--ai-muted);
}

.cd-ai__status:empty {
	display: none;
}

.cd-ai__status {
	color: #d6b16c;
}

.cd-ai__error {
	color: #fca5a5;
}

/* ---------- motion ---------- */

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

@keyframes cd-ai-spin {
	to {
		transform: rotate(360deg);
	}
}

@keyframes cd-ai-bounce {
	0%,
	80%,
	100% {
		opacity: 0.35;
		transform: translateY(0);
	}
	40% {
		opacity: 1;
		transform: translateY(-3px);
	}
}

/* ---------- responsive ---------- */

@media (max-width: 760px) {
	.cd-ai {
		padding: 64px 18px 8px;
	}

	.cd-ai__shell {
		margin-top: 26px;
		border-radius: 20px;
	}

	.cd-ai__log {
		padding: 18px;
		max-height: 540px;
		min-height: 180px;
	}

	.cd-ai__composer {
		padding: 14px;
	}

	.cd-ai__row {
		align-items: flex-start;
	}

	.cd-ai__modes {
		width: 100%;
	}

	.cd-ai__mode {
		flex: 1 1 0;
		text-align: center;
	}

	.cd-ai__inputrow {
		grid-template-columns: 1fr;
	}

	.cd-ai__send {
		min-height: 48px;
	}

	.cd-ai__msg {
		max-width: 94%;
	}

	.cd-ai__botcard {
		padding: 12px;
	}

	.cd-ai__sheet {
		padding: 10px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.cd-ai,
	.cd-ai *,
	.cd-ai *::before,
	.cd-ai *::after {
		animation-duration: 0.001ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.001ms !important;
	}

	.cd-ai__dots i {
		opacity: 0.8;
	}
}
