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

:root {
  --bg: #0f0f1a;
  --surface: #1a1a2e;
  --surface-hover: #22223a;
  --border: #2a2a3e;
  --accent: #e2a03f;
  --accent-dim: #b8832a;
  --text: #e8e8f0;
  --text-muted: #8a8aa0;
  --text-dim: #5a5a70;
  --success: #4ade80;
  --error: #f87171;
  --radius: 8px;
  --font-ui: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SF Mono', 'Cascadia Code', 'Consolas', 'Menlo', monospace;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

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

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

/* ── Layout ──────────────────────────────────────────────────── */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

header {
  border-bottom: 1px solid var(--border);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.logo {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.logo span {
  color: var(--accent);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

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

.btn-logout {
  font-size: 0.8rem;
  color: var(--text-muted);
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.3rem 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-logout:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

main {
  padding: 2rem 0 4rem;
}

/* ── Upload Area ─────────────────────────────────────────────── */
.upload-section {
  margin-bottom: 2.5rem;
}

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--surface);
  position: relative;
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--accent);
  background: var(--surface-hover);
}

.upload-zone.drag-over {
  border-style: solid;
}

.upload-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  opacity: 0.6;
}

.upload-zone h2 {
  font-size: 1.15rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.4rem;
}

.upload-zone p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.upload-zone input[type="file"] {
  display: none;
}

/* Upload progress bar */
.upload-progress {
  display: none;
  margin-top: 1rem;
}

.upload-progress.active {
  display: block;
}

.progress-bar-track {
  height: 4px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.2s;
  width: 0%;
}

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

.upload-error {
  color: var(--error);
  font-size: 0.85rem;
  margin-top: 1rem;
  padding: 0.5rem 1rem;
  background: rgba(248, 113, 113, 0.1);
  border-radius: var(--radius);
}

/* ── Two-Column Workspace ────────────────────────────────────── */
.workspace {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}

.task-column, .detail-column {
  min-width: 0;
}

/* ── Task List ───────────────────────────────────────────────── */
.task-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.task-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  cursor: pointer;
  transition: all 0.15s;
}

.task-card:hover {
  border-color: var(--text-dim);
  background: var(--surface-hover);
}

.task-card.selected {
  border-color: var(--accent);
  background: var(--surface-hover);
}

.task-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.task-filename {
  font-weight: 500;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

/* Status badges */
.status-badge {
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-weight: 500;
}

.status-queued {
  background: rgba(138, 138, 160, 0.15);
  color: var(--text-muted);
}

.status-processing {
  background: rgba(226, 160, 63, 0.15);
  color: var(--accent);
}

.status-completed {
  background: rgba(74, 222, 128, 0.15);
  color: var(--success);
}

.status-failed {
  background: rgba(248, 113, 113, 0.15);
  color: var(--error);
}

.task-time {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.task-progress {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Task detail */
.task-detail {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.task-detail .segments-info {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.segment-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0;
  font-size: 0.8rem;
  border-bottom: 1px solid rgba(42, 42, 62, 0.5);
}

.segment-row:last-child {
  border-bottom: none;
}

.segment-label {
  color: var(--text-dim);
}

.result-text {
  margin-top: 1rem;
  background: #0a0a14;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 500px;
  overflow-y: auto;
  color: var(--text);
}

.result-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.btn {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  padding: 0.45rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.btn:hover {
  border-color: var(--text-dim);
  background: var(--surface-hover);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #0f0f1a;
  font-weight: 500;
}

.btn-primary:hover {
  background: var(--accent-dim);
  border-color: var(--accent-dim);
}

/* ── Login Page ──────────────────────────────────────────────── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
}

.login-card h1 {
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
  text-align: center;
}

.login-card .login-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 1.5rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

.form-group input {
  width: 100%;
  padding: 0.65rem 0.8rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 0.95rem;
  transition: border-color 0.15s;
}

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

.form-error {
  font-size: 0.8rem;
  color: var(--error);
  margin-top: 0.75rem;
  text-align: center;
}

.btn-full {
  width: 100%;
  justify-content: center;
  margin-top: 0.5rem;
}

/* ── Empty State ─────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  opacity: 0.4;
}

.empty-state p {
  font-size: 0.9rem;
}

/* ── Section Title ───────────────────────────────────────────── */
.section-title {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Detail Panel ────────────────────────────────────────────── */
.detail-column {
  position: sticky;
  top: 4.5rem;
}

#detail-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  min-height: 200px;
}

#detail-panel .empty-state {
  padding: 2rem 1rem;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .detail-column {
    position: static;
  }
}

@media (max-width: 640px) {
  .container {
    padding: 0 1rem;
  }

  .header-inner {
    padding: 0 1rem;
  }

  .upload-zone {
    padding: 2rem 1rem;
  }

  .result-text {
    max-height: 350px;
    font-size: 0.8rem;
  }

  .task-card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
  }

  .login-card {
    margin: 1rem;
    padding: 2rem 1.25rem;
  }
}
