/* ═══════════════════════════════════════════════════════════════════════════
   Kronn Shared Component Classes
   Reusable across all pages: buttons, cards, inputs, badges, labels.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--kr-sp-3);
  padding: var(--kr-sp-4) var(--kr-sp-6);
  font-size: var(--kr-fs-sm);
  font-weight: 600;
  font-family: inherit;
  border-radius: var(--kr-r-md);
  border: 1px solid transparent;
  cursor: pointer;
  background: none;
  color: inherit;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: var(--kr-accent);
  color: var(--kr-bg-base);
  border-color: transparent;
  font-weight: 700;
}
.btn-primary:hover:not(:disabled) { opacity: 0.9; }

.btn-accent {
  background: rgba(var(--kr-accent-rgb), 0.08);
  color: var(--kr-accent);
  border-color: var(--kr-accent-border-light);
}
.btn-accent:hover:not(:disabled) { background: rgba(var(--kr-accent-rgb), 0.15); }

.btn-secondary {
  background: var(--kr-bg-hover);
  color: var(--kr-text-secondary);
  border-color: var(--kr-border-medium);
}
.btn-secondary:hover:not(:disabled) { background: var(--kr-bg-active); }

.btn-danger {
  background: rgba(var(--kr-error-rgb), 0.08);
  color: var(--kr-error);
  border-color: rgba(var(--kr-error-rgb), 0.2);
}
.btn-danger:hover:not(:disabled) { background: rgba(var(--kr-error-rgb), 0.15); }

.btn-ghost {
  background: transparent;
  color: var(--kr-text-muted);
  border-color: transparent;
}
.btn-ghost:hover:not(:disabled) { background: var(--kr-bg-hover); color: var(--kr-text-secondary); }

.btn-icon {
  padding: var(--kr-sp-2) var(--kr-sp-3);
  gap: var(--kr-sp-2);
}

.btn-sm {
  padding: var(--kr-sp-2) var(--kr-sp-4);
  font-size: var(--kr-fs-xs);
}

/* ── Cards ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--kr-bg-surface);
  border: 1px solid var(--kr-border);
  border-radius: var(--kr-r-xl);
  overflow: hidden;
}
.card-active {
  border-color: var(--kr-accent-border);
}
.card-header {
  padding: var(--kr-sp-8) var(--kr-sp-9);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}
.card-body {
  padding: var(--kr-sp-8) var(--kr-sp-9);
  border-top: 1px solid var(--kr-border-light);
}
.card-section {
  padding: var(--kr-sp-8) var(--kr-sp-9);
}

/* ── Inputs ─────────────────────────────────────────────────────────────── */
.input {
  width: 100%;
  padding: var(--kr-sp-5) var(--kr-sp-7);
  font-size: var(--kr-fs-sm);
  font-family: inherit;
  color: var(--kr-text-primary);
  background: var(--kr-bg-hover);
  border: 1px solid var(--kr-border-medium);
  border-radius: var(--kr-r-md);
  outline: none;
  transition: border-color 0.15s;
}
.input:focus { border-color: var(--kr-accent-border-light); }
.input::placeholder { color: var(--kr-text-dim); }

/* Native <select> option items: browser-default = black-on-white on
 * most OS dropdowns, illegible on the Lila Arcade dark theme. Tokenize
 * them to match the input's own background + text colour so the dropdown
 * panel stays readable when expanded. Caught 2026-05-19 on the 0.8.6
 * Custom plugin auth picker. Applies globally to any `.input` select,
 * fixes the existing endpoint method picker too. */
.input option,
select.input option {
  background: var(--kr-bg-surface);
  color: var(--kr-text-primary);
}
.input option:checked,
.input option:hover {
  background: var(--kr-bg-elevated);
  color: var(--kr-text-primary);
}

.input-sm {
  padding: var(--kr-sp-3) var(--kr-sp-4);
  font-size: var(--kr-fs-xs);
}

