/**
 * Milemarker Documentation Assistant Widget
 * Floating chat widget with search and AI-powered assistance
 */

/* Widget Container */
#docs-assistant-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  font-family: 'Inter', system-ui, sans-serif;
}

/* Floating Action Button */
.docs-fab {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(249, 115, 22, 0.4), 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.docs-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(249, 115, 22, 0.5), 0 4px 12px rgba(0, 0, 0, 0.15);
}

.docs-fab:active {
  transform: scale(0.95);
}

.docs-fab svg {
  width: 24px;
  height: 24px;
  color: white;
  transition: all 0.3s ease;
}

.docs-fab.open svg.icon-chat {
  opacity: 0;
  transform: rotate(90deg) scale(0.5);
}

.docs-fab svg.icon-close {
  position: absolute;
  opacity: 0;
  transform: rotate(-90deg) scale(0.5);
}

.docs-fab.open svg.icon-close {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

/* Badge for keyboard shortcut - hidden on mobile */
.docs-fab-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: #1e293b;
  color: white;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 10px;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Panel */
.docs-panel {
  position: absolute;
  bottom: 72px;
  right: 0;
  width: 380px;
  max-height: calc(100vh - 140px);
  background: white;
  border-radius: 16px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.05);
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px) scale(0.95);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

/* Dark mode support */
.dark .docs-panel,
[data-theme="dark"] .docs-panel {
  background: #1e293b;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.1);
}

/* Panel Header */
.docs-panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid #e2e8f0;
  background: linear-gradient(135deg, #fafafa 0%, #f8fafc 100%);
}

.dark .docs-panel-header,
[data-theme="dark"] .docs-panel-header {
  border-bottom-color: #334155;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}

.docs-panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.docs-panel-title svg {
  width: 20px;
  height: 20px;
  color: #f97316;
}

.docs-panel-title span {
  font-size: 15px;
  font-weight: 600;
  color: #1e293b;
}

.dark .docs-panel-title span,
[data-theme="dark"] .docs-panel-title span {
  color: #f1f5f9;
}

/* Search Input */
.docs-search-wrapper {
  position: relative;
}

.docs-search-input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  font-size: 14px;
  background: white;
  color: #1e293b;
  transition: all 0.2s ease;
}

.docs-search-input:focus {
  outline: none;
  border-color: #f97316;
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.1);
}

.docs-search-input::placeholder {
  color: #94a3b8;
}

.dark .docs-search-input,
[data-theme="dark"] .docs-search-input {
  background: #0f172a;
  border-color: #334155;
  color: #f1f5f9;
}

.dark .docs-search-input:focus,
[data-theme="dark"] .docs-search-input:focus {
  border-color: #f97316;
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.2);
}

.docs-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: #94a3b8;
}

/* Panel Content */
.docs-panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

/* Quick Actions */
.docs-quick-actions {
  margin-bottom: 16px;
}

.docs-section-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #64748b;
  margin-bottom: 10px;
}

.dark .docs-section-label,
[data-theme="dark"] .docs-section-label {
  color: #94a3b8;
}

.docs-action-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.docs-action-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  color: #475569;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.docs-action-btn:hover {
  background: #f1f5f9;
  border-color: #f97316;
  color: #f97316;
}

.dark .docs-action-btn,
[data-theme="dark"] .docs-action-btn {
  background: #0f172a;
  border-color: #334155;
  color: #94a3b8;
}

.dark .docs-action-btn:hover,
[data-theme="dark"] .docs-action-btn:hover {
  background: #1e293b;
  border-color: #f97316;
  color: #f97316;
}

.docs-action-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Search Results */
.docs-search-results {
  display: none;
}

.docs-search-results.active {
  display: block;
}

.docs-result-item {
  display: block;
  padding: 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.docs-result-item:hover {
  background: #f1f5f9;
  border-color: #f97316;
}

.dark .docs-result-item,
[data-theme="dark"] .docs-result-item {
  background: #0f172a;
  border-color: #334155;
}

.dark .docs-result-item:hover,
[data-theme="dark"] .docs-result-item:hover {
  background: #1e293b;
  border-color: #f97316;
}

.docs-result-title {
  font-size: 14px;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 4px;
}

.dark .docs-result-title,
[data-theme="dark"] .docs-result-title {
  color: #f1f5f9;
}

.docs-result-desc {
  font-size: 12px;
  color: #64748b;
  line-height: 1.4;
}

.dark .docs-result-desc,
[data-theme="dark"] .docs-result-desc {
  color: #94a3b8;
}

.docs-result-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  background: #dbeafe;
  color: #1d4ed8;
  margin-top: 6px;
}

.dark .docs-result-tag,
[data-theme="dark"] .docs-result-tag {
  background: #1e3a5f;
  color: #60a5fa;
}

/* Chat Section */
.docs-chat-section {
  border-top: 1px solid #e2e8f0;
  padding-top: 16px;
  margin-top: 8px;
}

.dark .docs-chat-section,
[data-theme="dark"] .docs-chat-section {
  border-top-color: #334155;
}

.docs-chat-messages {
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 12px;
}

