/* ============================================================
   FLUXATH CRM — Stripe-inspired form primitives
   (Phase 2A of stripe-reskin-2026-05-24)

   Scope: buttons (.btn, .btn.primary, .btn.subtle, .btn.danger,
   .btn-pill, .btn-sm), text inputs / textareas / selects,
   checkboxes, radios, toggle switches.

   Rules consume tokens from tokens-stripe.css (--rad-*, --ease-*,
   --shadow-soft-blue-*, --type-button-*). Color tokens stay sourced
   from style.css (--brand, --accent, --ink, etc.) so the FLUXATH
   palette + 12 accent themes + dark/light base survive intact.

   NO template logic edits. NO data-action wiring changes. CSS only.
   ============================================================ */

/* ============================================================
   1. BUTTONS
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--rad-md);
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--ink);
  font: var(--type-button-md);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background   var(--dur-fast) var(--ease-stripe),
    border-color var(--dur-fast) var(--ease-stripe),
    color        var(--dur-fast) var(--ease-stripe),
    transform    var(--dur-fast) var(--ease-stripe),
    box-shadow   var(--dur-fast) var(--ease-stripe);
}

.btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-bright);
  color: var(--ink);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft-blue-1);
}

.btn:active {
  transform: translateY(0);
  box-shadow: none;
}

.btn:disabled,
.btn[disabled],
.btn[aria-disabled="true"] {
  opacity: .55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  pointer-events: none;
}

/* Primary */
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--ink-on-accent);
}

.btn.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--ink-on-accent);
}

/* Subtle */
.btn.subtle {
  background: transparent;
  border-color: transparent;
  color: var(--ink-dim);
}

.btn.subtle:hover {
  background: var(--bg-elev);
  border-color: transparent;
  color: var(--ink);
}

/* Danger */
.btn.danger {
  background: transparent;
  border-color: var(--danger-soft);
  color: var(--danger);
}

.btn.danger:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--danger);
}

/* Small */
.btn.small,
.btn.sm {
  padding: 5px 12px;
  font: var(--type-button-sm);
}

/* Pill modifier (NEW utility class) */
.btn.pill {
  border-radius: var(--rad-pill);
}

/* Focus ring — WCAG 2.4.7, :focus-visible so mouse users don't see ring */
.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-line);
}

/* ── Density: compact ── */
[data-density="compact"] .btn {
  padding: 6px 12px;
}

[data-density="compact"] .btn.small,
[data-density="compact"] .btn.sm {
  padding: 4px 10px;
}

/* ============================================================
   2. TEXT-LIKE INPUTS (scoped — checkbox/radio excluded)
   ============================================================ */

input[type="text"],
input[type="email"],
input[type="search"],
input[type="url"],
input[type="tel"],
input[type="date"],
input[type="number"],
input[type="password"],
textarea,
select {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--rad-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--ink);
  font: var(--type-body-md);
  font-family: inherit;
  box-sizing: border-box;
  transition:
    border-color var(--dur-fast) var(--ease-stripe),
    box-shadow   var(--dur-fast) var(--ease-stripe);
  appearance: auto;
}

input[type="text"]:focus-visible,
input[type="email"]:focus-visible,
input[type="search"]:focus-visible,
input[type="url"]:focus-visible,
input[type="tel"]:focus-visible,
input[type="date"]:focus-visible,
input[type="number"]:focus-visible,
input[type="password"]:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-line);
}

/* Also handle plain :focus for browsers that don't support :focus-visible */
input[type="text"]:focus:not(:focus-visible),
input[type="email"]:focus:not(:focus-visible),
input[type="search"]:focus:not(:focus-visible),
input[type="url"]:focus:not(:focus-visible),
input[type="tel"]:focus:not(:focus-visible),
input[type="date"]:focus:not(:focus-visible),
input[type="number"]:focus:not(:focus-visible),
input[type="password"]:focus:not(:focus-visible),
textarea:focus:not(:focus-visible),
select:focus:not(:focus-visible) {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-line);
}

textarea {
  resize: vertical;
  line-height: 1.5;
}

select {
  cursor: pointer;
}

/* Dark-theme: --bg resolves to #13131f, --border to rgba(255,255,255,0.10)
   — both cascade correctly from style.css without additional overrides.
   Explicit confirmation comment only; no extra rule needed. */

/* ============================================================
   3. CHECKBOXES + RADIOS
   ============================================================ */

input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--accent);
  /* Stripe's preferred pattern: let the platform render natively,
     tinted to the accent color. No custom geometry. */
  width: 16px;
  height: 16px;
  cursor: pointer;
  flex-shrink: 0;
}

input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ============================================================
   4. TOGGLE SWITCH
   ============================================================ */

/* Generalized classes — IDs (#theme-toggle-pill, #theme-toggle-knob)
   continue to work because we keep both selectors. */

#theme-toggle-pill,
.toggle-switch {
  display: inline-flex;
  align-items: center;
  width: 36px;
  height: 20px;
  border-radius: var(--rad-pill);
  background: var(--brand);
  padding: 2px;
  flex-shrink: 0;
  cursor: pointer;
  transition: background 200ms var(--ease-stripe);
}

#theme-toggle-knob,
.toggle-switch-knob {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--toggle-knob-bg);
  /* Default: off state — knob at left */
  transform: translateX(0);
  transition: transform 200ms var(--ease-stripe);
}

/* On/checked state: JS adds data-on or moves the knob inline;
   the existing inline style `transform:translateX(16px)` on #theme-toggle-knob
   will cascade after this rule — no override needed.
   For .toggle-switch pattern, pair with .toggle-switch[aria-checked="true"] > .toggle-switch-knob */
.toggle-switch[aria-checked="true"] > .toggle-switch-knob,
.toggle-switch.on > .toggle-switch-knob {
  transform: translateX(16px);
}

/* Focus ring on the toggle host button */
#theme-toggle-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ============================================================
   5. FILE-UPLOAD / CHANGE PHOTO LABEL
   ============================================================ */

.change-photo-label {
  font-size: 11px;
  color: var(--accent);
  cursor: pointer;
  margin-top: 3px;
  display: inline-block;
  text-decoration: none;
  transition: text-decoration var(--dur-fast) var(--ease-stripe);
}

.change-photo-label:hover {
  text-decoration: underline;
  color: var(--accent-bright);
}

.change-photo-label:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ============================================================
   5. INLINE SVG ICONS  (shared _macros.html `icon()`)
   ============================================================ */

.ic {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}
/* In the sidebar the icon sits inside a fixed-width .icon span — center it */
.nav-link .icon .ic { vertical-align: -2px; }

/* ============================================================
   6. EMPTY STATES  (shared _macros.html `empty_state()` → .ui-empty)
   Distinct from the page-local `.empty-state` used by dashboard/pipeline.
   ============================================================ */

.ui-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
  padding: 48px 24px;
  color: var(--ink-muted, var(--muted));
}
.ui-empty-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--accent-line, rgba(0,200,255,0.08));
  color: var(--accent);
  margin-bottom: 4px;
}
.ui-empty-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}
.ui-empty-sub {
  font-size: 13px;
  line-height: 1.5;
  max-width: 380px;
}
.ui-empty-cta { margin-top: 10px; }

/* Compact variant for small mini-list cards (dashboard) */
.ui-empty.compact { padding: 22px 14px; gap: 5px; }
.ui-empty.compact .ui-empty-icon { width: 40px; height: 40px; margin-bottom: 2px; }
.ui-empty.compact .ui-empty-title { font-size: 13px; }
.ui-empty.compact .ui-empty-sub { font-size: 12px; }
