/* Trails Coffee Chat Widget */
.tc-chat-bubble {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6B4423, #8B6914);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(107, 68, 35, 0.4);
  z-index: 99998;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
  font-size: 28px;
  line-height: 1;
}
.tc-chat-bubble:hover {
  animation: none;
  transform: scale(1.1);
  box-shadow: 0 6px 28px rgba(107, 68, 35, 0.5);
}
.tc-chat-bubble.open {
  display: none;
}

/* Attention pulse animation */
.tc-chat-bubble::after {
  content: '';
  position: absolute;
  top: -4px;
  right: -4px;
  width: 14px;
  height: 14px;
  background: #e74c3c;
  border-radius: 50%;
  border: 2px solid #fff;
  animation: tc-dot-pulse 2s ease-in-out infinite;
}
@keyframes tc-dot-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.7; }
}
@keyframes tc-bubble-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
.tc-chat-bubble {
  animation: tc-bubble-bounce 3s ease-in-out infinite;
}

/* Chat Overlay — fixed fullscreen container */
.tc-chat-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 99999;
  display: none;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 24px;
  pointer-events: none;
}
.tc-chat-overlay.open {
  display: flex;
}

/* Chat Panel */
.tc-chat-panel {
  width: 380px;
  max-width: calc(100vw - 48px);
  height: 520px;
  max-height: calc(100vh - 48px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.2);
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: 'Quicksand', sans-serif;
  pointer-events: auto;
  box-sizing: border-box;
}
.tc-chat-panel *, .tc-chat-panel *::before, .tc-chat-panel *::after {
  box-sizing: border-box;
}
.tc-chat-panel.open {
  display: flex;
}

/* Header */
.tc-chat-header {
  background: linear-gradient(135deg, #6B4423, #8B6914);
  color: #fff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.tc-chat-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}
.tc-chat-header-info .avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}
.tc-chat-header-info .name {
  font-weight: 700;
  font-size: 15px;
}
.tc-chat-header-info .status {
  font-size: 12px;
  opacity: 0.8;
}
.tc-chat-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  opacity: 0.8;
  transition: opacity 0.2s;
}
.tc-chat-close:hover {
  opacity: 1;
}

/* Messages */
.tc-chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  background: #f7f3ef;
  display: flex;
  flex-direction: column;
  gap: 10px;
  word-break: break-word;
}
.tc-chat-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  word-wrap: break-word;
}
.tc-chat-msg.sent {
  align-self: flex-end;
  background: linear-gradient(135deg, #6B4423, #7a5230);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.tc-chat-msg.received {
  align-self: flex-start;
  background: #fff;
  color: #333;
  border: 1px solid #e8e0d6;
  border-bottom-left-radius: 4px;
}
.tc-chat-msg .time {
  font-size: 11px;
  opacity: 0.6;
  margin-top: 4px;
  display: block;
}

/* Welcome message */
.tc-chat-welcome {
  text-align: center;
  color: #8B7355;
  font-size: 13px;
  padding: 12px;
  line-height: 1.5;
  word-break: break-word;
  overflow-wrap: break-word;
}

/* Suggestion Bubbles */
.tc-chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 14px;
  background: #f7f3ef;
  border-top: 1px solid #e8e0d6;
  flex-shrink: 0;
  overflow: hidden;
  max-width: 100%;
  box-sizing: border-box;
}
.tc-chat-suggestion {
  padding: 8px 14px;
  border-radius: 20px;
  border: 1.5px solid #6B4423;
  background: #fff;
  color: #6B4423;
  font-size: 13px;
  font-family: 'Quicksand', sans-serif;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.15s;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tc-chat-suggestion:hover {
  background: linear-gradient(135deg, #6B4423, #8B6914);
  color: #fff;
  transform: scale(1.04);
}

/* Input */
.tc-chat-input-area {
  display: flex;
  padding: 12px;
  gap: 8px;
  background: #fff;
  border-top: 1px solid #e8e0d6;
  flex-shrink: 0;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}
.tc-chat-input {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  border: 1px solid #ddd;
  border-radius: 24px;
  font-size: 14px;
  font-family: 'Quicksand', sans-serif;
  outline: none;
  transition: border-color 0.2s;
  resize: none;
  overflow-y: auto;
  max-height: 100px;
  line-height: 1.4;
  box-sizing: border-box;
}
.tc-chat-input:focus {
  border-color: #6B4423;
}
.tc-chat-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6B4423, #8B6914);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: transform 0.15s;
  flex-shrink: 0;
}
.tc-chat-send:hover {
  transform: scale(1.08);
}
.tc-chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Typing indicator */
.tc-typing-indicator {
  padding: 12px 16px !important;
}
.tc-typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
}
.tc-typing-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #8B7355;
  opacity: 0.4;
  animation: tc-typing-bounce 1.4s infinite;
}
.tc-typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}
.tc-typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}
@keyframes tc-typing-bounce {
  0%, 60%, 100% { opacity: 0.4; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}

/* Connecting indicator */
.tc-chat-connecting {
  text-align: center;
  padding: 8px;
  font-size: 12px;
  color: #8B7355;
  background: #faf6f0;
  flex-shrink: 0;
}

/* Mobile */
@media (max-width: 768px) {
  .tc-chat-overlay {
    padding: 0;
  }
  .tc-chat-panel.open {
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    box-shadow: none;
    overflow: hidden;
  }
  .tc-chat-overlay {
    padding: 0 !important;
  }
  .tc-chat-header {
    padding: 14px 16px;
    padding-top: max(14px, env(safe-area-inset-top));
  }
  .tc-chat-input-area {
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
  .tc-chat-bubble {
    bottom: 16px;
    right: 16px;
    width: 54px;
    height: 54px;
    font-size: 24px;
  }
}
