/* ====================================================================
   Asistente Gemini WP — Frontend widget
   Botón flotante + panel conversacional + acciones visibles
   ==================================================================== */
#agwp-root {
	--agwp-primary: #0d1b7a;
	--agwp-secondary: #0fb8b8;
	--agwp-bg: #0d0f14;
	--agwp-text: #e8eaf0;
	--agwp-muted: #8a93a5;
	--agwp-line: rgba(255,255,255,.08);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
}
#agwp-root * { box-sizing: border-box; }
#agwp-root .material-symbols-rounded { font-variation-settings: 'FILL' 0, 'wght' 500, 'GRAD' 0, 'opsz' 24; }

/* ---- Botón flotante (FAB) ---- */
#agwp-fab {
	position: fixed; z-index: 2147483000; bottom: 22px; right: 22px;
	width: 62px; height: 62px; border-radius: 50%; border: none; cursor: pointer;
	display: flex; align-items: center; justify-content: center;
	background: radial-gradient(circle at 35% 30%, var(--agwp-secondary), var(--agwp-primary) 80%);
	color: #fff; box-shadow: 0 14px 36px rgba(13,27,122,.4), inset 0 1px 2px rgba(255,255,255,.3);
	transition: transform .2s ease, box-shadow .2s ease;
}
.agwp-pos-bottom-left #agwp-fab { right: auto; left: 22px; }
#agwp-fab:hover { transform: translateY(-2px) scale(1.05); }
#agwp-fab .material-symbols-rounded { font-size: 28px; }
.agwp-fab-pulse {
	position: absolute; inset: 0; border-radius: 50%;
	box-shadow: 0 0 0 0 rgba(15,184,184,.45); animation: agwpPulse 2.4s infinite;
}
@keyframes agwpPulse { 0% { box-shadow: 0 0 0 0 rgba(15,184,184,.45); } 70% { box-shadow: 0 0 0 16px rgba(15,184,184,0); } 100% { box-shadow: 0 0 0 0 rgba(15,184,184,0); } }
#agwp-root.agwp-open #agwp-fab { transform: scale(.9); opacity: .85; }

/* ---- Estado "en vivo" del botón flotante (visible aun minimizado) ---- */
#agwp-fab.agwp-live { box-shadow: 0 0 0 3px rgba(74,222,128,.55), 0 14px 36px rgba(13,27,122,.4); }
#agwp-fab.agwp-live::before {
	content: ''; position: absolute; top: 4px; right: 4px; width: 14px; height: 14px;
	border-radius: 50%; background: #4ade80; border: 2px solid #fff;
	box-shadow: 0 0 10px rgba(74,222,128,.9); animation: agwpLiveDot 1.4s ease infinite;
}
@keyframes agwpLiveDot { 0%,100% { transform: scale(1); opacity: 1; } 50% { transform: scale(.7); opacity: .6; } }
#agwp-fab.agwp-live .agwp-fab-pulse { box-shadow: 0 0 0 0 rgba(74,222,128,.6); animation: agwpLivePulse 1.6s infinite; }
@keyframes agwpLivePulse { 0% { box-shadow: 0 0 0 0 rgba(74,222,128,.55); } 70% { box-shadow: 0 0 0 14px rgba(74,222,128,0); } 100% { box-shadow: 0 0 0 0 rgba(74,222,128,0); } }
#agwp-fab.agwp-speaking { animation: agwpSpeak 1.1s ease infinite; }

/* ---- Panel ---- */
#agwp-panel {
	position: fixed; z-index: 2147483001; right: 22px; bottom: 96px;
	width: min(400px, calc(100vw - 32px)); height: min(620px, calc(100vh - 130px));
	background: var(--agwp-bg); color: var(--agwp-text);
	border-radius: 20px; border: 1px solid var(--agwp-line);
	box-shadow: 0 30px 80px rgba(0,0,0,.5);
	display: flex; flex-direction: column; overflow: hidden;
	opacity: 0; transform: translateY(20px) scale(.98); pointer-events: none;
	transition: opacity .22s ease, transform .22s ease;
}
.agwp-pos-bottom-left #agwp-panel { right: auto; left: 22px; }
#agwp-root.agwp-open #agwp-panel { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }

.agwp-panel-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--agwp-line); }
.agwp-brand { display: flex; align-items: center; gap: 10px; }
.agwp-orb-mini { width: 30px; height: 30px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, var(--agwp-secondary), var(--agwp-primary)); box-shadow: 0 0 14px rgba(15,184,184,.4); }
.agwp-brand-name { font-weight: 700; font-size: 15px; }
.agwp-brand-sub { font-size: 10px; letter-spacing: .18em; text-transform: uppercase; color: var(--agwp-muted); }
.agwp-head-actions { display: flex; gap: 4px; }
.agwp-icon-btn { background: rgba(255,255,255,.05); border: 1px solid var(--agwp-line); color: var(--agwp-muted); width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: .15s; }
.agwp-icon-btn:hover { color: #fff; background: rgba(255,255,255,.1); }
.agwp-icon-btn .material-symbols-rounded { font-size: 18px; }

.agwp-status { display: flex; gap: 6px; padding: 8px 14px; border-bottom: 1px solid var(--agwp-line); flex-wrap: wrap; }
.agwp-badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px; border-radius: 99px; font-size: 10px; letter-spacing: .04em; text-transform: uppercase; border: 1px solid var(--agwp-line); color: var(--agwp-muted); background: rgba(255,255,255,.02); }
.agwp-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--agwp-muted); }
.agwp-badge.ok { color: #4ade80; border-color: rgba(74,222,128,.25); } .agwp-badge.ok .agwp-dot { background: #4ade80; }
.agwp-badge.err { color: #f87171; border-color: rgba(248,113,113,.25); } .agwp-badge.err .agwp-dot { background: #f87171; }
.agwp-badge.warn { color: #fbbf24; border-color: rgba(251,191,36,.25); } .agwp-badge.warn .agwp-dot { background: #fbbf24; }

.agwp-screen { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 16px; }
.agwp-hidden { display: none !important; }

/* ---- Pantalla de inicio ---- */
.agwp-welcome { text-align: center; margin: auto 0 18px; }
.agwp-welcome h2 { font-size: 22px; margin: 0 0 8px; color: #fff; }
.agwp-welcome p { color: var(--agwp-muted); font-size: 14px; line-height: 1.5; margin: 0; }
.agwp-hint { font-size: 11px; color: var(--agwp-muted); text-align: center; margin-top: 10px; min-height: 14px; }

/* ---- Botones ---- */
.agwp-btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 13px 18px; border-radius: 12px; font-size: 14px; font-weight: 600; cursor: pointer; border: none; margin-top: 8px; transition: .15s; }
.agwp-btn .material-symbols-rounded { font-size: 18px; }
.agwp-btn-primary { background: linear-gradient(135deg, var(--agwp-primary), var(--agwp-secondary)); color: #fff; }
.agwp-btn-primary:hover { filter: brightness(1.08); }
.agwp-btn-ghost { background: rgba(255,255,255,.04); color: var(--agwp-text); border: 1px solid var(--agwp-line); }
.agwp-btn-ghost:hover { background: rgba(255,255,255,.08); }

/* ---- Conversación ---- */
.agwp-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding-right: 4px; }
.agwp-log::-webkit-scrollbar { width: 5px; } .agwp-log::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 3px; }
.agwp-msg { max-width: 88%; padding: 9px 12px; border-radius: 14px; font-size: 13.5px; line-height: 1.5; animation: agwpFade .2s ease; }
@keyframes agwpFade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }
.agwp-msg.user { align-self: flex-end; background: rgba(15,184,184,.14); border: 1px solid rgba(15,184,184,.2); border-bottom-right-radius: 4px; }
.agwp-msg.assistant { align-self: flex-start; background: rgba(255,255,255,.05); border: 1px solid var(--agwp-line); border-bottom-left-radius: 4px; }
.agwp-msg.sys { align-self: center; font-size: 10.5px; color: var(--agwp-muted); background: none; border: 1px dashed var(--agwp-line); border-radius: 99px; padding: 3px 10px; }
.agwp-caption { text-align: center; color: var(--agwp-muted); font-size: 13px; min-height: 18px; margin: 8px 0; font-style: italic; }

.agwp-orb-wrap { position: relative; width: 84px; height: 84px; margin: 6px auto; }
.agwp-orb { width: 76px; height: 76px; border-radius: 50%; border: none; cursor: pointer; position: absolute; inset: 4px; background: radial-gradient(circle at 38% 32%, rgba(127,168,212,.7), rgba(20,28,42,.2)); box-shadow: 0 8px 32px rgba(127,168,212,.18); transition: .3s; }
.agwp-orb.listening { background: radial-gradient(circle at 38% 32%, var(--agwp-secondary), rgba(30,50,80,.3)); box-shadow: 0 0 40px rgba(15,184,184,.5); }
.agwp-orb.speaking { background: radial-gradient(circle at 38% 32%, #e9cf92, #d4b87a 60%); box-shadow: 0 0 50px rgba(212,184,122,.5); animation: agwpSpeak 1.2s ease infinite; }
@keyframes agwpSpeak { 0%,100% { transform: scale(1); } 50% { transform: scale(1.05); } }
.agwp-ring { position: absolute; inset: 0; border-radius: 50%; border: 1px solid transparent; }
.agwp-orb-wrap.listening .agwp-ring { border-color: rgba(15,184,184,.3); animation: agwpRing 1.6s ease infinite; }
@keyframes agwpRing { 0% { transform: scale(1); opacity: .7; } 100% { transform: scale(1.35); opacity: 0; } }

.agwp-controls { display: flex; gap: 10px; justify-content: center; margin-top: 8px; }
.agwp-ctrl { width: 46px; height: 46px; border-radius: 14px; background: rgba(255,255,255,.05); color: var(--agwp-muted); border: 1px solid var(--agwp-line); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: .15s; }
.agwp-ctrl:hover { color: #fff; background: rgba(255,255,255,.1); }
.agwp-ctrl.on { color: var(--agwp-secondary); border-color: rgba(15,184,184,.4); background: rgba(15,184,184,.12); }
.agwp-ctrl-danger { color: #f87171; }
.agwp-ctrl-danger:hover { background: rgba(248,113,113,.12); }
.agwp-ctrl .material-symbols-rounded { font-size: 20px; }

/* ---- Modal de confirmación ---- */
.agwp-confirm { position: fixed; inset: 0; z-index: 2147483002; background: rgba(3,4,7,.7); backdrop-filter: blur(4px); display: none; align-items: center; justify-content: center; padding: 20px; }
.agwp-confirm.open { display: flex; animation: agwpFade .2s; }
.agwp-confirm-box { background: var(--agwp-bg); border: 1px solid var(--agwp-line); border-radius: 20px; padding: 24px; max-width: 360px; width: 100%; text-align: center; color: var(--agwp-text); }
.agwp-confirm-icon { width: 56px; height: 56px; margin: 0 auto 12px; border-radius: 50%; background: rgba(15,184,184,.15); display: flex; align-items: center; justify-content: center; color: var(--agwp-secondary); }
.agwp-confirm-icon .material-symbols-rounded { font-size: 30px; }
.agwp-confirm-box h3 { margin: 0 0 8px; color: #fff; }
.agwp-confirm-box p { color: var(--agwp-muted); font-size: 14px; margin: 0 0 18px; line-height: 1.5; }
.agwp-confirm-actions { display: flex; gap: 10px; }
.agwp-confirm-actions .agwp-btn { margin-top: 0; }

/* ---- Toast ---- */
.agwp-toast { position: fixed; z-index: 2147483003; bottom: 100px; left: 50%; transform: translateX(-50%) translateY(10px); background: #1f2330; color: #fff; padding: 11px 18px; border-radius: 12px; font-size: 13px; box-shadow: 0 12px 30px rgba(0,0,0,.4); opacity: 0; pointer-events: none; transition: .25s; max-width: 90vw; text-align: center; }
.agwp-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.agwp-toast.err { background: #c1191f; }
.agwp-toast.ok { background: #0a8754; }

/* ---- Acción visible: señal AMARILLA pulsante donde Ana actúa ---- */
.agwp-flash-target {
	outline: 3px solid #ffd400 !important;
	outline-offset: 3px !important;
	border-radius: 6px !important;
	position: relative;
	z-index: 2147482000 !important;
	box-shadow: 0 0 0 6px rgba(255,212,0,.35), 0 0 22px 5px rgba(255,212,0,.6) !important;
	animation: agwpFlash .7s ease infinite !important;
}
@keyframes agwpFlash {
	0%, 100% { outline-color: #ffd400; box-shadow: 0 0 0 6px rgba(255,212,0,.35), 0 0 22px 5px rgba(255,212,0,.6); }
	50% { outline-color: #ffb300; box-shadow: 0 0 0 11px rgba(255,212,0,.12), 0 0 34px 9px rgba(255,212,0,.8); }
}

/* ---- v2.4: resaltado por OVERLAY — se ve SIEMPRE, también dentro de
   shadow DOM, iframes del mismo dominio y apps React que re-pintan el
   elemento (el anillo vive en la ventana principal y sigue al elemento) ---- */
.agwp-hl-ring {
	position: fixed; z-index: 2147482990; pointer-events: none;
	border: 3px solid #ffd400; border-radius: 10px;
	box-shadow: 0 0 0 6px rgba(255,212,0,.30), 0 0 26px 6px rgba(255,212,0,.55), inset 0 0 18px rgba(255,212,0,.25);
	animation: agwpRingFlash .7s ease infinite;
}
@keyframes agwpRingFlash {
	0%, 100% { border-color: #ffd400; box-shadow: 0 0 0 6px rgba(255,212,0,.30), 0 0 26px 6px rgba(255,212,0,.55), inset 0 0 18px rgba(255,212,0,.25); }
	50% { border-color: #ffb300; box-shadow: 0 0 0 11px rgba(255,212,0,.12), 0 0 36px 10px rgba(255,212,0,.75), inset 0 0 24px rgba(255,212,0,.35); }
}
/* Punto expansivo en el sitio EXACTO del clic de Ana. */
.agwp-click-dot {
	position: fixed; z-index: 2147482991; pointer-events: none;
	width: 18px; height: 18px; margin: -9px 0 0 -9px; border-radius: 50%;
	background: rgba(255,212,0,.95);
	box-shadow: 0 0 0 4px rgba(255,212,0,.45), 0 0 18px 4px rgba(255,179,0,.7);
	animation: agwpClickDot .8s ease forwards;
}
@keyframes agwpClickDot {
	0% { transform: scale(.55); opacity: 1; }
	100% { transform: scale(3.4); opacity: 0; }
}

/* ---- Responsive: bottom sheet en móvil ---- */
@media (max-width: 600px) {
	#agwp-panel { right: 0; left: 0; bottom: 0; width: 100%; height: 86vh; height: 86dvh; border-radius: 20px 20px 0 0; }
	.agwp-pos-bottom-left #agwp-panel { left: 0; }
	#agwp-fab { bottom: 18px; right: 18px; }
	.agwp-pos-bottom-left #agwp-fab { left: 18px; right: auto; }
}

/* ---- Accesibilidad ---- */
#agwp-root button:focus-visible { outline: 2px solid var(--agwp-secondary); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
	.agwp-fab-pulse, .agwp-orb.speaking, .agwp-orb-wrap.listening .agwp-ring { animation: none; }
}

/* ---- v2: etiqueta "Habla con {nombre}" y offsets configurables ---- */
#agwp-fab { bottom: var(--agwp-off-y, 22px); right: var(--agwp-off-x, 22px); }
.agwp-pos-bottom-left #agwp-fab { right: auto; left: var(--agwp-off-x, 22px); }
.agwp-fab-label {
	position: fixed; z-index: 2147482999;
	bottom: calc(var(--agwp-off-y, 22px) + 16px);
	right: calc(var(--agwp-off-x, 22px) + 66px);
	background: var(--agwp-primary, #0d1b7a); color: #fff;
	font: 600 13px/1 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	padding: 9px 14px; border-radius: 18px 18px 4px 18px;
	box-shadow: 0 8px 22px rgba(0, 0, 0, .28);
	white-space: nowrap; pointer-events: none;
	animation: agwpLabelIn .5s ease both; animation-delay: 1.2s;
}
.agwp-pos-bottom-left .agwp-fab-label { right: auto; left: calc(var(--agwp-off-x, 22px) + 66px); border-radius: 18px 18px 18px 4px; }
#agwp-root.agwp-open .agwp-fab-label { display: none; }
@keyframes agwpLabelIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (max-width: 480px) { .agwp-fab-label { font-size: 12px; padding: 8px 12px; } }
