/* ==========================================================
   chat.css — Chat page styles
   ========================================================== */

.chat-page {
  display: flex;
  height: 100%;
  overflow: hidden;
}

/* Chat sidebar */
.chat-sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width var(--duration-base) var(--ease-out);
}

.chat-sidebar.hidden { width: 0; }

.chat-sidebar-header {
  padding: var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-2);
}

.chat-list-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--duration-micro) var(--ease-out);
  position: relative;
}

.chat-list-item:hover { background: var(--bg-hover); }
.chat-list-item.active { background: var(--accent-subtle); }

.chat-list-item-title {
  flex: 1;
  font-size: var(--text-sm);
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-list-item.active .chat-list-item-title { color: var(--accent); }

.chat-list-item-date {
  font-size: 11px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.chat-item-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity var(--duration-micro) var(--ease-out);
}

.chat-list-item:hover .chat-item-actions { opacity: 1; }

/* Chat main area */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.chat-topbar {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-base);
  flex-shrink: 0;
}

.chat-title-area {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.chat-kb-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  white-space: nowrap;
}

.chat-topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

/* Retrieval status */
.retrieval-status {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
}

.retrieval-status .spin {
  animation: spin 1s linear infinite;
}

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

/* Context viewer panel */
.context-panel {
  width: 380px;
  flex-shrink: 0;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateX(100%);
  transition: transform var(--duration-base) var(--ease-out);
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  z-index: 20;
}

.context-panel.open {
  transform: translateX(0);
  position: relative;
}

.context-panel-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.context-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.context-chunk {
  background: var(--bg-surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}

.context-chunk-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-2);
  gap: var(--space-2);
}

.context-chunk-source {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--accent);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.context-chunk-score {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: var(--success-subtle);
  color: var(--success);
  white-space: nowrap;
  flex-shrink: 0;
}

.context-chunk-text {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
  max-height: 160px;
  overflow-y: auto;
  white-space: pre-wrap;
}

/* Export dropdown */
.export-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg-surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: 50;
  overflow: hidden;
  animation: scaleIn var(--duration-fast) var(--ease-spring) both;
  transform-origin: top right;
}

.export-menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-primary);
  cursor: pointer;
  transition: background var(--duration-micro) var(--ease-out);
  width: 100%;
  border: none;
  background: none;
  text-align: left;
  font-family: inherit;
}

.export-menu-item:hover { background: var(--bg-hover); }

@media (max-width: 1023px) {
  .chat-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 90;
    transform: translateX(-100%);
    transition: transform var(--duration-base) var(--ease-out);
    width: 280px;
  }
  .chat-sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: var(--shadow-xl);
  }
}
