/**
 * Skynet Support Chat Widget Styles
 */

/* Chat Bubble Button */
.support-chat-bubble {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.support-chat-bubble:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 30px rgba(102, 126, 234, 0.5);
}

.support-chat-bubble:active {
  transform: scale(0.95);
}

.support-chat-bubble svg {
  width: 28px;
  height: 28px;
  color: white;
}

.support-chat-bubble .hidden {
  display: none;
}

.support-bubble-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 22px;
  height: 22px;
  background: #e74c3c;
  border-radius: 50%;
  color: white;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
}

.support-bubble-badge.hidden {
  display: none;
}

/* Chat Window */
.support-chat-window {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 380px;
  height: 550px;
  max-height: calc(100vh - 140px);
  background: #1a1a2e;
  border-radius: 16px;
  box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
  z-index: 9998;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  overflow-x: hidden;
  animation: supportChatSlideIn 0.3s ease-out;
}

.support-chat-window.hidden {
  display: none;
}

.support-chat-window.minimized {
  height: auto;
}

@keyframes supportChatSlideIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Header */
.support-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.support-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.support-avatar {
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.support-avatar svg {
  width: 24px;
  height: 24px;
}

.support-header-text {
  display: flex;
  flex-direction: column;
}

.support-header-title {
  font-weight: 600;
  font-size: 16px;
}

.support-header-status {
  font-size: 12px;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 8px;
  height: 8px;
  background: #2ecc71;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.support-header-actions {
  display: flex;
  gap: 8px;
}

.support-header-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.support-header-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.support-header-btn svg {
  width: 18px;
  height: 18px;
}

/* Messages Container */
.support-chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #16162a;
}

.support-chat-messages::-webkit-scrollbar {
  width: 6px;
}

.support-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.support-chat-messages::-webkit-scrollbar-thumb {
  background: #333;
  border-radius: 3px;
}

/* Messages */
.support-message {
  display: flex;
  gap: 10px;
  animation: messageSlideIn 0.3s ease-out;
  max-width: 85%;
}

@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.support-message-user {
  flex-direction: row-reverse;
  align-self: flex-end;
}

.support-message-bot {
  align-self: flex-start;
}

.support-message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.support-message-avatar svg {
  width: 18px;
  height: 18px;
  color: white;
}

.support-message-content {
  max-width: 100%;
}

.support-message-user .support-message-content {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 18px 18px 4px 18px;
  padding: 12px 16px;
}

.support-message-bot .support-message-content {
  background: #252540;
  color: #e0e0e0;
  border-radius: 18px 18px 18px 4px;
  padding: 12px 16px;
}

.support-message-text {
  font-size: 14px;
  line-height: 1.6;
  overflow-wrap: break-word;
  word-wrap: break-word;
  word-break: normal;
  hyphens: none;
  overflow-x: hidden;
}

.support-message-time {
  font-size: 11px;
  opacity: 0.6;
  margin-top: 4px;
  text-align: right;
}

/* Typing Indicator */
.support-typing .support-message-content {
  padding: 12px 16px;
}

.support-typing-dots {
  display: flex;
  gap: 4px;
  align-items: center;
}

.support-typing-dots span {
  width: 8px;
  height: 8px;
  background: #667eea;
  border-radius: 50%;
  animation: typingBounce 1.4s ease-in-out infinite;
}

.support-typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.support-typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingBounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-6px);
    opacity: 1;
  }
}

/* AI Disclaimer Banner */
.support-ai-disclaimer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(234, 179, 8, 0.1);
  border-bottom: 1px solid rgba(234, 179, 8, 0.2);
  color: #eab308;
  font-size: 11px;
}

.support-ai-disclaimer svg {
  flex-shrink: 0;
  opacity: 0.8;
}

.support-ai-disclaimer span {
  line-height: 1.3;
}

/* Input Area */
.support-chat-input-area {
  padding: 12px 16px 16px;
  background: #1a1a2e;
  border-top: 1px solid #2a2a4a;
}

.support-suggestions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.support-suggestions-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.support-suggestions.hidden {
  display: none;
}

