/* Sidebar - Document Management */
.sidebar {
  width: 360px;
  min-width: 320px;
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100%;
  z-index: 10;
  transition: transform var(--transition-normal);
  overflow-x: hidden;
}


.sidebar-header {
  height: var(--navbar-height, 60px);
  min-height: var(--navbar-height, 60px);
  max-height: var(--navbar-height, 60px);
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  gap: 8px;
  box-sizing: border-box;
}

.sidebar-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-close-btn {
  display: none;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.sidebar-close-btn:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.35);
  color: var(--status-failed);
}

.sidebar-backdrop {
  display: none;
}

.mobile-sidebar-toggle {
  display: none;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: var(--radius-md);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  padding: 8px;
  transition: all var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.mobile-sidebar-toggle:hover {
  background: rgba(99, 102, 241, 0.12);
  border-color: rgba(99, 102, 241, 0.4);
}

.mobile-sidebar-toggle .hamburger-bar {
  display: block;
  width: 18px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.logo-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.1rem;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1rem;
  box-shadow: var(--shadow-glow);
  -webkit-text-fill-color: initial;
}

/* Sidebar Navigation Tabs */
.sidebar-tabs {
  display: flex;
  align-items: stretch;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
  padding: 4px 6px 0;
  gap: 4px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
}

.sidebar-tabs::-webkit-scrollbar {
  display: none;
}

.sidebar-tab {
  flex: 1 0 auto;
  min-width: max-content;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 8px 10px;
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  user-select: none;
}

.sidebar-tab .tab-icon {
  font-size: 0.85rem;
  flex-shrink: 0;
  line-height: 1;
  display: inline-flex;
  align-items: center;
}

.sidebar-tab .tab-label {
  white-space: nowrap;
  overflow: visible;
  text-overflow: clip;
}

.sidebar-tab:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.sidebar-tab.active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
  background: rgba(99, 102, 241, 0.12);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  font-weight: 600;
}

.tab-badge {
  font-size: 0.62rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0 5px;
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  flex-shrink: 0;
  min-width: 17px;
  height: 17px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.sidebar-tab.active .tab-badge {
  background: rgba(99, 102, 241, 0.25);
  border-color: rgba(99, 102, 241, 0.4);
  color: #a5b4fc;
}


.tab-panel {
  display: none;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
}

.tab-panel.active {
  display: flex;
}

/* History List Panel */
.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: all var(--transition-fast);
}

.history-card:hover {
  border-color: var(--accent-primary);
  background: var(--bg-hover);
  transform: translateY(-1px);
}

.history-card.active {
  border-color: var(--accent-primary);
  background: rgba(99, 102, 241, 0.12);
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.18);
}

.history-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.history-title {
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.history-del-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 5px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  opacity: 0.6;
  transition: all var(--transition-fast);
}

.history-del-btn:hover {
  opacity: 1;
  color: var(--status-failed);
  background: rgba(239, 68, 68, 0.1);
}

.history-empty {
  text-align: center;
  padding: 36px 14px;
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.6;
}

/* Upload Dropzone */
.upload-section {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.dropzone {
  border: 2px dashed rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md);
  padding: 20px 16px;
  text-align: center;
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--accent-primary);
  background: rgba(99, 102, 241, 0.08);
  box-shadow: var(--shadow-glow);
}

.dropzone-icon {
  font-size: 1.8rem;
  margin-bottom: 8px;
  color: var(--accent-primary);
}

.dropzone-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.dropzone-text span {
  color: var(--accent-primary);
  font-weight: 500;
}

.dropzone-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* Dynamic File Uploading Loader States */
.dropzone.uploading {
  border-color: var(--accent-primary) !important;
  background: rgba(99, 102, 241, 0.12) !important;
  pointer-events: none;
  cursor: wait;
}

.dropzone-upload-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}

.dropzone-upload-spinner {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 3px solid rgba(99, 102, 241, 0.2);
  border-top-color: var(--accent-primary);
  border-right-color: #a855f7;
  animation: docsSpinnerRotate 0.8s linear infinite;
  box-shadow: 0 0 16px var(--accent-glow);
}

