:root {
  /* Professional palette: dark headings, muted body, subtle accent */
  --accent: #6b21a8;
  /* primary accent (used sparingly) */
  --heading: #0f172a;
  /* near-black for headings */
  --muted: #6b7280;
  /* muted body text */
  --card-bg: #ffffff;
  --border: #e6e6e6;
  --surface-ghost: #fbf9ff;
}

.container {
  padding: var(--space-lg);
  max-width: 1400px;
  margin: 0 auto;
}

@media (max-width: 768px) {
  .container {
    padding: var(--space-md);
  }
}

@media (max-width: 480px) {
  .container {
    padding: var(--space-sm);
  }
}

.headerRow {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}

.backButton {
  background: transparent;
  border: none;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 0;
  font-size: 14px;
  transition: color 0.2s;
}

.backButton:hover {
  color: var(--heading);
}

.title {
  color: var(--heading);
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.layout {
  display: flex;
  gap: 20px;
  margin-top: 20px;
}

.singleColumnLayout {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.leftColumn {
  width: 34%;
}

.rightColumn {
  flex: 1;
}

.cardHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  background: #fafafa;
}

.cardTitle {
  margin: 0;
  color: var(--heading);
  font-size: 18px;
  font-weight: 700;
}

.kbList {
  margin-top: 12px;
}

.kbItem {
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  background: var(--card-bg);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.kbItemSelected {
  background: rgba(107, 33, 168, 0.06);
  /* subtle purple tint */
  border: 1px solid var(--accent);
}

.kbItem:hover {
  box-shadow: 0 2px 8px rgba(107, 33, 168, 0.08);
}

.kbIcon {
  color: var(--muted);
  width: 20px;
  height: 20px;
}

/* color icon when its item is selected */
.kbItemSelected .kbIcon {
  color: var(--accent);
}

.kbName {
  font-weight: 700;
}

.kbId {
  font-size: 12px;
  color: var(--muted);
}

.kbSelectedName {
  color: var(--muted);
}

.uploadToggle {
  display: flex;
  gap: 4px;
  align-items: center;
  background: #f8f9fa;
  padding: 4px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.uploadLabel {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--muted);
}

.uploadLabel:has(input:checked) {
  background: white;
  color: var(--accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.uploadLabel input[type="radio"] {
  display: none;
}

.uploadArea {
  margin-top: 0;
  padding: 24px;
}

.fileRow {
  display: flex;
  gap: 8px;
  align-items: center;
}

.urlInput {
  flex: 1;
  padding: 8px;
  border-radius: 6px;
  border: 1px solid #e6e6e6;
}

.docsList {
  margin-top: 24px;
}

.noDocs {
  color: var(--muted);
}

.docItem {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: white;
}

.docItem:hover {
  background: #faf7ff;
}

.docMeta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.docIcon {
  color: var(--muted);
}

.docIcon {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.docMeta>div {
  flex: 1;
  min-width: 0;
  /* Allow shrinking below content width */
}

.docName {
  font-weight: 700;
}

.docName {
  font-weight: 700;
}

.docType {
  font-size: 12px;
  color: var(--muted);
}

.docActions {
  display: flex;
  gap: 8px;
}

/* file input styling */
.fileLabel {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  border: 1px solid rgba(107, 33, 168, 0.12);
  transition: all 0.2s;
  box-shadow: 0 1px 2px rgba(107, 33, 168, 0.1);
}

.fileLabel:hover {
  background: color-mix(in srgb, var(--accent) 88%, black 12%);
  box-shadow: 0 4px 12px rgba(107, 33, 168, 0.2);
  transform: translateY(-1px);
}

.fileLabel:active {
  transform: translateY(0);
}

.fileLabel:focus {
  outline: 3px solid rgba(107, 33, 168, 0.12);
  outline-offset: 2px;
}

.fileInput {
  display: none;
}

.fileLabelIcon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.fileName {
  color: var(--muted);
  font-size: 13px;
  margin-left: 8px;
}

.fileRow {
  display: flex;
  gap: 12px;
  align-items: center;
  background: var(--surface-ghost);
  padding: 16px;
  border-radius: 12px;
  border: 1px dashed var(--border);
}

.urlInput {
  flex: 1;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 14px;
}

.urlInput:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(107, 33, 168, 0.1);
}

.cardHeader {
  padding: 12px 16px;
}

.cardTitle {
  font-size: 16px
}

/* Unified drag and drop zone */
.dropZone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 280px;
  padding: 48px 32px;
  background: linear-gradient(135deg, #fafbfc 0%, var(--surface-ghost) 100%);
  border: 2px dashed var(--border);
  border-radius: 16px;
  cursor: pointer;
  position: relative;
  text-align: center;
}

.dropZone.compact {
  min-height: 140px;
  padding: 24px 32px;
  margin-bottom: 24px;
}

.dropZone:hover {
  background: linear-gradient(135deg, #fff 0%, rgba(107, 33, 168, 0.04) 100%);
  border-color: rgba(107, 33, 168, 0.3);
}

.dropZone.dragging {
  background: linear-gradient(135deg, rgba(107, 33, 168, 0.08) 0%, rgba(107, 33, 168, 0.12) 100%);
  border-color: var(--accent);
  border-width: 3px;
  box-shadow: 0 0 0 4px rgba(107, 33, 168, 0.1), 0 12px 32px rgba(107, 33, 168, 0.2);
  transform: scale(1.02);
}

.dropZone.hasFile {
  background: white;
  border-color: var(--accent);
  border-style: solid;
}

.dropZone.compact.hasFile {
  min-height: 120px;
  padding: 20px 24px;
}

.dropZoneIcon {
  color: var(--accent);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  background: rgba(107, 33, 168, 0.08);
  border-radius: 50%;
}

.dropZone.compact .dropZoneIcon {
  width: 56px;
  height: 56px;
  margin-bottom: 12px;
}

.dropZone:hover .dropZoneIcon {
  background: rgba(107, 33, 168, 0.15);
}

.dropZone.dragging .dropZoneIcon {
  animation: bounce 0.6s ease-in-out infinite;
}

@keyframes bounce {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-10px);
  }
}

.dropZone.uploading {
  pointer-events: none;
  opacity: 0.95;
}

.progressBar {
  width: 100%;
  max-width: 400px;
  height: 8px;
  background: rgba(107, 33, 168, 0.1);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 12px;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.progressBarFill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent) 0%, #8b5cf6 100%);
  border-radius: 999px;
  transition: width 0.3s ease;
  box-shadow: 0 0 8px rgba(107, 33, 168, 0.4);
}

.progressText {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  margin-top: 8px;
}

.dropZoneTitle {
  font-size: 20px;
  font-weight: 700;
  color: var(--heading);
  margin-bottom: 8px;
}

.dropZone.compact .dropZoneTitle {
  font-size: 16px;
  margin-bottom: 6px;
}

.dropZoneSubtitle {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 16px;
  font-weight: 500;
}

.dropZone.compact .dropZoneSubtitle {
  font-size: 13px;
  margin-bottom: 0;
}

.dropZoneText {
  font-size: 14px;
  color: var(--muted);
  max-width: 480px;
  line-height: 1.6;
  margin-bottom: 20px;
}

.dropZoneHint {
  font-size: 12px;
  color: var(--muted);
  background: white;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.dropZoneIconSmall {
  color: var(--accent);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.selectedFileInfo {
  margin-bottom: 16px;
}

.dropZone.compact .selectedFileInfo {
  margin-bottom: 12px;
}

.selectedFileName {
  font-size: 15px;
  font-weight: 700;
  color: var(--heading);
  margin-bottom: 4px;
  max-width: 400px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dropZone.compact .selectedFileName {
  font-size: 14px;
}

.selectedFileHint {
  font-size: 13px;
  color: var(--muted);
}

.dropZone.compact .selectedFileHint {
  font-size: 12px;
}

.uploadButtonWrapper {
  margin-top: 8px;
}

.uploadButtonWrapper button {
  min-width: 140px;
}

.dropZone.compact .uploadButtonWrapper button {
  min-width: 100px;
}

.uploadControls {
  display: flex;
  gap: 16px;
  align-items: center;
  background: var(--surface-ghost);
  padding: 16px;
  border-radius: 12px;
  border: 1px dashed var(--border);
  transition: all 0.3s ease;
  position: relative;
}

.uploadControls.dragging {
  background: rgba(107, 33, 168, 0.08);
  border-color: var(--accent);
  border-width: 2px;
  box-shadow: 0 0 0 4px rgba(107, 33, 168, 0.1);
  transform: scale(1.01);
}

.uploadControls.dragging::after {
  content: "Drop file here";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  pointer-events: none;
  background: white;
  padding: 12px 24px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(107, 33, 168, 0.2);
}

.fileMeta {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  justify-content: space-between;
}

.fileNamePill {
  background: #ffffff;
  color: var(--heading);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid var(--border);
  flex: 1;
  max-width: 400px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.uploadActions {
  display: flex;
  gap: 8px;
}

.docItem {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

@media (max-width: 640px) {
  .docItem {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .docActions {
    width: 100%;
    justify-content: flex-end;
  }
}

.docMeta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.docIcon {
  color: var(--muted);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.docName {
  font-weight: 700;
  font-size: 14px
}

.docType {
  font-size: 12px;
  color: var(--muted);
}

.docActions button {
  min-width: 64px;
}

/* empty state styles */
.emptyState {
  padding: 48px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  border-radius: 12px;
  background: linear-gradient(180deg, #fff 0%, var(--surface-ghost) 100%);
  text-align: center;
  border: 2px dashed var(--border);
  margin-top: 24px;
}

.emptyIcon {
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(107, 33, 168, 0.08);
  width: 72px;
  height: 72px;
  border-radius: 50%;
  margin-bottom: 8px;
}

.emptyTitle {
  font-weight: 700;
  font-size: 20px;
  color: var(--heading);
  margin-top: 4px;
}

.emptyText {
  color: var(--muted);
  max-width: 480px;
  font-size: 14px;
  line-height: 1.6;
}

/* Responsive: stack columns on small screens */
@media (max-width: 900px) {
  .layout {
    flex-direction: column
  }

  .leftColumn {
    width: 100%
  }
}

/* Document content modal styles */
.documentContent {
  max-height: 500px;
  overflow-y: auto;
  padding: 16px;
  background: #f9f9f9;
  border-radius: 8px;
}

.documentContent pre {
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: 'Georgia', 'Times New Roman', serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--heading);
  margin: 0;
}

.documentContent a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.documentContent a:hover {
  text-decoration: underline;
}

.noContentMessage {
  color: var(--muted);
  font-style: italic;
  text-align: center;
  padding: 24px;
}

.docActions {
  display: flex;
  gap: 8px;
}

.docActions button {
  display: flex;
  align-items: center;
  gap: 4px;
}