.support-suggestion-btn {
  padding: 6px 12px;
  background: #252540;
  border: 1px solid #3a3a5a;
  border-radius: 16px;
  color: #b0b0c0;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.support-suggestion-btn:hover {
  background: #3a3a5a;
  border-color: #667eea;
  color: white;
}

.support-input-container {
  display: flex;
  gap: 8px;
  align-items: center;
}

#support-input {
  flex: 1;
  padding: 12px 16px;
  background: #252540;
  border: 1px solid #3a3a5a;
  border-radius: 24px;
  color: white;
  font-size: 14px;
  outline: none;
  transition: all 0.2s;
}

#support-input:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#support-input::placeholder {
  color: #666;
}

#support-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

#support-send:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

#support-send:active {
  transform: scale(0.95);
}

#support-send svg {
  width: 20px;
  height: 20px;
}

/* Markdown Styles for Support Chat */
.support-message-text strong {
  font-weight: 600;
  color: inherit;
}

.support-message-text em {
  font-style: italic;
}

.support-message-text .support-h1,
.support-message-text .support-h2,
.support-message-text .support-h3,
.support-message-text .support-h4 {
  margin: 8px 0 4px;
  font-weight: 600;
}

.support-message-text .support-h1 { font-size: 18px; }
.support-message-text .support-h2 { font-size: 16px; }
.support-message-text .support-h3 { font-size: 15px; }
.support-message-text .support-h4 { font-size: 14px; }

.support-message-text .support-list {
  margin: 8px 0;
  padding-left: 20px;
}

.support-message-text .support-list li {
  margin: 4px 0;
}

.support-message-text .support-link {
  color: #8b9ff5;
  text-decoration: underline;
  text-decoration-color: rgba(139, 159, 245, 0.4);
  text-underline-offset: 2px;
  cursor: pointer;
  transition: all 0.2s ease;
  word-break: break-all;
  overflow-wrap: anywhere;
}

.support-message-text .support-link:hover {
  color: #a8b8ff;
  text-decoration-color: #a8b8ff;
  background: rgba(139, 159, 245, 0.1);
  border-radius: 2px;
  padding: 0 2px;
  margin: 0 -2px;
}

.support-message-text .support-link:active {
  color: #667eea;
}

/* Link with icon for external links */
.support-message-text .support-link[href^="http"]::after {
  content: " ↗";
  font-size: 0.8em;
  opacity: 0.7;
}

.support-message-text .support-code-block {
  background: #1a1a2e;
  border-radius: 8px;
  padding: 10px;
  margin: 8px 0;
  overflow-x: auto;
  font-family: monospace;
  font-size: 13px;
}

.support-message-text .support-inline-code {
  background: rgba(102, 126, 234, 0.2);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 13px;
  word-break: break-all;
}

/* Horizontal Rule */
.support-message-text .support-hr {
  border: none;
  border-top: 1px solid #3a3a5a;
  margin: 12px 0;
}

/* Table Styles */
.support-message-text .support-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 13px;
  border-radius: 8px;
  overflow: hidden;
}

.support-message-text .support-table thead {
  background: rgba(102, 126, 234, 0.2);
}

.support-message-text .support-table th {
  padding: 8px 12px;
  text-align: left;
  font-weight: 600;
  color: #8b9ff5;
  border-bottom: 2px solid #3a3a5a;
}

.support-message-text .support-table td {
  padding: 8px 12px;
  border-bottom: 1px solid #2a2a4a;
  color: #e0e0e0;
}

.support-message-text .support-table tbody tr:hover {
  background: rgba(102, 126, 234, 0.1);
}

.support-message-text .support-table tbody tr:last-child td {
  border-bottom: none;
}

/* Ordered List Styles */
.support-message-text ol.support-list {
  list-style-type: decimal;
}

.support-message-text ul.support-list {
  list-style-type: disc;
}

/* Responsive - Tablet */
@media (max-width: 768px) {
  .support-chat-window {
    width: 340px;
    height: 500px;
    right: 16px;
    bottom: 90px;
  }

  .support-message-text {
    font-size: 13px;
  }

  .support-message-text .support-table {
    font-size: 12px;
  }

  .support-message-text .support-table th,
  .support-message-text .support-table td {
    padding: 6px 8px;
  }
}

