/**
 * Procon Business Consultants - Chatbot Widget Styles
 *
 * Design System:
 * - Primary: #2d6a4f (forest green)
 * - Text: #333333
 * - Background: #ffffff
 * - Border radius: 12px
 * - Shadow: soft, modern
 */

/* ===========================================================================
   CSS VARIABLES
   =========================================================================== */

.chatbot-widget {
  --chatbot-primary: #2d6a4f;
  --chatbot-primary-dark: #1e4d38;
  --chatbot-primary-light: #3d8b68;
  --chatbot-text: #333333;
  --chatbot-text-light: #666666;
  --chatbot-bg: #ffffff;
  --chatbot-bg-light: #f8f9fa;
  --chatbot-border: #e5e5e5;
  --chatbot-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
  --chatbot-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
  --chatbot-radius: 12px;
  --chatbot-radius-sm: 8px;
  --chatbot-transition: 0.2s ease;
  --chatbot-z-index: 9999;
}

/* ===========================================================================
   WIDGET CONTAINER
   =========================================================================== */

.chatbot-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--chatbot-z-index);
  font-family: 'Poppins', 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--chatbot-text);
}

/* ===========================================================================
   TOGGLE BUTTON
   =========================================================================== */

.chatbot-toggle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--chatbot-primary);
  border: none;
  cursor: pointer;
  box-shadow: var(--chatbot-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--chatbot-transition);
  position: relative;
  color: white;
}

.chatbot-toggle:hover {
  background: var(--chatbot-primary-dark);
  transform: scale(1.05);
}

.chatbot-toggle:focus {
  outline: 2px solid var(--chatbot-primary-light);
  outline-offset: 2px;
}

.chatbot-toggle-icon,
.chatbot-toggle-close {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity var(--chatbot-transition), transform var(--chatbot-transition);
}

.chatbot-toggle-close {
  position: absolute;
  opacity: 0;
  transform: rotate(-90deg);
}

/* Open state */
.chatbot-widget.chatbot-open .chatbot-toggle-icon {
  opacity: 0;
  transform: rotate(90deg);
}

.chatbot-widget.chatbot-open .chatbot-toggle-close {
  opacity: 1;
  transform: rotate(0);
}

/* ===========================================================================
   CHAT WINDOW
   =========================================================================== */

.chatbot-window {
  position: absolute;
  bottom: 76px;
  right: 0;
  width: 380px;
  max-width: calc(100vw - 48px);
  height: 520px;
  max-height: calc(100vh - 140px);
  background: var(--chatbot-bg);
  border-radius: var(--chatbot-radius);
  box-shadow: var(--chatbot-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: chatbot-slide-up 0.3s ease;
}

@keyframes chatbot-slide-up {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===========================================================================
   HEADER
   =========================================================================== */

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

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

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

.chatbot-header-text h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.chatbot-status {
  font-size: 12px;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chatbot-status::before {
  content: '';
  width: 8px;
  height: 8px;
  background: #4ade80;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.chatbot-close {
  background: transparent;
  border: none;
  color: white;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--chatbot-transition);
}

.chatbot-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ===========================================================================
   MESSAGES CONTAINER
   =========================================================================== */

.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--chatbot-bg-light);
}

/* Scrollbar styling */
.chatbot-messages::-webkit-scrollbar {
  width: 6px;
}

.chatbot-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chatbot-messages::-webkit-scrollbar-thumb {
  background: var(--chatbot-border);
  border-radius: 3px;
}

/* ===========================================================================
   MESSAGES
   =========================================================================== */

.chatbot-message {
  display: flex;
  max-width: 85%;
  animation: chatbot-message-in 0.2s ease;
}

