/* Shared styles across dashboard, collect, and viewer pages. */
:root {
  --accent: #22c55e;
  --accent-hover: #16a34a;
  --accent-20: #22c55e20;
  --accent-40: #22c55e40;
  --bg: #0a0a0a;
  --card: #141414;
  --card2: #1a1a1a;
  --border: #262626;
  --muted: #737373;
  --err: #ef4444;
  --blue: #3b82f6;
  --warn: #eab308;
  --text: #e5e5e5;
  --text-strong: #fff;
  --text-soft: #aaa;
  --text-subtle: #555;
  --text-faint: #333;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", monospace;
}

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

body {
  min-height: 100vh;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
}

.hidden {
  display: none !important;
}

/* Scope-controlled chrome. Server-side checks remain the source of truth. */
body:not(.is-master) .admin-only,
body.is-customer .admin-only,
body:not(.is-customer) .customer-scope-only {
  display: none !important;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

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

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

::-webkit-scrollbar-thumb:hover {
  background: var(--text-subtle);
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--text-faint) transparent;
}

/* Loading */
@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

.skeleton {
  background: linear-gradient(
    90deg,
    var(--card2) 25%,
    var(--border) 50%,
    var(--card2) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

/* Shared simulator screen/touch primitives */
.screen-container,
#screen-container {
  position: relative;
  border: 3px solid var(--text-faint);
  border-radius: 24px;
  overflow: hidden;
  background: #000;
  cursor: crosshair;
}

body.is-tvos .screen-container,
body.is-visionos .screen-container,
body.is-tvos #screen-container,
body.is-visionos #screen-container {
  border-radius: 14px;
  cursor: default;
}

.screen-container img,
#screen {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.touch-overlay,
#touch-overlay {
  position: absolute;
  inset: 0;
  touch-action: none;
}

body.is-tvos .touch-overlay,
body.is-visionos .touch-overlay,
body.is-tvos #touch-overlay,
body.is-visionos #touch-overlay {
  cursor: not-allowed;
}

.touch-indicator {
  position: absolute;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--blue);
  background: rgba(59, 130, 246, 0.2);
  transform: translate(-50%, -50%);
  pointer-events: none;
  animation: tap-fade 0.4s ease-out forwards;
}

.touch-indicator.swipe-end {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.25);
}

.touch-indicator.long-press {
  border-color: var(--accent);
  background: rgba(34, 197, 94, 0.24);
}

@keyframes tap-fade {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(2);
  }
}

.viewer-footer,
.ios-footer,
.vnc-footer {
  padding: 4px 12px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  font-size: 10px;
  color: var(--text-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ios-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: #0a0a0acc;
}

/* Step indicator */
.steps-bar {
  display: flex;
  align-items: center;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
  gap: 8px;
}

.step-pill {
  font-size: 11px;
  padding: 4px 14px;
  border-radius: 20px;
  font-weight: 600;
  border: 1px solid var(--text-faint);
  background: var(--card2);
  color: var(--text-subtle);
  cursor: default;
}

.step-pill.active {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
}

.step-pill.done {
  background: var(--border);
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 25%, transparent);
}

.step-arrow {
  color: var(--text-faint);
  font-size: 12px;
}

.steps-bar .spacer {
  flex: 1;
}

.steps-bar .meta {
  font-size: 11px;
  color: var(--text-subtle);
  font-family: var(--font-mono);
}

/* Config page */
.config-page {
  display: flex;
  align-items: center;
  justify-content: center;
  height: calc(100vh - 45px);
}

.config-card {
  width: 480px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
}

.config-card h2 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}

.config-card .subtitle {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 24px;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.field input,
.field textarea,
.field select,
.config-card > input,
.config-card > textarea,
.config-card > select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
}

.field input:focus,
.field textarea:focus,
.field select:focus,
.config-card > input:focus,
.config-card > textarea:focus,
.config-card > select:focus {
  outline: none;
  border-color: var(--accent);
}

.field textarea,
.config-card > textarea {
  resize: vertical;
  min-height: 80px;
}

.field .hint {
  font-size: 10px;
  color: var(--text-subtle);
  margin-top: 2px;
}

.primary-btn {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
}

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

.primary-btn:disabled {
  background: var(--text-faint);
  color: var(--text-subtle);
  cursor: not-allowed;
}

.err-msg {
  color: var(--err);
  font-size: 12px;
  margin-top: 8px;
}

.config-card > input,
.config-card > textarea,
.config-card > select {
  margin-bottom: 12px;
}

.advanced-details {
  margin: 4px 0 12px;
  font-size: 12px;
  color: var(--muted);
}

.advanced-details summary {
  cursor: pointer;
  padding: 4px 0;
  user-select: none;
}

.advanced-details select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  color: var(--text);
  font-size: 13px;
  margin-top: 6px;
}

/* Setup sidebar */
.setup-sidebar {
  width: 360px;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--card);
}

.setup-sidebar section {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.setup-sidebar section h3 {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.cmd-row {
  display: flex;
  gap: 4px;
}

.cmd-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  color: var(--text);
  font-size: 12px;
  font-family: var(--font-mono);
}

.cmd-input:focus {
  outline: none;
  border-color: var(--blue);
}

/* Buttons */
.small-btn {
  padding: 6px 12px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--accent-20);
  color: var(--accent);
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
}

.small-btn:hover {
  background: var(--accent-40);
}

.small-btn.blue {
  border-color: var(--blue);
  background: #3b82f620;
  color: var(--blue);
}

.small-btn.blue:hover {
  background: #3b82f640;
}

.small-btn.red {
  border-color: var(--err);
  background: #ef444420;
  color: var(--err);
}

.small-btn.red:hover {
  background: #ef444440;
}

.btn-row {
  display: flex;
  gap: 8px;
}

.review-right .btn-row {
  margin-top: 12px;
}

/* Log */
.log {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--muted);
}

.log-entry {
  padding: 2px 0;
  border-bottom: 1px solid var(--card2);
}

.log-entry .time {
  color: var(--text-subtle);
}

.log-entry .act {
  color: var(--accent);
}

/* Task floating controls */
.task-float {
  position: fixed;
  top: 56px;
  right: 12px;
  display: flex;
  gap: 6px;
  z-index: 50;
}

.task-float .pill {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: #141414ee;
  border: 1px solid var(--text-faint);
  color: var(--text-soft);
  backdrop-filter: blur(4px);
}

.task-float .pill.recording {
  color: var(--err);
  border-color: #ef444480;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* Review */
.review-layout {
  display: flex;
  height: calc(100vh - 45px);
}

.review-left {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.review-right {
  width: 400px;
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px;
  background: var(--card);
}

.traj-step {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.traj-step img {
  width: 200px;
  height: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--text-faint);
  cursor: pointer;
}

.traj-step img:hover {
  border-color: var(--accent);
}

.traj-step .info {
  flex: 1;
  font-size: 12px;
}

.traj-step .action-label {
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 4px;
}

.traj-step .params {
  color: #888;
  font-family: var(--font-mono);
  font-size: 11px;
}

.traj-step .ts {
  color: var(--text-subtle);
  font-size: 10px;
  margin-top: 4px;
}

.review-section {
  margin-bottom: 20px;
}

.review-section h3 {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.review-section textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px;
  color: var(--text);
  font-size: 12px;
  font-family: var(--font-mono);
  resize: vertical;
}

.review-section textarea:focus {
  outline: none;
  border-color: var(--blue);
}

.review-section pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px;
  font-size: 11px;
  color: var(--text-soft);
  max-height: 300px;
  overflow: auto;
}