/* Responsive - Mobile */
@media (max-width: 480px) {
  .support-chat-bubble {
    bottom: 16px;
    right: 16px;
    width: 56px;
    height: 56px;
  }

  .support-chat-bubble svg {
    width: 24px;
    height: 24px;
  }

  .support-chat-window {
    position: fixed;
    bottom: 0;
    right: 0;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    animation: supportChatSlideUp 0.3s ease-out;
  }

  @keyframes supportChatSlideUp {
    from {
      opacity: 0;
      transform: translateY(100%);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  /* Header Mobile */
  .support-chat-header {
    padding: 12px 16px;
    padding-top: max(12px, env(safe-area-inset-top));
  }

  .support-avatar {
    width: 36px;
    height: 36px;
  }

  .support-avatar svg {
    width: 20px;
    height: 20px;
  }

  .support-header-title {
    font-size: 15px;
  }

  .support-header-status {
    font-size: 11px;
  }

  .support-header-btn {
    width: 36px;
    height: 36px;
  }

  .support-header-btn svg {
    width: 16px;
    height: 16px;
  }

  /* Messages Mobile */
  .support-chat-messages {
    padding: 12px;
    gap: 10px;
  }

  .support-message {
    max-width: 90%;
    gap: 8px;
  }

  .support-message-avatar {
    width: 28px;
    height: 28px;
  }

  .support-message-avatar svg {
    width: 16px;
    height: 16px;
  }

  .support-message-user .support-message-content,
  .support-message-bot .support-message-content {
    padding: 10px 14px;
  }

  .support-message-text {
    font-size: 14px;
    line-height: 1.5;
    word-break: normal;
    overflow-wrap: break-word;
  }

  .support-message-time {
    font-size: 10px;
    margin-top: 3px;
  }

  /* AI Disclaimer Mobile */
  .support-ai-disclaimer {
    padding: 6px 10px;
    font-size: 10px;
    gap: 6px;
  }

  .support-ai-disclaimer svg {
    width: 14px;
    height: 14px;
  }

  /* Input Area Mobile */
  .support-chat-input-area {
    padding: 10px 12px 16px;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }

  .support-suggestions {
    gap: 6px;
    margin-bottom: 10px;
  }

  .support-suggestions-row {
    gap: 4px;
  }

  .support-suggestion-btn {
    padding: 8px 10px;
    font-size: 11px;
    border-radius: 18px;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #support-input {
    padding: 12px 16px;
    font-size: 16px; /* Prevents iOS zoom on focus */
    border-radius: 22px;
  }

  #support-send {
    width: 44px;
    height: 44px;
  }

  #support-send svg {
    width: 18px;
    height: 18px;
  }

  /* Markdown Mobile Styles */
  .support-message-text .support-h1 {
    font-size: 16px;
    margin: 6px 0 4px;
  }

  .support-message-text .support-h2 {
    font-size: 15px;
    margin: 6px 0 4px;
  }

  .support-message-text .support-h3 {
    font-size: 14px;
  }

  .support-message-text .support-h4 {
    font-size: 13px;
  }

  .support-message-text .support-list {
    margin: 6px 0;
    padding-left: 18px;
  }

  .support-message-text .support-list li {
    margin: 3px 0;
    font-size: 14px;
  }

  .support-message-text .support-code-block {
    padding: 8px 10px;
    margin: 6px 0;
    font-size: 12px;
    border-radius: 6px;
    overflow-x: hidden;
    word-wrap: break-word;
    white-space: pre-wrap;
  }

  .support-message-text .support-code-block code {
    word-wrap: break-word;
    white-space: pre-wrap;
    overflow-wrap: break-word;
  }

  .support-message-text .support-inline-code {
    padding: 1px 5px;
    font-size: 12px;
    word-break: break-word;
  }

  .support-message-text .support-table {
    font-size: 12px;
    display: block;
    width: 100%;
    overflow-x: hidden;
    margin: 8px 0;
  }

  .support-message-text .support-table thead,
  .support-message-text .support-table tbody,
  .support-message-text .support-table tr {
    display: block;
    width: 100%;
  }

  .support-message-text .support-table thead {
    display: none;
  }

  .support-message-text .support-table tr {
    margin-bottom: 8px;
    border: 1px solid #3a3a5a;
    border-radius: 6px;
    padding: 8px;
    background: rgba(102, 126, 234, 0.05);
  }

  .support-message-text .support-table td {
    display: block;
    width: 100%;
    text-align: left;
    padding: 4px 8px;
    border-bottom: 1px solid #2a2a4a;
    white-space: normal;
    word-wrap: break-word;
  }

  .support-message-text .support-table td:last-child {
    border-bottom: none;
  }

  .support-message-text .support-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: #8b9ff5;
    display: block;
    margin-bottom: 2px;
    font-size: 10px;
    text-transform: uppercase;
  }

  .support-message-text .support-hr {
    margin: 10px 0;
  }

  /* Typing indicator mobile */
  .support-typing-dots span {
    width: 6px;
    height: 6px;
  }
}

