/**
 * REAL CONVERSATIONAL AI CHAT PANEL STYLING
 * ChatGPT-inspired dark theme with modern interactions
 */

:root {
  --chat-bg: linear-gradient(135deg, #090f18 0%, #1d253d 100%);
  --chat-surface: linear-gradient(135deg, #090f18 0%, #1d253d 100%);
  --chat-border: #2e5092;
  --chat-text: #ececec;
  --chat-text-secondary: #b4b4b4;
  --chat-user-bg: linear-gradient(135deg, #090f18 0%, #1d253d 100%);
  --chat-assistant-bg: linear-gradient(135deg, #090f18 0%, #1d253d 100%);
  --chat-primary: #10a37f;
  --chat-primary-light: rgba(16, 163, 127, 0.15);
  --chat-accent: #6366f1;
  --chat-error: #ff6b6b;
  --chat-success: #51cf66;
}

/* Panel Container */
#real-chat-panel {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 420px;
  height: 600px;
  border-radius: 12px;
  background: linear-gradient(135deg, #090f18 0%, #1d253d 100%);
  border: 1px solid var(--chat-border);
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  transform: translateY(calc(100% + 20px));
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 10000;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
}

#real-chat-panel.open {
  transform: translateY(0);
}

/* Header */
.real-chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--chat-border);
}

.chat-title {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

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

.provider-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--chat-text-secondary);
}

.provider-status .status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--chat-success);
  animation: pulse 2s infinite;
}

.provider-status.status-loading .status-dot {
  background: var(--chat-accent);
  animation: pulse 1s infinite;
}

.provider-status.status-error .status-dot {
  background: var(--chat-error);
  animation: none;
}

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

.chat-close-btn {
  background: none;
  border: none;
  color: var(--chat-text-secondary);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s;
}

.chat-close-btn:hover {
  background: var(--chat-border);
  color: var(--chat-text);
}

/* Messages Container */
.real-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: linear-gradient(135deg, #090f18 0%, #1d253d 100%);
}

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

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

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

.real-chat-messages::-webkit-scrollbar-thumb:hover {
  background: var(--chat-text-secondary);
}

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

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

.chat-welcome p {
  font-size: 13px;
  margin: 0 0 16px 0;
  line-height: 1.5;
}

.quick-prompts {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quick-prompt {
  background: linear-gradient(135deg, #090f18 0%, #1d253d 100%);
  color: var(--chat-text);
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}

.quick-prompt:hover {
  background: linear-gradient(135deg, #090f18 0%, #1d253d 100%);
}

/* Chat Messages */
.chat-message {
  display: flex;
  animation: slideIn 0.3s ease-out;
}

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

.chat-message-user {
  justify-content: flex-end;
}

.chat-message-assistant {
  justify-content: flex-start;
}

.message-content {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}

.chat-message-user .message-content {
  background: var(--chat-user-bg);
  border: 1px solid var(--chat-border);
  color: var(--chat-text);
  border-bottom-right-radius: 4px;
}

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

.chat-message-assistant .message-content p {
  margin: 6px 0;
}

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

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

/* Provider Badge */
.message-provider {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  margin-top: 8px;
  padding: 0 4px;
  color: var(--chat-text-secondary);
}

.provider-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 4px;
  background: var(--chat-primary-light);
  color: var(--chat-primary);
  font-weight: 500;
}

.provider-badge.gemini {
  background: rgba(51, 168, 220, 0.15);
  color: #33a8dc;
}

.provider-badge.groq {
  background: rgba(255, 193, 7, 0.15);
  color: #ffc107;
}

.provider-badge.openrouter {
  background: rgba(233, 30, 99, 0.15);
  color: #e91e63;
}

.provider-badge.error {
  background: rgba(255, 107, 107, 0.15);
  color: var(--chat-error);
}

.token-info {
  font-size: 11px;
  opacity: 0.7;
}

/* Reasoning Section */
.message-reasoning {
  margin-top: 8px;
  font-size: 12px;
  color: var(--chat-text-secondary);
}

.message-reasoning summary {
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.2s;
  user-select: none;
}

.message-reasoning summary:hover {
  background: var(--chat-border);
}

.message-reasoning pre {
  margin: 8px 0 0 0;
  padding: 8px;
  background: var(--chat-bg);
  border-radius: 4px;
  overflow-x: auto;
  font-family: 'Monaco', 'Menlo', monospace;
  font-size: 11px;
  line-height: 1.4;
  max-height: 200px;
  overflow-y: auto;
}

/* Input Area */
.real-chat-input-area {
  padding: 12px 16px;
  border-top: 1px solid var(--chat-border);
  background: linear-gradient(135deg, #090f18 0%, #1d253d 100%);
}

.real-chat-input-wrapper {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.real-chat-input {
  flex: 1;
  background: linear-gradient(135deg, #090f18 0%, #1d253d 100%);
  border: 1px solid var(--chat-border);
  color: var(--chat-text);
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 14px;
  outline: none;
  transition: all 0.2s;
  font-family: inherit;
}

.real-chat-input:focus {
  background: black;
}

.real-chat-input::placeholder {
  color: var(--chat-text-secondary);
  opacity: 0.6;
}

.chat-send-btn {
  background: var(--chat-primary);
  border: none;
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  transition: all 0.2s;
}

.chat-send-btn:hover {
  background: #0d8b6f;
  transform: scale(1.05);
}

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

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

.chat-hints {
  font-size: 11px;
  color: var(--chat-text-secondary);
  line-height: 1.4;
}

/* Toggle Button (Floating) */
.chat-toggle-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 28px;
  background: linear-gradient(135deg, var(--chat-primary), var(--chat-accent));
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(16, 163, 127, 0.3);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 9999;
}

.chat-toggle-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(16, 163, 127, 0.4);
}

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

.chat-toggle-btn.active {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.8);
}

.chat-unread {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ff6b6b;
  animation: pulse-unread 2s infinite;
}

@keyframes pulse-unread {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.3); }
}

/* Responsive */
@media (max-width: 640px) {
  #real-chat-panel {
    width: calc(100vw - 20px);
    height: 70vh;
    max-height: 600px;
  }

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

  .chat-toggle-btn {
    width: 48px;
    height: 48px;
    font-size: 20px;
  }
}

/* Dark mode (default) */
@media (prefers-color-scheme: light) {
  :root {
    --chat-bg: #ffffff;
    --chat-surface: #f7f7f7;
    --chat-border: #e5e5e5;
    --chat-text: #1a1a1a;
    --chat-text-secondary: #565656;
    --chat-user-bg: #e5e5ea;
    --chat-assistant-bg: #f0f0f0;
  }
}
