/* ============================================================
   Planet Solara — Component styles
   Class-based styling for the React primitives. Shipped to
   consumers via styles.css so window.<NS>.Button etc. render
   correctly anywhere the global stylesheet is linked.
   All visual values reference design tokens.
   ============================================================ */

/* ---------------- Button ---------------- */
.sol-btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--space-2);
  height: 40px; padding: 0 var(--space-5);
  font-family: var(--font-sans); font-size: var(--text-sm);
  font-weight: var(--weight-semibold); letter-spacing: 0.01em;
  line-height: 1; white-space: nowrap;
  border: 1px solid transparent; border-radius: var(--radius-md);
  cursor: pointer; user-select: none;
  transition: var(--transition-color), transform var(--dur-fast) var(--ease-out);
}
.sol-btn:active { transform: translateY(1px); }
.sol-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.sol-btn[disabled], .sol-btn[aria-disabled="true"] {
  opacity: 0.42; cursor: not-allowed; pointer-events: none;
}
.sol-btn--sm { height: 32px; padding: 0 var(--space-4); font-size: var(--text-xs); }
.sol-btn--lg { height: 48px; padding: 0 var(--space-6); font-size: var(--text-base); }
.sol-btn--block { display: flex; width: 100%; }
.sol-btn__icon { display: inline-flex; flex: none; }
.sol-btn__icon svg { width: 1.05em; height: 1.05em; display: block; }

.sol-btn--primary {
  background: var(--grad-solar); color: var(--text-on-solar);
  box-shadow: 0 1px 0 rgba(255,255,255,.18) inset, var(--shadow-sm);
}
.sol-btn--primary:hover { box-shadow: var(--glow-solar-md); }
.sol-btn--secondary {
  background: var(--surface-raised); color: var(--text-strong);
  border-color: var(--border-strong);
}
.sol-btn--secondary:hover { border-color: var(--accent-line); background: var(--surface-overlay); }
.sol-btn--ghost { background: transparent; color: var(--text-body); }
.sol-btn--ghost:hover { background: var(--surface-raised); color: var(--text-strong); }
.sol-btn--outline {
  background: transparent; color: var(--accent); border-color: var(--accent-line);
}
.sol-btn--outline:hover { background: var(--accent-soft); border-color: var(--accent); }
.sol-btn--danger {
  background: var(--ember-600); color: var(--white); border-color: var(--ember-500);
}
.sol-btn--danger:hover { box-shadow: var(--glow-ember); }
.sol-btn__spin { width: 1em; height: 1em; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: solara-spin 0.7s linear infinite; }

/* ---------------- IconButton ---------------- */
.sol-iconbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; flex: none;
  border-radius: var(--radius-md); border: 1px solid transparent;
  background: transparent; color: var(--text-muted);
  cursor: pointer; transition: var(--transition-color);
}
.sol-iconbtn:hover { color: var(--text-strong); background: var(--surface-raised); }
.sol-iconbtn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.sol-iconbtn--sm { width: 32px; height: 32px; }
.sol-iconbtn--lg { width: 48px; height: 48px; }
.sol-iconbtn--solid { background: var(--surface-raised); border-color: var(--border-default); color: var(--text-strong); }
.sol-iconbtn--solid:hover { border-color: var(--accent-line); }
.sol-iconbtn--active { color: var(--accent); background: var(--accent-soft); }
.sol-iconbtn svg { width: 18px; height: 18px; display: block; }

/* ---------------- Badge ---------------- */
.sol-badge {
  display: inline-flex; align-items: center; gap: var(--space-1_5);
  height: 22px; padding: 0 var(--space-2_5, 10px);
  font-family: var(--font-mono); font-size: var(--text-2xs);
  font-weight: var(--weight-medium); letter-spacing: 0.04em;
  text-transform: uppercase; border-radius: var(--radius-sm);
  border: 1px solid transparent; white-space: nowrap;
}
.sol-badge__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.sol-badge--neutral  { background: var(--surface-inset); color: var(--text-muted); border-color: var(--border-subtle); }
.sol-badge--solar    { background: var(--accent-soft); color: var(--solar-300); border-color: var(--accent-line); }
.sol-badge--nominal  { background: var(--status-nominal-soft); color: var(--aurora-400); border-color: color-mix(in oklab, var(--aurora-500) 35%, transparent); }
.sol-badge--caution  { background: var(--status-caution-soft); color: var(--amber-400); border-color: color-mix(in oklab, var(--amber-500) 35%, transparent); }
.sol-badge--critical { background: var(--status-critical-soft); color: var(--ember-400); border-color: color-mix(in oklab, var(--ember-500) 40%, transparent); }
.sol-badge--solid    { background: var(--grad-solar); color: var(--text-on-solar); }

