/* Tony chat widget for twaprinting.com.
   Design language follows award.css: navy #13294c band, red accent,
   paper ground, Sora and Inter. The widget never sits above the site
   pop-up (z-index stays under the tent pop's 200) and yields aside
   while that pop-up is on screen. */

#twa-chat-btn {
  position: fixed; left: 18px; bottom: 18px; z-index: 190;
  display: flex; align-items: center; gap: 10px;
  padding: 6px 16px 6px 6px; border: 0; border-radius: 999px;
  background: #13294c; color: #fff; cursor: pointer;
  font-family: Sora, Inter, system-ui, sans-serif; font-size: 15px; font-weight: 650;
  box-shadow: 0 16px 34px -12px rgba(8, 22, 39, .45);
  transition: transform .25s cubic-bezier(.23,1,.32,1), opacity .25s;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
#twa-chat-btn:hover { transform: translateY(-2px); }
#twa-chat-btn img { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; background: #f6f6f3; border: 2px solid #ffc52e; pointer-events: none; }
#twa-chat-btn .twa-dot {
  position: absolute; top: 4px; left: 46px; width: 13px; height: 13px; border-radius: 50%;
  background: #cf2935; border: 2px solid #13294c;
  animation: twa-pulse 2.2s ease-in-out infinite;
}
@keyframes twa-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.25); } }
#twa-chat-btn.twa-hidden { opacity: 0; pointer-events: none; transform: translateY(12px); }

#twa-chat-panel {
  position: fixed; left: 18px; bottom: 18px; z-index: 191;
  width: min(396px, calc(100vw - 20px)); height: min(640px, calc(100dvh - 96px));
  display: none; flex-direction: column; overflow: hidden;
  background: #f6f6f3; border-radius: 20px; border: 1px solid #d9dee6;
  box-shadow: 0 30px 60px -18px rgba(8, 22, 39, .45);
  font-family: Inter, system-ui, sans-serif; color: #122845;
}
#twa-chat-panel.twa-open { display: flex; }
#twa-chat-panel.twa-dragging { transition: none !important; }

/* When the visitor drags the widget, JS switches it to left/top coords. */
#twa-chat-btn.twa-placed, #twa-chat-panel.twa-placed { right: auto; bottom: auto; }

/* Yield: while the site pop-up is on screen, the closed button moves to
   the bottom left; an open panel narrows and hugs the left too. */
#twa-chat-btn.twa-yield { right: auto; left: 18px; }
#twa-chat-panel.twa-yield { right: auto; left: 10px; }

