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

:root {
  --blue: #13429b;
  --blue-light: #eff6ff;
  --green: #16a34a;
  --red: #ef4444;
  --yellow: #eab308;
  --orange: #f97316;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
}

html,
body {
  height: 100%;
  font-family:
    'Inter',
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--gray-900);
  background: var(--gray-50);
}

/* ── Top bar ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 20px;
  background: var(--blue);
  flex-shrink: 0;
}

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

.topbar-sparkle {
  color: #fff;
  flex-shrink: 0;
}

.topbar-title {
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Controls (inputs / buttons) ── */
.ctrl-input {
  padding: 7px 12px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-family: inherit;
  font-size: 13px;
  outline: none;
  width: 100px;
  transition:
    border-color 0.15s,
    background 0.15s;
}

.ctrl-input--wide {
  width: 120px;
}

.ctrl-input::placeholder {
  color: rgba(255, 255, 255, 0.6);
}

.ctrl-input:focus {
  border-color: #fff;
  background: rgba(255, 255, 255, 0.25);
}

.ctrl-btn {
  padding: 7px 18px;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition:
    opacity 0.15s,
    background 0.15s;
}

.ctrl-btn:hover {
  opacity: 0.92;
}

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

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

.ctrl-btn--secondary {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.ctrl-btn--sm {
  padding: 5px 14px;
  font-size: 12px;
}

/* Buttons used outside topbar (in detail) */
.run-detail .ctrl-btn--primary {
  background: var(--blue);
  color: #fff;
}

.run-detail .ctrl-btn--secondary {
  background: var(--gray-100);
  color: var(--gray-700);
  border: 1px solid var(--gray-200);
}

/* ── Main layout ── */
.main {
  display: grid;
  grid-template-columns: 300px 1fr;
  height: calc(100vh - 50px);
  overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
  background: #fff;
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--gray-200);
}

.sidebar-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray-500);
}

.sidebar-count {
  font-size: 12px;
  color: var(--gray-400);
  background: var(--gray-100);
  padding: 1px 8px;
  border-radius: 10px;
  font-weight: 500;
}

.sidebar-count:empty {
  display: none;
}

.runs-list {
  flex: 1;
  overflow-y: auto;
}

/* ── Run item in sidebar ── */
.run-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-100);
  cursor: pointer;
  transition: background 0.12s;
}

.run-item:hover {
  background: var(--gray-50);
}

.run-item.active {
  background: var(--blue-light);
  border-left: 3px solid var(--blue);
  padding-left: 13px;
}

.run-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.run-item-id {
  font-size: 13px;
  font-weight: 600;
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: var(--gray-800);
}

.run-item-meta {
  font-size: 12px;
  color: var(--gray-500);
}

.run-item-date {
  font-size: 11px;
  color: var(--gray-400);
  margin-top: 2px;
}

/* ── Status pills ── */
.status-pill {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.status-pill--running {
  background: #13429b1a;
  color: var(--blue);
}

.status-pill--completed {
  background: #16a34a1a;
  color: var(--green);
}

.status-pill--failed {
  background: #ef44441a;
  color: var(--red);
}

.status-pill--paused {
  background: #eab3081a;
  color: var(--yellow);
}

.status-pill--pending {
  background: var(--gray-100);
  color: var(--gray-500);
}

.status-pill--halted {
  background: #9333ea1a;
  color: #9333ea;
}

/* ── Content panel ── */
.content {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.content-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--gray-400);
  font-size: 14px;
}

/* ── Run detail ── */
.run-detail {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--gray-200);
  background: #fff;
  flex-shrink: 0;
}

.detail-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.detail-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Detail/Live View tabs ── */
.detail-tabs {
  background: var(--gray-100);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
}

.detail-tab {
  padding: 5px 14px;
  border: none;
  border-radius: 6px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  color: var(--gray-500);
  background: transparent;
  transition:
    background 0.15s,
    color 0.15s;
}

.detail-tab:hover {
  color: var(--gray-700);
}

.detail-tab.active {
  background: #fff;
  color: var(--gray-900);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.detail-title {
  font-size: 16px;
  font-weight: 700;
}

.detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

.detail-section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 10px;
}

/* ── Meta grid ── */
.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 24px;
}

.meta-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  padding: 12px 14px;
}

.meta-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray-400);
  margin-bottom: 4px;
  font-weight: 500;
}

.meta-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-800);
}

.meta-value.mono {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 11px;
  word-break: break-all;
  font-weight: 500;
}

/* ── Checkpoint grid ── */
.cp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}

.cp-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 10px;
}

.cp-icon {
  font-size: 15px;
  margin-top: 2px;
  flex-shrink: 0;
}

.cp-icon--completed {
  color: var(--green);
}

.cp-icon--running {
  color: var(--orange);
}

.cp-icon--failed {
  color: var(--red);
}

.cp-icon--pending,
.cp-icon--skipped,
.cp-icon--deferred {
  color: var(--gray-400);
}

.cp-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-800);
}

.cp-meta {
  font-size: 11px;
  color: var(--gray-400);
  margin-top: 3px;
}

/* ── Widget + screenshot split ── */
.widget-split {
  flex: 1;
  display: flex;
  min-height: 0;
  gap: 0;
}

.widget-frame-wrap {
  flex: 6;
  display: flex;
  min-height: 0;
  min-width: 0;
}

.widget-frame {
  flex: 1;
  width: 100%;
  height: 100%;
  border: none;
}

/* ── Screenshot panel (right side, 40%) ── */
.screenshot-panel {
  flex: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--gray-50);
  border-left: 1px solid var(--gray-200);
  overflow: hidden;
  min-width: 0;
}

.screenshot-panel-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--gray-400);
  font-size: 13px;
}

.screenshot-panel-img {
  max-width: 95%;
  max-height: 95%;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid var(--gray-200);
  cursor: zoom-in;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

/* ── Admin lightbox ── */
.admin-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.85);
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}

.admin-lightbox.visible {
  display: flex;
}

.admin-lightbox img {
  max-width: 94vw;
  max-height: 94vh;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

/* ── Empty state ── */
.empty-state {
  padding: 32px;
  text-align: center;
  color: var(--gray-400);
  font-size: 13px;
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
  width: 5px;
}

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

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

::-webkit-scrollbar-thumb:hover {
  background: var(--gray-400);
}

/* ── Toast notifications ── */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  box-shadow:
    0 4px 16px rgba(0, 0, 0, 0.12),
    0 1px 4px rgba(0, 0, 0, 0.08);
  animation: toast-in 0.25s ease-out;
  max-width: 400px;
  word-break: break-word;
}

.toast--error {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}

.toast--success {
  background: #f0fdf4;
  color: #16a34a;
  border: 1px solid #bbf7d0;
}

.toast--info {
  background: #eff6ff;
  color: #13429b;
  border: 1px solid #bfdbfe;
}

.toast.removing {
  animation: toast-out 0.2s ease-in forwards;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(40px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toast-out {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(40px);
  }
}

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

  .sidebar {
    max-height: 200px;
    border-right: none;
    border-bottom: 1px solid var(--gray-200);
  }

  .topbar {
    flex-direction: column;
    gap: 8px;
    align-items: stretch;
  }

  .topbar-controls {
    flex-wrap: wrap;
  }

  .ctrl-input {
    flex: 1;
    min-width: 80px;
  }

  .widget-split {
    flex-direction: column;
  }

  .screenshot-panel {
    flex: none;
    height: 200px;
    border-left: none;
    border-top: 1px solid var(--gray-200);
  }
}
