/* White GEO Chat Widget */

.wg-chat-widget {
  --wg-chat-primary: #2563eb;
  --wg-chat-primary-dark: #1d4ed8;
  --wg-chat-bg: #ffffff;
  --wg-chat-dark: #0f172a;
  --wg-chat-text: #334155;
  --wg-chat-muted: #64748b;
  --wg-chat-line: #e2e8f0;
  --wg-chat-bot-bg: #f1f5f9;
  --wg-chat-user-bg: #2563eb;
  --wg-chat-user-text: #ffffff;
  --wg-chat-radius: 16px;
  --wg-chat-shadow: 0 8px 32px rgba(15, 23, 42, 0.18);

  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Toggle button */
.wg-chat-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--wg-chat-primary);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: var(--wg-chat-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: transform 0.2s ease, background 0.2s ease;
}

.wg-chat-toggle:hover {
  background: var(--wg-chat-primary-dark);
  transform: scale(1.05);
}

.wg-chat-toggle svg {
  width: 28px;
  height: 28px;
}

/* Chat window */
.wg-chat-window {
  position: fixed;
  bottom: 92px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 120px);
  background: var(--wg-chat-bg);
  border-radius: var(--wg-chat-radius);
  box-shadow: var(--wg-chat-shadow);
  display: flex;
  flex-direction: column;
  z-index: 9999;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.wg-chat-window.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Header */
.wg-chat-header {
  background: var(--wg-chat-primary);
  color: #fff;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.wg-chat-header-title {
  font-weight: 600;
  font-size: 15px;
  line-height: 1.3;
}

.wg-chat-header-subtitle {
  font-size: 12px;
  opacity: 0.85;
  margin-top: 2px;
}

.wg-chat-header-actions {
  display: flex;
  gap: 8px;
}

.wg-chat-btn-icon {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.wg-chat-btn-icon:hover {
  background: rgba(255,255,255,0.25);
}

/* Messages area */
.wg-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.wg-chat-message {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
  animation: wg-chat-pop 0.2s ease;
}

@keyframes wg-chat-pop {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.wg-chat-message--user {
  align-self: flex-end;
  background: var(--wg-chat-user-bg);
  color: var(--wg-chat-user-text);
  border-bottom-right-radius: 4px;
}

.wg-chat-message--bot {
  align-self: flex-start;
  background: var(--wg-chat-bot-bg);
  color: var(--wg-chat-text);
  border-bottom-left-radius: 4px;
}

.wg-chat-message--system {
  align-self: center;
  background: transparent;
  color: var(--wg-chat-muted);
  font-size: 12px;
  padding: 4px 8px;
}

/* Typing indicator */
.wg-chat-typing {
  align-self: flex-start;
  background: var(--wg-chat-bot-bg);
  padding: 14px 18px;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  display: flex;
  gap: 4px;
}

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

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

@keyframes wg-chat-bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-5px); }
}

/* Sources */
.wg-chat-sources {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--wg-chat-line);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.wg-chat-source {
  font-size: 12px;
  color: var(--wg-chat-primary);
  text-decoration: none;
}

.wg-chat-source:hover {
  text-decoration: underline;
}

/* Input area */
.wg-chat-input-area {
  padding: 12px 16px;
  border-top: 1px solid var(--wg-chat-line);
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  background: var(--wg-chat-bg);
}

.wg-chat-input {
  flex: 1;
  border: 1px solid var(--wg-chat-line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--wg-chat-text);
  outline: none;
  resize: none;
  min-height: 40px;
  max-height: 100px;
  transition: border-color 0.15s ease;
}

.wg-chat-input:focus {
  border-color: var(--wg-chat-primary);
}

.wg-chat-send {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--wg-chat-primary);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s ease;
}

.wg-chat-send:hover:not(:disabled) {
  background: var(--wg-chat-primary-dark);
}

.wg-chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Escalate button */
.wg-chat-escalate {
  margin: 0 16px 12px;
  padding: 10px;
  border: 1px dashed var(--wg-chat-line);
  border-radius: 10px;
  background: transparent;
  color: var(--wg-chat-muted);
  font-size: 13px;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
}

.wg-chat-escalate:hover {
  border-color: var(--wg-chat-primary);
  color: var(--wg-chat-primary);
}

/* Mobile */
@media (max-width: 480px) {
  .wg-chat-window {
    right: 8px;
    bottom: 80px;
    width: calc(100vw - 16px);
    height: calc(100vh - 96px);
    max-height: none;
    border-radius: 12px;
  }
  .wg-chat-toggle {
    bottom: 16px;
    right: 16px;
  }
}
