/* ── Base resets ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

/* ── Terminal log window ─────────────────────────────────────────────────── */
#log_box {
  background: #0d1117;
  color: #58a65c;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 12px;
  line-height: 1.6;
  padding: 12px 14px;
  border-radius: 8px;
  height: 420px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  border: 1px solid #21262d;
  scroll-behavior: smooth;
}

#log_box .log-error   { color: #f85149; }
#log_box .log-skip    { color: #8b949e; }
#log_box .log-success { color: #3fb950; }
#log_box .log-info    { color: #79c0ff; }

/* R-063: log-trim notice surfaced when the SSE stream pushes us past the
 * client-side cap of 5000 lines. Styled to match the log-box dark theme. */
.log-truncated-notice {
  font-size: 11px;
  color: #c9d1d9;
  background: #21262d;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 6px 10px;
  margin-bottom: 6px;
}

/* Fullscreen mode for the log box */
#log_box.log-box-fullscreen {
  position: fixed;
  inset: 0;
  height: 100vh;
  width: 100vw;
  border-radius: 0;
  z-index: 60;
}

/* ── Status badges ───────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-queued    { background: #374151; color: #9ca3af; }
.badge-running   { background: #1e3a5f; color: #60a5fa; }
.badge-done      { background: #14532d; color: #4ade80; }
.badge-failed    { background: #4b1010; color: #f87171; }
.badge-cancelled { background: #292524; color: #78716c; }

/* Running pulse animation */
.badge-running::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  background: #60a5fa;
  border-radius: 50%;
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.8); }
}

