/* ============================================
   AI AGENT PANEL STYLES
   ============================================ */

/* Agent Sidebar Container */
.ai-agent-sidebar {
  flex: 0 0 320px;
  min-width: 320px;
  max-width: 320px;
  background: #ffffff;
  border-right: 1px solid #e5e7eb;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: all 0.3s ease;
  position: relative;
}

/* Collapsed state - moves to bottom left */
.ai-agent-sidebar.collapsed {
  position: fixed !important;
  bottom: 20px;
  left: 120px;
  width: auto !important;
  min-width: 200px !important;
  max-width: 280px;
  flex: none;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  border-right: none;
  overflow: visible;
}

/* Mobile specific styles */
/* Hide backdrop by default */
.agent-mobile-backdrop {
  display: none;
}

/* Agent Panel */
.ai-agent-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: white;
}

/* Collapsed panel styling */
.ai-agent-sidebar.collapsed .ai-agent-panel {
  height: auto;
  border-radius: 12px;
  overflow: hidden;
}

/* Panel Header */
.agent-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
  cursor: pointer;
  transition: all 0.2s ease;
}

/* Collapsed header styling */
.ai-agent-sidebar.collapsed .agent-panel-header {
  border-bottom: none;
  border-radius: 12px;
  padding: 12px 16px;
}

.ai-agent-sidebar.collapsed .agent-panel-header:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(102, 126, 234, 0.4);
}

.agent-header-content {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.agent-icon {
  font-size: 24px;
  line-height: 1;
}

.agent-header-text h3 {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 2px 0;
  color: white;
}

.agent-status {
  font-size: 11px;
  margin: 0;
  color: rgba(255, 255, 255, 0.85);
  font-weight: 500;
}

.agent-toggle-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  font-size: 12px;
  flex-shrink: 0;
}

.agent-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Hide toggle button when collapsed (entire header becomes clickable) */
.ai-agent-sidebar.collapsed .agent-toggle-btn {
  display: none;
}

/* Panel Body */
.agent-panel-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
  transition: all 0.3s ease;
}

/* Hide body when collapsed */
.ai-agent-sidebar.collapsed .agent-panel-body {
  display: none;
}

/* Messages Container */
.agent-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  background: #f9fafb;
  min-height: 0;
}

/* Custom scrollbar for messages */
.agent-messages::-webkit-scrollbar {
  width: 6px;
}

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

.agent-messages::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 3px;
}

.agent-messages::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

