/* ===================================== */
/* AI ASSISTANT - REDESIGNED LAYOUT */
/* ===================================== */

/* Root application container with background image */
.app {
  width: 100%;
  height: 100%;
  position: fixed;
  inset: 0;
  background: url('../assets/stickerbookappicon.png') center center / cover no-repeat fixed;
  overflow: hidden;
}

.app.hidden {
  display: none;
}

/* Main shell - transparent, allows background to show through */
.admin-shell {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: transparent;
}

/* View container - transparent */
.view-container {
  display: none;
  flex: 1;
  width: 100%;
  height: 100%;
  background: transparent;
}

.view-container.active {
  display: flex;
}

/* Floating Icon Dock (Bottom Left) */
.icon-dock {
  position: fixed;
  bottom: 24px;
  left: 24px;
  display: flex;
  gap: 16px;
  z-index: 100;
}

.dock-icon {
  width: 48px;
  height: 48px;
  background: white;
  border: none;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.dock-icon:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
}

.dock-icon svg {
  width: 24px;
  height: 24px;
  color: #374151;
}

/* Chat Panel (Right side, anchored) */
.ai-chat-panel {
  position: fixed;
  right: 24px;
  top: 50%;
  transform: translateY(-50%);
  width: calc((100vh - 48px) * 9 / 16);
  height: calc(100vh - 48px);
  max-width: 500px;

  background: white;
  border-radius: 16px;
  border: 4px solid var(--color-purple);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);

  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* View Modal (Left area, no overlap with chat) */
.view-modal {
  position: fixed;
  top: 24px;
  left: 24px;
  bottom: 96px; /* Above dock: 24px bottom + 48px dock height + 24px gap = 96px */
  /* Chat panel left edge: 100vw - 500px (chat width) - 24px (right padding) = 100vw - 524px */
  /* Modal right edge: 20px gap before chat = 100vw - 524px - 20px = 100vw - 544px */
  right: 544px;
  z-index: 50;

  display: flex;
  align-items: stretch;
  justify-content: stretch;
  pointer-events: none;
}

.view-modal.hidden {
  display: none;
}

.view-modal-content {
  position: relative;
  width: 100%;
  height: 100%;
  background: white;
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.view-modal-search {
  position: absolute;
  top: 16px;
  right: 56px; /* 32px button width + 8px gap + 16px from edge = 56px */
  width: 32px;
  height: 32px;
  background: #f3f4f6;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  display: none; /* Hidden by default, shown only in Documents view */
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: all 0.15s ease;
}

.view-modal-search.visible {
  display: flex;
}

.view-modal-search:hover {
  background: #e5e7eb;
}

.view-modal-search svg {
  width: 18px;
  height: 18px;
  color: #6b7280;
}

.view-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  background: #f3f4f6;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: all 0.15s ease;
}

.view-modal-close:hover {
  background: #e5e7eb;
}

.view-modal-close svg {
  width: 18px;
  height: 18px;
  color: #6b7280;
}

.view-modal-back {
  position: absolute;
  top: 16px;
  left: 16px;
  width: 32px;
  height: 32px;
  background: #f3f4f6;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  display: none; /* Hidden by default, shown when viewing document */
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: all 0.15s ease;
}

.view-modal-back.visible {
  display: flex;
}

.view-modal-back:hover {
  background: #e5e7eb;
}

.view-modal-back svg {
  width: 18px;
  height: 18px;
  color: #6b7280;
}

.view-modal-body {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* When modal body has regular content (not file browser) */
.view-modal-body:not(:has(#artifact-preview)) {
  overflow-y: auto;
  padding: 24px;
}

/* Artifact preview container (in modal or standalone) */
#artifact-preview {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
  width: 100%;
}

/* Chat Container */
.ai-chat-container {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Clear Chat Button */
.ai-chat-clear {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border: none;
  background: #f3f4f6;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: all 0.15s ease;
}

.ai-chat-clear:hover {
  background: #e5e7eb;
}

.ai-chat-clear-icon {
  width: 18px;
  height: 18px;
  color: #6b7280;
}

/* Chat Messages */
.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

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

.ai-chat-messages::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 4px;
}

/* Messages */
.ai-message {
  display: flex;
  flex-direction: column;
  animation: fadeInUp 0.3s ease;
}

.message-avatar {
  font-size: 24px;
  margin-bottom: 8px;
}

.message-content {
  background: #f9fafb;
  border-radius: 12px;
  padding: 16px;
  border: 1px solid #e5e7eb;
}

.user-message .message-content {
  background: #ede9fe;
  border-color: #c4b5fd;
}

.message-text {
  font-size: 14px;
  line-height: 1.6;
  color: #374151;
  font-family: 'Poppins', sans-serif;
}

.message-time {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 8px;
}

/* Empty State */
.ai-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #9ca3af;
  text-align: center;
  padding: 48px;
}

.ai-empty-state h3 {
  font-size: 20px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 8px;
}

.ai-empty-state p {
  font-size: 14px;
  color: #6b7280;
  margin-bottom: 24px;
}

/* Typing Indicator */
.ai-typing-indicator {
  padding: 0;
  margin-top: 8px;
}

.ai-typing-bubble {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #f3f4f6;
  padding: 12px 16px;
  border-radius: 18px;
}

