/**
 * AI Assistant Modal Component Styles
 * 
 * Responsive modal component with liquid glass design
 * Features: backdrop blur, focus management, smooth animations
 */

/* Modal Container */
.ai-assistant-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  animation: fadeIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

/* Modal Backdrop */
.ai-modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--material-bar-bg);
  backdrop-filter: blur(var(--material-thin-blur));
  -webkit-backdrop-filter: blur(var(--material-thin-blur));
}

/* Modal Content Container */
.ai-modal-content {
  position: relative;
  width: 90%;
  max-width: 800px;
  max-height: 90vh;
  background: var(--card-background);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--glass-shadow);
  overflow: hidden;
  transform: scale(0.9) translateY(20px);
  animation: modalSlideIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) 0.1s forwards;
}

/* Modal Header */
.ai-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-xl);
  border-bottom: 1px solid var(--subtle-border);
  background: var(--liquid-overlay);
}

.ai-modal-header h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--heading-color);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.ai-modal-header h2 i {
  color: var(--ai-icon-blue);
  font-size: 1.25rem;
}

/* Close Button */
.ai-modal-close {
  background: none;
  border: none;
  padding: var(--space-sm);
  border-radius: var(--radius-sm);
  color: var(--secondary-text);
  cursor: pointer;
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
}

.ai-modal-close:hover {
  background: var(--material-ultra-thin-bg);
  color: var(--foreground-text);
  transform: scale(1.1);
}

.ai-modal-close:focus {
  outline: 2px solid var(--ai-icon-blue);
  outline-offset: 2px;
}

/* Modal Body */
.ai-modal-body {
  padding: var(--space-sm) var(--space-xl) var(--space-md);
  max-height: 70vh;
  overflow-y: auto;
}

/* Loading and Error States */
.loading-state,
.error-state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-xl);
  text-align: center;
  color: var(--secondary-text);
}

.loading-state i {
  color: var(--ai-icon-blue);
  font-size: 1.5rem;
}

.error-state {
  color: var(--danger);
}

.error-state i {
  color: var(--danger);
  font-size: 1.25rem;
}

/* Chat Interface */
.chat-interface {
  display: block;
}

.chat-welcome {
  margin-bottom: var(--space-lg);
}

.chat-welcome .chat-message {
  display: flex;
  gap: var(--space-md);
  align-items: flex-start;
}

.message-avatar {
  width: 40px;
  height: 40px;
  background: var(--ai-accent-gradient);
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1rem;
  flex-shrink: 0;
}

.message-content {
  flex: 1;
}

.message-content p {
  margin: 0;
  color: var(--foreground-text);
  line-height: 1.6;
}

/* Demo Hint */
.demo-hint {
  margin-bottom: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: linear-gradient(135deg, #e3f2fd 0%, #f3e5f5 100%);
  border: 1px solid #90caf9;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
}

.demo-hint-content {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
}

.demo-hint-content i {
  color: #1976d2;
  margin-top: 0.125rem;
  flex-shrink: 0;
}

.demo-hint-text {
  line-height: 1.4;
  color: var(--foreground-text);
}

.demo-hint-text strong {
  color: #1976d2;
}

/* Predefined Questions */
.predefined-questions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.question-btn {
  display: flex;
  align-items: flex-start;
  padding: var(--space-md) var(--space-lg);
  background: white;
  border: 2px solid var(--subtle-border);
  border-radius: var(--radius-md);
  text-align: left;
  cursor: pointer;
  transition: var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.question-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--ai-accent-gradient);
  opacity: 0;
  transition: var(--transition-fast);
  z-index: -1;
}

.question-btn:hover {
  border-color: var(--ai-icon-blue);
  transform: translateY(-2px);
  box-shadow: var(--button-hover-shadow);
}

.question-btn:hover::before {
  opacity: 0.05;
}

.question-btn:focus {
  outline: 2px solid var(--ai-icon-blue);
  outline-offset: 2px;
}

.question-btn:active {
  transform: translateY(0);
}

/* Icon styles removed - no longer needed */

.question-content {
  flex: 1;
}

.question-text {
  font-weight: 600;
  color: var(--foreground-text);
  display: block;
  margin-bottom: var(--space-xs);
}

.question-description {
  color: var(--secondary-text);
  font-size: 0.875rem;
  line-height: 1.4;
}

/* Chat Messages - Improved Structure */
.chat-messages {
  background: #f0f2f5;
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  min-height: 300px;
  max-height: 500px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* Welcome message styling - removed empty state since we show welcome message */

/* Message Container */
.chat-message {
  display: flex;
  align-items: flex-end;
  margin-bottom: 8px;
  opacity: 0;
  transform: translateY(8px);
  transition: all 0.25s ease;
}

.chat-message.message-visible {
  opacity: 1;
  transform: translateY(0);
}

.chat-message.user {
  justify-content: flex-end;
  padding-left: 60px;
}

.chat-message.assistant {
  justify-content: flex-start;
  padding-right: 60px;
  gap: 8px;
}

/* Message Avatar */
.message-avatar {
  width: 28px;
  height: 28px;
  background: var(--ai-accent-gradient);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.8rem;
  flex-shrink: 0;
}

/* Message Bubbles */
.message-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  max-width: 100%;
  word-wrap: break-word;
  position: relative;
  box-shadow: var(--glass-shadow);
}

