/**
 * PromptLayer UI components — sourced from Kitchen Sink.html.
 * Typography, buttons, forms, badges, and tags. Import after tokens.css.
 */

/* ---------- Type ---------- */
h1,
h2,
h3,
h4 {
  color: var(--ink);
  margin: 0;
  letter-spacing: -0.02em;
  font-weight: 600;
}

h1 {
  font-size: 56px;
  line-height: 1.05;
  letter-spacing: -0.035em;
  text-wrap: balance;
}

h2 {
  font-size: 32px;
  line-height: 1.15;
  letter-spacing: -0.025em;
}

h3 {
  font-size: 17px;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

h4 {
  font-size: 14px;
  line-height: 1.3;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.lede {
  font-size: 18px;
  line-height: 1.5;
  color: var(--muted);
}

.mono {
  font-family: var(--font-mono);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--r-sm);
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

.btn-primary {
  background: var(--ink);
  color: var(--bg);
}

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

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--border-strong);
}

.btn-ghost:hover {
  background: var(--surface-2);
}

.btn-quiet {
  background: transparent;
  color: var(--muted);
  padding: 0 4px;
}

.btn-quiet:hover {
  color: var(--ink);
}

.btn-danger {
  background: var(--err);
  color: #fff;
}

.btn-danger:hover {
  filter: brightness(0.92);
}

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

[data-theme='dark'] .btn-accent {
  color: var(--bg);
}

.btn-accent:hover {
  filter: brightness(0.95);
}

.btn-sm {
  height: 26px;
  padding: 0 10px;
  font-size: 12px;
}

.btn-lg {
  height: 40px;
  padding: 0 18px;
  font-size: 14px;
  border-radius: var(--r-md);
}

.btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn .arrow {
  font-family: var(--font-mono);
}

/* App shell aliases (Blade views use pl-btn-*) */
.pl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--r-sm);
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

.pl-btn-primary {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

.pl-btn-primary:hover {
  background: var(--ink-2);
  border-color: var(--ink-2);
}

.pl-btn-secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--border-strong);
}

.pl-btn-secondary:hover {
  background: var(--surface-2);
}

.pl-btn-ghost {
  background: transparent;
  color: var(--ink-2);
  border-color: transparent;
}

.pl-btn-ghost:hover {
  background: var(--surface-2);
}

.pl-btn-danger {
  background: var(--err);
  color: #fff;
  border-color: var(--err);
}

.pl-btn-danger:hover {
  filter: brightness(0.92);
}

/* ---------- Theme toggle ---------- */
.theme-tog {
  display: inline-flex;
  padding: 2px;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.theme-tog button {
  width: 24px;
  height: 22px;
  padding: 0;
  border: 0;
  cursor: pointer;
  border-radius: 4px;
  background: transparent;
  color: var(--subtle);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.theme-tog button.on {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-1);
}

.theme-tog svg {
  width: 12px;
  height: 12px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
}

/* ---------- Forms ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.field:last-child {
  margin-bottom: 0;
}

.field-label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink);
}

.field-hint {
  font-size: 11.5px;
  color: var(--subtle);
}

.field-error {
  font-size: 11.5px;
  color: var(--err);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

p.field-error {
  display: block;
}

.field-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.input,
.textarea,
.select,
.pl-input,
.pl-select,
.pl-textarea {
  width: 100%;
  height: 32px;
  padding: 0 10px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  font-family: var(--font-sans);
  font-size: 13px;
  transition: border-color 100ms ease, box-shadow 100ms ease;
}

.input::placeholder,
.textarea::placeholder,
.pl-input::placeholder,
.pl-textarea::placeholder {
  color: var(--subtle);
}

.input:hover,
.textarea:hover,
.select:hover,
.pl-input:hover,
.pl-select:hover,
.pl-textarea:hover {
  border-color: var(--muted);
}

.input:focus,
.textarea:focus,
.select:focus,
.pl-input:focus,
.pl-select:focus,
.pl-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 22%, transparent);
}

.input.error,
.textarea.error,
.select.error,
.pl-input.error,
.pl-select.error {
  border-color: var(--err);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--err) 18%, transparent);
}

.input[disabled],
.textarea[disabled],
.select[disabled],
.pl-input:disabled,
.pl-select:disabled,
.pl-textarea:disabled {
  background: var(--surface-2);
  color: var(--muted);
  cursor: not-allowed;
}

.textarea,
.pl-textarea {
  height: auto;
  padding: 8px 10px;
  line-height: 1.5;
  resize: vertical;
  min-height: 80px;
}

.input.mono,
.textarea.mono,
.pl-input.mono,
.pl-textarea.mono {
  font-family: var(--font-mono);
  font-size: 12.5px;
}

.input-group {
  display: flex;
  align-items: stretch;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  overflow: hidden;
  transition: border-color 100ms ease, box-shadow 100ms ease;
}

.input-group:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 22%, transparent);
}

.input-group .affix {
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  background: var(--surface-2);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 12px;
  border-right: 1px solid var(--border-faint);
}

.input-group .affix.suffix {
  border-right: 0;
  border-left: 1px solid var(--border-faint);
}

.input-group .input,
.input-group .pl-input {
  border: 0;
  border-radius: 0;
  height: 30px;
  background: transparent;
  flex: 1;
}

.input-group .input:focus,
.input-group .pl-input:focus {
  box-shadow: none;
}

.select,
.pl-select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 28px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10' fill='none' stroke='%236B6B76' stroke-width='1.4'><path d='M2 4l3 3 3-3'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

[data-theme='dark'] .select,
[data-theme='dark'] .pl-select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10' fill='none' stroke='%238B8B95' stroke-width='1.4'><path d='M2 4l3 3 3-3'/></svg>");
}

.check,
.radio {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 100ms ease, border-color 100ms ease;
}

.radio {
  border-radius: 50%;
}

.check:hover,
.radio:hover {
  border-color: var(--muted);
}

.check:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.check:checked::after {
  content: '';
  width: 8px;
  height: 8px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M2 5.5l2 2 4-4.5'/></svg>");
  background-repeat: no-repeat;
  background-size: contain;
}

.radio:checked {
  border-color: var(--accent);
  border-width: 5px;
  background: var(--surface);
}

[data-theme='dark'] .check:checked::after {
  filter: brightness(0.2);
}

.check:focus-visible,
.radio:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 22%, transparent);
}

.choice-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
  padding: 4px 0;
}

.switch {
  appearance: none;
  -webkit-appearance: none;
  width: 28px;
  height: 16px;
  flex-shrink: 0;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
}

.switch::after {
  content: '';
  position: absolute;
  top: 1px;
  left: 1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow-1);
  transition: transform 140ms ease;
}

.switch:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.switch:checked::after {
  transform: translateX(12px);
  background: #fff;
}

[data-theme='dark'] .switch:checked::after {
  background: var(--bg);
}

.pl-label,
.field-label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink);
}

.pl-label {
  display: block;
  margin-bottom: 6px;
  text-transform: none;
  letter-spacing: normal;
}

/* ---------- Badges & tags ---------- */
.pbadge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 18px;
  padding: 0 7px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 500;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border-faint);
}