.ai-typing-dot {
  width: 8px;
  height: 8px;
  background: var(--color-purple);
  border-radius: 50%;
  animation: typing-bounce 1.4s infinite ease-in-out;
}

.ai-typing-dot:nth-child(1) { animation-delay: 0s; }
.ai-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.ai-typing-dot:nth-child(3) { animation-delay: 0.4s; }

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

/* Chat Input Area */
.ai-chat-input-container {
  padding: 16px 24px;
  border-top: 2px solid var(--color-purple);
  flex-shrink: 0;
  background: white;
}

.ai-chat-input-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.ai-chat-input {
  flex: 1;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 14px;
  resize: none;
  outline: none;
  transition: border-color 0.15s ease;
  font-family: 'Poppins', sans-serif;
  max-height: 120px;
  min-height: 48px;
}

.ai-chat-input:focus {
  border-color: var(--color-purple);
  box-shadow: 0 0 0 3px rgba(109, 40, 217, 0.1);
}

.ai-chat-upload {
  background: #e5e7eb;
  color: #4b5563;
  border: none;
  border-radius: 12px;
  padding: 12px;
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.ai-chat-upload:hover {
  background: #d1d5db;
  color: #1f2937;
}

.ai-chat-upload-icon {
  width: 20px;
  height: 20px;
}

.ai-chat-send {
  background: var(--color-purple);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 12px 24px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s ease;
  font-family: 'Poppins', sans-serif;
  height: 48px;
  flex-shrink: 0;
}

.ai-chat-send:hover {
  background: var(--color-purple-dark);
}

/* File Browser */
.file-browser {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  padding: 24px;
}

.file-browser-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 2px solid var(--color-turquoise);
  gap: 16px;
}

.file-browser-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
}

.breadcrumb-btn {
  background: transparent;
  border: none;
  color: #6b7280;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.15s ease;
}

.breadcrumb-btn:hover {
  background: #f3f4f6;
  color: #374151;
}

.file-browser-search {
  position: relative;
  width: 100%;
  margin-bottom: 16px;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: all 0.3s ease;
}

.file-browser-search.expanded {
  max-height: 50px;
  opacity: 1;
  margin-bottom: 16px;
}

.file-browser-search input {
  width: 100%;
  padding: 8px 36px 8px 12px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-size: 13px;
  transition: all 0.15s ease;
}

.file-browser-search input:focus {
  outline: none;
  border-color: var(--color-turquoise);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.1);
}

.file-search-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: #9ca3af;
}

.file-browser-content {
  flex: 1;
  overflow-y: auto;
}

.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.file-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: #f9fafb;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
}

.file-item:hover {
  background: white;
  border-color: var(--color-turquoise);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.file-icon {
  width: 32px;
  height: 32px;
  margin-bottom: 8px;
  color: var(--color-turquoise);
}

.file-name {
  font-size: 13px;
  font-weight: 500;
  color: #374151;
  word-break: break-word;
}

/* Artifact Content */
.artifact-content {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ai-artifact-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 2px solid var(--color-turquoise);
  flex-shrink: 0;
  background: white;
}

.ai-artifact-title {
  font-weight: 600;
  font-size: 16px;
  color: #1f2937;
}

.ai-artifact-type {
  font-size: 12px;
  color: #6b7280;
  background: #f3f4f6;
  padding: 4px 8px;
  border-radius: 4px;
  margin-left: 8px;
}

.ai-artifact-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  font-size: 14px;
  line-height: 1.6;
  color: #374151;
  background: white;
}

/* Message Attachments */
.message-attachments {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
  margin-bottom: 8px;
}

.message-attachment-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  max-width: 120px;
  transition: all 0.15s ease;
}

.message-attachment-item:hover {
  background: rgba(255, 255, 255, 0.9);
  border-color: var(--color-turquoise);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
}

.message-attachment-thumb {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  background: #f3f4f6;
}

.message-attachment-icon {
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  background: #f9fafb;
  border-radius: 8px;
}

.message-attachment-name {
  font-size: 11px;
  font-weight: 500;
  color: #374151;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.message-attachment-size {
  font-size: 10px;
  color: #9ca3af;
}

/* Preview Footer for file artifacts */
.preview-footer {
  display: flex;
  gap: 12px;
  padding: 16px 24px;
  border-top: 2px solid var(--color-turquoise);
  background: white;
  flex-shrink: 0;
  justify-content: flex-start;
}

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

/* Hide drop zone overlays */
.ai-drop-zone-overlay {
  display: none !important;
}

/* Responsive adjustments */
@media (max-width: 1400px) {
  .ai-preview-panel {
    height: calc(100vh - 40px);
    width: calc((100vh - 40px) * 13 / 10); /* Maintain 13:10 ratio */
    aspect-ratio: 13 / 10;
  }

  .ai-chat-panel {
    height: calc(100vh - 40px);
    width: calc((100vh - 40px) * 9 / 16);
    aspect-ratio: 9 / 16;
  }
}

@media (max-width: 1024px) {
  .ai-split-container {
    flex-direction: column;
    gap: 16px;
    padding: 16px;
  }

  .ai-preview-panel {
    width: 100%;
    height: 50vh;
    aspect-ratio: auto;
  }

  .ai-chat-panel {
    width: 100%;
    height: auto;
    flex: 1;
    aspect-ratio: auto;
  }
}
