/**
 * Premium AI Chatbot Styling for Krav Maga Colchester
 * Modern, responsive design with brand consistency
 */

/* Chatbot Container */
.kmc-chatbot {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 10000;
  font-family: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, sans-serif;
}

/* Floating Toggle Button */
.kmc-chatbot-toggle {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #d1272a 0%, #b91e1e 100%);
  color: white;
  cursor: pointer;
  box-shadow: 0 8px 32px rgba(209, 39, 42, 0.3);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.kmc-chatbot-toggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 40px rgba(209, 39, 42, 0.4);
  background: linear-gradient(135deg, #e63946 0%, #d1272a 100%);
}

.kmc-chatbot-toggle:active {
  transform: translateY(0);
}

/* Chatbot Icons */
.kmc-chatbot-icon {
  position: relative;
  width: 28px;
  height: 28px;
}

.kmc-chatbot-icon svg,
.kmc-chatbot-icon img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transition: all 0.3s ease;
}

.kmc-chatbot-icon-close {
  opacity: 0;
  transform: rotate(180deg) scale(0.8);
}

.kmc-chatbot-open .kmc-chatbot-icon-chat {
  opacity: 0;
  transform: rotate(-180deg) scale(0.8);
}

.kmc-chatbot-open .kmc-chatbot-icon-close {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

/* AI Badge */
.kmc-chatbot-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: #2d3748;
  color: white;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 10px;
  border: 2px solid white;
  letter-spacing: 0.5px;
  z-index: 10001;
}

/* Chat Window */
.kmc-chatbot-window {
  position: absolute;
  bottom: 80px;
  right: 0;
  width: 380px;
  max-width: calc(100vw - 40px);
  height: 600px;
  max-height: calc(100vh - 140px);
  background: white;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.kmc-window-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* Chat Header */
.kmc-chatbot-header {
  background: linear-gradient(135deg, #d1272a 0%, #b91e1e 100%);
  color: white;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: 16px 16px 0 0;
  position: relative;
}

.kmc-chatbot-avatar {
  position: relative;
}

.kmc-avatar-img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 1px;
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.kmc-status-indicator {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  background: #10b981;
  border-radius: 50%;
  border: 2px solid white;
  animation: pulse 2s infinite;
}

.kmc-chatbot-info h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
}

.kmc-chatbot-info p {
  margin: 4px 0 0;
  font-size: 13px;
  opacity: 0.9;
  line-height: 1.2;
}

.kmc-ai-badge {
  background: rgba(255, 255, 255, 0.2);
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.kmc-chatbot-minimize {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: background-color 0.2s ease;
  margin-left: auto;
}

.kmc-chatbot-minimize:hover {
  background: rgba(255, 255, 255, 0.1);
}

.kmc-chatbot-minimize svg {
  width: 20px;
  height: 20px;
}

/* Chat Messages */
.kmc-chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: #f8f9fa;
}

.kmc-chatbot-messages::-webkit-scrollbar {
  width: 6px;
}

.kmc-chatbot-messages::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.kmc-chatbot-messages::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 3px;
}

.kmc-chatbot-messages::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* Message Styling */
.kmc-message {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  max-width: 85%;
  animation: fadeInUp 0.3s ease;
}

.kmc-message-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.kmc-message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #d1272a 0%, #b91e1e 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.kmc-message-user .kmc-message-avatar {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
}

.kmc-message-content {
  flex: 1;
}

.kmc-message-text {
  background: white;
  padding: 12px 16px;
  border-radius: 18px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  font-size: 14px;
  line-height: 1.5;
  color: #374151;
  position: relative;
}

.kmc-message-user .kmc-message-text {
  background: linear-gradient(135deg, #d1272a 0%, #b91e1e 100%);
  color: white;
  border-bottom-right-radius: 6px;
}

.kmc-message-error .kmc-message-text {
  background: #fef2f2;
  color: #dc2626;
  border-left: 3px solid #dc2626;
}

.kmc-message-disclaimer {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 4px;
  font-style: italic;
}

/* Typing Indicator */
.kmc-typing-indicator .kmc-message-text {
  background: white;
  padding: 12px 16px;
  display: flex;
  align-items: center;
}

.kmc-typing-dots {
  display: flex;
  gap: 4px;
}

.kmc-typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #9ca3af;
  animation: typing-bounce 1.4s infinite ease-in-out;
}

