/**
 * FlowRunner™ Documentation Chat Widget Styles
 */

/* Chat Widget Button (Bottom Right Corner) */
.chat-widget-button {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4F46E5 0%, #6366F1 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 9998;
  border: none;
  outline: none;
}

.chat-widget-button:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(79, 70, 229, 0.5);
}

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

.chat-widget-button svg {
  width: 28px;
  height: 28px;
}

/* Chat Widget Container */
.chat-widget-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 400px;
  max-width: calc(100vw - 48px);
  height: 600px;
  max-height: calc(100vh - 100px);
  background: #1e1e1e;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  z-index: 9999;
  animation: chatSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

[data-md-color-scheme="default"] .chat-widget-container {
  background: #ffffff;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

@keyframes chatSlideIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Mobile Responsive */
@media (max-width: 640px) {
  .chat-widget-container {
    width: calc(100vw - 32px);
    height: calc(100vh - 80px);
    bottom: 16px;
    right: 16px;
  }

  .chat-widget-button {
    bottom: 16px;
    right: 16px;
  }
}

/* Header */
.chat-widget-header {
  background: linear-gradient(135deg, #4F46E5 0%, #6366F1 100%);
  color: white;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.chat-widget-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 16px;
}

.chat-widget-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.chat-widget-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Toolbar */
.chat-widget-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

[data-md-color-scheme="default"] .chat-widget-toolbar {
  background: rgba(0, 0, 0, 0.03);
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.chat-toolbar-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: rgba(255, 255, 255, 0.8);
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  padding: 0;
}

[data-md-color-scheme="default"] .chat-toolbar-btn {
  background: rgba(0, 0, 0, 0.05);
  color: rgba(0, 0, 0, 0.7);
}

.chat-toolbar-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

[data-md-color-scheme="default"] .chat-toolbar-btn:hover {
  background: rgba(0, 0, 0, 0.1);
  color: rgba(0, 0, 0, 0.9);
}

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

.chat-toolbar-btn svg {
  pointer-events: none;
}

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

[data-md-color-scheme="default"] .chat-widget-messages {
  background: #f9fafb;
}

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

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

.chat-widget-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

[data-md-color-scheme="default"] .chat-widget-messages::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
}

/* Welcome Message */
.chat-welcome-message {
  background: rgba(79, 70, 229, 0.1);
  border: 1px solid rgba(79, 70, 229, 0.2);
  border-radius: 12px;
  padding: 16px;
  color: #e5e7eb;
}

[data-md-color-scheme="default"] .chat-welcome-message {
  color: #374151;
}

.chat-welcome-message p {
  margin: 0 0 8px 0;
}

.chat-welcome-message p:last-child {
  margin-bottom: 0;
}

/* Chat Messages */
.chat-message {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  animation: messageSlideIn 0.3s ease-out;
}

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

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

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

.chat-message-content {
  padding: 12px 16px;
  border-radius: 12px;
  word-wrap: break-word;
  line-height: 1.5;
}

.chat-message-user .chat-message-content {
  background: linear-gradient(135deg, #4F46E5 0%, #6366F1 100%);
  color: white;
  border-bottom-right-radius: 4px;
}

.chat-message-bot .chat-message-content {
  background: #2a2a2a;
  color: #e5e7eb;
  border-bottom-left-radius: 4px;
}

[data-md-color-scheme="default"] .chat-message-bot .chat-message-content {
  background: #ffffff;
  color: #374151;
  border: 1px solid #e5e7eb;
}

.chat-message-error .chat-message-content {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

[data-md-color-scheme="default"] .chat-message-error .chat-message-content {
  color: #dc2626;
}

.chat-message-time {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.4);
  margin-top: 4px;
  padding: 0 4px;
}

[data-md-color-scheme="default"] .chat-message-time {
  color: rgba(0, 0, 0, 0.4);
}

.chat-message-user .chat-message-time {
  text-align: right;
}

/* Code formatting in messages */
.chat-message-content code {
  background: rgba(0, 0, 0, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
  font-family: 'JetBrains Mono', monospace;
}

[data-md-color-scheme="default"] .chat-message-content code {
  background: rgba(0, 0, 0, 0.05);
}

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

/* Markdown elements in messages */
.chat-message-content h1,
.chat-message-content h2,
.chat-message-content h3,
.chat-message-content h4,
.chat-message-content h5,
.chat-message-content h6 {
  margin: 16px 0 8px 0;
  font-weight: 600;
  line-height: 1.3;
  color: inherit;
}

.chat-message-content h1:first-child,
.chat-message-content h2:first-child,
.chat-message-content h3:first-child,
.chat-message-content h4:first-child,
.chat-message-content h5:first-child,
.chat-message-content h6:first-child {
  margin-top: 0;
}

.chat-message-content h1 {
  font-size: 1.5em;
  border-bottom: 2px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 8px;
}

[data-md-color-scheme="default"] .chat-message-content h1 {
  border-bottom-color: rgba(0, 0, 0, 0.1);
}

.chat-message-content h2 {
  font-size: 1.3em;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 6px;
}

[data-md-color-scheme="default"] .chat-message-content h2 {
  border-bottom-color: rgba(0, 0, 0, 0.1);
}

.chat-message-content h3 {
  font-size: 1.15em;
}

.chat-message-content h4 {
  font-size: 1.05em;
}

.chat-message-content h5,
.chat-message-content h6 {
  font-size: 1em;
}

.chat-message-content p {
  margin: 8px 0;
  line-height: 1.6;
}

.chat-message-content p:first-child {
  margin-top: 0;
}

.chat-message-content p:last-child {
  margin-bottom: 0;
}

.chat-message-content ul,
.chat-message-content ol {
  margin: 8px 0;
  padding-left: 24px;
}

.chat-message-content ul {
  list-style-type: disc;
}

.chat-message-content ol {
  list-style-type: decimal;
}

.chat-message-content li {
  margin: 4px 0;
  line-height: 1.6;
}

.chat-message-content li > ul,
.chat-message-content li > ol {
  margin: 4px 0;
}

.chat-message-content pre {
  background: rgba(0, 0, 0, 0.4);
  border-radius: 6px;
  padding: 12px;
  margin: 12px 0;
  overflow-x: auto;
}

[data-md-color-scheme="default"] .chat-message-content pre {
  background: rgba(0, 0, 0, 0.05);
}

.chat-message-content pre code {
  background: transparent;
  padding: 0;
  font-size: 0.85em;
  line-height: 1.5;
  display: block;
}

.chat-message-content a {
  color: #60A5FA;
  text-decoration: underline;
  transition: color 0.2s;
}

.chat-message-content a:hover {
  color: #93C5FD;
}

[data-md-color-scheme="default"] .chat-message-content a {
  color: #2563EB;
}

[data-md-color-scheme="default"] .chat-message-content a:hover {
  color: #1D4ED8;
}

.chat-message-content blockquote {
  border-left: 3px solid rgba(79, 70, 229, 0.5);
  padding-left: 12px;
  margin: 12px 0;
  color: rgba(255, 255, 255, 0.8);
  font-style: italic;
}

[data-md-color-scheme="default"] .chat-message-content blockquote {
  color: rgba(0, 0, 0, 0.7);
}

.chat-message-content hr {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  margin: 16px 0;
}

[data-md-color-scheme="default"] .chat-message-content hr {
  border-top-color: rgba(0, 0, 0, 0.2);
}

/* Typing Indicator */
.chat-typing-dots {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}

.chat-typing-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.6);
  animation: typingDot 1.4s infinite;
}

[data-md-color-scheme="default"] .chat-typing-dots span {
  background: rgba(0, 0, 0, 0.4);
}

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

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

@keyframes typingDot {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.6;
  }
  30% {
    transform: translateY(-8px);
    opacity: 1;
  }
}