.twa-head {
  background: #13294c; color: #fff; padding: 12px 14px;
  display: flex; align-items: center; gap: 11px; cursor: grab; touch-action: none;
  user-select: none; -webkit-user-select: none; flex: 0 0 auto;
}
.twa-head:active { cursor: grabbing; }
.twa-head img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; background: #f6f6f3; border: 2px solid #ffc52e; pointer-events: none; }
.twa-head .twa-name { font-family: Sora, Inter, sans-serif; font-weight: 700; font-size: 16.5px; line-height: 1.15; }
.twa-head .twa-role { font-size: 12px; color: #c9d5e8; line-height: 1.2; }
.twa-head .twa-close {
  margin-left: auto; background: rgba(255,255,255,.12); color: #fff; border: 0; border-radius: 50%;
  width: 34px; height: 34px; font-size: 19px; line-height: 1; cursor: pointer; flex: 0 0 auto;
}
.twa-head .twa-close:hover { background: #cf2935; }

.twa-hero { background: #13294c; color: #eaf0f9; display: flex; gap: 12px; padding: 4px 16px 16px; align-items: flex-end; flex: 0 0 auto; }
.twa-hero video, .twa-hero img.twa-hero-still {
  width: 96px; height: 128px; object-fit: cover; object-position: top center;
  border-radius: 12px; background: transparent; flex: 0 0 auto;
}
.twa-hero p { margin: 0 0 4px; font-size: 13.5px; line-height: 1.45; }
.twa-hero p b { color: #fff; }
.twa-hero p.twa-sign { margin-top: 9px; }
.twa-hero .twa-sign-name { display: block; font-family: Sora, Inter, sans-serif; font-weight: 700; font-size: 13px; color: #fff; }
.twa-hero .twa-sign-line { display: block; font-size: 12.5px; font-style: italic; color: #ffc52e; }
#twa-chat-panel.twa-started .twa-hero { display: none; }

.twa-msgs { flex: 1 1 auto; overflow-y: auto; padding: 16px 14px 8px; display: flex; flex-direction: column; gap: 9px; overscroll-behavior: contain; }
.twa-msg { max-width: 86%; padding: 10px 13px; border-radius: 16px; font-size: 14.5px; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; }
.twa-msg.tony { background: #fff; border: 1px solid #d9dee6; border-bottom-left-radius: 5px; align-self: flex-start; box-shadow: 0 4px 14px -8px rgba(8,22,39,.25); }
.twa-msg.me { background: #13294c; color: #fff; border-bottom-right-radius: 5px; align-self: flex-end; }
.twa-msg a { color: #1745c5; font-weight: 600; }
.twa-msg.me a { color: #ffc52e; }
.twa-typing { align-self: flex-start; display: flex; gap: 5px; padding: 12px 14px; background: #fff; border: 1px solid #d9dee6; border-radius: 16px; border-bottom-left-radius: 5px; }
.twa-typing i { width: 7px; height: 7px; border-radius: 50%; background: #8fa3c2; animation: twa-blink 1.1s infinite; }
.twa-typing i:nth-child(2) { animation-delay: .18s; } .twa-typing i:nth-child(3) { animation-delay: .36s; }
@keyframes twa-blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.twa-chips { display: flex; flex-wrap: wrap; gap: 7px; padding: 2px 14px 10px; flex: 0 0 auto; }
.twa-chips button {
  border: 1.5px solid #1745c5; color: #1745c5; background: #fff; border-radius: 999px;
  padding: 7px 13px; font-size: 13.5px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.twa-chips button:hover { background: #1745c5; color: #fff; }

.twa-input { display: flex; gap: 8px; padding: 10px 12px; background: #fff; border-top: 1px solid #d9dee6; flex: 0 0 auto; }
.twa-input textarea {
  flex: 1; resize: none; border: 1.5px solid #c6cfdd; border-radius: 12px; padding: 10px 12px;
  font: inherit; font-size: 15px; max-height: 96px; color: #122845; background: #fbfbf9;
}
.twa-input textarea:focus { outline: 2px solid #1745c5; outline-offset: 0; border-color: #1745c5; }
.twa-input button {
  background: #cf2935; color: #fff; border: 0; border-radius: 12px; padding: 0 18px;
  font-family: Sora, Inter, sans-serif; font-weight: 700; font-size: 15px; cursor: pointer;
}
.twa-input button:hover { background: #a71930; }
.twa-input button:disabled { opacity: .55; cursor: wait; }

.twa-foot { padding: 8px 14px 11px; background: #fff; border-top: 1px solid #eceee9; font-size: 12.5px; color: #51617c; display: flex; justify-content: space-between; gap: 10px; flex: 0 0 auto; }
.twa-foot a { color: #1745c5; font-weight: 650; text-decoration: none; }
.twa-foot a:hover { text-decoration: underline; }

@media (max-width: 560px) {
  #twa-chat-panel { right: 10px; left: 10px; width: auto; bottom: 10px; height: min(78dvh, 640px); }
  #twa-chat-panel.twa-yield { left: 10px; }
  #twa-chat-btn { left: 12px; bottom: 12px; }
  #twa-chat-btn.twa-yield { left: 12px; right: auto; }
  #twa-chat-btn .twa-label { display: none; }
  #twa-chat-btn { padding: 5px; }
  #twa-chat-btn img { width: 54px; height: 54px; }
  #twa-chat-btn .twa-dot { left: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  #twa-chat-btn .twa-dot, .twa-typing i { animation: none; }
  #twa-chat-btn { transition: none; }
}