/* ── Toast notifications ─────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  top: 24px;
  left: 0;
  right: 0;
  margin-inline: auto;
  width: fit-content;
  max-width: calc(100vw - 32px);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: auto;
  max-width: 320px;
}
.toast.show   { opacity: 1; transform: translateY(0); }
.toast-success { background: #166534; border: 1px solid #16a34a; }
.toast-error   { background: #7f1d1d; border: 1px solid #dc2626; }
.toast-info    { background: #1e3a5f; border: 1px solid #2563eb; }

/* R-068: error toasts have a dismiss button, so they need horizontal layout. */
.toast-error {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}
.toast-msg { flex: 1; min-width: 0; }
.toast-close {
  background: transparent;
  border: 0;
  color: inherit;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  margin: -4px -8px -4px 0;
  border-radius: 4px;
  opacity: 0.8;
}
.toast-close:hover, .toast-close:focus { opacity: 1; outline: 2px solid #fff; }

/* ── File drop zone ──────────────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed #374151;
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  color: #6b7280;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.drop-zone.drag-over,
.drop-zone:hover {
  border-color: #3b82f6;
  background: #1e3a5f22;
  color: #93c5fd;
}

/* ── Validate status ─────────────────────────────────────────────────────── */
.validate-ok   { color: #4ade80; }
.validate-err  { color: #f87171; }
.validate-info { color: #60a5fa; }

/* ── Spinner ─────────────────────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── SSE connection dot ──────────────────────────────────────────────────── */
.sse-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: #4ade80;
  border-radius: 50%;
  animation: pulse 1.8s ease-in-out infinite;
}
.sse-dot.disconnected { background: #6b7280; animation: none; }

/* ── Tab buttons ─────────────────────────────────────────────────────────── */
.tab-btn { transition: color 0.15s, border-color 0.15s; }

/* ── Table rows ──────────────────────────────────────────────────────────── */
tbody tr { transition: background 0.1s; }

/* ── Scrollbar theming (Webkit) ──────────────────────────────────────────── */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #161b22; }
::-webkit-scrollbar-thumb { background: #30363d; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #484f58; }

/* ── Form inputs global ──────────────────────────────────────────────────── */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
textarea,
select {
  color-scheme: dark;
}

/* ── T-147: suppress the native datalist dropdown arrow ──────────────────────
   Inputs with a `list=` attribute (the collection-name combobox) get a custom
   chevron button + popdown from collection-combobox.js. Chromium ALSO renders
   its own ::-webkit-calendar-picker-indicator for list-bound inputs, which
   surfaces a second down-arrow on hover, just left of the custom chevron.
   Hide the native control so only the custom chevron shows. */
input[list]::-webkit-calendar-picker-indicator {
  display: none !important;
}

/* ── R-067: invalid-field highlight ──────────────────────────────────────────
   When the server rejects a submission (422), api.js adds .field-invalid to the
   offending input so the user sees WHERE the problem is, not just a toast. The
   ring clears as soon as they edit the field. */
.field-invalid,
.field-invalid:focus {
  border-color: #f87171 !important;                 /* red-400 */
  box-shadow: 0 0 0 1px #f87171 !important;
}

/* ── Mobile touch-target helper ──────────────────────────────────────────── */
/* Opt-in utility — do not apply globally. Used case-by-case for compact
   controls that need a 40px tap target on mobile. */
.min-h-touch { min-height: 40px; }

/* ── Cookie consent banner (R-019 / R-119) ───────────────────────────────── */
.cookie-banner {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 60;            /* above content, below blocking modals (100+) */
  background: #111827;
  border-top: 1px solid #374151;
  box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.45);
  color: #e5e7eb;
}
.cookie-banner[hidden] { display: none; }
.cookie-banner-inner {
  max-width: 72rem;
  margin: 0 auto;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
@media (min-width: 768px) {
  .cookie-banner-inner { flex-direction: row; align-items: center; justify-content: space-between; }
}
.cookie-banner-title { font-weight: 600; font-size: 0.9375rem; margin: 0 0 0.15rem; }
.cookie-banner-desc  { font-size: 0.8125rem; color: #9ca3af; margin: 0; line-height: 1.45; }
.cookie-banner-desc a { color: #93c5fd; text-decoration: underline; }
.cookie-banner-desc a:hover { color: #bfdbfe; }
.cookie-banner-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  flex-shrink: 0;
}
.cookie-banner-categories {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.cookie-cat-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.8125rem;
}
.cookie-cat-row input { margin-top: 0.2rem; flex-shrink: 0; }
.cookie-cat-title { display: block; font-weight: 600; color: #e5e7eb; }
.cookie-cat-desc  { display: block; color: #9ca3af; line-height: 1.4; }
.cookie-btn {
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 0.5rem 0.9rem;
  border-radius: 0.375rem;
  border: 1px solid transparent;
  cursor: pointer;
  min-height: 40px;
}
.cookie-btn-accept { background: #2563eb; color: #fff; }
.cookie-btn-accept:hover { background: #3b82f6; }
.cookie-btn-reject { background: #1f2937; color: #d1d5db; border-color: #374151; }
.cookie-btn-reject:hover { background: #374151; }
.cookie-btn-ghost  { background: transparent; color: #93c5fd; border-color: #374151; }
.cookie-btn-ghost:hover { background: #1f2937; }
.cookie-btn:focus-visible { outline: 2px solid #60a5fa; outline-offset: 2px; }

/* ── R-215: print stylesheet ──────────────────────────────────────────────────
   The app's dark theme (bg-gray-950 / light text) prints as heavy ink and
   washed-out gray, and Ctrl+P of a job's log was barely legible. Force a clean
   light render, drop interactive chrome that has no meaning on paper, and let
   the log box expand to its full content so the whole run prints. Print-only —
   nothing here affects the on-screen experience. */
@media print {
  body { background: #fff !important; }

  /* Black text + transparent fills throughout the content area so Tailwind's
     dark card backgrounds and light text utilities don't survive onto paper. */
  main, main * { color: #000 !important; background-color: transparent !important; }

  /* Chrome that doesn't belong in a printout. */
  nav, footer,
  #toast-container, #cookie-banner, #verify-banner,
  button, .tab-btn { display: none !important; }

  a { text-decoration: underline; }

  /* The log box is a fixed-height scroll region on screen — expand it so the
     full transcript/log prints instead of just the visible slice. */
  #log_box {
    max-height: none !important;
    height: auto !important;
    overflow: visible !important;
    border: 1px solid #999 !important;
    white-space: pre-wrap !important;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace !important;
  }

  /* Hidden tab panels stay hidden; only the active tab prints. */
}