/* Input Area */
.chat-widget-input-container {
  display: flex;
  gap: 8px;
  padding: 16px;
  background: #1a1a1a;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

[data-md-color-scheme="default"] .chat-widget-input-container {
  background: #ffffff;
  border-top: 1px solid #e5e7eb;
}

.chat-widget-input {
  flex: 1;
  background: #2a2a2a;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 12px 16px;
  color: #e5e7eb;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  outline: none;
  transition: all 0.2s;
  min-height: 44px;
  max-height: 120px;
}

[data-md-color-scheme="default"] .chat-widget-input {
  background: #f9fafb;
  border: 1px solid #d1d5db;
  color: #111827;
}

.chat-widget-input:focus {
  border-color: #4F46E5;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.chat-widget-input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

[data-md-color-scheme="default"] .chat-widget-input::placeholder {
  color: rgba(0, 0, 0, 0.4);
}

.chat-widget-send {
  background: linear-gradient(135deg, #4F46E5 0%, #6366F1 100%);
  border: none;
  color: white;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.chat-widget-send:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
}

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

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

/* Footer */
.chat-widget-footer {
  padding: 8px 16px;
  text-align: center;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  background: #1a1a1a;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  flex-shrink: 0;
}

[data-md-color-scheme="default"] .chat-widget-footer {
  color: rgba(0, 0, 0, 0.5);
  background: #f9fafb;
  border-top: 1px solid #e5e7eb;
}

.chat-widget-footer strong {
  color: #4F46E5;
}

/* Confirmation Dialog */
.chat-confirm-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.chat-confirm-dialog {
  background: #2a2a2a;
  border-radius: 12px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
  max-width: 400px;
  width: calc(100% - 32px);
  animation: slideUp 0.2s ease-out;
  overflow: hidden;
}

[data-md-color-scheme="default"] .chat-confirm-dialog {
  background: #ffffff;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

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

.chat-confirm-header {
  padding: 20px 24px 16px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

[data-md-color-scheme="default"] .chat-confirm-header {
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.chat-confirm-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #e5e7eb;
}

[data-md-color-scheme="default"] .chat-confirm-header h3 {
  color: #111827;
}

.chat-confirm-body {
  padding: 20px 24px;
}

.chat-confirm-body p {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.8);
}

[data-md-color-scheme="default"] .chat-confirm-body p {
  color: rgba(0, 0, 0, 0.7);
}

.chat-confirm-footer {
  padding: 16px 24px 20px 24px;
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.chat-confirm-btn {
  padding: 8px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  outline: none;
}

.chat-confirm-btn:focus {
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

.chat-confirm-cancel {
  background: rgba(255, 255, 255, 0.1);
  color: #e5e7eb;
}

[data-md-color-scheme="default"] .chat-confirm-cancel {
  background: rgba(0, 0, 0, 0.05);
  color: #374151;
}

.chat-confirm-cancel:hover {
  background: rgba(255, 255, 255, 0.15);
}

[data-md-color-scheme="default"] .chat-confirm-cancel:hover {
  background: rgba(0, 0, 0, 0.1);
}

.chat-confirm-ok {
  background: linear-gradient(135deg, #EF4444 0%, #DC2626 100%);
  color: white;
}

.chat-confirm-ok:hover {
  background: linear-gradient(135deg, #DC2626 0%, #B91C1C 100%);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.chat-confirm-btn:active {
  transform: scale(0.98);
}
