/*
 * Design primitives — the reusable component vocabulary. Every app/module
 * UI in the control room (Jobs, Files, Chat, Terminal, Trivia, Registry,
 * and anything added later) should reach for these classes instead of
 * re-declaring its own button/card/input/badge/chip look. A module
 * stylesheet should only ever add *layout* for its own screens, composed
 * from these primitives and the tokens in tokens.css.
 */

/* Buttons */

.btn {
  min-height: 48px;
  border-radius: var(--radius-md);
  border: var(--border-width) solid var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0 20px;
  cursor: pointer;
  color: var(--text);
  background: var(--card);
  box-shadow: var(--shadow-brutal-sm);
  transition: transform var(--duration-fast), box-shadow var(--duration-fast);
}

.btn:active {
  transform: translate(var(--press-offset), var(--press-offset));
  box-shadow: none;
}

.btn-block {
  width: 100%;
  display: block;
  margin-top: 12px;
}

.btn-large {
  min-height: 56px;
  font-size: 17px;
}

.btn-small {
  min-height: 40px;
  padding: 0 14px;
  font-size: 14px;
}

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

.btn-primary:active {
  background: var(--accent-hover);
  color: #fff;
}

.btn-secondary {
  background: var(--card-2);
  color: var(--text);
}

.btn-danger {
  background: var(--danger-fill);
  color: var(--ink);
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
  box-shadow: var(--shadow-brutal-sm);
  transform: none;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text);
  font-size: 20px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.link {
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}

.back-link {
  display: inline-block;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  margin-bottom: 12px;
  font-size: 15px;
}

/* Cards */

.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 16px;
  border: var(--border-width) solid var(--ink);
  box-shadow: var(--shadow-brutal);
}

/* Forms */

.field-label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin: 14px 0 6px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field-label:first-child {
  margin-top: 0;
}

.field-group {
  margin-bottom: 4px;
}

.textarea,
.input {
  width: 100%;
  background: var(--card-2);
  border: var(--border-width) solid var(--ink);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 16px;
  padding: 12px 14px;
  font-family: inherit;
  transition: box-shadow var(--duration-fast);
}

.textarea:focus,
.input:focus {
  outline: none;
  box-shadow: var(--shadow-brutal-sm);
}

.textarea {
  resize: vertical;
  min-height: 96px;
}

.input-with-action {
  display: flex;
  gap: 8px;
  align-items: center;
}

.input-with-action .input {
  flex: 1;
}

.hint {
  font-size: 12px;
  color: var(--text-tertiary);
  line-height: 1.5;
  margin: 8px 0 4px;
}

.segmented {
  display: flex;
  gap: 6px;
  background: var(--card-2);
  padding: 4px;
  border-radius: var(--radius-md);
  border: var(--border-width) solid var(--ink);
}

.segmented-option {
  flex: 1;
  min-height: 44px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  text-transform: capitalize;
  cursor: pointer;
}

.segmented-option.active {
  background: var(--accent);
  color: #fff;
}

/* Chips */

.attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--card-2);
  color: var(--text);
  border-radius: var(--radius-pill);
  padding: 8px 12px;
  font-size: 13px;
  border: var(--border-width-sm) solid var(--ink);
}

.chip.error {
  border-color: var(--danger);
  color: var(--danger);
}

.chip-remove {
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 14px;
  padding: 0;
  margin-left: 2px;
  cursor: pointer;
  min-height: auto;
}

.filter-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 12px;
  -webkit-overflow-scrolling: touch;
}

.filter-chips .chip {
  flex: none;
  min-height: 36px;
  cursor: pointer;
  background: var(--card);
  white-space: nowrap;
}

.filter-chips .chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Section headers */

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 22px 0 10px;
}

.section-header h2 {
  font-size: 11px;
  margin: 0;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-family: var(--font-pixel);
}

.section-header-in-card {
  margin: 0 0 10px;
}

/* Outdated-format badge/section — jobs, mastery courses, trivia quizzes
   all use this same pattern for a record saved by an older version of
   the app (see web/app.js's isOutdatedJob/isOutdatedCourse/isOutdatedQuiz
   and the matching CURRENT_*_VERSION constants). */

.outdated-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  border: var(--border-width-sm) solid var(--warning);
  color: var(--warning);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.outdated-section-header h2 {
  color: var(--warning);
}

.outdated-list {
  opacity: 0.75;
}

.outdated-notice {
  color: var(--warning);
}

/* Status badge */

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  border: var(--border-width-sm) solid var(--ink);
  font-size: 13px;
  font-weight: 700;
  text-transform: capitalize;
  background: var(--card-2);
}

.status-complete {
  color: var(--success);
}

.status-failed {
  color: var(--danger);
}

.status-running,
.status-queued,
.status-waiting_for_laptop {
  color: var(--warning);
}

.status-cancelled {
  color: var(--text-tertiary);
}

.status-paused {
  color: var(--accent);
}

/* Feedback states */

.empty-state {
  text-align: center;
  color: var(--text-secondary);
  padding: 40px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  font-size: 14px;
}

.loading {
  text-align: center;
  color: var(--text-secondary);
  padding: 40px 0;
}

.error-box {
  background: color-mix(in srgb, var(--danger) 8%, var(--card));
  border: var(--border-width) solid var(--danger);
  color: var(--danger);
  padding: 12px;
  border-radius: var(--radius-md);
  font-size: 14px;
  white-space: pre-wrap;
}

.plain-list {
  margin: 0;
  padding-left: 20px;
  color: var(--text-secondary);
  font-size: 14px;
}

/* Rich text rendering (chat replies, job/markdown output) */

.markdown-body {
  font-size: 15px;
  line-height: 1.6;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
  margin: 14px 0 8px;
}

.markdown-body p {
  margin: 0 0 10px;
}

.markdown-body pre {
  background: var(--card-2);
  border: var(--border-width-sm) solid var(--ink);
  padding: 12px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
}

.markdown-body code {
  background: var(--card-2);
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  font-size: 13px;
  font-family: var(--font-mono);
}

.markdown-body pre code {
  background: none;
  padding: 0;
}

.markdown-body a {
  color: var(--accent);
}

.markdown-body ul {
  padding-left: 20px;
}
