/* ═══════════════════════════════════════════════════════════
   CHAT WIDGET & SCROLL-TO-TOP
   ═══════════════════════════════════════════════════════════ */

/* Skip link */
.skip-link {
  position: absolute;
  top: -100px;
  left: 1rem;
  z-index: 10001;
  padding: 0.75rem 1.25rem;
  background: var(--gold);
  color: var(--bg-deep);
  font-weight: 600;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
  transition: top 0.3s;
}

.skip-link:focus {
  top: 1rem;
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

/* Scroll to top */
.scroll-top {
  position: fixed;
  bottom: 6.5rem;
  right: 1.5rem;
  z-index: 998;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: all 0.4s var(--ease-out-expo);
  backdrop-filter: blur(12px);
}

.scroll-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.scroll-top:hover {
  border-color: var(--teal);
  color: var(--teal);
  background: var(--teal-dim);
  transform: translateY(-2px);
}

/* Chat launcher */
.chat-launcher {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 999;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--teal) 0%, #00a8b5 100%);
  color: var(--bg-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 32px rgba(30, 202, 211, 0.35);
  transition: transform 0.4s var(--ease-out-expo), box-shadow 0.4s;
}

.chat-launcher:hover {
  transform: scale(1.06);
  box-shadow: 0 12px 48px rgba(30, 202, 211, 0.5);
}

.chat-launcher.open {
  transform: rotate(0deg) scale(1);
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow);
}

.chat-launcher svg { transition: transform 0.3s; }
.chat-launcher.open .icon-chat { display: none; }
.chat-launcher.open .icon-close { display: block; }
.chat-launcher .icon-close { display: none; }

.chat-launcher-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 18px;
  height: 18px;
  background: var(--orange);
  border-radius: 50%;
  font-size: 0.65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  border: 2px solid var(--bg-deep);
  animation: badge-pulse 2s ease-in-out infinite;
}

.chat-launcher.open .chat-launcher-badge { display: none; }

@keyframes badge-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

/* Chat panel */
.chat-panel {
  position: fixed;
  bottom: 5.5rem;
  right: 1.5rem;
  z-index: 999;
  width: min(380px, calc(100vw - 2rem));
  height: min(520px, calc(100vh - 8rem));
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  transition: all 0.4s var(--ease-out-expo);
  backdrop-filter: blur(20px);
}

.chat-panel.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.chat-header {
  padding: 1.1rem 1.25rem;
  background: linear-gradient(135deg, var(--bg-elevated) 0%, var(--navy) 100%);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.chat-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--teal-dim);
  border: 1px solid rgba(30, 202, 211, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-header-avatar img {
  width: 28px;
  height: auto;
}

.chat-header-info h4 {
  font-family: var(--font-body);
  font-size: 0.92rem;
  font-weight: 600;
  margin-bottom: 0.1rem;
}

.chat-header-status {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.72rem;
  color: var(--teal);
}

.chat-header-status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--teal);
  animation: status-blink 2s ease-in-out infinite;
}

@keyframes status-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 4px;
}

.chat-msg {
  max-width: 88%;
  animation: msg-in 0.35s var(--ease-out-expo);
}

@keyframes msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-msg--bot { align-self: flex-start; }
.chat-msg--user { align-self: flex-end; }

.chat-bubble {
  padding: 0.75rem 1rem;
  border-radius: 16px;
  font-size: 0.88rem;
  line-height: 1.55;
}

.chat-msg--bot .chat-bubble {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.chat-msg--user .chat-bubble {
  background: linear-gradient(135deg, var(--teal) 0%, #00a8b5 100%);
  color: var(--bg-deep);
  border-bottom-right-radius: 4px;
}

.chat-bubble a {
  color: var(--gold-light);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.chat-msg--user .chat-bubble a { color: var(--bg-deep); font-weight: 600; }

.chat-msg-time {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
  padding: 0 0.25rem;
}

.chat-msg--user .chat-msg-time { text-align: right; }

.chat-typing {
  align-self: flex-start;
  display: none;
  padding: 0.75rem 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  margin-top: 0.25rem;
}

.chat-typing.active { display: flex; gap: 4px; align-items: center; }

.chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typing 1.2s ease-in-out infinite;
}

.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* Quick replies */
.chat-quick-replies {
  padding: 0 1.25rem 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chat-quick-btn {
  padding: 0.45rem 0.85rem;
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid var(--border-light);
  border-radius: 100px;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  transition: all 0.25s;
  white-space: nowrap;
}

.chat-quick-btn:hover {
  border-color: var(--teal);
  color: var(--teal);
  background: var(--teal-dim);
}

/* Chat input */
.chat-input-area {
  padding: 0.85rem 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.6rem;
  align-items: flex-end;
  background: var(--bg-primary);
}

.chat-input {
  flex: 1;
  padding: 0.7rem 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 100px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.88rem;
  resize: none;
  max-height: 80px;
  line-height: 1.4;
  transition: border-color 0.3s;
}

.chat-input:focus {
  outline: none;
  border-color: var(--teal);
}

.chat-input::placeholder { color: var(--text-muted); }

.chat-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold) 0%, var(--orange) 100%);
  color: var(--bg-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.3s, box-shadow 0.3s;
}

.chat-send:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 16px rgba(212, 168, 83, 0.4);
}

.chat-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.chat-footer-note {
  text-align: center;
  padding: 0.4rem;
  font-size: 0.65rem;
  color: var(--text-muted);
  background: var(--bg-primary);
  border-top: 1px solid var(--border);
}

.chat-footer-note a {
  color: var(--teal);
  text-decoration: underline;
}

@media (max-width: 480px) {
  .chat-panel {
    right: 1rem;
    bottom: 5rem;
    width: calc(100vw - 2rem);
    height: calc(100vh - 7rem);
  }

  .chat-launcher { right: 1rem; bottom: 1rem; }
  .scroll-top { right: 1rem; bottom: 5.5rem; }
}
