/* ============================================================
   S3 Regnskap — Component styles
   Class-based so :hover / :focus / :active states work.
   JSX components apply these classes; all values come from tokens.
   ============================================================ */

/* ---------------------------------------------------------- BUTTON */
.s3-btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--space-2);
  font-family: var(--font-sans); font-weight: var(--weight-semibold);
  line-height: 1; white-space: nowrap; text-decoration: none;
  border: 1px solid transparent; border-radius: var(--radius-md);
  cursor: pointer; user-select: none;
  transition: background var(--dur-fast) var(--ease-standard),
              border-color var(--dur-fast) var(--ease-standard),
              color var(--dur-fast) var(--ease-standard),
              transform var(--dur-fast) var(--ease-standard),
              box-shadow var(--dur-fast) var(--ease-standard);
}
.s3-btn:focus-visible { outline: none; box-shadow: var(--ring); }
.s3-btn:active { transform: translateY(1px); }
.s3-btn[disabled], .s3-btn[aria-disabled="true"] { opacity: .45; pointer-events: none; }
.s3-btn--full { width: 100%; }

/* sizes */
.s3-btn--sm { height: 32px; padding: 0 var(--space-3); font-size: var(--text-sm); }
.s3-btn--md { height: 40px; padding: 0 var(--space-4); font-size: var(--text-sm); }
.s3-btn--lg { height: 48px; padding: 0 var(--space-5); font-size: var(--text-md); }

/* variants */
.s3-btn--primary   { background: var(--brand); color: var(--on-brand); }
.s3-btn--primary:hover   { background: var(--brand-hover); }
.s3-btn--primary:active  { background: var(--brand-press); }

.s3-btn--secondary { background: var(--surface-card); color: var(--text-strong); border-color: var(--border-default); }
.s3-btn--secondary:hover { background: var(--surface-hover); border-color: var(--border-strong); }

.s3-btn--ghost     { background: transparent; color: var(--text-body); }
.s3-btn--ghost:hover { background: var(--surface-hover); color: var(--text-strong); }

.s3-btn--soft      { background: var(--brand-subtle); color: var(--text-brand); }
.s3-btn--soft:hover { background: var(--brand-subtle-2); }

