/* ============================================
   AI Chat Widget Styles
   ============================================ */

/* Hero Chat Trigger Input */
.hero-chat-trigger {
  margin-top: 10px;
}

.hero-chat-form {
  display: inline-flex;
  align-items: center;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 50px;
  transition: all 0.3s ease;
  min-width: 320px;
  overflow: hidden;
}

.hero-chat-form:hover,
.hero-chat-form:focus-within {
  border-color: var(--color-primary);
  box-shadow: 0 0 20px rgba(74, 222, 128, 0.15);
}

[data-theme="light"] .hero-chat-form:focus-within {
  box-shadow: 0 0 20px rgba(21, 128, 61, 0.15);
}

.hero-chat-input-field {
  flex: 1;
  padding: 16px 20px;
  background: transparent;
  border: none;
  outline: none;
  color: var(--color-text);
  font-size: 15px;
  font-family: inherit;
  min-width: 200px;
}

.hero-chat-input-field::placeholder {
  color: var(--color-text-muted);
}

.hero-chat-send {
  width: 48px;
  height: 48px;
  margin: 4px;
  border-radius: 50%;
  background: #333;
  border: none;
  cursor: not-allowed;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  flex-shrink: 0;
  opacity: 0.5;
}

.hero-chat-send.active {
  background: var(--color-primary);
  cursor: pointer;
  opacity: 1;
}

.hero-chat-send.active:hover {
  transform: scale(1.05);
}

.hero-chat-send.active:active {
  transform: scale(0.95);
}

.hero-chat-send svg {
  width: 22px;
  height: 22px;
  margin: 0 !important;
  display: block;
  transition: fill 0.3s ease;
}

.hero-chat-send svg,
.hero-chat-send svg path {
  fill: #666 !important;
}

.hero-chat-send.active svg,
.hero-chat-send.active svg path {
  fill: #fff !important;
}

@media (max-width: 767px) {
  .hero-chat-form {
    min-width: 280px;
  }
  
  .hero-chat-input-field {
    padding: 14px 16px;
    font-size: 14px;
    min-width: 160px;
  }
  
  .hero-chat-send {
    width: 42px;
    height: 42px;
  }
}

/* Chat Toggle Button */
.chat-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--color-primary);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(74, 222, 128, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  z-index: 9998;
}

.chat-toggle:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 25px rgba(74, 222, 128, 0.4);
}

.chat-toggle:active {
  transform: scale(0.95);
}

.chat-toggle svg {
  width: 28px;
  height: 28px;
  margin: 0 !important;
  display: block;
}

.chat-toggle svg,
.chat-toggle svg path {
  fill: #000 !important;
}

.chat-toggle.active svg {
  transform: none;
}

/* Chat Container */
.chat-container {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 400px;
  max-width: calc(100vw - 48px);
  height: 620px;
  max-height: calc(100vh - 140px);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  box-shadow: 0 10px 50px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  z-index: 9999;
  overflow: hidden;
}

.chat-container.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Chat Header */
.chat-header {
  padding: 16px 20px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  box-sizing: border-box;
  flex-shrink: 0;
}

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

.chat-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--color-primary);
  flex-shrink: 0;
}

.chat-header-info {
  flex: 1;
  min-width: 0;
}

.chat-header-info h4 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text);
}

.chat-header-info span {
  font-size: 13px;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-header-info .status-dot {
  width: 8px;
  height: 8px;
  background: var(--color-primary);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

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

.chat-close {
  background: transparent;
  border: none;
  cursor: pointer;
  width: 36px;
  height: 36px;
  color: var(--color-text-muted);
  transition: color 0.2s ease, background 0.2s ease;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  padding: 0;
}

.chat-close:hover {
  color: var(--color-text);
  background: rgba(255, 255, 255, 0.1);
}

.chat-close .close-icon {
  font-size: 18px;
  font-weight: 300;
  line-height: 1;
  color: #888;
  transition: color 0.2s ease;
}

.chat-close:hover .close-icon {
  color: #fff;
}

/* Chat Messages Area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

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

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

/* Message Bubbles */
.chat-message {
  max-width: 85%;
  animation: messageIn 0.3s ease;
}

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

.chat-message.user {
  align-self: flex-end;
}

.chat-message.assistant {
  align-self: flex-start;
}

.chat-message .bubble {
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.5;
}

.chat-message.user .bubble {
  background: var(--color-primary);
  color: var(--color-primary-text);
  border-bottom-right-radius: 6px;
}

.chat-message.assistant .bubble {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-bottom-left-radius: 6px;
}

/* Markdown styling in chat */
.chat-message .bubble strong {
  font-weight: 600;
  color: inherit;
}

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

.chat-message .bubble code {
  background: rgba(74, 222, 128, 0.15);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
}

.chat-message.user .bubble code {
  background: rgba(0, 0, 0, 0.15);
}

/* Links in chat messages */
.chat-message .bubble a {
  color: var(--color-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: opacity 0.2s ease;
}

.chat-message .bubble a:hover {
  opacity: 0.8;
}

.chat-message.user .bubble a {
  color: var(--color-primary-text);
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 18px;
  border-bottom-left-radius: 6px;
  width: fit-content;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--color-text-muted);
  border-radius: 50%;
  animation: typing 1.4s infinite ease-in-out;
}

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

.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);
    opacity: 0.5;
  }
  30% {
    transform: translateY(-6px);
    opacity: 1;
  }
}