/* Message */
.agent-message {
  margin-bottom: 14px;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message-content {
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.5;
  max-width: 100%;
  word-wrap: break-word;
}

.user-message .message-content {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  margin-left: 16px;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 4px rgba(102, 126, 234, 0.2);
}

.assistant-message .message-content {
  background: white;
  color: #1f2937;
  border: 1px solid #e5e7eb;
  margin-right: 16px;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.message-content p {
  margin: 0 0 6px 0;
}

.message-content p:last-child {
  margin-bottom: 0;
}

.message-content ul {
  margin: 6px 0;
  padding-left: 18px;
}

.message-content li {
  margin-bottom: 3px;
  font-size: 12px;
}

.message-content code {
  background: rgba(0, 0, 0, 0.06);
  padding: 2px 5px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
}

.user-message .message-content code {
  background: rgba(255, 255, 255, 0.25);
}

.message-content strong {
  font-weight: 600;
}

/* Typing Indicator */
.typing-indicator {
  opacity: 0.7;
}

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

.typing-dots span {
  width: 7px;
  height: 7px;
  background: #667eea;
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) {
  animation-delay: -0.32s;
}

.typing-dots span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes bounce {

  0%,
  80%,
  100% {
    transform: scale(0);
  }

  40% {
    transform: scale(1);
  }
}

/* Chat History Messages (from original chat conversation) */
.chat-history-message {
  opacity: 0.7;
}

.chat-history-message .message-content {
  position: relative;
  font-size: 12px;
}

.chat-source-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 1px 6px;
  border-radius: 4px;
  margin-bottom: 4px;
}

.user-message.chat-history-message .chat-source-badge {
  background: rgba(255, 255, 255, 0.3);
}

.chat-history-separator {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0;
  color: #9ca3af;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.chat-history-separator::before,
.chat-history-separator::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #e5e7eb;
}

.chat-history-separator span {
  white-space: nowrap;
}

/* Suggestions */
.agent-suggestions {
  padding: 10px 14px;
  border-top: 1px solid #e5e7eb;
  background: #f9fafb;
  flex-shrink: 0;
}

.suggestions-label {
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  margin-bottom: 7px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.suggestion-chip {
  background: white;
  border: 1px solid #d1d5db;
  color: #374151;
  padding: 5px 10px;
  border-radius: 14px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.suggestion-chip:hover {
  background: #667eea;
  color: white;
  border-color: #667eea;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(102, 126, 234, 0.3);
}

/* Input Area */
.agent-input-area {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid #e5e7eb;
  background: white;
  flex-shrink: 0;
}

.agent-input-field {
  flex: 1;
  padding: 12px 14px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 13px;
  color: #1f2937;
  resize: none;
  font-family: inherit;
  transition: all 0.2s;
  max-height: 120px;
  overflow-y: auto;
  line-height: 1.5;
  min-height: 100px;
}

.agent-input-field:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.agent-input-field::placeholder {
  color: #9ca3af;
  font-size: 13px;
}

.agent-send-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: none;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.agent-send-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.agent-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.agent-send-btn svg {
  width: 18px;
  height: 18px;
}

/* All floating bar styles strictly in mobile media query below */
.agent-mobile-floating-bar {
  display: none;
}

@keyframes slideUpFade {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.pulse-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(139, 92, 246, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #7c3aed;
  flex-shrink: 0;
  transition: opacity 0.2s ease;
}

.pulse-icon svg {
  width: 18px;
  height: 18px;
  animation: pulseColor 2s infinite;
}

.bar-collapse-btn {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.bar-collapse-btn:hover {
  background: rgba(0, 0, 0, 0.1);
}

@keyframes pulseColor {
  0% {
    transform: scale(1);
    opacity: 0.8;
  }

  50% {
    transform: scale(1.1);
    opacity: 1;
  }

  100% {
    transform: scale(1);
    opacity: 0.8;
  }
}

/* Update mobile responsive styles */
/* Consolidated Mobile Response Styles */
@media (max-width: 768px) {

  /* Replace toggle button with floating bar */
  .agent-mobile-toggle {
    display: none !important;
  }

  .agent-mobile-floating-bar {
    display: flex !important;
    position: fixed;
    bottom: 80px;
    /* Float above the bottom nav */
    left: 50%;
    transform: translateX(-50%) translateY(0);
    height: 50px;
    width: calc(100% - 40px);
    background: #ffffff;
    /* Expanded state: White background */
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    /* Colorful gradient border */
    border: 1px solid rgb(209, 134, 241);
    background-image: linear-gradient(white, white), linear-gradient(135deg, #667eea 0%, #764ba2 100%, #f1b2ff 100%);
    background-origin: border-box;
    background-clip: padding-box, border-box;
    border-radius: 25px;
    z-index: 10001;
    /* High enough to be over everything */
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    animation: slideUpFade 0.5s ease-out;
    overflow: visible !important;
  }

  @keyframes slideUpFade {
    from {
      opacity: 0;
      transform: translateX(-50%) translateY(20px);
    }

    to {
      opacity: 1;
      transform: translateX(-50%) translateY(0);
    }
  }

  /* Bubble State: Purple Pill with text */
  .agent-mobile-floating-bar.is-bubble {
    width: auto !important;
    min-width: 130px;
    height: 50px;
    max-width: 130px;
    padding: 0 15px 0 12px;
    border-radius: 25px;
    background-image: linear-gradient(135deg, #6366f1 0%, #a855f7 100%) !important;
    border: none;
    display: flex !important;
    align-items: center;
    justify-content: center;
    overflow: visible;
    left: 80%;
  }

  .bubble-text {
    display: none;
  }

  .agent-mobile-floating-bar.is-bubble .bubble-text {
    display: inline;
  }

  .agent-mobile-floating-bar.is-bubble .sparkle-icon {
    color: white;
    font-size: 15px;
    font-weight: 700;
    width: auto;
    height: auto;
    display: inline-block;
    white-space: nowrap;
  }

  .agent-mobile-floating-bar .sparkle-icon {
    transition: all 0.3s ease;
  }

  .floating-bar-content {
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0 10px;
    gap: 12px;
    width: 100%;
    white-space: nowrap;
  }

  .sparkle-icon {
    font-size: 18px;
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .mobile-agent-input {
    flex: 1;
    background: transparent;
    border: none;
    font-size: 13px;
    color: #1e293b;
    padding: 0;
    outline: none;
    font-family: inherit;
    transition: opacity 0.3s ease;
    width: 0;
    /* Let flexbox expand it */
  }

  .mobile-agent-input::placeholder {
    color: #94a3b8;
    font-weight: 400;
  }

  .mobile-agent-send-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin-left: 8px;
    padding: 0;
    transition: transform 0.2s ease, opacity 0.2s ease;
  }

  .mobile-agent-send-btn svg {
    width: 16px;
    height: 16px;
    stroke-width: 2.5;
  }

  .agent-mobile-floating-bar.is-bubble .mobile-agent-input,
  .agent-mobile-floating-bar.is-bubble .bar-collapse-btn,
  .agent-mobile-floating-bar.is-bubble .mobile-agent-send-btn {
    opacity: 0;
    pointer-events: none;
  }

  /* When panel is open, hide the floating bar */
  .mobile-agent-open .agent-mobile-floating-bar {
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) translateY(20px);
  }

  /* Show backdrop when panel is open */
  .mobile-agent-open .agent-mobile-backdrop {
    display: block !important;
    opacity: 1;
  }

  /* Backdrop base styles */
  .agent-mobile-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
  }

  /* AI Agent Sidebar as Bottom Sheet on Mobile */
  /* Using higher specificity to override wedding_editor.css */
  .editor-sidebar-left.ai-agent-sidebar {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    top: auto !important;
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    height: 50vh;
    display: flex !important;
    flex-direction: column !important;
    z-index: 9999 !important;
    border-radius: 24px 24px 0 0 !important;
    transform: translateY(105%) !important;
    transition: transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1), height 0.3s ease !important;
    box-shadow: 0 -10px 25px rgba(0, 0, 0, 0.2) !important;
    background: #ffffff !important;
    overflow: hidden !important;
  }

  /* Disable transitions during drag for real-time feedback */
  .editor-sidebar-left.ai-agent-sidebar.is-dragging {
    transition: none !important;
  }

  .mobile-agent-open .editor-sidebar-left.ai-agent-sidebar {
    transform: translateY(0) !important;
    visibility: visible !important;
    opacity: 1 !important;
  }

  .mobile-agent-open .editor-sidebar-left.ai-agent-sidebar.mobile-expanded {
    height: 90vh;
    /* No !important here to let drag handle override it */
  }

  /* Bottom sheet handle - Larger hit area for easier dragging */
  .mobile-sheet-handle {
    width: 60px;
    height: 6px;
    background: #cbd5e1;
    border-radius: 4px;
    margin: 12px auto 8px;
    padding: 10px 0;
    /* Vertical hit area expanded */
    background-clip: content-box;
    /* Maintain visual bar while having larger hit area */
    flex-shrink: 0;
    cursor: grab;
    transition: background 0.2s ease;
  }

  .mobile-sheet-handle:active {
    background: #94a3b8;
    cursor: grabbing;
  }

  /* Specific hit area for dragging */
  .mobile-sheet-handle,
  .agent-panel-header {
    touch-action: none !important;
  }

  /* Adjustments for the panel inside sidebar */
  .ai-agent-panel {
    border-radius: 24px 24px 0 0 !important;
    height: 100% !important;
  }

  .agent-panel-header {
    padding: 12px 16px !important;
    border-radius: 0 !important;
  }
}

/* Extra small screens adjustments */
@media (max-width: 480px) {
  .editor-sidebar-left.ai-agent-sidebar.mobile-expanded {
    height: 92vh !important;
  }
}