.docs-chat-message {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.docs-chat-message.user {
  flex-direction: row-reverse;
}

.docs-chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.docs-chat-message.assistant .docs-chat-avatar {
  background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
}

.docs-chat-message.user .docs-chat-avatar {
  background: #1e293b;
}

.docs-chat-avatar svg {
  width: 14px;
  height: 14px;
  color: white;
}

.docs-chat-bubble {
  max-width: 260px;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
}

.docs-chat-message.assistant .docs-chat-bubble {
  background: #f1f5f9;
  color: #1e293b;
  border-bottom-left-radius: 4px;
}

.docs-chat-message.user .docs-chat-bubble {
  background: #f97316;
  color: white;
  border-bottom-right-radius: 4px;
}

.dark .docs-chat-message.assistant .docs-chat-bubble,
[data-theme="dark"] .docs-chat-message.assistant .docs-chat-bubble {
  background: #0f172a;
  color: #f1f5f9;
}

/* Typing indicator */
.docs-typing-indicator {
  display: flex;
  gap: 4px;
  padding: 12px 14px;
}

.docs-typing-indicator span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #94a3b8;
  animation: typing-bounce 1.4s infinite ease-in-out both;
}

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

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

@keyframes typing-bounce {
  0%, 80%, 100% {
    transform: scale(0.8);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Chat Input */
.docs-chat-input-wrapper {
  display: flex;
  gap: 8px;
}

.docs-chat-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  font-size: 13px;
  background: white;
  color: #1e293b;
  resize: none;
  font-family: inherit;
}

.docs-chat-input:focus {
  outline: none;
  border-color: #f97316;
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.1);
}

.docs-chat-input::placeholder {
  color: #94a3b8;
}

.dark .docs-chat-input,
[data-theme="dark"] .docs-chat-input {
  background: #0f172a;
  border-color: #334155;
  color: #f1f5f9;
}

.docs-chat-send {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 10px;
  background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

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

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

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

/* No results */
.docs-no-results {
  text-align: center;
  padding: 24px;
  color: #64748b;
}

.docs-no-results svg {
  width: 40px;
  height: 40px;
  margin: 0 auto 12px;
  color: #cbd5e1;
}

.dark .docs-no-results svg,
[data-theme="dark"] .docs-no-results svg {
  color: #475569;
}

/* Mobile responsiveness - Multiple breakpoints */

/* Tablet and small desktop */
@media (max-width: 768px) {
  .docs-panel {
    width: 340px;
  }

  .docs-chat-bubble {
    max-width: 240px;
  }
}

/* Large phones and small tablets */
@media (max-width: 480px) {
  #docs-assistant-widget {
    bottom: 16px;
    right: 16px;
  }

  .docs-panel {
    width: calc(100vw - 32px);
    max-width: 360px;
    max-height: calc(100vh - 100px);
    right: 0;
    bottom: 68px;
  }

  .docs-fab {
    width: 52px;
    height: 52px;
  }

  .docs-fab svg {
    width: 22px;
    height: 22px;
  }

  /* Hide keyboard shortcut badge on mobile */
  .docs-fab-badge {
    display: none;
  }

  .docs-panel-header {
    padding: 14px 16px;
  }

  .docs-panel-content {
    padding: 14px 16px;
  }

  .docs-action-grid {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .docs-action-btn {
    padding: 12px 14px;
    font-size: 14px;
  }

  .docs-chat-bubble {
    max-width: calc(100% - 50px);
    font-size: 14px;
  }

  .docs-chat-input {
    font-size: 16px; /* Prevents iOS zoom on focus */
    padding: 12px 14px;
  }

  .docs-search-input {
    font-size: 16px; /* Prevents iOS zoom on focus */
  }
}

/* Small phones */
@media (max-width: 375px) {
  #docs-assistant-widget {
    bottom: 12px;
    right: 12px;
  }

  .docs-panel {
    width: calc(100vw - 24px);
    max-height: calc(100vh - 90px);
    bottom: 64px;
  }

  .docs-fab {
    width: 48px;
    height: 48px;
  }

  .docs-fab svg {
    width: 20px;
    height: 20px;
  }

  .docs-panel-header {
    padding: 12px 14px;
  }

  .docs-panel-content {
    padding: 12px 14px;
  }

  .docs-panel-title span {
    font-size: 14px;
  }

  .docs-chat-messages {
    max-height: 160px;
  }
}

/* Very small phones (iPhone SE, etc) */
@media (max-width: 320px) {
  .docs-panel {
    width: calc(100vw - 16px);
    bottom: 60px;
  }

  .docs-action-btn {
    padding: 10px 12px;
    font-size: 13px;
  }

  .docs-chat-bubble {
    padding: 8px 12px;
  }
}

/* Landscape mode on phones */
@media (max-height: 500px) and (orientation: landscape) {
  .docs-panel {
    max-height: calc(100vh - 80px);
  }

  .docs-chat-messages {
    max-height: 100px;
  }
}

/* High DPI screens - ensure crisp rendering */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .docs-fab {
    -webkit-font-smoothing: antialiased;
  }
}

/* Scrollbar styling */
.docs-panel-content::-webkit-scrollbar,
.docs-chat-messages::-webkit-scrollbar {
  width: 6px;
}

.docs-panel-content::-webkit-scrollbar-track,
.docs-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.docs-panel-content::-webkit-scrollbar-thumb,
.docs-chat-messages::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.dark .docs-panel-content::-webkit-scrollbar-thumb,
.dark .docs-chat-messages::-webkit-scrollbar-thumb,
[data-theme="dark"] .docs-panel-content::-webkit-scrollbar-thumb,
[data-theme="dark"] .docs-chat-messages::-webkit-scrollbar-thumb {
  background: #475569;
}