.textarea {
  width: 100%;
  padding: var(--kr-sp-5) var(--kr-sp-7);
  font-size: var(--kr-fs-sm);
  font-family: inherit;
  color: var(--kr-text-primary);
  background: var(--kr-bg-hover);
  border: 1px solid var(--kr-border-medium);
  border-radius: var(--kr-r-md);
  outline: none;
  resize: vertical;
  min-height: 60px;
}
.textarea:focus { border-color: var(--kr-accent-border-light); }

/* ── Badges ─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--kr-sp-1);
  padding: 1px var(--kr-sp-3);
  font-size: var(--kr-fs-2xs);
  font-weight: 600;
  border-radius: var(--kr-r-sm);
  white-space: nowrap;
}

.badge-accent {
  background: rgba(var(--kr-accent-rgb), 0.1);
  color: var(--kr-accent);
  border: 1px solid rgba(var(--kr-accent-rgb), 0.2);
}
.badge-success {
  background: rgba(var(--kr-success-rgb), 0.1);
  color: var(--kr-success);
  border: 1px solid rgba(var(--kr-success-rgb), 0.2);
}
.badge-error {
  background: rgba(var(--kr-error-rgb), 0.1);
  color: var(--kr-error);
  border: 1px solid rgba(var(--kr-error-rgb), 0.2);
}
.badge-warning {
  background: rgba(var(--kr-warning-rgb), 0.1);
  color: var(--kr-warning);
  border: 1px solid rgba(var(--kr-warning-rgb), 0.2);
}
.badge-info {
  background: rgba(var(--kr-info-rgb), 0.1);
  color: var(--kr-info);
  border: 1px solid rgba(var(--kr-info-rgb), 0.2);
}
.badge-muted {
  background: var(--kr-bg-hover);
  color: var(--kr-text-muted);
  border: 1px solid var(--kr-border-light);
}

/* ── Code ───────────────────────────────────────────────────────────────── */
.code {
  font-family: var(--kr-font-mono);
  font-size: var(--kr-fs-sm);
  background: var(--kr-bg-code);
  padding: var(--kr-sp-3) var(--kr-sp-5);
  border-radius: var(--kr-r-md);
  word-break: break-all;
}

/* ── Labels ─────────────────────────────────────────────────────────────── */
.label {
  display: block;
  font-size: var(--kr-fs-base);
  font-weight: 600;
  color: var(--kr-text-secondary);
  margin-bottom: var(--kr-sp-3);
}
.label-sm {
  font-size: var(--kr-fs-sm);
  color: var(--kr-text-muted);
}

/* ── Section title ──────────────────────────────────────────────────────── */
.section-title {
  font-size: var(--kr-fs-xs);
  font-weight: 700;
  color: var(--kr-text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--kr-sp-4);
}

/* ── Status dot ─────────────────────────────────────────────────────────── */
.dot {
  width: 7px;
  height: 7px;
  border-radius: var(--kr-r-full);
  flex-shrink: 0;
}
.dot-on {
  background: var(--kr-success);
  box-shadow: 0 0 6px rgba(var(--kr-success-rgb), 0.4);
}
.dot-off {
  background: var(--kr-text-ghost);
}

/* ── Hint text ──────────────────────────────────────────────────────────── */
.hint {
  font-size: var(--kr-fs-xs);
  color: var(--kr-text-faint);
  margin-top: var(--kr-sp-2);
}

