/* ===== Reset & Variables ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-primary: #0f0f0f;
  --bg-secondary: #1a1a1a;
  --bg-tertiary: #242424;
  --bg-hover: #2a2a2a;
  --text-primary: #e8e8e8;
  --text-secondary: #a0a0a0;
  --text-muted: #666;
  --accent: #6c63ff;
  --accent-hover: #7c74ff;
  --accent-muted: rgba(108, 99, 255, 0.15);
  --success: #4caf50;
  --warning: #ff9800;
  --error: #f44336;
  --border: #333;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --transition: 0.2s ease;
}

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

/* ===== Header ===== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-header h1 {
  font-size: 1.4rem;
  font-weight: 700;
}

.icon-btn {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}

.icon-btn:hover {
  background: var(--bg-hover);
}

/* ===== Main Content ===== */
.main-content {
  max-width: 800px;
  margin: 0 auto;
  padding: 24px;
}

/* ===== Steps ===== */
.step {
  display: none;
  animation: fadeIn 0.3s ease;
}

.step.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.step-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.step-number {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
}

.step-header h2 {
  font-size: 1.3rem;
  font-weight: 600;
}

/* ===== Dropzone ===== */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--bg-secondary);
}

.dropzone:hover, .dropzone.drag-over {
  border-color: var(--accent);
  background: var(--accent-muted);
}

.dropzone-small {
  padding: 24px;
}

.dropzone-icon {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 12px;
}

.dropzone p {
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.dropzone-hint {
  font-size: 0.85rem;
  color: var(--text-muted) !important;
}

.upload-section {
  margin-top: 32px;
}

.upload-section h3 {
  font-size: 1rem;
  margin-bottom: 8px;
}

.section-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.optional, .required {
  font-size: 0.8rem;
  font-weight: 400;
}

.optional { color: var(--text-muted); }
.required { color: var(--error); }

/* ===== File List ===== */
.file-list {
  margin-top: 12px;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  cursor: grab;
  transition: background var(--transition);
}

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

.file-item.dragging {
  opacity: 0.5;
  cursor: grabbing;
}

.file-item .file-icon {
  font-size: 1.2rem;
}

.file-item .file-info {
  flex: 1;
}

.file-item .file-name {
  font-weight: 500;
  font-size: 0.95rem;
}

.file-item .file-size {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.file-item .file-chunks {
  font-size: 0.75rem;
  color: var(--warning);
}

.file-item .file-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all var(--transition);
}

.file-item .file-remove:hover {
  color: var(--error);
  background: rgba(244, 67, 54, 0.1);
}

.file-item .drag-handle {
  color: var(--text-muted);
  cursor: grab;
  font-size: 1rem;
}

/* ===== Config ===== */
.config-grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.config-card {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--border);
}

.config-card label {
  font-weight: 600;
  font-size: 0.95rem;
  display: block;
  margin-bottom: 12px;
}

.config-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 8px;
}

.radio-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.radio-btn {
  padding: 10px 18px;
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.9rem;
  transition: all var(--transition);
}

.radio-btn:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.radio-btn.active {
  background: var(--accent-muted);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

/* ===== Pipeline ===== */
.pipeline {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.pipeline-stage {
  display: grid;
  grid-template-columns: 40px 120px 1fr 80px;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.stage-icon {
  font-size: 1.3rem;
  text-align: center;
}

.stage-label {
  font-weight: 500;
}

.stage-progress {
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
}

.stage-progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  width: 0%;
  transition: width 0.5s ease;
}

.stage-status {
  text-align: right;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.pipeline-stage.active {
  border-color: var(--accent);
}

.pipeline-stage.active .stage-status {
  color: var(--accent);
}

.pipeline-stage.done .stage-progress-bar {
  background: var(--success);
  width: 100%;
}

.pipeline-stage.done .stage-status {
  color: var(--success);
}

.pipeline-stage.error .stage-status {
  color: var(--error);
}

/* ===== Log Output ===== */
.log-output {
  margin-top: 20px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.8rem;
  max-height: 300px;
  overflow-y: auto;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.log-output .log-entry {
  padding: 2px 0;
}

.log-output .log-entry.error {
  color: var(--error);
}

.log-output .log-entry.success {
  color: var(--success);
}

.log-output .log-entry .timestamp {
  color: var(--text-muted);
  margin-right: 8px;
}

/* ===== Results ===== */
.results-area {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.result-card {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--border);
}

.result-card h3 {
  margin-bottom: 12px;
  font-size: 1.05rem;
}

.result-card .result-body {
  font-size: 0.9rem;
  color: var(--text-secondary);
  white-space: pre-wrap;
  max-height: 400px;
  overflow-y: auto;
}

/* ===== Buttons ===== */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
}

.action-bar {
  display: flex;
  justify-content: space-between;
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* ===== Modal ===== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
}

.modal-content {
  position: relative;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  width: 90%;
  max-width: 500px;
  max-height: 85vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

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

.modal-header h2 {
  font-size: 1.2rem;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}

.modal-close:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}

/* ===== Settings ===== */
.setting-group {
  margin-bottom: 24px;
}

.setting-group:last-child {
  margin-bottom: 0;
}

.setting-group label {
  font-weight: 600;
  font-size: 0.9rem;
  display: block;
  margin-bottom: 8px;
}

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

.setting-hint a {
  color: var(--accent);
  text-decoration: none;
}

.setting-hint a:hover {
  text-decoration: underline;
}

.input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.9rem;
  transition: border-color var(--transition);
}

.input:focus {
  outline: none;
  border-color: var(--accent);
}

.input::placeholder {
  color: var(--text-muted);
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
  .main-content {
    padding: 16px;
  }

  .pipeline-stage {
    grid-template-columns: 32px 1fr;
    grid-template-rows: auto auto;
    gap: 4px 8px;
  }

  .stage-progress {
    grid-column: 1 / -1;
  }

  .stage-status {
    display: none;
  }

  .radio-group {
    flex-direction: column;
  }

  .radio-btn {
    text-align: center;
  }
}
