/* AI Assistant Iframe Panel Styles - Persistent Across Navigation */

.ai-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 400px;
  height: 100vh;
  background: #ffffff;
  border-left: 1px solid #dee2e6;
  box-shadow: -2px 0 15px rgba(0,0,0,0.2);
  z-index: 2000; /* Higher z-index to ensure it's always on top */
  transform: translateX(100%); /* Hidden by default */
  transition: transform 0.3s ease;
}

.ai-panel.show {
  transform: translateX(0); /* Slide in when active */
}

/* Adjust main content when AI panel is open */
.main.with-ai {
  margin-right: 400px;
  transition: margin-right 0.3s ease;
}

/* Iframe styling */
#ai-chat-frame {
  border: none;
  background: #ffffff;
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.ai-panel-header {
  background: linear-gradient(135deg, #007bff, #0056b3);
  color: white;
  padding: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #dee2e6;
  flex-shrink: 0;
}

.ai-panel-header h5 {
  margin: 0;
  font-weight: 600;
}

.ai-panel-header .btn {
  color: white;
  border-color: rgba(255,255,255,0.3);
}

.ai-panel-header .btn:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.5);
}

.ai-panel-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 15px;
  background: #f8f9fa;
  scrollbar-width: thin;
  scrollbar-color: #007bff #f8f9fa;
}

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

.ai-messages::-webkit-scrollbar-track {
  background: #f8f9fa;
}

.ai-messages::-webkit-scrollbar-thumb {
  background: #007bff;
  border-radius: 3px;
}

.ai-message {
  margin-bottom: 15px;
  animation: fadeInUp 0.3s ease;
}

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

.ai-message-content {
  padding: 12px 15px;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  position: relative;
}

.ai-message.ai-user .ai-message-content {
  background: #007bff;
  color: white;
  margin-left: 20px;
  border-bottom-right-radius: 4px;
}

.ai-message.ai-system .ai-message-content,
.ai-message.ai-assistant .ai-message-content {
  background: white;
  color: #333;
  margin-right: 20px;
  border-bottom-left-radius: 4px;
  border: 1px solid #e9ecef;
}

.ai-message.ai-system .ai-message-content {
  background: #e3f2fd;
  border-color: #90caf9;
}

.ai-message-content ul {
  font-size: 0.9em;
  margin-bottom: 0;
}

.ai-message-content li {
  margin-bottom: 2px;
}

.ai-quick-actions {
  padding: 15px;
  border-top: 1px solid #dee2e6;
  background: white;
  flex-shrink: 0;
}

.ai-quick-actions .btn {
  width: 100%;
  text-align: left;
  font-size: 0.85em;
  margin-bottom: 5px;
}

.ai-input-container {
  padding: 15px;
  background: white;
  border-top: 1px solid #dee2e6;
  flex-shrink: 0;
}

.ai-input-container .input-group {
  margin-bottom: 8px;
}

.ai-input-container small {
  font-size: 0.75em;
  display: block;
}

#ai-input {
  border-radius: 20px 0 0 20px;
  border: 1px solid #007bff;
}

#ai-input:focus {
  border-color: #0056b3;
  box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.ai-input-container .btn-primary {
  border-radius: 0 20px 20px 0;
  border: 1px solid #007bff;
}

.ai-typing-indicator {
  display: none;
  padding: 10px 15px;
  color: #6c757d;
  font-style: italic;
  font-size: 0.9em;
}

.ai-typing-indicator.show {
  display: block;
}

.ai-typing-dots {
  display: inline-block;
}

.ai-typing-dots::after {
  content: '...';
  animation: typing 1.5s infinite;
}

@keyframes typing {
  0%, 20% { content: '.'; }
  40% { content: '..'; }
  60%, 100% { content: '...'; }
}

/* Responsive design */
@media (max-width: 768px) {
  .ai-panel {
    width: 100%;
    position: fixed;
    top: 0;
    right: 0;
    z-index: 1050;
    height: 100vh;
  }
  
  #main-content.with-ai {
    display: none;
  }
  
  .ai-panel-header {
    padding-top: 60px; /* Account for mobile header */
  }
}

/* AI Assistant Toggle Button */
#ai-assistant-toggle {
  position: relative;
  overflow: hidden;
}

#ai-assistant-toggle::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
  transition: left 0.5s;
}

#ai-assistant-toggle:hover::before {
  left: 100%;
}

/* Page Loading Integration */
.ai-page-frame {
  width: 100%;
  border: none;
  border-radius: 8px;
  margin: 10px 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  min-height: 300px;
}

.ai-message-content .ai-page-frame {
  max-height: 400px;
  overflow-y: auto;
}

/* Enhanced Message Types */
.ai-message.ai-error .ai-message-content {
  background: #f8d7da;
  color: #721c24;
  border-color: #f5c6cb;
}

.ai-message.ai-success .ai-message-content {
  background: #d4edda;
  color: #155724;
  border-color: #c3e6cb;
}

.ai-message.ai-info .ai-message-content {
  background: #d1ecf1;
  color: #0c5460;
  border-color: #bee5eb;
}

/* Code and technical content styling */
.ai-message-content pre {
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 4px;
  padding: 10px;
  margin: 8px 0;
  font-size: 0.85em;
  overflow-x: auto;
}

.ai-message-content code {
  background: #f8f9fa;
  padding: 2px 4px;
  border-radius: 3px;
  font-size: 0.9em;
}

/* Trademark-specific content styling */
.trademark-info {
  background: #fff3cd;
  border: 1px solid #ffeaa7;
  border-radius: 6px;
  padding: 10px;
  margin: 8px 0;
}

.trademark-info h6 {
  color: #856404;
  margin-bottom: 5px;
  font-weight: 600;
}

.collision-alert {
  background: #f8d7da;
  border: 1px solid #f5c6cb;
  border-radius: 6px;
  padding: 10px;
  margin: 8px 0;
}

.collision-alert h6 {
  color: #721c24;
  margin-bottom: 5px;
  font-weight: 600;
}