@keyframes chatbot-message-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chatbot-message-content {
  padding: 12px 16px;
  border-radius: var(--chatbot-radius);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* User messages */
.chatbot-message-user {
  align-self: flex-end;
  justify-content: flex-end;
}

.chatbot-message-user .chatbot-message-content {
  background: var(--chatbot-primary);
  color: white;
  border-bottom-right-radius: 4px;
}

/* Assistant messages */
.chatbot-message-assistant {
  align-self: flex-start;
}

.chatbot-message-assistant .chatbot-message-content {
  background: var(--chatbot-bg);
  color: var(--chatbot-text);
  border: 1px solid var(--chatbot-border);
  border-bottom-left-radius: 4px;
}

/* Links in messages */
.chatbot-message-content a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.chatbot-message-user .chatbot-message-content a {
  color: white;
}

.chatbot-message-assistant .chatbot-message-content a {
  color: var(--chatbot-primary);
}

/* ===========================================================================
   TYPING INDICATOR
   =========================================================================== */

.chatbot-typing .chatbot-message-content {
  padding: 16px 20px;
}

.chatbot-typing-dots {
  display: flex;
  gap: 4px;
  align-items: center;
}

.chatbot-typing-dots span {
  width: 8px;
  height: 8px;
  background: var(--chatbot-text-light);
  border-radius: 50%;
  animation: chatbot-typing 1.4s infinite;
}

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

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

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

/* ===========================================================================
   SUGGESTIONS
   =========================================================================== */

.chatbot-suggestions {
  padding: 12px 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  background: var(--chatbot-bg);
  border-top: 1px solid var(--chatbot-border);
}

.chatbot-suggestions[hidden] {
  display: none;
}

.chatbot-suggestion {
  padding: 8px 14px;
  background: var(--chatbot-bg-light);
  border: 1px solid var(--chatbot-border);
  border-radius: 20px;
  font-size: 13px;
  color: var(--chatbot-text);
  cursor: pointer;
  transition: all var(--chatbot-transition);
  white-space: nowrap;
}

.chatbot-suggestion:hover {
  background: var(--chatbot-primary);
  color: white;
  border-color: var(--chatbot-primary);
}

.chatbot-suggestion:focus {
  outline: 2px solid var(--chatbot-primary-light);
  outline-offset: 2px;
}

/* ===========================================================================
   INPUT AREA
   =========================================================================== */

.chatbot-input-area {
  padding: 16px 20px;
  background: var(--chatbot-bg);
  border-top: 1px solid var(--chatbot-border);
  flex-shrink: 0;
}

.chatbot-form {
  display: flex;
  gap: 12px;
  align-items: center;
}

.chatbot-input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--chatbot-border);
  border-radius: var(--chatbot-radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--chatbot-text);
  background: var(--chatbot-bg);
  transition: border-color var(--chatbot-transition), box-shadow var(--chatbot-transition);
}

.chatbot-input::placeholder {
  color: var(--chatbot-text-light);
}

.chatbot-input:focus {
  outline: none;
  border-color: var(--chatbot-primary);
  box-shadow: 0 0 0 3px rgba(45, 106, 79, 0.1);
}

.chatbot-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--chatbot-primary);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--chatbot-transition);
  flex-shrink: 0;
}

.chatbot-send:hover {
  background: var(--chatbot-primary-dark);
  transform: scale(1.05);
}

.chatbot-send:focus {
  outline: 2px solid var(--chatbot-primary-light);
  outline-offset: 2px;
}

.chatbot-send:disabled {
  background: var(--chatbot-border);
  cursor: not-allowed;
  transform: none;
}

/* ===========================================================================
   RESPONSIVE - MOBILE
   =========================================================================== */

@media (max-width: 480px) {
  .chatbot-widget {
    bottom: 16px;
    right: 16px;
  }

  .chatbot-toggle {
    width: 56px;
    height: 56px;
  }

  .chatbot-window {
    width: calc(100vw - 32px);
    height: calc(100vh - 120px);
    bottom: 72px;
    right: -8px;
    border-radius: var(--chatbot-radius-sm);
  }

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

  .chatbot-messages {
    padding: 16px;
  }

  .chatbot-suggestions {
    padding: 10px 16px;
  }

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

  .chatbot-message {
    max-width: 90%;
  }
}

/* ===========================================================================
   ACCESSIBILITY - REDUCED MOTION
   =========================================================================== */

@media (prefers-reduced-motion: reduce) {
  .chatbot-widget * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===========================================================================
   PRINT - HIDE CHATBOT
   =========================================================================== */

@media print {
  .chatbot-widget {
    display: none !important;
  }
}