/* Extra small devices */
@media (max-width: 360px) {
  .support-ai-disclaimer {
    padding: 5px 8px;
    font-size: 9px;
  }

  .support-ai-disclaimer svg {
    width: 12px;
    height: 12px;
  }

  .support-header-title {
    font-size: 14px;
  }

  .support-message-text {
    font-size: 13px;
  }

  .support-suggestions-row {
    gap: 3px;
  }

  .support-suggestion-btn {
    padding: 6px 8px;
    font-size: 10px;
  }

  #support-input {
    padding: 10px 14px;
  }

  #support-send {
    width: 40px;
    height: 40px;
  }

  .support-message-text .support-code-block {
    font-size: 11px;
  }

  .support-message-text .support-table {
    font-size: 10px;
  }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
  .support-chat-bubble {
    width: 60px;
    height: 60px;
  }

  .support-suggestion-btn {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  #support-send {
    min-width: 44px;
    min-height: 44px;
  }

  .support-header-btn {
    min-width: 44px;
    min-height: 44px;
  }

  /* Disable hover effects on touch */
  .support-chat-bubble:hover {
    transform: none;
  }

  .support-chat-bubble:active {
    transform: scale(0.95);
  }

  .support-suggestion-btn:hover {
    transform: none;
  }

  .support-suggestion-btn:active {
    background: #3a3a5a;
    border-color: #667eea;
  }
}

/* Landscape mobile optimization */
@media (max-width: 812px) and (orientation: landscape) {
  .support-chat-window {
    height: 100%;
    max-height: 100vh;
  }

  .support-chat-messages {
    max-height: calc(100vh - 180px);
  }

  .support-chat-header {
    padding: 8px 16px;
  }

  .support-chat-input-area {
    padding: 8px 12px;
  }

  .support-suggestions {
    margin-bottom: 6px;
  }
}

/* Retry Status */
.support-retry-status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #f59e0b;
  font-size: 12px;
  padding: 4px 0;
}

.support-retry-status .retry-spin {
  animation: retrySpin 1s linear infinite;
}

@keyframes retrySpin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Retry Button */
.support-retry-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 6px 12px;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 16px;
  color: #f87171;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.support-retry-btn:hover {
  background: rgba(239, 68, 68, 0.25);
  border-color: rgba(239, 68, 68, 0.5);
  color: #fca5a5;
}

.support-retry-btn:active {
  transform: scale(0.95);
}

.support-retry-btn svg {
  flex-shrink: 0;
}

/* Error Message Styling */
.support-message-error .support-message-content {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Streaming Cursor Animation */
.streaming-cursor {
  display: inline-block;
  animation: streamBlink 1s infinite;
  color: #667eea;
}

@keyframes streamBlink {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}

/* iOS safe area support */
@supports (padding: max(0px)) {
  .support-chat-header {
    padding-top: max(16px, env(safe-area-inset-top));
  }

  .support-chat-input-area {
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }
}

/* Dark mode support (already dark, but ensure consistency) */
@media (prefers-color-scheme: light) {
  /* Keep dark theme for chat widget regardless of system preference */
}
