/* Chat Plugin - Floating chat widget */

.chat-widget {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 320px;
  z-index: 1000;
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

.chat-bubble {
  background: #52a9df;
  color: white;
  padding: 15px 20px;
  border-radius: 25px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 4px 15px rgba(82, 169, 223, 0.4);
  transition: all 0.3s ease;
}

.chat-bubble:hover {
  background: #3a8bc2;
  transform: scale(1.02);
}

.chat-bubble.hidden {
  transform: translateY(100px);
  opacity: 0;
  pointer-events: none;
}

.chat-bubble {
  position: relative;
}

.chat-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: #e74c3c;
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
  animation: badge-pulse 2s infinite;
}

.chat-badge.hidden {
  display: none;
}

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

.chat-bubble-icon {
  font-size: 1.5rem;
}

.chat-bubble-text {
  font-weight: 500;
}

.chat-box {
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  overflow: hidden;
  flex-direction: column;
  height: 450px;
  display: flex;
  transform: translateY(100%);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.4s ease, opacity 0.3s ease;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
}

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

.chat-header {
  background: #52a9df;
  color: white;
  padding: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-header-title {
  font-weight: 700;
  font-size: 1rem;
}

.chat-header-status {
  font-size: 0.75rem;
  opacity: 0.9;
}

.chat-close {
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.chat-close:hover {
  opacity: 0.8;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: linear-gradient(to bottom, #52a9df 0px, #52a9df 5px, #ffffff 100px);
}

.chat-message {
  max-width: 80%;
  padding: 10px 15px;
  border-radius: 18px;
  font-size: 0.9rem;
  line-height: 1.4;
}

.chat-message.received {
  background: #f0f0f0;
  color: #333;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.chat-message.sent {
  background: #52a9df;
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.chat-message .time {
  font-size: 0.7rem;
  opacity: 0.7;
  margin-top: 4px;
  display: block;
}

.chat-input-area {
  padding: 15px;
  border-top: 1px solid #eee;
  display: flex;
  gap: 10px;
}

.chat-input {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 20px;
  padding: 10px 15px;
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.chat-input:focus {
  border-color: #52a9df;
}

.chat-send {
  background: #52a9df;
  color: white;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.chat-send:hover {
  background: #3a8bc2;
}

.chat-send:disabled {
  background: #ccc;
  cursor: not-allowed;
}

/* Name prompt screen */
.chat-name-prompt {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 30px;
  text-align: center;
  background: linear-gradient(to bottom, #52a9df 0px, #52a9df 5px, #ffffff 100px);
}

.chat-name-prompt.hidden {
  display: none;
}

.chat-name-prompt h3 {
  margin: 0 0 8px 0;
  color: #333;
  font-size: 1.1rem;
}

.chat-name-prompt p {
  margin: 0 0 20px 0;
  color: #666;
  font-size: 0.9rem;
}

.chat-name-input {
  width: 100%;
  max-width: 250px;
  border: 2px solid #ddd;
  border-radius: 25px;
  padding: 12px 20px;
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  text-align: center;
  transition: border-color 0.2s;
}

.chat-name-input:focus {
  border-color: #52a9df;
}

.chat-name-submit {
  margin-top: 15px;
  background: #52a9df;
  color: white;
  border: none;
  border-radius: 25px;
  padding: 12px 30px;
  font-size: 1rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s;
}

.chat-name-submit:hover {
  background: #3a8bc2;
}

.chat-name-submit:disabled {
  background: #ccc;
  cursor: not-allowed;
}

/* Hide messages area until name entered */
.chat-messages.hidden,
.chat-input-area.hidden {
  display: none;
}

/* Typing indicator */
.typing-indicator {
  display: none;
  align-self: flex-start;
  padding: 10px 15px;
  background: #f0f0f0;
  border-radius: 18px;
  border-bottom-left-radius: 4px;
}

.typing-indicator.visible {
  display: flex;
  gap: 4px;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: #999;
  border-radius: 50%;
  animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}

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

/* Mobile: bottom sheet style */
@media (max-width: 1200px) {
  .chat-widget {
    bottom: 90px;
    right: 15px;
    width: auto;
  }

  .chat-bubble {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    justify-content: center;
    padding: 0;
  }

  .chat-bubble.hidden {
    transform: scale(0);
  }

  .chat-bubble-text {
    display: none;
  }

  .chat-bubble-icon {
    font-size: 1.8rem;
  }

  .chat-box {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 70vh;
    border-radius: 20px 20px 0 0;
  }
}
