/*
 * BBC CHATBOT WIDGET STYLES
 * Uses design tokens from bbc-tokens.css (loaded via styles.css)
 */

/* Widget container — sized to bubble only; panel floats above */
#bbc-chat-widget {
  position: fixed;
  bottom: 88px;
  right: var(--sp-6);
  z-index: calc(var(--z-modal) + 5);
  width: 56px;
  height: 56px;
  transition: bottom var(--t-slow) var(--ease-out);
}

/* Raise chat bubble above the PWA install banner when it's visible */
body.has-install-banner #bbc-chat-widget {
  bottom: calc(88px + 72px);
}

/* Bubble trigger */
#bbc-chat-bubble {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--c-accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  transition: background var(--t-fast), transform var(--t-fast);
  position: relative;
  z-index: 1;
}
#bbc-chat-bubble:hover { background: var(--c-accent-hover); transform: scale(1.06); }
#bbc-chat-bubble:active { transform: scale(0.97); }

#bbc-chat-bubble svg {
  width: 24px;
  height: 24px;
  color: #fff;
}

#bbc-chat-bubble .bbc-bubble-icon-open  { display: block; }
#bbc-chat-bubble .bbc-bubble-icon-close { display: none;  }
#bbc-chat-bubble[aria-expanded="true"] .bbc-bubble-icon-open  { display: none;  }
#bbc-chat-bubble[aria-expanded="true"] .bbc-bubble-icon-close { display: block; }

/* Panel — floats above the bubble via absolute positioning */
#bbc-chat-panel {
  position: absolute;
  bottom: calc(100% + var(--sp-3));
  right: 0;
  width: 360px;
  max-width: calc(100vw - var(--sp-12));
  height: 500px;
  max-height: calc(100vh - 120px);
  background: var(--c-surface);
  border: var(--border);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px) scale(0.97);
  pointer-events: none;
  transition: opacity var(--t-slow) var(--ease-out),
              transform var(--t-slow) var(--ease-out);
}
#bbc-chat-panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Panel header */
.bbc-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-5);
  border-bottom: var(--border);
  background: var(--c-surface-2);
  flex-shrink: 0;
}

.bbc-chat-header-info {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.bbc-chat-avatar {
  width: 36px;
  height: 36px;
  background: var(--c-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  color: #fff;
  flex-shrink: 0;
}

.bbc-chat-title {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--c-text);
  letter-spacing: 0.04em;
}

.bbc-chat-status {
  font-size: var(--fs-xs);
  color: var(--c-accent);
}

#bbc-chat-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--c-text-2);
  padding: var(--sp-1);
  line-height: 1;
  display: flex;
  align-items: center;
  transition: color var(--t-fast);
}
#bbc-chat-close:hover { color: var(--c-text); }

/* Message thread */
#bbc-chat-thread {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  scroll-behavior: smooth;
}
#bbc-chat-thread::-webkit-scrollbar { width: 4px; }
#bbc-chat-thread::-webkit-scrollbar-track { background: transparent; }
#bbc-chat-thread::-webkit-scrollbar-thumb { background: var(--c-border); }

/* Message bubbles */
.bbc-msg {
  max-width: 85%;
  font-size: var(--fs-sm);
  line-height: var(--lh-relaxed);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-sm);
  word-break: break-word;
}
.bbc-msg--assistant {
  background: var(--c-bg);
  border: var(--border);
  color: var(--c-text);
  align-self: flex-start;
}
.bbc-msg--user {
  background: var(--c-accent);
  color: #fff;
  align-self: flex-end;
  border: none;
}

/* Typing indicator */
.bbc-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: var(--sp-3) var(--sp-4);
  background: var(--c-bg);
  border: var(--border);
  align-self: flex-start;
  border-radius: var(--radius-sm);
}
.bbc-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--c-text-3);
  animation: bbc-dot-bounce 1.2s infinite ease-in-out;
}
.bbc-typing span:nth-child(2) { animation-delay: 0.2s; }
.bbc-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bbc-dot-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%            { transform: translateY(-5px); opacity: 1; }
}

/* Lead capture card */
.bbc-lead-card {
  background: var(--c-surface-2);
  border: 1px solid var(--c-accent-border);
  padding: var(--sp-4) var(--sp-5);
  align-self: stretch;
}

.bbc-lead-text {
  font-size: var(--fs-sm);
  color: var(--c-text);
  margin-bottom: var(--sp-3);
  line-height: var(--lh-normal);
}

.bbc-lead-form {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.bbc-lead-input {
  background: var(--c-surface);
  border: var(--border);
  color: var(--c-text);
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm);
  transition: border-color var(--t-fast);
}
.bbc-lead-input:focus {
  outline: none;
  border-color: var(--c-accent);
}
.bbc-lead-input::placeholder { color: var(--c-text-3); }

.bbc-lead-input[aria-invalid="true"] {
  border-color: var(--c-accent);
}

.bbc-lead-error {
  font-size: var(--fs-xs);
  color: #ff8f73;
  line-height: var(--lh-normal);
}

.bbc-lead-btn {
  background: var(--c-accent);
  color: #fff;
  border: none;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--t-fast);
  align-self: flex-start;
}
.bbc-lead-btn:hover { background: var(--c-accent-hover); }
.bbc-lead-btn:disabled {
  background: var(--c-text-3);
  cursor: wait;
}

.bbc-lead-thanks {
  font-size: var(--fs-sm);
  color: var(--c-accent);
  padding: var(--sp-2) 0;
}

/* Input row */
.bbc-chat-input-row {
  display: flex;
  gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-5);
  border-top: var(--border);
  background: var(--c-surface-2);
  flex-shrink: 0;
}

#bbc-chat-input {
  flex: 1;
  background: var(--c-surface);
  border: var(--border);
  color: var(--c-text);
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm);
  transition: border-color var(--t-fast);
  min-width: 0;
}
#bbc-chat-input:focus {
  outline: none;
  border-color: var(--c-accent);
}
#bbc-chat-input::placeholder { color: var(--c-text-3); }

#bbc-chat-send {
  background: var(--c-accent);
  border: none;
  cursor: pointer;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--t-fast);
  flex-shrink: 0;
}
#bbc-chat-send:hover  { background: var(--c-accent-hover); }
#bbc-chat-send:disabled { opacity: 0.5; cursor: not-allowed; }

#bbc-chat-send svg {
  width: 18px;
  height: 18px;
  color: #fff;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  #bbc-chat-panel { transition: none; }
  .bbc-typing span { animation: none; opacity: 0.6; }
}
