/* ==========================================
   DORI CHATBOT - ENTERPRISE AI ASSISTANT
   Subtle, brand-centric conversational interface
   Dark theme integration with DataOrbix design system
   ========================================== */

/* Dori Chat Button in Navigation */
#dori-chat-btn {
  position: relative;
  width: 48px;
  height: 48px;
  padding: 0;
  margin: 0 8px;
  border: 1px solid rgba(74, 158, 255, 0.4);
  background: rgba(74, 158, 255, 0.25);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

#dori-chat-btn:hover {
  background: rgba(74, 158, 255, 0.35);
  border-color: rgba(74, 158, 255, 0.6);
  transform: translateY(-1px);
}

#dori-chat-btn:focus {
  outline: 2px solid rgba(74, 158, 255, 0.6);
  outline-offset: 2px;
}

#dori-chat-btn.active {
  background: rgba(74, 158, 255, 0.4);
  border-color: rgba(74, 158, 255, 0.8);
}

#dori-chat-btn i {
  font-size: 16px;
  color: #4a9eff;
  transition: transform 0.2s ease;
}

#dori-chat-btn:hover i {
  transform: scale(1.1);
}

/* Override nav-actions button styles for Dori button */
.nav-actions #dori-chat-btn {
  padding: 0;
  font-size: 0;
  min-height: auto;
}

/* Dori logo inside navigation button */
#dori-chat-btn img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  opacity: 0.9;
  transition: transform 0.2s ease;
  border-radius: 50%;
}

#dori-chat-btn:hover img {
  transform: scale(1.05);
}

