:root {
  --twf-agent-navy: #041a2a;
  --twf-agent-blue: #08658b;
  --twf-agent-cyan: #43d9ff;
  --twf-agent-soft: #e8f8ff;
  --twf-agent-line: rgba(79, 199, 235, .22);
  --twf-agent-green: #20c774;
  --twf-agent-text: #102938;
}

.twf-agent-launcher {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 9998;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 8px 16px 8px 9px;
  border: 1px solid rgba(93, 221, 255, .72);
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, rgba(4, 36, 57, .98), rgba(5, 102, 137, .96));
  box-shadow: 0 18px 48px rgba(0, 17, 31, .4), 0 0 0 5px rgba(67, 217, 255, .1);
  font: 750 .9rem/1.1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease;
}

.twf-agent-launcher:hover { transform: translateY(-2px); box-shadow: 0 22px 56px rgba(0, 17, 31, .48), 0 0 0 7px rgba(67, 217, 255, .13); }
.twf-agent-launcher:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.twf-agent-launcher-mark { display: grid; place-items: center; width: 41px; height: 41px; border-radius: 50%; color: var(--twf-agent-navy); background: linear-gradient(145deg, #fff, var(--twf-agent-cyan)); font-size: .72rem; font-weight: 950; letter-spacing: -.03em; }
.twf-agent-launcher-copy { display: grid; gap: 2px; text-align: left; }
.twf-agent-launcher-copy small { color: #aeeeff; font-size: .67rem; font-weight: 650; }
.twf-agent-launcher-pulse { position: absolute; top: 3px; left: 44px; width: 10px; height: 10px; border: 2px solid var(--twf-agent-navy); border-radius: 50%; background: var(--twf-agent-green); }

.twf-agent-nudge {
  position: fixed;
  right: 22px;
  bottom: 94px;
  z-index: 9997;
  width: min(300px, calc(100vw - 32px));
  padding: 14px 44px 14px 16px;
  border: 1px solid var(--twf-agent-line);
  border-radius: 17px;
  color: #dff7ff;
  background: rgba(3, 28, 43, .96);
  box-shadow: 0 18px 45px rgba(0, 14, 27, .35);
  font: 650 .84rem/1.42 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.twf-agent-nudge.is-visible { opacity: 1; transform: translateY(0); pointer-events: auto; }
.twf-agent-nudge button { position: absolute; top: 6px; right: 8px; width: 30px; height: 30px; border: 0; color: #b9ddeb; background: transparent; font-size: 1.25rem; cursor: pointer; }

.twf-agent-backdrop { position: fixed; inset: 0; z-index: 9998; background: rgba(0, 13, 23, .44); opacity: 0; pointer-events: none; transition: opacity .22s ease; }
.twf-agent-backdrop.is-open { opacity: 1; pointer-events: auto; }

.twf-agent-panel {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 9999;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  width: min(420px, calc(100vw - 36px));
  height: min(720px, calc(100dvh - 36px));
  overflow: hidden;
  border: 1px solid rgba(93, 221, 255, .38);
  border-radius: 24px;
  color: var(--twf-agent-text);
  background: #f8fcfe;
  box-shadow: 0 32px 90px rgba(0, 14, 26, .48);
  opacity: 0;
  transform: translateY(18px) scale(.98);
  transform-origin: bottom right;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.twf-agent-panel.is-open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }

.twf-agent-header { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 11px; padding: 15px 14px; color: #fff; background: linear-gradient(125deg, #031b2a, #075e80 74%, #0b7da0); }
.twf-agent-avatar { display: grid; place-items: center; width: 43px; height: 43px; border: 1px solid rgba(255,255,255,.45); border-radius: 14px; color: var(--twf-agent-navy); background: linear-gradient(145deg, #fff, #62defa); font-size: .72rem; font-weight: 950; }
.twf-agent-title { min-width: 0; }
.twf-agent-title strong { display: block; font-size: .98rem; }
.twf-agent-title span { display: flex; align-items: center; gap: 6px; margin-top: 2px; color: #bcecff; font-size: .72rem; }
.twf-agent-title span::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #8eb1bf; box-shadow: 0 0 0 4px rgba(142,177,191,.14); }
.twf-agent-title span.is-connected::before { background: var(--twf-agent-green); box-shadow: 0 0 0 4px rgba(32,199,116,.14); }
.twf-agent-close { width: 38px; height: 38px; border: 0; border-radius: 50%; color: #fff; background: rgba(255,255,255,.1); font-size: 1.45rem; cursor: pointer; }
.twf-agent-close:hover { background: rgba(255,255,255,.19); }

.twf-agent-notice { padding: 8px 13px; border-bottom: 1px solid #d9edf4; color: #456575; background: #edf9fd; font-size: .69rem; line-height: 1.35; }
.twf-agent-notice a { color: #006a91; font-weight: 750; }

.twf-agent-body { overflow-y: auto; padding: 17px 13px 10px; scroll-behavior: smooth; }
.twf-agent-message { display: flex; margin: 0 0 12px; }
.twf-agent-message.is-user { justify-content: flex-end; }
.twf-agent-bubble { max-width: 86%; padding: 11px 13px; border: 1px solid #d7e8ef; border-radius: 17px 17px 17px 5px; color: #173645; background: #fff; box-shadow: 0 4px 14px rgba(6, 57, 77, .06); white-space: pre-wrap; font-size: .88rem; line-height: 1.48; }
.twf-agent-message.is-user .twf-agent-bubble { border-radius: 17px 17px 5px 17px; color: #fff; background: linear-gradient(135deg, #08658b, #0780a5); }
.twf-agent-message.is-system .twf-agent-bubble { color: #173645; background: #fff; }
.twf-agent-time { display: block; margin-top: 5px; color: inherit; opacity: .62; font-size: .62rem; }

.twf-agent-typing { display: none; gap: 4px; align-items: center; width: max-content; margin: 4px 0 12px; padding: 11px 14px; border: 1px solid #d7e8ef; border-radius: 17px 17px 17px 5px; background: #fff; }
.twf-agent-typing.is-visible { display: flex; }
.twf-agent-typing i { width: 6px; height: 6px; border-radius: 50%; background: #4d879d; animation: twf-agent-dot 1s infinite ease-in-out; }
.twf-agent-typing i:nth-child(2) { animation-delay: .15s; }
.twf-agent-typing i:nth-child(3) { animation-delay: .3s; }

.twf-agent-quick { display: flex; flex-wrap: wrap; gap: 7px; margin: 2px 0 14px; }
.twf-agent-quick button { padding: 8px 11px; border: 1px solid #9bd9ea; border-radius: 999px; color: #075979; background: #fff; font: 700 .75rem/1.2 system-ui, sans-serif; cursor: pointer; }
.twf-agent-quick button:hover { color: #fff; background: #08789e; border-color: #08789e; }

.twf-agent-composer { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; padding: 10px 11px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid #d8eaf1; background: #fff; }
.twf-agent-composer textarea { min-height: 45px; max-height: 110px; resize: none; padding: 11px 12px; border: 1px solid #bdd9e4; border-radius: 15px; color: #173645; background: #f8fcfe; font: .86rem/1.35 system-ui, sans-serif; }
.twf-agent-composer textarea:focus { outline: 2px solid rgba(26, 170, 211, .3); border-color: #1599c0; }
.twf-agent-send { align-self: end; width: 45px; height: 45px; border: 0; border-radius: 14px; color: #fff; background: linear-gradient(145deg, #08749a, #064c6d); font-size: 1.15rem; font-weight: 900; cursor: pointer; }
.twf-agent-send:disabled { opacity: .5; cursor: wait; }

.twf-agent-form-wrap { margin: 7px 0 14px; padding: 14px; border: 1px solid #c8e4ee; border-radius: 18px; background: #fff; box-shadow: 0 12px 30px rgba(7, 78, 104, .08); }
.twf-agent-form-wrap h3 { margin: 0 0 5px; color: #062f46; font-size: 1rem; }
.twf-agent-form-wrap > p { margin: 0 0 12px; color: #527080; font-size: .77rem; line-height: 1.45; }
.twf-agent-form { display: grid; gap: 9px; }
.twf-agent-form label { display: grid; gap: 4px; color: #315263; font-size: .7rem; font-weight: 750; }
.twf-agent-form input, .twf-agent-form select, .twf-agent-form textarea { width: 100%; min-height: 40px; padding: 9px 10px; border: 1px solid #c3dce5; border-radius: 10px; color: #173645; background: #fbfeff; font: .8rem/1.35 system-ui, sans-serif; }
.twf-agent-form textarea { min-height: 70px; resize: vertical; }
.twf-agent-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.twf-agent-consent { display: grid !important; grid-template-columns: auto 1fr; align-items: start; gap: 8px !important; font-weight: 550 !important; line-height: 1.4; }
.twf-agent-consent input { width: 17px; min-height: 17px; margin-top: 2px; }
.twf-agent-form button { min-height: 44px; border: 0; border-radius: 999px; color: #fff; background: linear-gradient(135deg, #0a8a5b, #16b977); font: 800 .82rem/1 system-ui, sans-serif; cursor: pointer; }
.twf-agent-form-note { text-align: center; color: #6b8793; font-size: .66rem; }

.twf-agent-emergency { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; color: #9b360e; font-size: .72rem; font-weight: 750; }
.twf-agent-error { padding: 10px 12px; border: 1px solid #f0c3b5; border-radius: 12px; color: #873617; background: #fff3ee; font-size: .76rem; }

body.twf-agent-ready .whatsapp-float,
body.twf-agent-ready .whatsapp-guide { display: none !important; }

@keyframes twf-agent-dot { 0%, 60%, 100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-3px); opacity: 1; } }

@media (max-width: 640px) {
  .twf-agent-launcher { right: 14px; bottom: calc(74px + env(safe-area-inset-bottom)); min-height: 52px; padding-right: 13px; }
  .twf-agent-launcher-mark { width: 36px; height: 36px; }
  .twf-agent-nudge { right: 14px; bottom: calc(136px + env(safe-area-inset-bottom)); }
  .twf-agent-panel { inset: 0; width: 100%; height: 100dvh; max-height: none; border: 0; border-radius: 0; transform: translateY(24px); }
  .twf-agent-panel.is-open { transform: translateY(0); }
  .twf-agent-header { padding-top: calc(13px + env(safe-area-inset-top)); }
  .twf-agent-backdrop { display: none; }
  .twf-agent-form-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .twf-agent-launcher, .twf-agent-nudge, .twf-agent-backdrop, .twf-agent-panel { transition: none; }
  .twf-agent-typing i { animation: none; }
  .twf-agent-body { scroll-behavior: auto; }
}
