/* ── CX Auditor Web UI ───────────────────────────────────────────── */

:root {
  --green: #21a038;
  --green-hover: #1a8a2e;
  --green-light: #e8f5e9;
  --green-dark: #1565c0;
  --bg: #f5f7fa;
  --card-bg: #ffffff;
  --text: #1a1a2e;
  --text-secondary: #6b7280;
  --border: #e2e8f0;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-hover: 0 10px 25px rgba(0,0,0,0.1), 0 4px 10px rgba(0,0,0,0.06);
  --transition: 0.2s ease;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 40px 20px;
}

/* ── Header ───────────────────────────────────────────────────── */

.header {
  text-align: center;
  margin-bottom: 48px;
}

.header h1 {
  font-size: 32px;
  font-weight: 700;
  color: var(--green);
  letter-spacing: -0.5px;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 16px;
  margin-top: 4px;
}

/* ── Steps ─────────────────────────────────────────────────────── */

.step { margin-bottom: 40px; }

.step h2 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--text);
}

/* ── Scenario Cards ────────────────────────────────────────────── */

.scenario-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

@media (max-width: 640px) {
  .scenario-grid { grid-template-columns: 1fr; }
  .container { padding: 24px 12px; }
  .header h1 { font-size: 24px; }
  .header { margin-bottom: 32px; }
  #step-queue { padding: 16px 12px 20px; }
  .step h2 { font-size: 18px; }
  .progress-card { padding: 16px; }
  .progress-header { flex-direction: column; gap: 12px; }
  .progress-status-block { align-items: flex-start; }
  .queue-controls { justify-content: flex-start; }
  .form-buttons { flex-wrap: wrap; }
}

.scenario-card {
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
  box-shadow: var(--shadow);
}

.scenario-card:hover {
  border-color: var(--green);
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.scenario-card.selected {
  border-color: var(--green);
  background: var(--green-light);
  box-shadow: 0 0 0 3px rgba(33, 160, 56, 0.15);
}

.card-icon {
  color: var(--green);
  margin-bottom: 12px;
}

.scenario-card h3 {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 4px;
}

.card-time {
  color: var(--green);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 10px;
}

.card-desc {
  list-style: none;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.card-desc li::before {
  content: "— ";
  color: var(--green);
}

/* ── Form ──────────────────────────────────────────────────────── */

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 14px;
  font-size: 15px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card-bg);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
  font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(33, 160, 56, 0.12);
}

.form-group textarea {
  resize: vertical;
  min-height: 72px;
}