/* ---------------- Tag ---------------- */
.sol-tag {
  display: inline-flex; align-items: center; gap: var(--space-2);
  height: 28px; padding: 0 var(--space-3);
  font-family: var(--font-sans); font-size: var(--text-xs); font-weight: var(--weight-medium);
  color: var(--text-body); background: var(--surface-raised);
  border: 1px solid var(--border-default); border-radius: var(--radius-pill);
}
.sol-tag__x {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; margin-right: -4px; border-radius: 50%;
  color: var(--text-faint); cursor: pointer; transition: var(--transition-color);
}
.sol-tag__x:hover { color: var(--text-strong); background: var(--surface-overlay); }
.sol-tag__x svg { width: 12px; height: 12px; }

/* ---------------- Avatar ---------------- */
.sol-avatar {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; flex: none; border-radius: 50%;
  background: var(--surface-overlay); color: var(--text-strong);
  font-family: var(--font-sans); font-weight: var(--weight-semibold); font-size: var(--text-sm);
  overflow: hidden; border: 1px solid var(--border-default);
}
.sol-avatar img { width: 100%; height: 100%; object-fit: cover; }
.sol-avatar--sm { width: 28px; height: 28px; font-size: var(--text-2xs); }
.sol-avatar--lg { width: 56px; height: 56px; font-size: var(--text-lg); }
.sol-avatar--ring { box-shadow: 0 0 0 2px var(--bg-app), 0 0 0 3px var(--accent); }
.sol-avatar__status {
  position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px;
  border-radius: 50%; border: 2px solid var(--bg-app);
}

/* ---------------- Input ---------------- */
.sol-field { display: flex; flex-direction: column; gap: var(--space-2); }
.sol-field__label { font-family: var(--font-mono); font-size: var(--text-2xs);
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-faint); }
.sol-input-wrap { position: relative; display: flex; align-items: center; }
.sol-input {
  width: 100%; height: 42px; padding: 0 var(--space-3);
  font-family: var(--font-sans); font-size: var(--text-base); color: var(--text-strong);
  background: var(--surface-sunken); border: 1px solid var(--border-default);
  border-radius: var(--radius-md); transition: var(--transition-color); outline: none;
}
.sol-input::placeholder { color: var(--text-faint); }
.sol-input:hover { border-color: var(--border-strong); }
.sol-input:focus { border-color: var(--accent); box-shadow: var(--glow-solar-sm); background: var(--space-900); }
.sol-input-wrap--icon .sol-input { padding-left: 38px; }
.sol-input__icon { position: absolute; left: 12px; color: var(--text-faint); display: flex; pointer-events: none; }
.sol-input__icon svg { width: 16px; height: 16px; }
.sol-input--error { border-color: var(--ember-500); }
.sol-input--error:focus { box-shadow: var(--glow-ember); }
.sol-field__hint { font-size: var(--text-xs); color: var(--text-faint); }
.sol-field__hint--error { color: var(--ember-400); }

/* ---------------- Select ---------------- */
.sol-select-wrap { position: relative; display: flex; align-items: center; }
.sol-select {
  appearance: none; width: 100%; height: 42px; padding: 0 36px 0 var(--space-3);
  font-family: var(--font-sans); font-size: var(--text-base); color: var(--text-strong);
  background: var(--surface-sunken); border: 1px solid var(--border-default);
  border-radius: var(--radius-md); cursor: pointer; outline: none; transition: var(--transition-color);
}
.sol-select:hover { border-color: var(--border-strong); }
.sol-select:focus { border-color: var(--accent); box-shadow: var(--glow-solar-sm); }
.sol-select-wrap__chevron { position: absolute; right: 12px; color: var(--text-faint); pointer-events: none; display: flex; }
.sol-select-wrap__chevron svg { width: 16px; height: 16px; }

/* ---------------- Switch ---------------- */
.sol-switch { display: inline-flex; align-items: center; gap: var(--space-3); cursor: pointer; user-select: none; }
.sol-switch__track {
  position: relative; width: 42px; height: 24px; flex: none;
  background: var(--surface-inset); border: 1px solid var(--border-default);
  border-radius: var(--radius-pill); transition: var(--transition-color);
}
.sol-switch__thumb {
  position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  border-radius: 50%; background: var(--text-muted);
  transition: transform var(--dur-base) var(--ease-out), background var(--dur-fast);
}
.sol-switch--on .sol-switch__track { background: var(--accent-soft); border-color: var(--accent); }
.sol-switch--on .sol-switch__thumb { transform: translateX(18px); background: var(--accent); box-shadow: var(--glow-solar-sm); }
.sol-switch__label { font-size: var(--text-sm); color: var(--text-body); }

