/* ============================================================================
   Reason PV Onboarding Dashboard — Dark Theme CSS
   ============================================================================ */

:root {
  --bg-primary:    #0d1117;
  --bg-secondary:  #161b22;
  --bg-tertiary:   #21262d;
  --bg-card:       #1c2128;
  --border:        #30363d;
  --border-subtle: #21262d;

  --text-primary:  #e6edf3;
  --text-secondary:#8b949e;
  --text-muted:    #484f58;

  --accent-blue:   #388bfd;
  --accent-green:  #3fb950;
  --accent-orange: #d29922;
  --accent-red:    #f85149;
  --accent-purple: #bc8cff;

  --status-active:    #3fb950;
  --status-blocked:   #f85149;
  --status-completed: #388bfd;
  --status-pending:   #8b949e;
  --status-cancelled: #484f58;

  --stage-completed: #3fb950;
  --stage-active:    #d29922;
  --stage-blocked:   #f85149;
  --stage-pending:   #30363d;

  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;

  --radius-sm: 4px;
  --radius:    8px;
  --radius-lg: 12px;

  --shadow: 0 2px 8px rgba(0,0,0,0.4);
}

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

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

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

/* ── Layout ── */
.app-shell {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}

.nav {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  height: 56px;
  gap: 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  font-weight: 600;
  font-size: 15px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-brand .dot {
  width: 8px; height: 8px;
  background: var(--accent-green);
  border-radius: 50%;
  display: inline-block;
}

.nav-links {
  display: flex;
  gap: 4px;
  flex: 1;
}

.nav-link {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  background: none;
  font-size: 14px;
  font-family: var(--font-sans);
}

.nav-link:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.nav-link.active { background: var(--bg-tertiary); color: var(--text-primary); }

.nav-user {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-secondary);
  font-size: 13px;
}

.btn-logout {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
}
.btn-logout:hover { border-color: var(--accent-red); color: var(--accent-red); }

.main-content {
  padding: 24px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

/* ── Page headings ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.page-title {
  font-size: 20px;
  font-weight: 600;
}

.page-subtitle {
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 2px;
}

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
}

/* ── Login page ── */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-primary);
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
}

.login-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}

.login-subtitle {
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 28px;
}

/* ── Forms ── */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text-secondary);
}

.form-input {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-sans);
  transition: border-color 0.15s;
  outline: none;
}

.form-input:focus { border-color: var(--accent-blue); }
.form-input::placeholder { color: var(--text-muted); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font-sans);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
  text-decoration: none;
}

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

.btn-primary {
  background: var(--accent-blue);
  color: #fff;
  border-color: var(--accent-blue);
}
.btn-primary:hover:not(:disabled) { background: #1f6feb; }

.btn-success {
  background: var(--accent-green);
  color: #000;
}
.btn-success:hover:not(:disabled) { background: #2ea043; }

.btn-warning {
  background: var(--accent-orange);
  color: #000;
}
.btn-warning:hover:not(:disabled) { background: #bb8009; }

.btn-danger {
  background: transparent;
  color: var(--accent-red);
  border-color: var(--accent-red);
}
.btn-danger:hover:not(:disabled) { background: rgba(248,81,73,0.1); }

.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) { border-color: var(--text-secondary); color: var(--text-primary); }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }

/* ── Status badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.badge::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-active    { color: var(--status-active);    background: rgba(63,185,80,0.12); }
.badge-blocked   { color: var(--status-blocked);   background: rgba(248,81,73,0.12); }
.badge-completed { color: var(--status-completed); background: rgba(56,139,253,0.12); }
.badge-pending   { color: var(--status-pending);   background: rgba(139,148,158,0.1); }
.badge-cancelled { color: var(--status-cancelled); background: rgba(72,79,88,0.1); }

/* ── Tables ── */
.table-container {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  background: var(--bg-secondary);
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.02); }

.table-link { color: var(--accent-blue); cursor: pointer; }
.table-link:hover { text-decoration: underline; }

/* ── Filters ── */
.filters {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}

.filter-select {
  padding: 7px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font-sans);
  cursor: pointer;
  outline: none;
}

.filter-select:focus { border-color: var(--accent-blue); }

/* ── Detail page ── */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

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

.detail-row {
  display: flex;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 13px;
}

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

.detail-label {
  color: var(--text-secondary);
  min-width: 180px;
  flex-shrink: 0;
}

.detail-value { color: var(--text-primary); word-break: break-all; }

/* ── Step checklist ── */
.checklist { list-style: none; }

.checklist-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--border-subtle);
}

.checklist-item:last-child { border-bottom: none; }

.check-icon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 10px;
}

.check-completed { background: rgba(63,185,80,0.15); color: var(--stage-completed); }
.check-active    { background: rgba(210,153,34,0.15); color: var(--stage-active); }
.check-blocked   { background: rgba(248,81,73,0.15);  color: var(--stage-blocked); }
.check-pending   { background: var(--stage-pending); opacity: 0.4; }

.checklist-label-completed { color: var(--text-primary); }
.checklist-label-active    { color: var(--stage-active); font-weight: 500; }
.checklist-label-blocked   { color: var(--stage-blocked); font-weight: 500; }
.checklist-label-pending   { color: var(--text-muted); }