.user-bubble {
  background: var(--ai-accent-gradient);
  color: white;
  border-bottom-right-radius: 6px;
}

.assistant-bubble {
  background: white;
  color: var(--foreground-text);
  border: 1px solid #e1e5e9;
  border-bottom-left-radius: 6px;
}

/* Message Text */
.message-text {
  font-size: 0.9rem;
  line-height: 1.35;
  margin: 0 0 4px 0;
  word-break: break-word;
}

.user-bubble .message-text {
  color: white;
}

.assistant-bubble .message-text {
  color: var(--foreground-text);
}

/* Message Time */
.message-time {
  font-size: 0.7rem;
  opacity: 0.65;
  margin: 0;
  text-align: right;
}

.user-bubble .message-time {
  color: var(--glass-text-overlay);
}

.assistant-bubble .message-time {
  color: var(--secondary-text);
  text-align: left;
}

/* Typing Indicator */
.typing-bubble {
  background: white !important;
  border: 1px solid #e1e5e9 !important;
  padding: 10px 14px !important;
  border-bottom-left-radius: 6px !important;
}

.typing-dots {
  display: flex;
  gap: 3px;
  align-items: center;
}

.typing-dots .dot {
  width: 6px;
  height: 6px;
  background: #8b9098;
  border-radius: 50%;
  animation: typingPulse 1.2s infinite ease-in-out;
}

.typing-dots .dot:nth-child(1) { animation-delay: 0s; }
.typing-dots .dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dots .dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes typingPulse {
  0%, 60%, 100% {
    transform: scale(0.8);
    opacity: 0.4;
  }
  30% {
    transform: scale(1);
    opacity: 0.8;
  }
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

/* Responsive Design */
@media (max-width: 768px) {
  .ai-modal-content {
    width: 95%;
    max-height: 95vh;
    margin: var(--space-sm);
  }

  .ai-modal-header {
    padding: var(--space-md);
  }

  .ai-modal-header h2 {
    font-size: 1.25rem;
  }

  .ai-modal-body {
    padding: var(--space-md);
    max-height: 75vh;
  }

  .predefined-questions {
    grid-template-columns: 1fr;
    gap: var(--space-sm);
  }

  .question-btn {
    padding: var(--space-md);
  }

  /* Icon styles removed - no longer needed */

  .question-text {
    font-size: 0.875rem;
  }

  .question-description {
    font-size: 0.75rem;
  }

  .chat-messages {
    max-height: 350px;
    min-height: 200px;
    padding: 8px 12px;
  }

  .chat-message.user {
    padding-left: 40px;
  }

  .chat-message.assistant {
    padding-right: 40px;
    gap: 6px;
  }

  .message-bubble {
    padding: 8px 12px;
  }

  .message-avatar {
    width: 24px;
    height: 24px;
    font-size: 0.7rem;
  }

  .message-text {
    font-size: 0.85rem;
  }
}

@media (max-width: 480px) {
  .ai-modal-content {
    width: 100%;
    height: 100%;
    max-height: 100vh;
    border-radius: 0;
    margin: 0;
  }

  .ai-modal-header {
    padding: var(--space-sm) var(--space-md);
  }

  .ai-modal-body {
    padding: var(--space-md);
    max-height: calc(100vh - 80px);
  }

  .chat-messages {
    max-height: calc(100vh - 220px);
    min-height: 250px;
    padding: 6px 8px;
  }

  .chat-message.user {
    padding-left: 20px;
  }

  .chat-message.assistant {
    padding-right: 20px;
    gap: 4px;
  }

  .message-bubble {
    padding: 6px 10px;
  }

  .message-avatar {
    width: 22px;
    height: 22px;
    font-size: 0.65rem;
  }

  .message-text {
    font-size: 0.8rem;
    line-height: 1.3;
  }

  .message-time {
    font-size: 0.65rem;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .ai-modal-content {
    border: 2px solid var(--foreground-text);
  }

  .question-btn {
    border: 2px solid var(--foreground-text);
  }

  .message-bubble {
    border: 2px solid var(--subtle-border);
  }

  .user-bubble {
    border: 2px solid var(--material-thick-border);
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .ai-assistant-modal {
    animation: none;
    opacity: 1;
  }

  .ai-modal-content {
    animation: none;
    transform: none;
  }

  .question-btn {
    transition: none;
  }

  .ai-modal-close {
    transition: none;
  }

  .question-btn:hover {
    transform: none;
  }

  .chat-message {
    transition: none;
    opacity: 1;
    transform: none;
  }

  .typing-dots .dot {
    animation: none;
  }
}

/* Focus visible support */
.ai-modal-close:focus-visible,
.question-btn:focus-visible {
  outline: 2px solid var(--ai-icon-blue);
  outline-offset: 2px;
}

/* Print styles */
@media print {
  .ai-assistant-modal {
    display: none !important;
  }
}