/* MDS Native Chat Widget Styles */

#mds-chat-widget {
  --mds-primary: #2563eb;
  --mds-primary-dark: #1d4ed8;
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.mds-chat-fab {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--mds-primary) 0%, #3b82f6 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(37, 99, 235, 0.4);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s;
  animation: mds-fab-entrance 0.6s cubic-bezier(0.34, 1.56, 0.64, 1), mds-fab-pulse 3s ease-in-out 2s infinite;
  position: relative;
}

.mds-chat-fab::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--mds-primary), #60a5fa);
  opacity: 0;
  z-index: -1;
  animation: mds-fab-glow 3s ease-in-out 2s infinite;
}

.mds-chat-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 8px 25px rgba(37, 99, 235, 0.5);
}

.mds-chat-fab:hover::before {
  animation: none;
  opacity: 0;
}

.mds-chat-fab svg {
  width: 26px;
  height: 26px;
  color: white;
  transition: transform 0.3s;
}

.mds-chat-fab:hover .mds-chat-icon-open {
  animation: mds-icon-wave 0.5s ease-in-out;
}

.mds-chat-icon-close {
  display: none;
}

#mds-chat-widget.open .mds-chat-fab {
  animation: none;
  background: #64748b;
}

#mds-chat-widget.open .mds-chat-fab::before {
  animation: none;
  opacity: 0;
}

#mds-chat-widget.open .mds-chat-icon-open {
  display: none;
}

#mds-chat-widget.open .mds-chat-icon-close {
  display: block;
}

/* Chat tooltip */
.mds-chat-tooltip {
  position: absolute;
  right: 70px;
  top: 50%;
  transform: translateY(-50%) translateX(10px);
  background: white;
  color: #1e293b;
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
}

.mds-chat-tooltip::after {
  content: '';
  position: absolute;
  right: -6px;
  top: 50%;
  transform: translateY(-50%);
  border: 6px solid transparent;
  border-left-color: white;
}

.mds-chat-tooltip.show {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

#mds-chat-widget.open .mds-chat-tooltip {
  display: none;
}

/* Animations */
@keyframes mds-fab-entrance {
  0% {
    opacity: 0;
    transform: scale(0) rotate(-180deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0);
  }
}

@keyframes mds-fab-pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.08);
  }
}

@keyframes mds-fab-glow {
  0%, 100% {
    opacity: 0;
    transform: scale(1);
  }
  50% {
    opacity: 0.6;
    transform: scale(1.15);
  }
}

@keyframes mds-icon-wave {
  0%, 100% {
    transform: rotate(0deg);
  }
  25% {
    transform: rotate(-10deg);
  }
  75% {
    transform: rotate(10deg);
  }
}

.mds-chat-window {
  position: absolute;
  bottom: 70px;
  right: 0;
  width: 380px;
  max-width: calc(100vw - 40px);
  height: 520px;
  max-height: calc(100vh - 100px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  display: none;
  flex-direction: column;
  overflow: hidden;
}

#mds-chat-widget.open .mds-chat-window {
  display: flex;
  animation: mds-chat-slide-up 0.3s ease;
}

@keyframes mds-chat-slide-up {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.mds-chat-header {
  background: var(--mds-primary);
  color: white;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mds-chat-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mds-chat-avatar {
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mds-chat-avatar svg {
  width: 22px;
  height: 22px;
  color: white;
}

.mds-chat-header-text {
  display: flex;
  flex-direction: column;
}

.mds-chat-title {
  font-weight: 600;
  font-size: 15px;
}

.mds-chat-status {
  font-size: 12px;
  opacity: 0.9;
}

.mds-chat-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mds-chat-close svg {
  width: 20px;
  height: 20px;
  color: white;
}

.mds-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f9fafb;
}

.mds-chat-welcome {
  background: white;
  padding: 12px 16px;
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  font-size: 14px;
  color: #374151;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.mds-chat-welcome p {
  margin: 0;
}

.mds-chat-message {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}

.mds-chat-message.inbound {
  align-self: flex-end;
  background: var(--mds-primary);
  color: white;
  border-bottom-right-radius: 4px;
  white-space: pre-wrap;
}

.mds-chat-message.outbound {
  align-self: flex-start;
  background: white;
  color: #374151;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.mds-chat-message.outbound a {
  color: var(--mds-primary);
  text-decoration: underline;
  word-break: break-all;
}

.mds-chat-message.outbound a:hover {
  color: var(--mds-primary-dark);
}

.mds-chat-message.outbound strong {
  font-weight: 600;
}

.mds-chat-message.outbound em {
  font-style: italic;
}

.mds-chat-typing {
  align-self: flex-start;
  background: white;
  padding: 12px 16px;
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  display: flex;
  gap: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.mds-chat-typing span {
  width: 8px;
  height: 8px;
  background: #9ca3af;
  border-radius: 50%;
  animation: mds-typing 1.4s infinite;
}

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

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

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

.mds-chat-input-container {
  padding: 12px;
  background: white;
  border-top: 1px solid #e5e7eb;
}

.mds-chat-form {
  display: flex;
  gap: 8px;
}

.mds-chat-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 24px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

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

.mds-chat-send {
  width: 40px;
  height: 40px;
  background: var(--mds-primary);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.mds-chat-send:hover {
  background: var(--mds-primary-dark);
}

.mds-chat-send:disabled {
  background: #9ca3af;
  cursor: not-allowed;
}

.mds-chat-send svg {
  width: 18px;
  height: 18px;
  color: white;
}

@media (max-width: 480px) {
  #mds-chat-widget {
    bottom: 10px;
    right: 10px;
  }

  .mds-chat-window {
    bottom: 66px;
    width: calc(100vw - 20px);
    height: calc(100vh - 80px);
    max-height: none;
    border-radius: 12px;
  }
}