/* ---------------- Card ---------------- */
.sol-card {
  background: var(--surface-card); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg); padding: var(--space-5);
  box-shadow: var(--shadow-md); position: relative;
}
.sol-card--raised { background: var(--surface-raised); box-shadow: var(--shadow-lg); }
.sol-card--glow { border-color: var(--accent-line); box-shadow: var(--shadow-md), var(--glow-solar-md); }
.sol-card--inset { background: var(--surface-sunken); box-shadow: none; }
.sol-card__corner { position: absolute; top: 0; left: 0; width: 14px; height: 14px;
  border-top: 1.5px solid var(--accent); border-left: 1.5px solid var(--accent);
  border-top-left-radius: var(--radius-lg); }

/* ---------------- StatCard ---------------- */
.sol-stat { display: flex; flex-direction: column; gap: var(--space-3); }
.sol-stat__head { display: flex; align-items: center; justify-content: space-between; }
.sol-stat__label { font-family: var(--font-mono); font-size: var(--text-2xs);
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-faint); }
.sol-stat__value { font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: var(--text-3xl); line-height: 1; color: var(--text-strong); letter-spacing: -0.02em; }
.sol-stat__unit { font-size: var(--text-md); color: var(--text-faint); margin-left: 4px; }
.sol-stat__delta { display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--font-mono); font-size: var(--text-xs); font-weight: var(--weight-medium); }
.sol-stat__delta--up { color: var(--aurora-400); }
.sol-stat__delta--down { color: var(--ember-400); }
.sol-stat__delta svg { width: 13px; height: 13px; }

/* ---------------- Gauge ---------------- */
.sol-gauge { position: relative; display: inline-flex; align-items: center; justify-content: center; }
.sol-gauge svg { transform: rotate(-90deg); display: block; }
.sol-gauge__track { stroke: var(--surface-inset); }
.sol-gauge__fill { transition: stroke-dashoffset var(--dur-slower) var(--ease-out); stroke-linecap: round; }
.sol-gauge__center { position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; }
.sol-gauge__num { font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: var(--text-xl); color: var(--text-strong); line-height: 1; }
.sol-gauge__cap { font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--text-faint); margin-top: 4px; }

/* ---------------- ProgressBar ---------------- */
.sol-progress { width: 100%; }
.sol-progress__top { display: flex; justify-content: space-between; margin-bottom: var(--space-2);
  font-family: var(--font-mono); font-size: var(--text-2xs); letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-faint); }
.sol-progress__track { height: 6px; background: var(--surface-inset); border-radius: var(--radius-pill); overflow: hidden; }
.sol-progress__fill { height: 100%; border-radius: var(--radius-pill);
  background: var(--grad-solar); box-shadow: var(--glow-solar-sm);
  transition: width var(--dur-slower) var(--ease-out); }
.sol-progress__fill--nominal { background: var(--aurora-500); box-shadow: var(--glow-aurora); }
.sol-progress__fill--caution { background: var(--amber-500); box-shadow: var(--glow-amber); }
.sol-progress__fill--critical { background: var(--ember-500); box-shadow: var(--glow-ember); }

/* ---------------- StatusDot ---------------- */
.sol-status { display: inline-flex; align-items: center; gap: var(--space-2);
  font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-muted); }
.sol-status__dot { position: relative; width: 8px; height: 8px; border-radius: 50%; flex: none; }
.sol-status__dot::after { content: ""; position: absolute; inset: -3px; border-radius: 50%;
  border: 1px solid currentColor; opacity: 0.4; }
.sol-status--pulse .sol-status__dot { animation: solara-pulse 1.6s var(--ease-in-out) infinite; }
.sol-status--nominal  { color: var(--aurora-400); }
.sol-status--active   { color: var(--solar-400); }
.sol-status--caution  { color: var(--amber-400); }
.sol-status--critical { color: var(--ember-400); }
.sol-status--offline  { color: var(--text-faint); }
.sol-status__dot { background: currentColor; box-shadow: 0 0 8px currentColor; }
.sol-status__text { color: var(--text-body); }

/* ---------------- Tabs ---------------- */
.sol-tabs { display: inline-flex; gap: 2px; padding: 4px; background: var(--surface-sunken);
  border: 1px solid var(--border-subtle); border-radius: var(--radius-md); }
.sol-tab { appearance: none; border: none; background: transparent; cursor: pointer;
  height: 32px; padding: 0 var(--space-4); border-radius: var(--radius-sm);
  font-family: var(--font-sans); font-size: var(--text-sm); font-weight: var(--weight-medium);
  color: var(--text-muted); transition: var(--transition-color); white-space: nowrap; }
.sol-tab:hover { color: var(--text-strong); }
.sol-tab--active { background: var(--surface-raised); color: var(--text-strong); box-shadow: var(--shadow-sm); }
/* underline variant */
.sol-tabs--line { background: none; border: none; border-bottom: 1px solid var(--border-subtle);
  border-radius: 0; padding: 0; gap: var(--space-5); }