.kmc-typing-dots span:nth-child(1) {
  animation-delay: -0.32s;
}

.kmc-typing-dots span:nth-child(2) {
  animation-delay: -0.16s;
}

/* Input Area */
.kmc-chatbot-input-area {
  padding: 20px;
  background: white;
  border-top: 1px solid #e5e7eb;
}

.kmc-chatbot-form {
  margin-bottom: 0;
}

.kmc-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  background: #f9fafb;
  border: 2px solid #e5e7eb;
  border-radius: 24px;
  padding: 4px 4px 4px 16px;
  transition: all 0.2s ease;
}

.kmc-input-wrapper:focus-within {
  border-color: #d1272a;
}

.kmc-chatbot-input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 12px 12px 12px 0;
  font-size: 14px;
  line-height: 1.4;
  color: #374151;
  resize: none;
  outline: none;
  font-family: inherit;
  min-height: 20px;
  max-height: 80px;
}

.kmc-chatbot-input::placeholder {
  color: #9ca3af;
}

.kmc-chatbot-send {
  width: 40px;
  height: 40px;
  border: none;
  background: linear-gradient(135deg, #d1272a 0%, #b91e1e 100%);
  color: white;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.kmc-chatbot-send:hover {
  background: linear-gradient(135deg, #b91e1e 0%, #a01719 100%);
  transform: scale(1.05);
}

.kmc-chatbot-send:active {
  transform: scale(0.95);
}

.kmc-chatbot-send svg {
  width: 18px;
  height: 18px;
}

.kmc-chatbot-disclaimer {
  text-align: center;
  margin-top: 12px;
  color: #9ca3af;
  font-size: 11px;
}

/* Animations */
@keyframes pulse {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.7;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

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

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .kmc-chatbot {
    bottom: 16px;
    right: 16px;
    left: 16px;
  }

  .kmc-chatbot-window {
    width: 100%;
    height: 500px;
    max-height: calc(100vh - 100px);
    right: 0;
    left: 0;
  }

  .kmc-chatbot-toggle {
    width: 56px;
    height: 56px;
    position: fixed;
    bottom: 20px;
    right: 20px;
  }

  .kmc-chatbot-header {
    padding: 16px;
  }

  .kmc-chatbot-messages {
    padding: 16px;
  }

  .kmc-message-content {
    max-width: 100%;
  }

  .kmc-chatbot-input-area {
    padding: 16px;
  }
}

@media (max-width: 480px) {
  .kmc-chatbot-window {
    height: 450px;
    max-height: calc(100vh - 80px);
  }

  .kmc-message-content {
    font-size: 13px;
  }

  .kmc-chatbot-header {
    padding: 12px;
  }

  .kmc-avatar-img {
    width: 40px;
    height: 40px;
    font-size: 14px;
  }

  .kmc-chatbot-info h3 {
    font-size: 14px;
  }

  .kmc-chatbot-info p {
    font-size: 11px;
  }
}

/* Dark Mode */
@media (prefers-color-scheme: dark) {
  .kmc-chatbot-window {
    background: #1f2937;
    color: #f9fafb;
  }

  .kmc-chatbot-messages {
    background: #111827;
  }

  .kmc-message-text {
    background: #374151;
    color: #f9fafb;
  }

  .kmc-chatbot-input-area {
    background: #1f2937;
    border-color: #374151;
  }

  .kmc-input-wrapper {
    background: #374151;
    border-color: #4b5563;
  }

  .kmc-chatbot-input {
    color: #f9fafb;
  }

  .kmc-chatbot-input::placeholder {
    color: #9ca3af;
  }
}

/* Focus and Accessibility */
.kmc-chatbot-toggle:focus,
.kmc-chatbot-send:focus,
.kmc-chatbot-minimize:focus {
  outline: 2px solid #d1272a;
  outline-offset: 2px;
}

.kmc-chatbot-input:focus {
  outline: none;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
  .kmc-chatbot-toggle,
  .kmc-chatbot-send {
    border: 2px solid #000;
  }

  .kmc-message-text {
    border: 1px solid #000;
  }
}
