/* ===== CUSTOM CHAT INTERFACE - 2026 GLASSMORPHISM ===== */
/* Replaces CustomGPT Web Widget with branded interface */

/* Chat Toggle Button - Bottom Right Floating */
.chat-toggle-btn {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 9999;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-600) 0%, var(--primary-700) 100%);
  border: none;
  box-shadow: 0 8px 24px rgba(5, 150, 105, 0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  color: white;
}

.chat-toggle-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 12px 32px rgba(5, 150, 105, 0.6);
}

.chat-toggle-btn svg {
  width: 28px;
  height: 28px;
  transition: transform 0.3s ease;
}

.chat-toggle-btn.active svg {
  transform: rotate(90deg);
}

/* Unread Badge */
.chat-unread-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #dc2626;
  color: white;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid white;
  display: none;
}

.chat-unread-badge.active {
  display: flex;
}

/* Chat Panel - Sliding from Right */
.chat-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 100%;
  max-width: 450px;
  height: 100vh;
  background: var(--glass-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-left: 1px solid var(--glass-border);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
  z-index: 10000;
  transform: translateX(100%);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}

.chat-panel.active {
  transform: translateX(0);
}

/* Chat Header */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-6) var(--space-6) var(--space-4);
  border-bottom: 1px solid var(--glass-border);
  background: linear-gradient(135deg, var(--primary-600) 0%, var(--primary-700) 100%);
  color: white;
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.chat-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  object-fit: cover;
}

.chat-header-text h3 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 700;
  color: white;
}

.chat-header-text p {
  margin: 0;
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.8);
}

.chat-close-btn {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  color: white;
  font-size: 1.5rem;
}

.chat-close-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* Chat Messages Container */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  background: var(--bg-primary);
}

/* Custom Scrollbar */
.chat-messages::-webkit-scrollbar {
  width: 8px;
}

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

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--zinc-300);
  border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: var(--zinc-400);
}

@media (prefers-color-scheme: dark) {
  .chat-messages::-webkit-scrollbar-thumb {
    background: var(--zinc-700);
  }

  .chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--zinc-600);
  }
}

/* Message Bubble */
.chat-message {
  display: flex;
  gap: var(--space-3);
  animation: messageSlideIn 0.3s ease-out;
}

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

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

.chat-message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
}

.chat-message-bubble {
  max-width: 75%;
  padding: var(--space-3) var(--space-4);
  border-radius: 18px;
  line-height: 1.5;
  font-size: 1rem;
  word-wrap: break-word;
}

.chat-message.assistant .chat-message-bubble {
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.chat-message.user .chat-message-bubble {
  background: linear-gradient(135deg, var(--primary-600) 0%, var(--primary-700) 100%);
  color: white;
  border-bottom-right-radius: 4px;
}

/* Typing Indicator */
.chat-typing {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}

.chat-typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary-600);
  animation: typingBounce 1.4s infinite;
}

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

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

@keyframes typingBounce {
  0%, 60%, 100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-8px);
  }
}

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

.chat-welcome h4 {
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.chat-welcome p {
  font-size: 0.9375rem;
  margin-bottom: var(--space-4);
}

.chat-suggestions {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.chat-suggestion-btn {
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: var(--space-3) var(--space-4);
  font-size: 0.9375rem;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.chat-suggestion-btn:hover {
  border-color: var(--primary-600);
  background: var(--zinc-50);
  transform: translateY(-2px);
}

@media (prefers-color-scheme: dark) {
  .chat-suggestion-btn:hover {
    background: var(--zinc-800);
  }
}

/* Chat Input Area */
.chat-input-container {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--glass-border);
  background: var(--bg-primary);
}

.chat-input-wrapper {
  display: flex;
  gap: var(--space-2);
  align-items: flex-end;
}

.chat-input {
  flex: 1;
  padding: var(--space-3) var(--space-4);
  border: 2px solid var(--zinc-200);
  border-radius: 12px;
  font-family: var(--font-body);
  font-size: 1rem;
  background: white;
  color: var(--text-primary);
  resize: none;
  max-height: 120px;
  transition: all 0.2s ease;
  line-height: 1.5;
}

@media (prefers-color-scheme: dark) {
  .chat-input {
    background: var(--zinc-900);
    border-color: var(--zinc-700);
    color: var(--zinc-100);
  }
}

.chat-input:focus {
  outline: none;
  border-color: var(--primary-600);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.1);
}

.chat-input::placeholder {
  color: var(--zinc-400);
}

.chat-send-btn {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary-600) 0%, var(--primary-700) 100%);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.chat-send-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.4);
}

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

.chat-send-btn svg {
  width: 20px;
  height: 20px;
}

/* Error Message */
.chat-error {
  padding: var(--space-3);
  background: #fef2f2;
  border: 1px solid #dc2626;
  border-radius: 12px;
  color: #991b1b;
  font-size: 0.875rem;
  text-align: center;
  margin: var(--space-2) 0;
}

@media (prefers-color-scheme: dark) {
  .chat-error {
    background: rgba(220, 38, 38, 0.1);
    border-color: rgba(220, 38, 38, 0.3);
    color: #fca5a5;
  }
}

/* Backdrop Overlay for Mobile */
.chat-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.chat-backdrop.active {
  display: block;
  opacity: 1;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .chat-panel {
    max-width: 100%;
  }

  .chat-toggle-btn {
    bottom: 1.5rem;
    right: 1.5rem;
    width: 56px;
    height: 56px;
  }

  .chat-toggle-btn svg {
    width: 24px;
    height: 24px;
  }

  .chat-header {
    padding: var(--space-4);
  }

  .chat-messages {
    padding: var(--space-4);
  }

  .chat-input-container {
    padding: var(--space-3);
  }
}

/* Accessibility */
.chat-panel:focus-visible,
.chat-toggle-btn:focus-visible,
.chat-send-btn:focus-visible {
  outline: 2px solid var(--primary-600);
  outline-offset: 2px;
}

/* Loading State */
.chat-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-8);
  color: var(--text-secondary);
}

.chat-loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--zinc-200);
  border-top-color: var(--primary-600);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Markdown-style formatting in messages */
.chat-message-bubble code {
  background: rgba(0, 0, 0, 0.05);
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
  font-family: 'Monaco', 'Courier New', monospace;
  font-size: 0.875em;
}

@media (prefers-color-scheme: dark) {
  .chat-message-bubble code {
    background: rgba(255, 255, 255, 0.1);
  }
}

.chat-message-bubble pre {
  background: rgba(0, 0, 0, 0.05);
  padding: var(--space-3);
  border-radius: 8px;
  overflow-x: auto;
  margin: var(--space-2) 0;
}

@media (prefers-color-scheme: dark) {
  .chat-message-bubble pre {
    background: rgba(255, 255, 255, 0.1);
  }
}

.chat-message-bubble pre code {
  background: none;
  padding: 0;
}

.chat-message-bubble a {
  color: inherit;
  text-decoration: underline;
  font-weight: 600;
}

.chat-message-bubble ul,
.chat-message-bubble ol {
  margin: var(--space-2) 0;
  padding-left: var(--space-6);
}

.chat-message-bubble li {
  margin: var(--space-1) 0;
}