/* Chat Input Area */
.chat-input-container {
  padding: 16px;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
}

.chat-input-wrapper {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.chat-input {
  flex: 1;
  padding: 12px 16px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 24px;
  color: var(--color-text);
  font-size: 14px;
  font-family: inherit;
  resize: none;
  max-height: 100px;
  transition: border-color 0.2s ease;
}

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

.chat-input::placeholder {
  color: var(--color-text-muted);
}

.chat-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--color-primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, opacity 0.2s ease;
  flex-shrink: 0;
}

.chat-send:hover {
  transform: scale(1.05);
}

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

.chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.chat-send svg {
  width: 22px;
  height: 22px;
  margin: 0 !important;
  display: block;
}

.chat-send svg,
.chat-send svg path {
  fill: #fff !important;
}

/* Welcome Message */
.chat-welcome {
  text-align: center;
  padding: 20px;
  color: var(--color-text-muted);
  font-size: 13px;
}

.chat-welcome h5 {
  color: var(--color-text);
  font-size: 16px;
  margin: 0 0 8px 0;
}

/* Quick Actions */
.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  justify-content: center;
}

.quick-action {
  padding: 8px 14px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  font-size: 12px;
  color: var(--color-text);
  cursor: pointer;
  transition: all 0.2s ease;
}

.quick-action:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* Mobile Responsive */
@media (max-width: 480px) {
  .chat-toggle {
    bottom: 16px;
    right: 16px;
    width: 56px;
    height: 56px;
  }
  
  .chat-container {
    bottom: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    border: none;
  }
  
  .chat-container.open {
    transform: translateY(0);
  }
}

/* Light Theme Adjustments */
[data-theme="light"] .chat-toggle {
  box-shadow: 0 4px 20px rgba(21, 128, 61, 0.25);
}

[data-theme="light"] .chat-toggle:hover {
  box-shadow: 0 6px 25px rgba(21, 128, 61, 0.35);
}

[data-theme="light"] .chat-container {
  box-shadow: 0 10px 50px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .chat-message .bubble code {
  background: rgba(21, 128, 61, 0.1);
}

/* ============================================
   Contact Form in Chat
   ============================================ */

.chat-contact-form {
  padding: 16px;
  margin: 8px 16px 16px;
  background: var(--color-bg-elevated);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
}

.chat-contact-form form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-contact-form .form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-contact-form label {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.chat-contact-form input,
.chat-contact-form textarea {
  padding: 12px 14px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-family: inherit;
  font-size: 14px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  width: 100%;
  box-sizing: border-box;
}

.chat-contact-form input:focus,
.chat-contact-form textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.15);
}

.chat-contact-form input::placeholder,
.chat-contact-form textarea::placeholder {
  color: var(--color-text-muted);
}

.chat-contact-form textarea {
  resize: vertical;
  min-height: 80px;
}

.contact-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  background: var(--color-primary);
  color: #000;
  border: none;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.contact-submit:hover:not(:disabled) {
  background: var(--color-primary);
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.contact-submit:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.contact-submit svg {
  width: 16px !important;
  height: 16px !important;
  margin: 0 !important;
}

/* Sending spinner */
.sending-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(0, 0, 0, 0.2);
  border-top-color: #000;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Light theme adjustments for contact form */
[data-theme="light"] .chat-contact-form {
  background: #f8f9fa;
  border-color: #e0e0e0;
}

[data-theme="light"] .chat-contact-form input,
[data-theme="light"] .chat-contact-form textarea {
  background: #fff;
  border-color: #ddd;
}

[data-theme="light"] .contact-submit {
  color: #000;
}

