/* Chat Widget Styles — matches Trading Closets Collection site palette */

.chat-widget-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1050;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background-color: var(--tc-primary);
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  transition: background-color 0.2s, transform 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-widget-btn:hover {
  background-color: var(--tc-primary-dark);
  transform: scale(1.05);
}

.chat-widget-btn:focus-visible {
  outline: 3px solid var(--tc-accent);
  outline-offset: 2px;
}

/* Panel */
.chat-widget-panel {
  position: fixed;
  bottom: 92px;
  right: 24px;
  z-index: 1050;
  width: 380px;
  max-height: 520px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.chat-widget-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

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

.chat-widget-header-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-weight: 600;
  font-size: 1rem;
  margin: 0;
}

.chat-widget-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  opacity: 0.8;
  transition: opacity 0.2s;
}

.chat-widget-close:hover {
  opacity: 1;
}

.chat-widget-close:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* Messages area */
.chat-widget-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

/* Message bubbles */
.chat-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.45;
  word-wrap: break-word;
}

.chat-msg-user {
  align-self: flex-end;
  background-color: var(--tc-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-msg-assistant {
  align-self: flex-start;
  background-color: var(--tc-light);
  color: var(--tc-dark);
  border-bottom-left-radius: 4px;
}

.chat-msg-error {
  align-self: center;
  background-color: #fde8e8;
  color: #991b1b;
  font-size: 0.85rem;
  text-align: center;
}

/* Typing indicator */
.chat-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  align-self: flex-start;
  background-color: var(--tc-light);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}

.chat-typing-dot {
  width: 7px;
  height: 7px;
  background-color: #999;
  border-radius: 50%;
  animation: chat-typing-bounce 1.2s infinite;
}

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

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

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

/* Input area */
.chat-widget-input {
  display: flex;
  border-top: 1px solid #e9ecef;
  padding: 10px 12px;
  flex-shrink: 0;
  gap: 8px;
}

.chat-widget-input input {
  flex: 1;
  border: 1px solid #dee2e6;
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 0.9rem;
  font-family: 'Lato', sans-serif;
  outline: none;
  transition: border-color 0.2s;
}

.chat-widget-input input:focus {
  border-color: var(--tc-primary);
  box-shadow: 0 0 0 2px rgba(140, 27, 36, 0.15);
}

.chat-widget-input button {
  background-color: var(--tc-primary);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 38px;
  height: 38px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  transition: background-color 0.2s;
}

.chat-widget-input button:hover {
  background-color: var(--tc-primary-dark);
}

.chat-widget-input button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chat-widget-input button:focus-visible {
  outline: 3px solid var(--tc-accent);
  outline-offset: 2px;
}

/* Welcome message */
.chat-welcome {
  text-align: center;
  color: #6c757d;
  font-size: 0.85rem;
  padding: 8px 0;
}

/* Mobile responsive */
@media (max-width: 576px) {
  .chat-widget-panel {
    width: calc(100vw - 24px);
    right: 12px;
    bottom: 84px;
    max-height: calc(100vh - 120px);
    border-radius: 12px;
  }

  .chat-widget-btn {
    bottom: 16px;
    right: 16px;
    width: 50px;
    height: 50px;
    font-size: 1.3rem;
  }
}

/* Print — hide widget */
@media print {
  .chat-widget-btn,
  .chat-widget-panel {
    display: none !important;
  }
}
