/* IT Bench Chat Widget Styles */
:root {
  --chat-primary: #1f6feb;
  --chat-accent: #0ea5e9;
  --chat-bg: #ffffff;
  --chat-surface: #f8fafc;
  --chat-border: #e2e8f0;
  --chat-text: #1e293b;
  --chat-text-muted: #64748b;
  --chat-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
  --chat-radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --chat-bg: #1e293b;
    --chat-surface: #334155;
    --chat-border: #475569;
    --chat-text: #f1f5f9;
    --chat-text-muted: #94a3b8;
    --chat-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  }
}

/* Widget launcher button */
#itbench-chat-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  background: var(--chat-primary);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: var(--chat-shadow);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

#itbench-chat-launcher:hover {
  transform: scale(1.05);
  background: var(--chat-accent);
}

#itbench-chat-launcher svg {
  width: 24px;
  height: 24px;
  fill: white;
}

/* Chat panel */
#itbench-chat-panel {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 380px;
  height: 60vh;
  max-height: 600px;
  min-height: 400px;
  background: var(--chat-bg);
  border: 1px solid var(--chat-border);
  border-radius: var(--chat-radius);
  box-shadow: var(--chat-shadow);
  z-index: 9999;
  display: none;
  flex-direction: column;
  animation: slideUp 0.3s ease;
}

#itbench-chat-panel.open {
  display: flex;
}

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

/* Mobile responsive */
@media (max-width: 640px) {
  #itbench-chat-panel {
    left: 16px;
    right: 16px;
    bottom: 90px;
    width: auto;
    height: 70vh;
  }
  
  #itbench-chat-launcher {
    bottom: 16px;
    right: 16px;
  }
}

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

.chat-title {
  font-weight: 600;
  color: var(--chat-text);
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-status {
  width: 8px;
  height: 8px;
  background: #10b981;
  border-radius: 50%;
}

.chat-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--chat-text-muted);
  border-radius: 4px;
  transition: all 0.2s ease;
}

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

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

.chat-message {
  display: flex;
  gap: 8px;
  max-width: 85%;
}

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

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

.message-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--chat-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

.message-avatar.user {
  background: var(--chat-accent);
}

.message-content {
  background: var(--chat-surface);
  padding: 12px 16px;
  border-radius: 16px;
  color: var(--chat-text);
  font-size: 14px;
  line-height: 1.4;
  word-wrap: break-word;
}

.chat-message.user .message-content {
  background: var(--chat-primary);
  color: white;
}

.message-time {
  font-size: 11px;
  color: var(--chat-text-muted);
  margin-top: 4px;
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: var(--chat-surface);
  border-radius: 16px;
  align-items: center;
}

.typing-dots {
  display: flex;
  gap: 4px;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: var(--chat-text-muted);
  border-radius: 50%;
  animation: typing 1.4s infinite;
}

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

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

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

/* Quick chips */
.chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.chat-chip {
  background: transparent;
  border: 1px solid var(--chat-border);
  color: var(--chat-text);
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.chat-chip:hover {
  background: var(--chat-primary);
  color: white;
  border-color: var(--chat-primary);
}

/* Input area */
.chat-input-area {
  padding: 16px;
  border-top: 1px solid var(--chat-border);
  background: var(--chat-bg);
  border-radius: 0 0 var(--chat-radius) var(--chat-radius);
}

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

.chat-input {
  flex: 1;
  background: var(--chat-surface);
  border: 1px solid var(--chat-border);
  border-radius: 20px;
  padding: 12px 16px;
  font-size: 14px;
  color: var(--chat-text);
  resize: none;
  min-height: 20px;
  max-height: 80px;
  line-height: 1.4;
}

.chat-input:focus {
  outline: none;
  border-color: var(--chat-primary);
  box-shadow: 0 0 0 2px rgba(31, 111, 235, 0.1);
}

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

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

.chat-send:hover:not(:disabled) {
  background: var(--chat-accent);
  transform: scale(1.05);
}

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

/* Error states */
.chat-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #dc2626;
  padding: 12px;
  border-radius: 8px;
  font-size: 14px;
  margin: 8px 0;
}

.retry-button {
  background: var(--chat-primary);
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  margin-top: 8px;
}

/* Accessibility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Focus styles */
.chat-input:focus,
.chat-send:focus,
.chat-close:focus,
#itbench-chat-launcher:focus {
  outline: 2px solid var(--chat-primary);
  outline-offset: 2px;
}