.s3-btn--danger    { background: var(--danger); color: #fff; }
.s3-btn--danger:hover { background: var(--danger-600); }

.s3-btn__icon { display: inline-flex; }
.s3-btn__icon svg { display: block; width: 1.15em; height: 1.15em; }

/* ---------------------------------------------------------- ICON BUTTON */
.s3-icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid transparent; border-radius: var(--radius-md);
  cursor: pointer; color: var(--text-body); background: transparent;
  transition: background var(--dur-fast) var(--ease-standard),
              color var(--dur-fast) var(--ease-standard),
              border-color var(--dur-fast) var(--ease-standard);
}
.s3-icon-btn:hover { background: var(--surface-hover); color: var(--text-strong); }
.s3-icon-btn:focus-visible { outline: none; box-shadow: var(--ring); }
.s3-icon-btn[disabled] { opacity: .45; pointer-events: none; }
.s3-icon-btn--sm { width: 32px; height: 32px; }
.s3-icon-btn--md { width: 40px; height: 40px; }
.s3-icon-btn--lg { width: 48px; height: 48px; }
.s3-icon-btn--solid { background: var(--brand); color: var(--on-brand); }
.s3-icon-btn--solid:hover { background: var(--brand-hover); color: #fff; }
.s3-icon-btn--outline { border-color: var(--border-default); }
.s3-icon-btn--outline:hover { border-color: var(--border-strong); }
.s3-icon-btn svg { display: block; width: 1.2em; height: 1.2em; }

/* ---------------------------------------------------------- BADGE */
.s3-badge {
  display: inline-flex; align-items: center; gap: var(--space-1);
  font-family: var(--font-sans); font-size: var(--text-xs); font-weight: var(--weight-semibold);
  line-height: 1; padding: 4px 9px; border-radius: var(--radius-pill);
  letter-spacing: .01em; white-space: nowrap;
}
.s3-badge__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.s3-badge--neutral { background: var(--neutral-100); color: var(--neutral-700); }
.s3-badge--brand   { background: var(--brand-subtle); color: var(--text-brand); }
.s3-badge--success { background: var(--success-surface); color: var(--success-text); }
.s3-badge--warning { background: var(--warning-surface); color: var(--warning-text); }
.s3-badge--danger  { background: var(--danger-surface); color: var(--danger-text); }
.s3-badge--info    { background: var(--info-surface); color: var(--info-text); }
.s3-badge--solid.s3-badge--brand   { background: var(--brand); color: #fff; }
.s3-badge--solid.s3-badge--success { background: var(--success); color: #fff; }
.s3-badge--solid.s3-badge--warning { background: var(--warning); color: #fff; }
.s3-badge--solid.s3-badge--danger  { background: var(--danger); color: #fff; }
.s3-badge--solid.s3-badge--info    { background: var(--info); color: #fff; }
.s3-badge--solid.s3-badge--neutral { background: var(--neutral-700); color: #fff; }

/* ---------------------------------------------------------- TAG / CHIP */
.s3-tag {
  display: inline-flex; align-items: center; gap: var(--space-2);
  font-family: var(--font-sans); font-size: var(--text-sm); font-weight: var(--weight-medium);
  color: var(--text-body); background: var(--surface-card);
  border: 1px solid var(--border-default); border-radius: var(--radius-pill);
  padding: 4px 6px 4px 12px; line-height: 1.2;
}
.s3-tag--plain { padding-right: 12px; }
.s3-tag__remove {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%; border: none; cursor: pointer;
  background: transparent; color: var(--text-muted);
  transition: background var(--dur-fast) var(--ease-standard), color var(--dur-fast) var(--ease-standard);
}
.s3-tag__remove:hover { background: var(--neutral-100); color: var(--text-strong); }
.s3-tag__remove svg { width: 12px; height: 12px; display: block; }

/* ---------------------------------------------------------- AVATAR */
.s3-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-pill); overflow: hidden; flex: none;
  background: var(--brand-subtle); color: var(--text-brand);
  font-family: var(--font-sans); font-weight: var(--weight-semibold);
  letter-spacing: .01em;
}
.s3-avatar img { width: 100%; height: 100%; object-fit: cover; }
.s3-avatar--sm { width: 28px; height: 28px; font-size: 11px; }
.s3-avatar--md { width: 36px; height: 36px; font-size: 13px; }
.s3-avatar--lg { width: 48px; height: 48px; font-size: 16px; }
.s3-avatar--xl { width: 64px; height: 64px; font-size: 22px; }
.s3-avatar--brand { background: var(--brand); color: #fff; }

/* ---------------------------------------------------------- CARD */
.s3-card {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.s3-card--pad { padding: var(--space-5); }
.s3-card--interactive { cursor: pointer; transition: box-shadow var(--dur-base) var(--ease-standard), transform var(--dur-base) var(--ease-standard), border-color var(--dur-base) var(--ease-standard); }
.s3-card--interactive:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: var(--border-default); }

/* ---------------------------------------------------------- STAT / KPI */
.s3-stat { display: flex; flex-direction: column; gap: var(--space-2); }
.s3-stat__label { font-size: var(--text-xs); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--text-muted); }
.s3-stat__value { font-family: var(--font-display); font-size: var(--text-3xl); line-height: 1; letter-spacing: .01em; color: var(--text-strong); font-feature-settings: 'tnum'; white-space: nowrap; }
.s3-stat__row { display: flex; align-items: baseline; gap: var(--space-3); }
.s3-stat__delta { display: inline-flex; align-items: center; gap: 3px; font-size: var(--text-sm); font-weight: var(--weight-semibold); white-space: nowrap; }
.s3-stat__delta--up { color: var(--success-text); }
.s3-stat__delta--down { color: var(--danger-text); }
.s3-stat__sub { font-size: var(--text-sm); color: var(--text-muted); }

/* ---------------------------------------------------------- FORM FIELD */
.s3-field { display: flex; flex-direction: column; gap: var(--space-2); }
.s3-label { font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--text-strong); }
.s3-label__req { color: var(--danger); margin-left: 2px; }
.s3-input-wrap { position: relative; display: flex; align-items: center; }
.s3-input {
  width: 100%; height: 40px; font-family: var(--font-sans); font-size: var(--text-base);
  color: var(--text-strong); background: var(--surface-card);
  border: 1px solid var(--border-default); border-radius: var(--radius-md);
  padding: 0 var(--space-3); transition: border-color var(--dur-fast) var(--ease-standard), box-shadow var(--dur-fast) var(--ease-standard);
}
.s3-input::placeholder { color: var(--text-subtle); }
.s3-input:hover { border-color: var(--border-strong); }
.s3-input:focus { outline: none; border-color: var(--border-focus); box-shadow: var(--ring); }
.s3-input--affix-left { padding-left: 38px; }
.s3-input--affix-right { padding-right: 38px; }
.s3-input__affix { position: absolute; display: flex; align-items: center; color: var(--text-muted); font-size: var(--text-sm); pointer-events: none; }
.s3-input__affix--left { left: 12px; }
.s3-input__affix--right { right: 12px; }
.s3-input__affix svg { width: 16px; height: 16px; display: block; }
textarea.s3-input { height: auto; padding: var(--space-3); line-height: var(--leading-normal); resize: vertical; }
.s3-field.is-error .s3-input { border-color: var(--danger); }
.s3-field.is-error .s3-input:focus { box-shadow: 0 0 0 3px var(--danger-surface); }
.s3-hint { font-size: var(--text-sm); color: var(--text-muted); }
.s3-hint--error { color: var(--danger-text); }

/* ---------------------------------------------------------- SELECT */
.s3-select-wrap { position: relative; display: flex; align-items: center; }
.s3-select {
  width: 100%; height: 40px; font-family: var(--font-sans); font-size: var(--text-base);
  color: var(--text-strong); background: var(--surface-card);
  border: 1px solid var(--border-default); border-radius: var(--radius-md);
  padding: 0 36px 0 var(--space-3); appearance: none; cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-standard), box-shadow var(--dur-fast) var(--ease-standard);
}
.s3-select:hover { border-color: var(--border-strong); }
.s3-select:focus { outline: none; border-color: var(--border-focus); box-shadow: var(--ring); }
.s3-select-wrap__chev { position: absolute; right: 12px; pointer-events: none; color: var(--text-muted); display: flex; }
.s3-select-wrap__chev svg { width: 16px; height: 16px; display: block; }

/* ---------------------------------------------------------- CHECKBOX */
.s3-check { display: inline-flex; align-items: flex-start; gap: var(--space-2); cursor: pointer; font-size: var(--text-base); color: var(--text-body); }
.s3-check input { position: absolute; opacity: 0; width: 0; height: 0; }
.s3-check__box {
  flex: none; width: 20px; height: 20px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-strong); background: var(--surface-card);
  display: inline-flex; align-items: center; justify-content: center; color: #fff;
  transition: background var(--dur-fast) var(--ease-standard), border-color var(--dur-fast) var(--ease-standard);
  margin-top: 1px;
}
.s3-check__box svg { width: 13px; height: 13px; opacity: 0; transition: opacity var(--dur-fast) var(--ease-standard); }
.s3-check input:checked + .s3-check__box { background: var(--brand); border-color: var(--brand); }
.s3-check input:checked + .s3-check__box svg { opacity: 1; }
.s3-check input:focus-visible + .s3-check__box { box-shadow: var(--ring); }
.s3-check input:disabled + .s3-check__box { opacity: .45; }

/* ---------------------------------------------------------- RADIO */
.s3-radio { display: inline-flex; align-items: flex-start; gap: var(--space-2); cursor: pointer; font-size: var(--text-base); color: var(--text-body); }
.s3-radio input { position: absolute; opacity: 0; width: 0; height: 0; }
.s3-radio__dot {
  flex: none; width: 20px; height: 20px; border-radius: 50%;
  border: 1.5px solid var(--border-strong); background: var(--surface-card);
  display: inline-flex; align-items: center; justify-content: center;
  transition: border-color var(--dur-fast) var(--ease-standard); margin-top: 1px;
}
.s3-radio__dot::after { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); transform: scale(0); transition: transform var(--dur-fast) var(--ease-emphasis); }
.s3-radio input:checked + .s3-radio__dot { border-color: var(--brand); }
.s3-radio input:checked + .s3-radio__dot::after { transform: scale(1); }
.s3-radio input:focus-visible + .s3-radio__dot { box-shadow: var(--ring); }
.s3-radio input:disabled + .s3-radio__dot { opacity: .45; }

/* ---------------------------------------------------------- SWITCH */
.s3-switch { display: inline-flex; align-items: center; gap: var(--space-2); cursor: pointer; }
.s3-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.s3-switch__track {
  width: 40px; height: 24px; border-radius: var(--radius-pill); background: var(--neutral-300);
  position: relative; transition: background var(--dur-base) var(--ease-standard); flex: none;
}
.s3-switch__track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform var(--dur-base) var(--ease-emphasis); }
.s3-switch input:checked + .s3-switch__track { background: var(--brand); }
.s3-switch input:checked + .s3-switch__track::after { transform: translateX(16px); }
.s3-switch input:focus-visible + .s3-switch__track { box-shadow: var(--ring); }
.s3-switch input:disabled + .s3-switch__track { opacity: .45; }