/* ── Log timeline ── */
.log-entry {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 13px;
}

.log-entry:last-child { border-bottom: none; }

.log-time {
  color: var(--text-muted);
  font-size: 12px;
  min-width: 130px;
  flex-shrink: 0;
  font-family: var(--font-mono);
}

.log-content { flex: 1; }

.log-step {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  margin-bottom: 2px;
}

.log-message { color: var(--text-primary); }
.log-tech { color: var(--text-secondary); margin-top: 4px; font-family: var(--font-mono); font-size: 12px; }

.log-status-success  { color: var(--accent-green); }
.log-status-failure  { color: var(--accent-red); }
.log-status-started  { color: var(--accent-orange); }
.log-status-retried  { color: var(--accent-purple); }
.log-status-skipped  { color: var(--text-muted); }

/* ── Links section ── */
.link-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--accent-blue);
  font-size: 13px;
  text-decoration: none;
  transition: all 0.15s;
}

.link-btn:hover {
  background: var(--bg-secondary);
  border-color: var(--accent-blue);
  text-decoration: none;
}

/* ── Blocker alert box ── */
.blocker-box {
  background: rgba(248,81,73,0.08);
  border: 1px solid rgba(248,81,73,0.3);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.blocker-title {
  color: var(--accent-red);
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.blocker-message { color: var(--text-primary); font-size: 13px; }

/* ── Controls section ── */
.controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
}

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 420px;
  max-width: 90vw;
  box-shadow: var(--shadow);
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
}

.modal-body { margin-bottom: 20px; color: var(--text-secondary); font-size: 13px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}

.empty-state-title { font-size: 16px; font-weight: 500; margin-bottom: 8px; }
.empty-state-body { font-size: 13px; }

/* ── Error / toast ── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  z-index: 9999;
  max-width: 380px;
  animation: slideIn 0.2s ease;
  box-shadow: var(--shadow);
}

.toast-success { background: var(--accent-green); color: #000; }
.toast-error   { background: var(--accent-red);   color: #fff; }
.toast-info    { background: var(--accent-blue);  color: #fff; }

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

/* ── Spinner ── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

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

.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  color: var(--text-muted);
  gap: 12px;
}

/* ── Pagination ── */
.pagination {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  margin-top: 20px;
}

/* ── Utility ── */
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.flex  { display: flex; }
.gap-8 { gap: 8px; }
.items-center { align-items: center; }
.text-muted { color: var(--text-secondary); }
.text-sm { font-size: 12px; }
.mono { font-family: var(--font-mono); }
.hidden { display: none !important; }

/* ── Integrations tab ── */
.integrations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(520px, 1fr));
  gap: 16px;
}

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

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

.int-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.int-card-title {
  font-size: 15px;
  font-weight: 600;
}

.badge-connected {
  color: var(--accent-green);
  background: rgba(63,185,80,0.12);
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.badge-not-configured {
  color: var(--text-muted);
  background: rgba(72,79,88,0.12);
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 12px;
}

.badge-unverified {
  color: #d29922;
  background: rgba(210,153,34,0.14);
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

/* Field row with label + input + tooltip */
.int-field {
  margin-bottom: 12px;
}

.int-field-label-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
}

.int-field-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.int-tooltip-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  padding: 0 2px;
  line-height: 1;
  position: relative;
}

.int-tooltip-btn:hover { color: var(--text-secondary); }

.int-tooltip-popup {
  position: absolute;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 12px;
  color: var(--text-primary);
  width: 300px;
  max-width: 80vw;
  line-height: 1.5;
  left: 0;
  top: 20px;
  box-shadow: var(--shadow);
  white-space: normal;
  /* pointer-events enabled so the embedded link is clickable */
  pointer-events: auto;
  font-weight: 400;
  text-align: left;
}

.int-tooltip-popup.hidden { display: none; }

.int-tooltip-text {
  color: var(--text-secondary);
}

.int-tooltip-link {
  display: inline-block;
  align-self: flex-start;
  color: var(--accent-blue, #388bfd);
  text-decoration: none;
  font-weight: 600;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(56,139,253,0.08);
}

.int-tooltip-link:hover {
  background: rgba(56,139,253,0.18);
  text-decoration: underline;
}

.int-input-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.int-input-row .form-input {
  flex: 1;
  font-size: 13px;
  padding: 7px 10px;
}

.int-show-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 11px;
  padding: 6px 8px;
  white-space: nowrap;
}
.int-show-toggle:hover { color: var(--text-primary); border-color: var(--text-secondary); }

/* Card footer: save + test buttons + result */
.int-card-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.int-test-result {
  font-size: 12px;
  flex: 1;
  min-width: 0;
}

.int-test-ok   { color: var(--accent-green); }
.int-test-fail { color: var(--accent-red); }

/* QBO connect button */
.btn-qbo {
  background: #2ca01c;
  color: #fff;
  border-color: #2ca01c;
}
.btn-qbo:hover:not(:disabled) { background: #1f7d14; }