.form-buttons {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

/* ── Buttons ───────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

.btn-primary {
  background: var(--green);
  color: #fff;
}

.btn-primary:hover {
  background: var(--green-hover);
  box-shadow: 0 4px 12px rgba(33, 160, 56, 0.3);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-secondary {
  background: var(--card-bg);
  color: var(--text);
  border: 1.5px solid var(--border);
}

.btn-secondary:hover {
  border-color: var(--green);
  background: var(--green-light);
}

/* ── Result ────────────────────────────────────────────────────── */

.result-card {
  background: var(--card-bg);
  border: 2px solid var(--green);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  box-shadow: var(--shadow);
}

.result-card-error {
  border-color: #ef4444;
}

.result-icon {
  font-size: 40px;
  margin-bottom: 12px;
}

.result-card h3 {
  font-size: 20px;
  margin-bottom: 8px;
}

.result-card p {
  color: var(--text-secondary);
  font-size: 14px;
}

.result-details {
  margin-top: 20px;
  text-align: left;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

@media (max-width: 480px) {
  .result-details { max-width: 100%; }
}

.result-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

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

.result-label { color: var(--text-secondary); }

.mono { font-family: 'SFMono-Regular', 'Menlo', 'Monaco', monospace; font-size: 12px; }

.status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  background: var(--green-light);
  color: var(--green);
  font-weight: 600;
  font-size: 12px;
}

/* ── Spinner ───────────────────────────────────────────────────── */

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ── Error ─────────────────────────────────────────────────────── */

.error-message {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 16px;
  display: none;
}

/* ── Progress ────────────────────────────────────────────────── */

.progress-card {
  background: var(--card-bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}

.progress-info {
  flex: 1;
}

.progress-row {
  display: flex;
  gap: 8px;
  padding: 4px 0;
  font-size: 13px;
}

.progress-label {
  color: var(--text-secondary);
  min-width: 70px;
}

.progress-status-block {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.progress-timer {
  font-size: 13px;
  color: var(--text-secondary);
  font-family: 'SFMono-Regular', 'Menlo', monospace;
}



.progress-text {
  font-size: 14px;
  color: var(--text);
  text-align: center;
  padding: 8px 0;
}

.progress-final {
  margin-top: 8px;
}

/* ── Status badge variants ────────────────────────────────── */

.status-pending { background: #fef3c7; color: #92400e; }
.status-queued { background: #fef3c7; color: #92400e; }
.status-running { background: #dbeafe; color: #1e40af; }
.status-processing { background: #dbeafe; color: #1e40af; }
.status-completed { background: #d1fae5; color: #065f46; }
.status-failed { background: #fee2e2; color: #991b1b; }
.status-error { background: #fee2e2; color: #991b1b; }
.status-sent { background: #e0e7ff; color: #3730a3; }

/* ── Footer ────────────────────────────────────────────────────── */

.footer {
  text-align: center;
  color: var(--text-secondary);
  font-size: 12px;
  margin-top: 60px;
  border-top: 1px solid var(--border);
  padding-top: 20px;
}

/* ── Sites table (Step 2) ──────────────────────────────────── */

.sites-toolbar {
  margin-bottom: 16px;
  padding: 14px 16px;
  background: #f8fafc;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.sites-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
}

.sites-table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  font-size: 14px;
}

.sites-table thead {
  background: #f8fafc;
}

.sites-table th {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 2px solid var(--border);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.sites-table th:last-child {
  width: 140px;
}

.sites-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

.sites-table tbody tr {
  transition: background 0.12s ease;
}

.sites-table tbody tr:hover td {
  background: #fafcfc;
}

.sites-table tbody tr:last-child td {
  border-bottom: none;
}

.site-cell {
  min-width: 180px;
}

.site-name {
  display: block;
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
}

.site-url {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  font-family: 'SFMono-Regular', 'Menlo', 'Monaco', monospace;
  margin-top: 2px;
  word-break: break-all;
}

.site-last-run {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.site-pdf {
  text-align: center;
}

.site-action {
  text-align: right;
  white-space: nowrap;
}

.sites-na {
  color: #d1d5db;
  font-size: 13px;
}

.sites-empty {
  text-align: center;
  padding: 40px 16px !important;
  color: var(--text-secondary);
  font-size: 14px;
}

.sites-error {
  color: #991b1b;
}

.sites-footer {
  margin-top: 20px;
}

/* ── Sites expanded (full-view of audit bar) ────────────────── */

/* (removed — unused) */

/* ── Audit bar (inline status) ─────────────────────────────── */

.audit-bar {
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  overflow: hidden;
  transition: border-color 0.3s ease;
  border-left: 3px solid var(--green);
}

.audit-bar.is-done {
  border-left-color: #059669;
}

.audit-bar.is-error {
  border-left-color: #dc2626;
}

.audit-bar-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
}

.audit-bar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.audit-bar-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  flex-shrink: 0;
}

.audit-bar-info {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  flex-wrap: wrap;
}

.audit-bar-site {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
}

.audit-bar-sep {
  color: var(--border);
  font-size: 14px;
  flex-shrink: 0;
}

.audit-bar-type {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.audit-bar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.audit-bar-progress {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.audit-bar-timer {
  font-size: 12px;
  color: var(--text-secondary);
  font-family: 'SFMono-Regular', 'Menlo', monospace;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  min-width: 55px;
  text-align: right;
}

.audit-bar-dl {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--green);
  background: var(--green-light);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: background 0.15s;
}

.audit-bar-dl:hover {
  background: #d1fae5;
}

.audit-bar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}

.audit-bar-toggle:hover {
  background: var(--border);
  color: var(--text);
}

.audit-bar-detail {
  padding: 0 16px 14px;
  border-top: 1px solid var(--border);
}

.audit-bar-detail-row {
  display: flex;
  gap: 10px;
  padding: 10px 0 4px;
  font-size: 13px;
}

.audit-bar-detail-label {
  color: var(--text-secondary);
  font-size: 12px;
}

.audit-bar-detail-value {
  font-size: 12px;
  color: var(--text);
}

.audit-bar-detail-text {
  padding: 4px 0 8px;
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.5;
}

/* ── Restart button ────────────────────────────────────────── */

.btn-restart {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  color: var(--green);
  background: transparent;
  border: 1.5px solid var(--green);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-restart:hover {
  background: var(--green);
  color: #fff;
}

.btn-restart:active {
  transform: scale(0.97);
}

.btn-restart:disabled,
.btn-restart-busy {
  opacity: 0.6;
  cursor: not-allowed;
  color: var(--text-secondary);
  border-color: var(--border);
  background: #f8fafc;
}

.btn-restart-busy:hover {
  background: #f8fafc;
  color: var(--text-secondary);
}

/* ── Mini spinner ──────────────────────────────────────────── */

.mini-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
}

/* ── Download link with label ──────────────────────────────── */

.sites-dl {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: auto;
  height: 32px;
  padding: 0 10px;
  border-radius: 6px;
  color: var(--green);
  transition: background 0.15s;
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
}

.sites-dl:hover {
  background: var(--green-light);
}

/* ── Queue / History table ──────────────────────────────────── */

#step-queue {
  background: var(--card-bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px 24px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

#step-queue h2 {
  margin-bottom: 12px;
}

.queue-controls {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.queue-controls .btn {
  padding: 6px 16px;
  font-size: 13px;
}

#queue-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.queue-table {
  width: 100%;
  min-width: 600px;
  border-collapse: collapse;
  font-size: 13px;
}

.queue-table th {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 2px solid var(--border);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.queue-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.queue-table tr:hover td {
  background: #f8fafc;
}

.queue-table .queue-url {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-table .queue-time {
  color: var(--text-secondary);
  white-space: nowrap;
  font-size: 12px;
}

.queue-table .queue-dl {
  text-align: center;
}

.queue-table .queue-empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-secondary);
  font-size: 14px;
}

.queue-table .queue-error {
  color: #991b1b;
}

.dl-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  color: var(--green);
  transition: background 0.15s;
  text-decoration: none;
}

.dl-link:hover {
  background: var(--green-light);
}

.dl-none {
  color: #d1d5db;
  font-size: 14px;
}