/* ---------------------------------------------------------- ALERT */
.s3-alert {
  display: flex; gap: var(--space-3); padding: var(--space-4);
  border-radius: var(--radius-md); border: 1px solid transparent;
}
.s3-alert__icon { flex: none; display: flex; margin-top: 1px; }
.s3-alert__icon svg { width: 18px; height: 18px; display: block; }
.s3-alert__body { display: flex; flex-direction: column; gap: 2px; }
.s3-alert__title { font-weight: var(--weight-semibold); font-size: var(--text-sm); color: var(--text-strong); }
.s3-alert__text { font-size: var(--text-sm); color: var(--text-body); }
.s3-alert--info    { background: var(--info-surface); border-color: color-mix(in srgb, var(--info) 22%, transparent); }
.s3-alert--info .s3-alert__icon { color: var(--info); }
.s3-alert--success { background: var(--success-surface); border-color: color-mix(in srgb, var(--success) 22%, transparent); }
.s3-alert--success .s3-alert__icon { color: var(--success); }
.s3-alert--warning { background: var(--warning-surface); border-color: color-mix(in srgb, var(--warning) 22%, transparent); }
.s3-alert--warning .s3-alert__icon { color: var(--warning); }
.s3-alert--danger  { background: var(--danger-surface); border-color: color-mix(in srgb, var(--danger) 22%, transparent); }
.s3-alert--danger .s3-alert__icon { color: var(--danger); }

/* ---------------------------------------------------------- TABS */
.s3-tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--border-default); }
.s3-tab {
  position: relative; background: none; border: none; cursor: pointer;
  font-family: var(--font-sans); font-size: var(--text-sm); font-weight: var(--weight-semibold);
  color: var(--text-muted); padding: var(--space-3) var(--space-3); margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  transition: color var(--dur-fast) var(--ease-standard), border-color var(--dur-fast) var(--ease-standard);
}
.s3-tab:hover { color: var(--text-strong); }
.s3-tab--active { color: var(--text-brand); border-bottom-color: var(--brand); }
.s3-tab:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-sm); }