.dropzone-upload-text {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.dropzone-upload-subtext {
  font-size: 0.72rem;
  color: var(--accent-primary);
  max-width: 90%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  animation: docsPulseText 1.5s ease-in-out infinite;
}

.dropzone-progress-bar {
  width: 85%;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 4px;
}

.dropzone-progress-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--accent-primary), #a855f7);
  animation: docsShimmer 1.5s infinite;
}

/* Uploading placeholder card in docs list */
.doc-card-uploading {
  background: rgba(99, 102, 241, 0.08);
  border: 1px dashed rgba(99, 102, 241, 0.4);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  animation: docsPulseText 2s ease-in-out infinite;
}

/* Document Library */
.docs-header {
  padding: 14px 20px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.docs-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
}

.docs-count {
  font-size: 0.75rem;
  background: var(--bg-tertiary);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  color: var(--text-secondary);
}

.docs-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Knowledge Library Loader & Skeleton Styles */
.docs-loader-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 4px;
  gap: 14px;
  width: 100%;
}

.docs-loader-spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid rgba(99, 102, 241, 0.15);
  border-top-color: var(--accent-primary);
  border-right-color: #a855f7;
  animation: docsSpinnerRotate 0.8s linear infinite;
  box-shadow: 0 0 14px var(--accent-glow);
}

.docs-loader-text {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
  animation: docsPulseText 1.5s ease-in-out infinite;
}

.docs-skeleton-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  margin-top: 4px;
}

.doc-skeleton-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  overflow: hidden;
}

.doc-skeleton-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg,
      transparent 0%,
      rgba(255, 255, 255, 0.06) 50%,
      transparent 100%);
  animation: docsShimmer 1.8s infinite;
}

.skeleton-line {
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.06);
}

.skeleton-line.skeleton-header {
  height: 13px;
  width: 75%;
}

.skeleton-line.skeleton-sub {
  height: 9px;
  width: 45%;
}

@keyframes docsSpinnerRotate {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

@keyframes docsPulseText {

  0%,
  100% {
    opacity: 0.6;
  }

  50% {
    opacity: 1;
  }
}

@keyframes docsShimmer {
  0% {
    transform: translateX(0%);
  }

  100% {
    transform: translateX(200%);
  }
}

.doc-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  transition: all var(--transition-fast);
  position: relative;
}

.doc-card:hover {
  background: var(--bg-hover);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}

.doc-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.doc-info {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}

.doc-icon {
  font-size: 1.1rem;
}

.doc-name {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 170px;
}

.doc-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.doc-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 4px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
  transition: color var(--transition-fast);
}

.doc-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.doc-btn.delete:hover {
  color: var(--status-failed);
}

.doc-meta {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Status Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.7rem;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  font-weight: 500;
  text-transform: capitalize;
}

.status-badge.completed {
  background: rgba(16, 185, 129, 0.15);
  color: var(--status-completed);
}

.status-badge.processing {
  background: rgba(59, 130, 246, 0.15);
  color: var(--status-processing);
}

.status-badge.queued {
  background: rgba(245, 158, 11, 0.15);
  color: var(--status-queued);
}

.status-badge.failed {
  background: rgba(239, 68, 68, 0.15);
  color: var(--status-failed);
}

.status-pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: currentColor;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {

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

  50% {
    opacity: 0.4;
    transform: scale(0.8);
  }
}


/* Room Workspace Cards in Sidebar */
/* ==========================================================================
   Room Workspace & Multi-File Management
   ========================================================================== */
.room-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.room-card:hover {
  background: var(--bg-hover);
  border-color: rgba(99, 102, 241, 0.3);
  transform: translateY(-1px);
}

.room-card.active {
  border-color: var(--accent-primary);
  background: rgba(99, 102, 241, 0.12);
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.15);
}

.room-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.room-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

.room-badge-active {
  font-size: 0.65rem;
  padding: 2px 6px;
  background: var(--accent-primary);
  color: white;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

.room-desc {
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.35;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.room-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.room-actions {
  display: flex;
  gap: 4px;
}

.room-action-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 3px 5px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  opacity: 0.6;
  transition: opacity var(--transition-fast);
}

.room-action-btn:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.1);
}

