/* Floating chat support panel (inc/chat.php + assets/js/chat.js) */

/* Toggle button: chat icon <-> close icon */
.talk-fab .talk-fab-close { display: none; }
.talk-fab[aria-expanded="true"] .talk-fab-open { display: none; }
.talk-fab[aria-expanded="true"] .talk-fab-close { display: inline-block; }
.talk-fab[aria-expanded="true"],
.talk-fab[aria-expanded="true"]:hover { width: 52px; padding: 0; gap: 0; }
.talk-fab[aria-expanded="true"] span { max-width: 0; opacity: 0; visibility: hidden; }

/* Panel */
.chat-panel {
  position: fixed; right: 20px; bottom: 86px; z-index: 1045;
  width: 380px; max-width: calc(100vw - 32px); max-height: min(640px, calc(100vh - 110px));
  display: flex; flex-direction: column; overflow: hidden;
  background: #fff; color: var(--sns-ink); border-radius: 18px;
  box-shadow: 0 24px 60px rgba(7, 31, 63, .28), 0 2px 8px rgba(7, 31, 63, .12);
  transform-origin: bottom right;
}
.chat-panel[hidden] { display: none; }
.chat-panel.is-opening { animation: chat-in .22s cubic-bezier(.22, .61, .36, 1); }
@keyframes chat-in { from { opacity: 0; transform: translateY(12px) scale(.97); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .chat-panel.is-opening { animation: none; } }

/* Header */
.chat-head { display: flex; align-items: center; gap: .75rem; padding: 1rem 1rem 1rem 1.1rem; background: linear-gradient(135deg, var(--sns-navy) 0%, var(--sns-navy-dark) 100%); color: #fff; }
.chat-avatar { flex: 0 0 42px; width: 42px; height: 42px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--sns-cyan); color: var(--sns-navy-dark); font-size: 1.2rem; }
.chat-head-text { flex: 1 1 auto; min-width: 0; }
.chat-title { margin: 0; font-size: 1rem; font-weight: 800; letter-spacing: -.01em; color: #fff; }
.chat-status { margin: .1rem 0 0; font-size: .78rem; line-height: 1.35; color: #cfe3f7; }
.chat-dot { display: inline-block; width: 8px; height: 8px; margin-right: .4rem; border-radius: 50%; background: #34d399; box-shadow: 0 0 0 3px rgba(52, 211, 153, .25); vertical-align: 1px; }
.chat-close { flex: 0 0 36px; width: 36px; height: 36px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .1); color: #fff; display: inline-flex; align-items: center; justify-content: center; transition: background-color .2s ease; }
.chat-close:hover, .chat-close:focus-visible { background: rgba(255, 255, 255, .22); }

/* Body + messages */
.chat-body { flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; padding: 1.1rem 1rem 1rem; background: var(--sns-bg); }
.chat-log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.chat-msg { max-width: 85%; padding: .6rem .85rem; border-radius: 14px; font-size: .92rem; line-height: 1.5; animation: chat-msg-in .25s ease both; overflow-wrap: anywhere; }
.chat-msg-bot { align-self: flex-start; background: #fff; color: var(--sns-ink); border: 1px solid #e3eaf3; border-bottom-left-radius: 4px; }
.chat-msg-user { align-self: flex-end; background: var(--sns-navy); color: #fff; border-bottom-right-radius: 4px; }
.chat-msg-success { border-color: #a3e4c5; background: #ecfdf5; color: #065f46; }
.chat-msg-error { border-color: #f1aeb5; background: #fdf2f3; color: #842029; }
@keyframes chat-msg-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .chat-msg { animation: none; } }

.chat-typing { display: inline-flex; gap: 4px; align-items: center; padding: .75rem .9rem; }
.chat-typing i { width: 6px; height: 6px; border-radius: 50%; background: #9aabbf; animation: chat-typing 1s infinite ease-in-out; }
.chat-typing i:nth-child(2) { animation-delay: .15s; }
.chat-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes chat-typing { 0%, 80%, 100% { opacity: .35; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

/* Topic chips */
.chat-chips { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: .85rem; }
.chat-chips[hidden] { display: none; }
.chat-chip { border: 1.5px solid var(--sns-navy); background: #fff; color: var(--sns-navy); border-radius: 999px; padding: .38rem .85rem; font-size: .85rem; font-weight: 700; line-height: 1.3; transition: background-color .2s ease, color .2s ease; }
.chat-chip:hover, .chat-chip:focus-visible { background: var(--sns-navy); color: #fff; }

/* Form (Smart Contact Form, Bootstrap markup from inc/contact-form.php) */
.chat-form { margin-top: .85rem; padding: .9rem; background: #fff; border: 1px solid #e3eaf3; border-radius: 14px; }
.chat-form[hidden], .chat-done[hidden] { display: none; }
.chat-panel .awscf-form-wrap { width: 100%; }
.chat-panel .awscf-form { margin: 0; }
.chat-panel .awscf-control, .chat-panel .awscf-sel-wrap { display: block; }
.chat-panel .sns-chat-topic { display: none; }
.chat-panel .form-control { font-size: .92rem; padding: .55rem .75rem; border-radius: 10px; }
.chat-panel textarea.form-control { resize: vertical; min-height: 84px; }
.chat-panel .awscf-sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.chat-panel .awscf-err.invalid-feedback { margin-top: .2rem; font-size: .8rem; }
.chat-panel .awscf-err[style*="display: block"],
.chat-panel .awscf-err[style*="display:block"],
.chat-panel .awscf-err[style*="inline"] { display: block !important; }
.chat-panel .form-control.awscf-ctrl-err { border-color: var(--bs-form-invalid-border-color, #dc3545); }
.chat-panel .awscf-submit-wrap { display: block; margin-top: .25rem; }
.chat-panel .awscf-submit-btn { padding: .6rem 1rem; }
.chat-panel .awscf-submit-btn:disabled { opacity: .75; cursor: progress; }
.chat-panel .awscf-submit-spin { display: inline-flex; align-items: center; gap: .5rem; }
.chat-panel .awscf-submit-spin::before { content: ""; width: 1rem; height: 1rem; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: chat-spin .7s linear infinite; }
@keyframes chat-spin { to { transform: rotate(360deg); } }
.chat-panel .awscf-msg { display: none !important; } /* shown as chat bubbles instead */

.chat-done { margin-top: .85rem; }

/* Footer */
.chat-foot { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .9rem; padding: .7rem 1rem; border-top: 1px solid #e3eaf3; background: #fff; font-size: .8rem; color: var(--sns-muted); }
.chat-foot a { color: var(--sns-navy); font-weight: 700; }
.chat-foot a:hover { color: #0a7d89; }

/* Phones: panel fills the width above the button */
@media (max-width: 575.98px) {
  .chat-panel { right: 12px; left: 12px; width: auto; max-width: none; bottom: 82px; max-height: calc(100vh - 100px); max-height: calc(100dvh - 100px); }
}