.pbadge.ok {
  background: var(--ok-bg);
  color: var(--ok);
  border-color: transparent;
}

.pbadge.warn {
  background: var(--warn-bg);
  color: var(--warn);
  border-color: transparent;
}

.pbadge.err {
  background: var(--err-bg);
  color: var(--err);
  border-color: transparent;
}

.pbadge.info {
  background: var(--info-bg);
  color: var(--info);
  border-color: transparent;
}

.pbadge.mono {
  font-family: var(--font-mono);
  font-weight: 400;
}

.pbadge .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.tag {
  align-self: flex-start;
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 500;
  color: var(--muted);
  padding: 3px 7px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--surface-2);
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px;
  box-shadow: var(--shadow-1);
}

.card.flat {
  box-shadow: none;
}

.card.pop {
  box-shadow: var(--shadow-pop);
}

.card .ctitle {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  margin: 0;
}

.card .cbody {
  font-size: 13px;
  color: var(--muted);
  margin: 6px 0 0;
  line-height: 1.5;
}

.card .card-form {
  margin-top: 18px;
}

/* ---------- Alerts ---------- */
.alert {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-1);
}

.alert + .alert {
  margin-top: 10px;
}

.alert .glyph {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 13px;
}

.alert .body .title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  margin: 0;
}

.alert .body .desc {
  font-size: 12.5px;
  color: var(--muted);
  margin: 2px 0 0;
  line-height: 1.45;
}

.alert.ok {
  background: color-mix(in oklab, var(--ok-bg) 60%, var(--surface));
  border-color: color-mix(in oklab, var(--ok) 18%, var(--border));
}

.alert.warn {
  background: color-mix(in oklab, var(--warn-bg) 60%, var(--surface));
  border-color: color-mix(in oklab, var(--warn) 18%, var(--border));
}

.alert.err {
  background: color-mix(in oklab, var(--err-bg) 60%, var(--surface));
  border-color: color-mix(in oklab, var(--err) 18%, var(--border));
}

.alert.info {
  background: color-mix(in oklab, var(--info-bg) 60%, var(--surface));
  border-color: color-mix(in oklab, var(--info) 18%, var(--border));
}

.gl-ok {
  background: var(--ok-bg);
  color: var(--ok);
}

.gl-warn {
  background: var(--warn-bg);
  color: var(--warn);
}

.gl-err {
  background: var(--err-bg);
  color: var(--err);
}

.gl-info {
  background: var(--info-bg);
  color: var(--info);
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.notice-box {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-faint);
  background: var(--surface-2);
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink-2);
}

/* ---------- Settings page ---------- */
.settings-page {
  max-width: 560px;
}

.settings-page .card + .card {
  margin-top: 14px;
}

.settings-header .eyebrow {
  display: block;
}

.settings-header h2 {
  margin-top: 8px;
}

.settings-header .lede {
  margin-top: 10px;
}

/* ---------- Auth (login / register) ---------- */
.auth-shell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 40px 24px;
}

.auth-shell-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 400px;
  margin-bottom: 28px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 28px;
  box-shadow: var(--shadow-1);
}

.auth-title {
  margin: 0 0 8px;
  font-size: 24px;
  line-height: 1.2;
  letter-spacing: -0.02em;
  font-weight: 600;
  color: var(--ink);
}

.auth-lede {
  margin: 0 0 24px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
}

.auth-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 24px;
  flex-wrap: wrap;
}

.auth-actions-end {
  justify-content: flex-end;
}

.auth-link {
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
}

.auth-link:hover {
  color: var(--ink);
}

.auth-status {
  margin-bottom: 16px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  font-size: 13px;
  line-height: 1.45;
  background: color-mix(in oklab, var(--ok-bg) 60%, var(--surface));
  border: 1px solid color-mix(in oklab, var(--ok) 18%, var(--border));
  color: var(--ok);
}
