﻿/* =====================================================
   ROOT / DESIGN TOKENS - aligned with Anton
===================================================== */

:root {
  --bg: #0f1115;
  --panel: #181b21;
  --panel-light: #20242c;
  --border: rgba(255,255,255,0.08);
  --text: #e6e6e6;
  --muted: #9aa0a6;
  --accent: #4da3ff;
  --danger: #ff5f56;
  --ok: #3fb950;
  --warning: #f59e0b;
  --radius: 12px;
  --radius-sm: 8px;
  --space: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
}

body { overflow-x: hidden; }

/* =====================================================
   APP LAYOUT
===================================================== */

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space);
  padding: 14px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.topbar h1 {
  margin: 0;
  font-size: 20px;
}

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

.pipeline-status {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.status-badge,
.badge {
  background: var(--panel-light);
  color: var(--text);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.status-badge.success,
.status-success { color: var(--ok); }

.status-badge.failed,
.status-failed { color: var(--danger); }

.status-badge.pending { color: var(--warning); }

.main {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.view-container {
  max-width: 1500px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--space);
}

/* =====================================================
   PANELS / FORMS
===================================================== */

.panel,
.download-form {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 17px;
}

.download-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
}

input[type=url],
input[type=text] {
  flex: 1;
  min-width: 0;
  background: var(--panel-light);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  padding: 10px 12px;
  outline: none;
}

input[type=url]:focus,
input[type=text]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(77,163,255,0.12);
}

button {
  background: var(--accent);
  border: none;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: #000;
  font-weight: 700;
  transition: 0.15s ease;
}

button:hover { opacity: 0.9; }

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

button.busy {
  opacity: 1;
  position: relative;
}

button.busy::after {
  animation: spin 0.8s linear infinite;
  border: 2px solid rgba(255,255,255,0.45);
  border-top-color: #000;
  border-radius: 50%;
  content: "";
  display: inline-block;
  height: 12px;
  margin-left: 8px;
  vertical-align: -2px;
  width: 12px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* =====================================================
   STATUS / LOG / TABLE
===================================================== */

.status-grid {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 9px 14px;
  margin: 0;
}

.status-grid dt {
  color: var(--muted);
  font-weight: 600;
}

.status-grid dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.log-output {
  overflow: auto;
  white-space: pre-wrap;
  background: #0b1220;
  color: #dbeafe;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  max-height: 360px;
  margin: 0;
  font-size: 13px;
}

.download-table {
  width: 100%;
  border-collapse: collapse;
}

.download-table th,
.download-table td {
  text-align: left;
  border-bottom: 1px solid var(--border);
  padding: 10px 8px;
  vertical-align: top;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.download-table th {
  color: var(--muted);
  font-weight: 600;
}

.download-table tr:hover td {
  background: rgba(77,163,255,0.05);
}

.empty-state {
  color: var(--muted);
  margin: 0;
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .main { padding: 16px; }

  .row {
    align-items: stretch;
    flex-direction: column;
  }

  .status-grid { grid-template-columns: 1fr; }
}

/* =====================================================
   LIVE DOWNLOAD PROGRESS
===================================================== */

.hidden {
  display: none !important;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-header h2 {
  margin: 0;
}

.progress-panel {
  border-color: rgba(77,163,255,0.22);
}

.progress-track {
  width: 100%;
  height: 18px;
  background: var(--panel-light);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 16px;
}

.progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--ok));
  border-radius: 999px;
  transition: width 0.25s ease;
}

.progress-grid {
  grid-template-columns: 150px 1fr;
}

.status-badge.running,
.status-badge.retrying {
  color: var(--accent);
}

.status-badge.success {
  color: var(--ok);
}

.status-badge.failed {
  color: var(--danger);
}

#progressPercent {
  background: var(--accent);
  color: #000;
  min-width: 56px;
}

button.neutral {
  background: #2b2f37;
  color: var(--text);
}

button.neutral:hover {
  background: #343a45;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.app-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  object-fit: cover;
  flex: 0 0 auto;
}

.inline-form {
  margin: 0;
}

.log-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

textarea {
  width: 100%;
  min-height: 76px;
  resize: vertical;
  background: var(--panel-light);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  padding: 10px 12px;
  outline: none;
}

textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(77,163,255,0.12);
}

.field-hint {
  color: var(--muted);
  font-size: 12px;
  margin-top: -4px;
}

.session-step {
  background: rgba(77,163,255,0.06);
  border: 1px solid rgba(77,163,255,0.22);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
}

.session-step h2 {
  font-size: 15px;
  margin: 0;
}

.wizard-step {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.wizard-step + .wizard-step {
  border-top: 1px solid var(--border);
  margin-top: 4px;
  padding-top: 16px;
}

.wizard-heading {
  align-items: center;
  display: flex;
  gap: 10px;
}

.wizard-heading h2 {
  font-size: 16px;
  margin: 0;
}

.step-number {
  align-items: center;
  background: var(--accent);
  border-radius: 50%;
  color: #000;
  display: inline-flex;
  font-size: 13px;
  font-weight: 800;
  height: 26px;
  justify-content: center;
  width: 26px;
}

.strategy-card {
  background: var(--panel-light);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.strategy-card strong {
  display: block;
  margin-bottom: 6px;
}

.diagnostic-panel {
  background: rgba(63,185,80,0.06);
  border: 1px solid rgba(63,185,80,0.22);
  border-radius: var(--radius-sm);
  padding: 14px;
}

body.analysis-busy .diagnostic-panel {
  border-color: rgba(77,163,255,0.65);
  box-shadow: 0 0 0 3px rgba(77,163,255,0.10);
}

.diagnostic-panel h3 {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 8px;
}

.diagnostic-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  margin: 12px 0 14px;
}

.diagnostic-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.diagnostic-item {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  padding: 9px 10px;
}

.diagnostic-item.strong {
  border-color: rgba(63,185,80,0.45);
}

.diagnostic-item.warning {
  border-color: rgba(245,158,11,0.55);
}

.diagnostic-raw {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  min-height: 220px;
}

@media (max-width: 760px) {
  .diagnostic-grid {
    grid-template-columns: 1fr;
  }
}
