/* ==========================================================================
   Sources panel: documents list, drag&drop, preview
   ========================================================================== */

.source-list { display: flex; flex-direction: column; gap: var(--space-2); }

.source-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: all var(--duration-fast) var(--ease-out);
  position: relative;
}
.source-item:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-xs);
}
.source-item.highlighted {
  border-color: var(--color-primary-500);
  box-shadow: var(--shadow-ring);
  background: var(--color-primary-50);
}
[data-theme="dark"] .source-item.highlighted,
:root:not([data-theme="light"]) .source-item.highlighted {
  background: rgba(99, 102, 241, 0.12);
}

.source-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-md);
  background: var(--bg-surface-2);
  color: var(--color-primary-600);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.source-icon svg { width: 18px; height: 18px; }

.source-meta { flex: 1; min-width: 0; }
.source-meta .title {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--fg-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.source-meta .filename {
  font-size: var(--fs-xs);
  color: var(--fg-tertiary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.source-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity var(--duration-fast) var(--ease-out);
}
.source-item:hover .source-actions { opacity: 1; }
@media (max-width: 1023px) { .source-actions { opacity: 1; } }
.source-actions .btn-icon { width: 28px; height: 28px; }
.source-actions .btn-icon .icon { width: 14px; height: 14px; }

/* ---------- Drop zone (manager) ---------- */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-5);
  background: var(--bg-surface);
  border: 2px dashed var(--border-default);
  border-radius: var(--radius-lg);
  color: var(--fg-tertiary);
  text-align: center;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--color-primary-500);
  background: var(--color-primary-50);
  color: var(--color-primary-700);
}
[data-theme="dark"] .dropzone:hover, [data-theme="dark"] .dropzone.dragover,
:root:not([data-theme="light"]) .dropzone:hover, :root:not([data-theme="light"]) .dropzone.dragover {
  background: rgba(99, 102, 241, 0.10);
  color: var(--color-primary-200);
}
.dropzone svg { width: 28px; height: 28px; }
.dropzone .label { font-weight: var(--fw-medium); font-size: var(--fs-sm); }
.dropzone .hint { font-size: var(--fs-xs); }

/* Upload progress chip */
.upload-progress {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--bg-surface-2);
  border-radius: var(--radius-md);
  font-size: var(--fs-xs);
  color: var(--fg-secondary);
  margin-top: var(--space-2);
}
.upload-progress .spinner { width: 14px; height: 14px; border-width: 2px; }

/* ---------- Source preview overlay/bottom-sheet ---------- */
.source-preview-overlay {
  position: fixed; inset: 0;
  background: var(--bg-overlay);
  z-index: var(--z-modal);
  display: flex; align-items: center; justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-base) var(--ease-out);
}
.source-preview-overlay.open { opacity: 1; pointer-events: auto; }
.source-preview {
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: min(720px, 100%);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.96);
  transition: transform var(--duration-base) var(--ease-out);
}
.source-preview-overlay.open .source-preview { transform: scale(1); }
.source-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
}
.source-preview-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-5);
  font-size: var(--fs-sm);
  line-height: var(--lh-loose);
  color: var(--fg-primary);
  white-space: pre-wrap;
  word-wrap: break-word;
}
.source-preview-body mark {
  background: var(--color-accent-500);
  color: #1f2937;
  padding: 1px 3px;
  border-radius: var(--radius-sm);
}

@media (max-width: 767px) {
  .source-preview-overlay { align-items: flex-end; padding: 0; }
  .source-preview {
    width: 100%;
    max-height: 90vh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    transform: translateY(100%);
  }
  .source-preview-overlay.open .source-preview { transform: translateY(0); }
}