.sol-tabs--line .sol-tab { height: 40px; padding: 0 2px; border-radius: 0; position: relative; }
.sol-tabs--line .sol-tab--active { background: none; box-shadow: none; color: var(--text-strong); }
.sol-tabs--line .sol-tab--active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px;
  height: 2px; background: var(--accent); box-shadow: var(--glow-solar-sm); }

/* ---------------- NavItem ---------------- */
.sol-nav-item { display: flex; align-items: center; gap: var(--space-3);
  height: 42px; padding: 0 var(--space-3); border-radius: var(--radius-md);
  color: var(--text-muted); cursor: pointer;
  font-size: var(--text-sm); font-weight: var(--weight-medium); position: relative; }
.sol-nav-item:hover { background: var(--surface-raised); color: var(--text-strong); }
.sol-nav-item__icon { display: flex; flex: none; }
.sol-nav-item__icon svg { width: 18px; height: 18px; }
.sol-nav-item__label { flex: 1; }
.sol-nav-item--active { background: var(--accent-soft); color: var(--solar-200); }
.sol-nav-item--active::before { content: ""; position: absolute; left: -8px; top: 9px; bottom: 9px;
  width: 3px; border-radius: 0 var(--radius-pill) var(--radius-pill) 0;
  background: var(--accent); box-shadow: var(--glow-solar-sm); }
.sol-nav-item__badge { font-family: var(--font-mono); font-size: 10px; color: var(--text-faint); }

/* ---------------- Tooltip ---------------- */
.sol-tooltip-wrap { position: relative; display: inline-flex; }
.sol-tooltip { position: absolute; z-index: 50; bottom: calc(100% + 8px); left: 50%;
  transform: translateX(-50%) translateY(4px); opacity: 0; pointer-events: none;
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm);
  background: var(--surface-overlay); border: 1px solid var(--border-strong);
  color: var(--text-strong); font-size: var(--text-xs); white-space: nowrap;
  box-shadow: var(--shadow-lg); transition: opacity var(--dur-fast), transform var(--dur-fast); }
.sol-tooltip-wrap:hover .sol-tooltip { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------------- Toast ---------------- */
.sol-toast { display: flex; align-items: flex-start; gap: var(--space-3);
  width: 340px; padding: var(--space-4); border-radius: var(--radius-lg);
  background: var(--glass-bg); backdrop-filter: var(--blur-md); -webkit-backdrop-filter: var(--blur-md);
  border: 1px solid var(--glass-border); box-shadow: var(--shadow-lg);
  border-left: 3px solid var(--accent); }
.sol-toast--nominal  { border-left-color: var(--aurora-500); }
.sol-toast--caution  { border-left-color: var(--amber-500); }
.sol-toast--critical { border-left-color: var(--ember-500); }
.sol-toast__icon { flex: none; color: var(--accent); margin-top: 1px; }
.sol-toast__icon svg { width: 18px; height: 18px; }
.sol-toast--nominal .sol-toast__icon { color: var(--aurora-400); }
.sol-toast--caution .sol-toast__icon { color: var(--amber-400); }
.sol-toast--critical .sol-toast__icon { color: var(--ember-400); }
.sol-toast__body { flex: 1; }
.sol-toast__title { font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--text-strong); }
.sol-toast__msg { font-size: var(--text-xs); color: var(--text-muted); margin-top: 2px; }

/* ---------------- Dialog ---------------- */
.sol-dialog-overlay { position: fixed; inset: 0; z-index: 100;
  background: color-mix(in oklab, var(--space-void) 72%, transparent);
  backdrop-filter: var(--blur-sm); -webkit-backdrop-filter: var(--blur-sm);
  display: flex; align-items: center; justify-content: center; padding: var(--space-6); }
.sol-dialog { width: 100%; max-width: 460px; background: var(--surface-card);
  border: 1px solid var(--border-default); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl), var(--grad-corona); overflow: hidden;
  animation: solara-pop var(--dur-base) var(--ease-out) both; }
@media (prefers-reduced-motion: reduce) { .sol-dialog { animation: none; } }
.sol-dialog__head { display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--space-4); padding: var(--space-5) var(--space-5) var(--space-3); }
.sol-dialog__title { font-size: var(--text-lg); }
.sol-dialog__desc { font-size: var(--text-sm); color: var(--text-muted); padding: 0 var(--space-5); }
.sol-dialog__body { padding: var(--space-4) var(--space-5); }
.sol-dialog__foot { display: flex; justify-content: flex-end; gap: var(--space-3);
  padding: var(--space-4) var(--space-5) var(--space-5); }
