/* Chat Congreso — diseño neutro. Todo va bajo .cc-root para no chocar con el tema. */

.cc-root {
	--cc-primary: #2b59c3;
	--cc-on-primary: #ffffff;
	--cc-bg: #ffffff;
	--cc-surface: #f3f4f6;
	--cc-text: #1f2937;
	--cc-muted: #6b7280;
	--cc-line: #e5e7eb;
	--cc-danger: #b42318;
	--cc-ok: #12a150;
	--cc-radius: 16px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	font-size: 15px;
	line-height: 1.45;
	color: var(--cc-text);
	-webkit-text-size-adjust: 100%;
}
.cc-root *,
.cc-root *::before,
.cc-root *::after { box-sizing: border-box; }
.cc-root button,
.cc-root input,
.cc-root textarea { font: inherit; color: inherit; margin: 0; letter-spacing: normal; text-transform: none; }
.cc-root [hidden] { display: none !important; }

/* ---------- Contenedor flotante ---------- */
.cc-float {
	position: fixed;
	bottom: calc(20px + env(safe-area-inset-bottom, 0px));
	z-index: 999990;
}
.cc-float[data-pos="right"] { right: calc(20px + env(safe-area-inset-right, 0px)); }
.cc-float[data-pos="left"]  { left: calc(20px + env(safe-area-inset-left, 0px)); }

.cc-root .cc-launcher {
	display: flex; align-items: center; justify-content: center;
	width: 58px; height: 58px; padding: 0;
	border: 0; border-radius: 50%;
	background: var(--cc-primary); color: var(--cc-on-primary);
	box-shadow: 0 6px 20px rgba(17, 24, 39, .28);
	cursor: pointer;
	transition: transform .15s ease, box-shadow .15s ease;
}
.cc-root .cc-launcher:hover { transform: scale(1.05); }
.cc-root .cc-launcher svg { width: 26px; height: 26px; fill: currentColor; }

.cc-root .cc-teaser {
	position: absolute; bottom: 72px;
	max-width: 260px; min-width: 180px;
	padding: 12px 34px 12px 14px;
	background: var(--cc-bg); color: var(--cc-text);
	border-radius: 14px; box-shadow: 0 6px 24px rgba(17, 24, 39, .18);
	font-size: 14px; cursor: pointer;
	animation: cc-pop .25s ease both;
}
.cc-float[data-pos="right"] .cc-teaser { right: 0; }
.cc-float[data-pos="left"]  .cc-teaser { left: 0; }
.cc-root .cc-teaser-x {
	position: absolute; top: 6px; right: 6px;
	width: 24px; height: 24px; padding: 0;
	border: 0; border-radius: 50%; background: transparent; color: var(--cc-muted);
	font-size: 18px; line-height: 24px; cursor: pointer;
}
.cc-root .cc-teaser-x:hover { background: var(--cc-surface); }

/* ---------- Panel ---------- */
.cc-root .cc-panel {
	display: flex; flex-direction: column;
	background: var(--cc-bg);
	border-radius: var(--cc-radius);
	overflow: hidden;
}
.cc-float .cc-panel {
	position: absolute; bottom: 0;
	width: 380px; max-width: calc(100vw - 24px);
	height: min(640px, calc(100vh - 40px));
	height: min(640px, calc(100dvh - 40px));
	box-shadow: 0 12px 48px rgba(17, 24, 39, .3);
	animation: cc-pop .2s ease both;
}
.cc-float[data-pos="right"] .cc-panel { right: 0; }
.cc-float[data-pos="left"]  .cc-panel { left: 0; }
.cc-float.cc-open .cc-launcher { display: none; }

.cc-inline { width: 100%; }
.cc-inline.cc-root .cc-panel {
	position: relative; width: 100%; height: 100%;
	border: 1px solid var(--cc-line);
	box-shadow: 0 2px 12px rgba(17, 24, 39, .08);
}