/* ── Divider ────────────────────────────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--kr-border-light);
  margin: var(--kr-sp-8) 0;
}

/* ── MCP origin badges (shared: Plugins page + Project cards) ──────────── */
.mcp-origin-badge {
  display: inline-block;
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 3px;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.mcp-origin-official {
  color: var(--kr-success);
  border: 1px solid rgba(var(--kr-success-rgb), 0.3);
}
.mcp-origin-community {
  color: var(--kr-warning);
  border: 1px solid rgba(var(--kr-warning-amber-rgb), 0.3);
}

/* ── Plugin kind badge (MCP / API / hybrid) ─────────────────────────────── */
.mcp-kind-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 3px;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.mcp-kind-badge-mcp {
  color: var(--kr-info);
  border: 1px solid rgba(var(--kr-info-rgb), 0.35);
}
.mcp-kind-badge-api {
  color: var(--kr-purple-soft);
  border: 1px solid rgba(var(--kr-purple-soft-rgb), 0.35);
}
.mcp-kind-badge-hybrid {
  color: var(--kr-text-primary);
  border: 1px solid var(--kr-border-heavy);
  background: linear-gradient(90deg, rgba(var(--kr-info-rgb), 0.12), rgba(var(--kr-purple-soft-rgb), 0.12));
}

/* ── MCP load indicator (shared: Plugins page + Project cards) ─────────── */
.mcp-load-ok { color: var(--kr-success); }
.mcp-load-warn { color: var(--kr-warning); }
.mcp-load-danger { color: var(--kr-error); }

/* ── 0.8.6 phase 2 — Disc participants header + invite modal ───────────
 * Tokens used (all defined in styles/tokens.css across themes) :
 *   --kr-bg-elevated, --kr-bg-code, --kr-bg-hover, --kr-border,
 *   --kr-accent, --kr-accent-rgb, --kr-text-primary, --kr-text-secondary,
 *   --kr-text-ghost, --kr-text-on-accent.
 * Bug 2026-05-21 : the first version used inline styles with two
 * invented tokens (`--kr-on-accent`, `--kr-bg-muted`) AND missed the
 * modal foreground color → black-on-black in dark theme. Locking the
 * theming via classes here.
 */

.disc-participants-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-right: 8px;
}

.disc-participants-empty {
  font-size: 0.85em;
  color: var(--kr-text-ghost);
}

.disc-participant-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  font-size: 0.8em;
  color: var(--kr-text-primary);
  border: 1px solid var(--kr-border);
  border-radius: 4px;
  background: transparent;
}

.disc-participant-chip[data-status="paused"] {
  background: var(--kr-bg-hover);
  opacity: 0.6;
}

.disc-participants-invite-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  font-size: 0.8em;
  border: 1px solid var(--kr-accent);
  border-radius: 4px;
  background: transparent;
  color: var(--kr-accent);
  cursor: pointer;
}

.disc-participants-invite-btn:hover:not(:disabled) {
  background: rgba(var(--kr-accent-rgb), 0.08);
}

.disc-participants-invite-btn:disabled {
  cursor: wait;
  opacity: 0.6;
}

.disc-invite-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.disc-invite-modal {
  background: var(--kr-bg-elevated);
  color: var(--kr-text-primary);
  border: 1px solid var(--kr-border);
  border-radius: 8px;
  padding: 16px;
  max-width: 520px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.disc-invite-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.disc-invite-modal-header h3 {
  margin: 0;
  font-size: 1em;
  color: var(--kr-text-primary);
}

.disc-invite-modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--kr-text-ghost);
}

.disc-invite-modal-close:hover {
  color: var(--kr-text-primary);
}

.disc-invite-modal-intro {
  font-size: 0.9em;
  color: var(--kr-text-secondary);
  margin: 0 0 8px 0;
}

.disc-invite-instruction {
  /* `--kr-bg-code-panel` is intentionally dark in EVERY theme (IDE
     convention, cf. tokens.css comments). But `--kr-text-primary`
     flips to a DARK value in light theme — that combo renders the
     copy-paste instruction black-on-black. Pin the text tokens to
     their dark-theme values inside this panel, mirroring the
     pattern used by `.git-panel-container` in GitPanel.css. */
  background: var(--kr-bg-code-panel);
  --kr-text-primary: #e8eaed;
  --kr-text-secondary: rgba(255, 255, 255, 0.7);
  --kr-text-ghost: rgba(255, 255, 255, 0.5);
  color: var(--kr-text-primary);
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  padding: 10px 12px;
  border-radius: 4px;
  font-size: 0.85em;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-all;
  margin: 8px 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.disc-invite-modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.disc-invite-copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border: 1px solid var(--kr-accent);
  border-radius: 4px;
  background: var(--kr-accent);
  color: var(--kr-text-on-accent);
  cursor: pointer;
}

.disc-invite-copy-btn:hover {
  filter: brightness(1.1);
}

.disc-invite-expires-hint {
  font-size: 0.8em;
  color: var(--kr-text-ghost);
  margin: 8px 0 0 0;
}
