/**
 * Estilos del chatbot.
 *
 * Todo queda encapsulado bajo .dscb-root para no chocar con el tema del sitio.
 *
 * @package DeepSeek_Chatbot
 */

.dscb-root {
	--dscb-accent: #4f46e5;
	--dscb-radius: 18px;
	--dscb-width: 400px;
	--dscb-height: 620px;
	--dscb-bg: #ffffff;
	--dscb-bg-soft: #f6f7fb;
	--dscb-text: #111827;
	--dscb-muted: #6b7280;
	--dscb-border: rgba(17, 24, 39, 0.1);
	--dscb-shadow: 0 18px 48px rgba(15, 23, 42, 0.18);
	--dscb-user-bg: var(--dscb-accent);
	--dscb-user-text: #ffffff;
	--dscb-bot-bg: #f1f3f9;
	--dscb-bot-text: #111827;
	--dscb-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

	position: relative;
	font-family: var(--dscb-font);
	font-size: 15px;
	line-height: 1.55;
	color: var(--dscb-text);
	box-sizing: border-box;
}

.dscb-root *,
.dscb-root *::before,
.dscb-root *::after {
	box-sizing: inherit;
}

.dscb-root[data-dscb-dark="1"] {
	--dscb-bg: #0f1420;
	--dscb-bg-soft: #161c2b;
	--dscb-text: #e8ecf5;
	--dscb-muted: #9aa4b8;
	--dscb-border: rgba(255, 255, 255, 0.12);
	--dscb-shadow: 0 18px 48px rgba(0, 0, 0, 0.55);
	--dscb-bot-bg: #1d2536;
	--dscb-bot-text: #e8ecf5;
}

/* --------------------------------- Lanzador -------------------------------- */

.dscb-widget {
	position: fixed;
	z-index: 99990;
}

.dscb-widget--bottom-right { right: 20px; bottom: 20px; }
.dscb-widget--bottom-left { left: 20px; bottom: 20px; }
.dscb-widget--top-right { right: 20px; top: 20px; }
.dscb-widget--top-left { left: 20px; top: 20px; }