/* Cabecera */
.cc-root .cc-head {
	display: flex; align-items: center; gap: 12px;
	padding: 14px 12px 14px 16px;
	background: var(--cc-primary); color: var(--cc-on-primary);
}
.cc-root .cc-avatar {
	flex: none; width: 40px; height: 40px; border-radius: 50%;
	display: flex; align-items: center; justify-content: center;
	background: rgba(255, 255, 255, .22); color: inherit;
	font-weight: 600; font-size: 17px; overflow: hidden;
}
.cc-root .cc-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cc-root .cc-titles { flex: 1; min-width: 0; }
.cc-root .cc-title { font-weight: 600; font-size: 15.5px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cc-root .cc-sub { font-size: 12.5px; opacity: .9; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cc-root .cc-sub::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: #4ade80; vertical-align: 1px; }
.cc-root .cc-hbtn {
	flex: none; display: flex; align-items: center; justify-content: center;
	width: 34px; height: 34px; padding: 0;
	border: 0; border-radius: 50%; background: transparent; color: inherit; cursor: pointer;
}
.cc-root .cc-hbtn:hover { background: rgba(255, 255, 255, .2); }
.cc-root .cc-hbtn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.cc-inline .cc-close { display: none; }

.cc-root .cc-banner {
	padding: 8px 16px; font-size: 13px;
	background: #ecfdf3; color: #05603a; border-bottom: 1px solid #c3ecd5;
}

/* Mensajes */
.cc-root .cc-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 16px 14px 8px; background: var(--cc-bg); scroll-behavior: smooth; }
.cc-root .cc-msgs { display: flex; flex-direction: column; gap: 8px; }
.cc-root .cc-row { display: flex; }
.cc-root .cc-row.cc-u { justify-content: flex-end; }
.cc-root .cc-row.cc-in { animation: cc-rise .22s ease both; }
.cc-root .cc-bubble {
	max-width: 86%; padding: 9px 13px;
	border-radius: 16px; word-wrap: break-word; overflow-wrap: anywhere;
	font-size: 14.5px; line-height: 1.45;
}
.cc-root .cc-b .cc-bubble { background: var(--cc-surface); color: var(--cc-text); border-bottom-left-radius: 4px; }
.cc-root .cc-u .cc-bubble { background: var(--cc-primary); color: var(--cc-on-primary); border-bottom-right-radius: 4px; }
.cc-root .cc-bubble a { color: inherit; text-decoration: underline; text-underline-offset: 2px; word-break: break-all; }
.cc-root .cc-err .cc-bubble { background: #fef3f2; color: var(--cc-danger); border: 1px solid #fecdca; }
.cc-root .cc-retry {
	display: inline-block; margin-top: 6px; padding: 5px 12px;
	border: 1px solid currentColor; border-radius: 999px; background: transparent; color: inherit;
	font-size: 13px; font-weight: 600; cursor: pointer;
}

/* Escribiendo… */
.cc-root .cc-typing .cc-bubble { display: flex; gap: 4px; padding: 13px 14px; }
.cc-root .cc-dot { width: 7px; height: 7px; border-radius: 50%; background: #9ca3af; animation: cc-blink 1.2s infinite ease-in-out; }
.cc-root .cc-dot:nth-child(2) { animation-delay: .15s; }
.cc-root .cc-dot:nth-child(3) { animation-delay: .3s; }

/* Respuestas rápidas */
.cc-root .cc-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 14px 10px; background: var(--cc-bg); }
.cc-root .cc-chip {
	padding: 7px 13px; border: 1px solid var(--cc-primary); border-radius: 999px;
	background: var(--cc-bg); color: var(--cc-primary);
	font-size: 13.5px; line-height: 1.25; cursor: pointer;
	transition: background .12s, color .12s;
}
.cc-root .cc-chip:hover { background: var(--cc-primary); color: var(--cc-on-primary); }

/* Tarjeta de contacto */
.cc-root .cc-card {
	margin: 4px 0; padding: 14px;
	border: 1px solid var(--cc-line); border-radius: 14px; background: var(--cc-bg);
	box-shadow: 0 1px 6px rgba(17, 24, 39, .06);
}
.cc-root .cc-card-title { font-weight: 600; font-size: 15px; margin-bottom: 2px; }
.cc-root .cc-card-sub { margin: 0 0 10px; font-size: 13px; color: var(--cc-muted); }
.cc-root .cc-field { display: block; margin-bottom: 10px; }
.cc-root .cc-field > span { display: block; margin-bottom: 4px; font-size: 12.5px; font-weight: 600; color: var(--cc-text); }
.cc-root .cc-input {
	display: block; width: 100%; height: 40px; padding: 0 12px;
	border: 1px solid #cfd4dc; border-radius: 10px; background: #fff; color: var(--cc-text);
	font-size: 16px; /* evita el zoom en iOS */
	box-shadow: none;
}
.cc-root .cc-input:focus { outline: 2px solid var(--cc-primary); outline-offset: 1px; border-color: var(--cc-primary); }
.cc-root .cc-input[aria-invalid="true"] { border-color: var(--cc-danger); }
.cc-root .cc-hp { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; overflow: hidden; }
.cc-root .cc-consent { display: flex; gap: 8px; align-items: flex-start; margin: 4px 0 10px; font-size: 12.5px; color: var(--cc-muted); line-height: 1.4; }
.cc-root .cc-consent input { flex: none; width: 18px; height: 18px; margin-top: 1px; accent-color: var(--cc-primary); }
.cc-root .cc-consent a { color: var(--cc-primary); text-decoration: underline; }
.cc-root .cc-formerr { margin: 0 0 8px; min-height: 0; font-size: 13px; color: var(--cc-danger); }
.cc-root .cc-formerr:empty { display: none; }
.cc-root .cc-actions { display: flex; align-items: center; gap: 12px; }
.cc-root .cc-btn {
	flex: 1; height: 42px; padding: 0 16px; border: 0; border-radius: 10px;
	background: var(--cc-primary); color: var(--cc-on-primary); font-weight: 600; cursor: pointer;
}
.cc-root .cc-btn[disabled] { opacity: .6; cursor: default; }
.cc-root .cc-link { flex: none; padding: 6px 2px; border: 0; background: transparent; color: var(--cc-muted); text-decoration: underline; font-size: 13px; cursor: pointer; }

/* Entrada */
.cc-root .cc-form { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--cc-line); background: var(--cc-bg); }
.cc-root .cc-text {
	flex: 1; min-height: 42px; max-height: 120px; padding: 10px 14px;
	border: 1px solid #cfd4dc; border-radius: 21px; background: #fff; color: var(--cc-text);
	font-size: 16px; line-height: 20px; resize: none; overflow-y: auto; box-shadow: none;
}
.cc-root .cc-text:focus { outline: 2px solid var(--cc-primary); outline-offset: 0; border-color: var(--cc-primary); }
.cc-root .cc-send {
	flex: none; display: flex; align-items: center; justify-content: center;
	width: 42px; height: 42px; padding: 0; border: 0; border-radius: 50%;
	background: var(--cc-primary); color: var(--cc-on-primary); cursor: pointer;
}
.cc-root .cc-send[disabled] { opacity: .45; cursor: default; }
.cc-root .cc-send svg { width: 19px; height: 19px; fill: currentColor; }
.cc-root .cc-count { padding: 0 16px 2px; text-align: right; font-size: 11.5px; color: var(--cc-muted); background: var(--cc-bg); }
.cc-root .cc-foot { padding: 6px 14px 10px; text-align: center; font-size: 11.5px; color: var(--cc-muted); background: var(--cc-bg); }
.cc-root .cc-foot a { color: inherit; text-decoration: underline; }

.cc-root button:focus-visible,
.cc-root a:focus-visible { outline: 2px solid var(--cc-primary); outline-offset: 2px; }
.cc-root .cc-head button:focus-visible { outline-color: var(--cc-on-primary); }

/* ---------- Móvil: pantalla completa ---------- */
@media (max-width: 520px) {
	.cc-float .cc-panel {
		position: fixed; inset: 0;
		width: 100%; max-width: none; height: 100vh; height: 100dvh;
		border-radius: 0; box-shadow: none; animation: none;
	}
	.cc-root .cc-head { padding-top: calc(14px + env(safe-area-inset-top, 0px)); }
	.cc-root .cc-form { padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
	.cc-root .cc-teaser { max-width: calc(100vw - 100px); }
}
html.cc-lock, html.cc-lock body { overflow: hidden !important; }

/* ---------- Animaciones ---------- */
@keyframes cc-pop   { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes cc-rise  { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes cc-blink { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }

@media (prefers-reduced-motion: reduce) {
	.cc-root *, .cc-root *::before, .cc-root *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