/* Chat Panel Container - Fixed positioning above navigation */
.dori-chat-panel {
  position: fixed;
  top: 70px; /* Position below navigation bar */
  right: -400px;
  width: 400px;
  height: calc(100vh - 70px); /* Full height minus navigation bar */
  background: var(--color-surface, #141414);
  border-left: 1px solid var(--color-border-subtle, #2a2a2a);
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.5);
  z-index: 1001; /* Above navigation (z-index: 1000) */
  transition: right 0.3s ease-in-out;
  display: flex;
  flex-direction: column;
  visibility: hidden; /* Hide when off-screen */
}

.dori-chat-panel.active {
  right: 0;
  visibility: visible; /* Show when active */
}

/* When no navigation is present, adjust positioning */
body:not([data-page="landing"]) .dori-chat-panel {
  top: 70px; /* Standard navigation height */
  height: calc(100vh - 70px);
}

/* For landing page with different navigation */
body[data-page="landing"] .dori-chat-panel {
  top: 80px; /* Landing page navigation height */
  height: calc(100vh - 80px);
}

.dori-chat-panel.active {
  right: 0;
}

/* Panel Header - Ensure proper visibility */
.dori-panel-header {
  padding: 20px 24px;
  background: var(--color-surface-elevated, #1e1e1e);
  border-bottom: 1px solid var(--color-border-subtle, #2a2a2a);
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 60px; /* Ensure consistent header height */
  position: sticky; /* Keep header visible when scrolling */
  top: 0;
  z-index: 1;
}

/* Backdrop overlay when chat is open */
.dori-chat-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000; /* Below chat panel but above navigation */
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.dori-chat-overlay.active {
  opacity: 1;
  visibility: visible;
}

.dori-panel-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.dori-panel-title h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--color-text-primary, #ffffff);
  font-family: 'Inter', sans-serif;
}

.dori-panel-subtitle {
  font-size: 12px;
  color: var(--color-text-muted, #808080);
  margin-top: 2px;
}

.dori-panel-close {
  background: none;
  border: none;
  color: var(--color-text-secondary, #b3b3b3);
  font-size: 20px;
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.dori-panel-close:hover {
  color: var(--color-text-primary, #ffffff);
  background: var(--color-surface-hover, #252525);
}

/* Chat Messages Area */
.dori-chat-messages {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.dori-message {
  display: flex;
  gap: 12px;
  max-width: 100%;
}

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

.dori-message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-surface-elevated, #1e1e1e);
  border: 1px solid var(--color-border-subtle, #2a2a2a);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.dori-avatar-svg {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.dori-message.user .dori-message-avatar {
  background: var(--color-primary, #4a9eff);
  border-color: var(--color-primary, #4a9eff);
}

.dori-message-avatar i {
  font-size: 14px;
  color: var(--color-text-secondary, #b3b3b3);
}

.dori-message.user .dori-message-avatar i {
  color: white;
}

.dori-message-content {
  max-width: 70%;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  font-family: 'Inter', sans-serif;
}

.dori-message.assistant .dori-message-content {
  background: var(--color-surface-elevated, #1e1e1e);
  border: 1px solid var(--color-border-subtle, #2a2a2a);
  color: var(--color-text-primary, #ffffff);
}

.dori-message.user .dori-message-content {
  background: var(--color-primary, #4a9eff);
  color: white;
  border: 1px solid var(--color-primary, #4a9eff);
}

.dori-message-time {
  font-size: 11px;
  color: var(--color-text-muted, #808080);
  margin-top: 4px;
  text-align: right;
}

/* Chat Input Area */
.dori-chat-input-area {
  padding: 24px;
  background: var(--color-surface-elevated, #1e1e1e);
  border-top: 1px solid var(--color-border-subtle, #2a2a2a);
}

.dori-input-container {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.dori-message-input {
  flex: 1;
  background: var(--color-surface, #141414);
  border: 1px solid var(--color-border-subtle, #2a2a2a);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  color: var(--color-text-primary, #ffffff);
  resize: none;
  min-height: 48px;
  max-height: 120px;
  transition: border-color 0.2s ease;
}

.dori-message-input:focus {
  outline: none;
  border-color: var(--color-primary, #4a9eff);
  background: var(--color-surface-hover, #252525);
}

.dori-message-input::placeholder {
  color: var(--color-text-muted, #808080);
}

.dori-send-button {
  background: var(--color-primary, #4a9eff);
  border: none;
  border-radius: 8px;
  padding: 12px 16px;
  color: white;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  height: 48px;
}

.dori-send-button:hover {
  background: var(--color-primary-light, #6bb6ff);
}

.dori-send-button:disabled {
  background: var(--color-surface-hover, #252525);
  color: var(--color-text-muted, #808080);
  cursor: not-allowed;
}

.dori-send-button i {
  font-size: 16px;
}

/* Contextual Integration with Right Panels */
.dori-chat-panel.contextual {
  position: absolute;
  right: 0;
  top: 0;
  height: 100%;
  width: 100%;
  border-left: none;
  border-top: 1px solid var(--color-border-subtle, #2a2a2a);
}

.dori-chat-panel.contextual .dori-panel-header {
  background: var(--color-surface, #141414);
  border-bottom: 1px solid var(--color-border-subtle, #2a2a2a);
}

/* Responsive Design - Adjust for mobile */
@media (max-width: 768px) {
  .dori-chat-panel {
    width: 100%;
    right: -100%;
    top: 60px; /* Adjust for mobile navigation height */
    height: calc(100vh - 60px);
  }
  
  .dori-chat-overlay {
    display: none; /* Hide overlay on mobile for better UX */
  }
}

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

.dori-chat-messages::-webkit-scrollbar-track {
  background: var(--color-surface, #141414);
}

.dori-chat-messages::-webkit-scrollbar-thumb {
  background: var(--color-border-subtle, #2a2a2a);
  border-radius: 3px;
}

.dori-chat-messages::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-muted, #808080);
}

/* Loading State */
.dori-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  color: var(--color-text-muted, #808080);
}

.dori-loading i {
  animation: spin 1s linear infinite;
  margin-right: 8px;
}

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

/* Welcome Message */
.dori-welcome-message {
  background: var(--color-surface-elevated, #1e1e1e);
  border: 1px solid var(--color-border-subtle, #2a2a2a);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  text-align: center;
}

.dori-welcome-message h4 {
  margin: 0 0 8px 0;
  font-size: 16px;
  color: var(--color-text-primary, #ffffff);
  font-weight: 600;
}

.dori-welcome-message p {
  margin: 0;
  font-size: 14px;
  color: var(--color-text-secondary, #b3b3b3);
  line-height: 1.5;
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  .dori-chat-panel,
  .dori-chat-icon,
  .dori-send-button,
  .dori-panel-close {
    transition: none;
  }
  
  .dori-loading i {
    animation: none;
  }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
  .dori-chat-panel {
    border-left: 2px solid var(--color-text-primary, #ffffff);
  }
  
  .dori-message.user .dori-message-content {
    border: 2px solid white;
  }
  
  .dori-message.assistant .dori-message-content {
    border: 2px solid var(--color-text-primary, #ffffff);
  }
}