.dscb-launcher {
	display: none;
	align-items: center;
	gap: 10px;
	padding: 12px 18px;
	border: 0;
	border-radius: 999px;
	background: var(--dscb-accent);
	color: #fff;
	font: inherit;
	font-weight: 600;
	cursor: pointer;
	box-shadow: 0 10px 28px rgba(15, 23, 42, 0.28);
	transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.dscb-root--bubble .dscb-launcher {
	display: inline-flex;
}

.dscb-launcher:hover {
	transform: translateY(-2px);
	box-shadow: 0 14px 34px rgba(15, 23, 42, 0.34);
}

.dscb-launcher:focus-visible {
	outline: 3px solid rgba(79, 70, 229, 0.45);
	outline-offset: 2px;
}

.dscb-launcher__icon {
	font-size: 20px;
	line-height: 1;
}

.dscb-root--bubble.is-open .dscb-launcher {
	opacity: 0;
	pointer-events: none;
}

/* ---------------------------------- Panel ---------------------------------- */

.dscb-panel {
	display: flex;
	flex-direction: column;
	background: var(--dscb-bg);
	border: 1px solid var(--dscb-border);
	border-radius: var(--dscb-radius);
	box-shadow: var(--dscb-shadow);
	overflow: hidden;
}

.dscb-root--bubble .dscb-panel {
	position: absolute;
	right: 0;
	bottom: 72px;
	width: var(--dscb-width);
	height: var(--dscb-height);
	max-height: calc(100vh - 120px);
	max-width: calc(100vw - 24px);
}

.dscb-widget--bottom-left .dscb-root--bubble .dscb-panel,
.dscb-widget--top-left .dscb-root--bubble .dscb-panel {
	right: auto;
	left: 0;
}

.dscb-widget--top-right .dscb-root--bubble .dscb-panel,
.dscb-widget--top-left .dscb-root--bubble .dscb-panel {
	bottom: auto;
	top: 72px;
}

.dscb-root--inline .dscb-panel {
	width: 100%;
	height: var(--dscb-inline-height, 560px);
	max-height: 80vh;
}

.dscb-panel[hidden] {
	display: none;
}

/* --------------------------------- Cabecera -------------------------------- */

.dscb-header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 12px 14px;
	background: linear-gradient(135deg, var(--dscb-accent), color-mix(in srgb, var(--dscb-accent) 72%, #000));
	color: #fff;
}

.dscb-header__avatar {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.2);
	display: grid;
	place-items: center;
	font-size: 20px;
	overflow: hidden;
	flex: 0 0 auto;
}

.dscb-header__avatar img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.dscb-header__titles {
	display: flex;
	flex-direction: column;
	min-width: 0;
	flex: 1;
}

.dscb-header__name {
	font-weight: 700;
	font-size: 15px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.dscb-header__status {
	font-size: 12px;
	opacity: 0.9;
	min-height: 15px;
}

.dscb-header__actions {
	display: flex;
	gap: 2px;
}

.dscb-icon-btn {
	background: transparent;
	border: 0;
	color: inherit;
	width: 34px;
	height: 34px;
	border-radius: 10px;
	font-size: 17px;
	line-height: 1;
	cursor: pointer;
	display: grid;
	place-items: center;
	transition: background 0.15s ease;
}

.dscb-icon-btn:hover {
	background: rgba(255, 255, 255, 0.18);
}

.dscb-icon-btn:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 1px;
}

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

.dscb-log {
	flex: 1;
	overflow-y: auto;
	padding: 16px 14px 8px;
	display: flex;
	flex-direction: column;
	gap: 14px;
	background: var(--dscb-bg);
	scroll-behavior: smooth;
	overscroll-behavior: contain;
}

.dscb-msg {
	display: flex;
	flex-direction: column;
	max-width: 88%;
	gap: 6px;
	animation: dscb-in 0.22s ease;
}

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

.dscb-msg--user {
	align-self: flex-end;
	align-items: flex-end;
}

.dscb-msg--bot {
	align-self: flex-start;
}

.dscb-msg__bubble {
	padding: 10px 14px;
	border-radius: var(--dscb-radius);
	background: var(--dscb-bot-bg);
	color: var(--dscb-bot-text);
	overflow-wrap: anywhere;
}

.dscb-msg--user .dscb-msg__bubble {
	background: var(--dscb-user-bg);
	color: var(--dscb-user-text);
	border-bottom-right-radius: 6px;
}

.dscb-msg--bot .dscb-msg__bubble {
	border-bottom-left-radius: 6px;
}

.dscb-msg__bubble > :first-child { margin-top: 0; }
.dscb-msg__bubble > :last-child { margin-bottom: 0; }

.dscb-msg__bubble p { margin: 0 0 8px; }
.dscb-msg__bubble ul,
.dscb-msg__bubble ol { margin: 6px 0 10px; padding-left: 20px; }
.dscb-msg__bubble li { margin-bottom: 3px; }

.dscb-msg__bubble a {
	color: inherit;
	text-decoration: underline;
	text-underline-offset: 2px;
}

.dscb-msg__bubble blockquote {
	margin: 6px 0;
	padding: 6px 12px;
	border-left: 3px solid var(--dscb-accent);
	background: rgba(127, 127, 127, 0.08);
	border-radius: 6px;
}

.dscb-msg__bubble code {
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 0.88em;
	background: rgba(127, 127, 127, 0.16);
	padding: 1px 5px;
	border-radius: 5px;
}

.dscb-code {
	margin: 8px 0;
	border-radius: 12px;
	overflow: hidden;
	background: #0b1020;
	border: 1px solid rgba(255, 255, 255, 0.08);
}

.dscb-code__bar {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 5px 10px;
	background: rgba(255, 255, 255, 0.06);
	color: #cbd5e1;
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: 0.05em;
}

.dscb-code__copy {
	background: transparent;
	border: 0;
	color: #cbd5e1;
	cursor: pointer;
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: 0.05em;
}

.dscb-code__copy:hover { color: #fff; }

.dscb-code pre {
	margin: 0;
	padding: 12px 14px;
	overflow-x: auto;
}

.dscb-code code {
	background: none;
	color: #e2e8f0;
	font-size: 12.5px;
	line-height: 1.6;
	padding: 0;
}

/* -------------------------------- Razonamiento ------------------------------ */

.dscb-reasoning {
	border: 1px dashed var(--dscb-border);
	border-radius: 12px;
	padding: 8px 12px;
	background: var(--dscb-bg-soft);
	font-size: 13px;
	color: var(--dscb-muted);
}

.dscb-reasoning summary {
	cursor: pointer;
	font-weight: 600;
	color: var(--dscb-muted);
}

.dscb-reasoning__body {
	margin-top: 8px;
	white-space: pre-wrap;
	max-height: 220px;
	overflow-y: auto;
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 12px;
}

/* ------------------------------- Acciones msg ------------------------------- */

.dscb-msg__actions {
	display: flex;
	gap: 6px;
	opacity: 0;
	transition: opacity 0.15s ease;
	flex-wrap: wrap;
}

.dscb-msg:hover .dscb-msg__actions,
.dscb-msg:focus-within .dscb-msg__actions {
	opacity: 1;
}

.dscb-mini {
	background: var(--dscb-bg-soft);
	border: 1px solid var(--dscb-border);
	color: var(--dscb-muted);
	border-radius: 999px;
	padding: 3px 10px;
	font-size: 11.5px;
	cursor: pointer;
	font-family: inherit;
}

.dscb-mini:hover {
	color: var(--dscb-text);
	border-color: var(--dscb-accent);
}

.dscb-mini.is-active {
	background: var(--dscb-accent);
	color: #fff;
	border-color: var(--dscb-accent);
}

.dscb-msg__images {
	display: flex;
	gap: 6px;
	flex-wrap: wrap;
}

.dscb-msg__images img {
	max-width: 160px;
	max-height: 160px;
	border-radius: 12px;
	border: 1px solid var(--dscb-border);
}

/* ------------------------------- Escribiendo ------------------------------- */

.dscb-dots {
	display: inline-flex;
	gap: 4px;
	align-items: center;
	height: 18px;
}

.dscb-dots i {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--dscb-muted);
	animation: dscb-blink 1.2s infinite ease-in-out;
}

.dscb-dots i:nth-child(2) { animation-delay: 0.18s; }
.dscb-dots i:nth-child(3) { animation-delay: 0.36s; }

@keyframes dscb-blink {
	0%, 60%, 100% { opacity: 0.28; transform: translateY(0); }
	30% { opacity: 1; transform: translateY(-3px); }
}

/* ------------------------------ Sugerencias -------------------------------- */

.dscb-suggestions {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	padding: 0 14px 8px;
}

.dscb-suggestions:empty { display: none; }

.dscb-chip {
	background: var(--dscb-bg-soft);
	border: 1px solid var(--dscb-border);
	color: var(--dscb-text);
	border-radius: 999px;
	padding: 6px 12px;
	font-size: 12.5px;
	cursor: pointer;
	font-family: inherit;
	text-align: left;
}

.dscb-chip:hover {
	border-color: var(--dscb-accent);
	background: color-mix(in srgb, var(--dscb-accent) 10%, var(--dscb-bg));
}

/* -------------------------------- Redactor -------------------------------- */

.dscb-composer {
	border-top: 1px solid var(--dscb-border);
	padding: 10px 12px 8px;
	background: var(--dscb-bg);
}

.dscb-composer__row {
	display: flex;
	align-items: flex-end;
	gap: 6px;
	background: var(--dscb-bg-soft);
	border: 1px solid var(--dscb-border);
	border-radius: calc(var(--dscb-radius) + 4px);
	padding: 6px;
}

.dscb-input {
	flex: 1;
	border: 0;
	background: transparent;
	color: var(--dscb-text);
	font: inherit;
	font-size: 15px;
	line-height: 1.45;
	resize: none;
	max-height: 140px;
	padding: 6px 4px;
	outline: none;
	font-family: inherit;
}

.dscb-input::placeholder { color: var(--dscb-muted); }

.dscb-send {
	width: 38px;
	height: 38px;
	flex: 0 0 auto;
	border-radius: 50%;
	border: 0;
	background: var(--dscb-accent);
	color: #fff;
	font-size: 16px;
	cursor: pointer;
	display: grid;
	place-items: center;
	transition: transform 0.15s ease;
}

.dscb-send:hover { transform: scale(1.06); }

.dscb-send.is-stop {
	background: #ef4444;
}

.dscb-send.is-stop span::before { content: "\25A0"; }
.dscb-send.is-stop span { font-size: 13px; }
.dscb-send.is-stop span { visibility: hidden; }
.dscb-send.is-stop::after {
	content: "\25A0";
	position: absolute;
	font-size: 13px;
}

.dscb-composer .dscb-icon-btn {
	color: var(--dscb-muted);
}

.dscb-composer .dscb-icon-btn:hover {
	background: rgba(127, 127, 127, 0.14);
	color: var(--dscb-text);
}

.dscb-mic.is-recording {
	color: #ef4444;
	animation: dscb-pulse 1.1s infinite;
}

.dscb-mic.is-active {
	background: rgba(239, 68, 68, 0.16);
	color: #ef4444;
}

@keyframes dscb-pulse {
	0%, 100% { transform: scale(1); }
	50% { transform: scale(1.16); }
}

.dscb-composer__meta {
	display: flex;
	justify-content: space-between;
	gap: 8px;
	padding: 6px 4px 0;
	font-size: 11px;
	color: var(--dscb-muted);
	flex-wrap: wrap;
}

/* ---------------------------------- Voz ----------------------------------- */

.dscb-voice {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 8px 10px;
	margin-bottom: 8px;
	border-radius: 14px;
	background: color-mix(in srgb, var(--dscb-accent) 10%, var(--dscb-bg));
	border: 1px solid color-mix(in srgb, var(--dscb-accent) 35%, transparent);
}

.dscb-voice[hidden] { display: none; }

.dscb-voice__wave {
	flex: 1;
	height: 36px;
	width: auto;
}

.dscb-voice__hint {
	font-size: 12px;
	color: var(--dscb-muted);
	white-space: nowrap;
}

.dscb-voice__cancel {
	background: transparent;
	border: 0;
	font-size: 18px;
	color: var(--dscb-muted);
	cursor: pointer;
}

/* ------------------------------- Adjuntos ---------------------------------- */

.dscb-attachments {
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
	padding-bottom: 8px;
}

.dscb-attachments[hidden] { display: none; }

.dscb-attachment {
	position: relative;
}

.dscb-attachment img {
	width: 54px;
	height: 54px;
	object-fit: cover;
	border-radius: 10px;
	border: 1px solid var(--dscb-border);
}

.dscb-attachment__remove {
	position: absolute;
	top: -6px;
	right: -6px;
	width: 20px;
	height: 20px;
	border-radius: 50%;
	border: 0;
	background: #ef4444;
	color: #fff;
	cursor: pointer;
	font-size: 13px;
	line-height: 1;
}

/* -------------------------------- Consentimiento ---------------------------- */

.dscb-consent {
	margin: 10px 12px;
	padding: 12px 14px;
	border-radius: 12px;
	background: var(--dscb-bg-soft);
	border: 1px solid var(--dscb-border);
	font-size: 13px;
	color: var(--dscb-muted);
}

.dscb-consent[hidden] { display: none; }

.dscb-consent__actions {
	display: flex;
	gap: 8px;
	margin-top: 10px;
}

.dscb-consent__link {
	display: inline-block;
	margin-top: 6px;
	font-size: 12px;
	color: var(--dscb-accent);
}

/* --------------------------------- Botones --------------------------------- */

.dscb-btn {
	background: var(--dscb-bg);
	border: 1px solid var(--dscb-border);
	color: var(--dscb-text);
	border-radius: 10px;
	padding: 7px 14px;
	font: inherit;
	font-size: 13px;
	cursor: pointer;
}

.dscb-btn:hover { border-color: var(--dscb-accent); }

.dscb-btn--primary {
	background: var(--dscb-accent);
	border-color: var(--dscb-accent);
	color: #fff;
	font-weight: 600;
}

.dscb-btn--small { padding: 5px 10px; font-size: 12px; }

.dscb-btn--danger { color: #ef4444; border-color: rgba(239, 68, 68, 0.4); }

.dscb-btn-row {
	display: flex;
	gap: 6px;
	flex-wrap: wrap;
	margin-top: 8px;
}

/* --------------------------------- Paneles --------------------------------- */

.dscb-panels { position: relative; }

.dscb-drawer {
	background: var(--dscb-bg);
	border-bottom: 1px solid var(--dscb-border);
	max-height: 62%;
	overflow-y: auto;
	padding: 12px 14px;
}

.dscb-drawer[hidden] { display: none; }

.dscb-drawer__head {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 10px;
}

.dscb-history-item {
	display: flex;
	align-items: stretch;
	gap: 6px;
	margin-bottom: 6px;
}

.dscb-history-item__open {
	flex: 1;
	text-align: left;
	background: var(--dscb-bg-soft);
	border: 1px solid var(--dscb-border);
	border-radius: 12px;
	padding: 8px 12px;
	cursor: pointer;
	font: inherit;
	color: var(--dscb-text);
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
}

.dscb-history-item__open:hover { border-color: var(--dscb-accent); }

.dscb-history-item__meta {
	font-size: 11px;
	color: var(--dscb-muted);
}

.dscb-history-item__del {
	background: transparent;
	border: 0;
	color: var(--dscb-muted);
	font-size: 18px;
	cursor: pointer;
	padding: 0 8px;
}

.dscb-history-item__del:hover { color: #ef4444; }

.dscb-setting-group {
	margin-bottom: 14px;
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.dscb-setting-group__label {
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--dscb-muted);
	font-weight: 700;
}

.dscb-select {
	width: 100%;
	padding: 7px 10px;
	border-radius: 10px;
	border: 1px solid var(--dscb-border);
	background: var(--dscb-bg-soft);
	color: var(--dscb-text);
	font: inherit;
	font-size: 13px;
}

.dscb-check-row {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 13px;
}

.dscb-help-inline {
	margin: 0;
	font-size: 11.5px;
	color: var(--dscb-muted);
}

.dscb-empty {
	color: var(--dscb-muted);
	font-size: 13px;
	text-align: center;
	padding: 16px 0;
}

.dscb-error {
	color: #ef4444;
	margin: 0;
}

/* ---------------------------------- Pie ------------------------------------ */

.dscb-footer {
	display: flex;
	justify-content: space-between;
	gap: 8px;
	padding: 7px 14px;
	border-top: 1px solid var(--dscb-border);
	font-size: 11px;
	color: var(--dscb-muted);
	background: var(--dscb-bg);
}

.dscb-footer__hint { flex: 1; }
.dscb-footer a { color: inherit; }

/* ------------------------------- Karaoke ----------------------------------- */

.dscb-karaoke {
	background: color-mix(in srgb, var(--dscb-accent) 30%, transparent);
	color: inherit;
	border-radius: 4px;
	padding: 0 2px;
}

/* --------------------------------- Avisos ---------------------------------- */

.dscb-overlay {
	position: fixed;
	inset: 0;
	background: rgba(15, 23, 42, 0.55);
	display: grid;
	place-items: center;
	z-index: 99999;
	padding: 20px;
}

.dscb-overlay__box {
	background: var(--dscb-bg, #fff);
	color: var(--dscb-text, #111827);
	border-radius: 16px;
	padding: 20px 22px;
	max-width: 380px;
	width: 100%;
	box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
	font-family: var(--dscb-font, system-ui, sans-serif);
}

.dscb-overlay__actions {
	display: flex;
	justify-content: flex-end;
	gap: 8px;
	margin-top: 16px;
}

.dscb-toast {
	position: fixed;
	left: 50%;
	bottom: 28px;
	transform: translateX(-50%);
	background: rgba(17, 24, 39, 0.94);
	color: #fff;
	padding: 10px 18px;
	border-radius: 999px;
	font-family: system-ui, sans-serif;
	font-size: 13px;
	z-index: 100000;
	transition: opacity 0.3s ease, transform 0.3s ease;
}

.dscb-toast.is-out {
	opacity: 0;
	transform: translate(-50%, 10px);
}

.dscb-notice {
	padding: 12px 16px;
	border-radius: 12px;
	background: #fff7ed;
	border: 1px solid #fdba74;
	color: #9a3412;
	font-family: system-ui, sans-serif;
	font-size: 14px;
}

/* --------------------------------- Movil ----------------------------------- */

@media (max-width: 520px) {
	.dscb-widget--bottom-right,
	.dscb-widget--bottom-left,
	.dscb-widget--top-right,
	.dscb-widget--top-left {
		left: 12px;
		right: 12px;
		bottom: 12px;
		top: auto;
	}

	.dscb-launcher { width: 100%; justify-content: center; }

	.dscb-root--bubble .dscb-panel {
		position: fixed;
		inset: 0;
		width: 100%;
		height: 100%;
		max-width: none;
		max-height: none;
		border-radius: 0;
		right: auto;
		left: auto;
		top: auto;
		bottom: auto;
	}

	.dscb-msg { max-width: 94%; }
}

body.dscb-locked { overflow: hidden; }

/* ------------------------------- Accesibilidad ----------------------------- */

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

@media (prefers-reduced-motion: reduce) {
	.dscb-root *,
	.dscb-root *::before,
	.dscb-root *::after {
		animation-duration: 0.01ms !important;
		transition-duration: 0.01ms !important;
	}
}
