/* ============================================================
   MordanSoft — Core component styles
   Built entirely on tokens. Components apply these classes;
   the .jsx never hardcodes color/spacing values.
   Imported by styles.css so consumers get it with one link.
   ============================================================ */

/* ---------------------------------------------------------- Button */
.ms-btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--space-2);
  height: 2.5rem;
  padding-inline: var(--space-5);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.005em;
  line-height: 1;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 140ms var(--ease-standard),
              border-color 140ms var(--ease-standard),
              color 140ms var(--ease-standard),
              box-shadow 140ms var(--ease-standard),
              transform 140ms var(--ease-standard);
}
.ms-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.ms-btn:active { transform: translateY(0.5px) scale(0.992); }
.ms-btn[disabled], .ms-btn[aria-disabled="true"] {
  opacity: 0.5; cursor: not-allowed; pointer-events: none;
}
.ms-btn__icon { display: inline-flex; flex: none; }
.ms-btn__icon svg { width: 1.05em; height: 1.05em; display: block; }

/* sizes */
.ms-btn--sm { height: 2rem; padding-inline: var(--space-4); font-size: var(--text-xs); border-radius: var(--radius-sm); }
.ms-btn--lg { height: 3rem; padding-inline: var(--space-6); font-size: var(--text-base); border-radius: var(--radius-lg); }
.ms-btn--block { display: flex; width: 100%; }

/* variants */
.ms-btn--primary { background: var(--accent); color: var(--accent-contrast); }
.ms-btn--primary:hover { background: var(--accent-hover); box-shadow: var(--glow-accent); }
.ms-btn--primary:active { background: var(--accent-press); box-shadow: none; }

.ms-btn--secondary { background: var(--surface-elevated); color: var(--text-primary); border-color: var(--border-strong); box-shadow: var(--shadow-xs); }
.ms-btn--secondary:hover { border-color: var(--text-faint); background: var(--surface); }
.ms-btn--secondary:active { background: var(--surface-sunken); }

.ms-btn--ghost { background: transparent; color: var(--text-primary); }
.ms-btn--ghost:hover { background: var(--surface-sunken); }
.ms-btn--ghost:active { background: var(--plane-3); }

.ms-btn--danger { background: var(--danger); color: var(--grey-0); }
.ms-btn--danger:hover { filter: brightness(1.06); }
.ms-btn--danger:active { filter: brightness(0.95); }

/* text link button — for secondary actions per brand */
.ms-btn--link {
  height: auto; padding: 0; background: transparent; color: var(--accent-text);
  border-radius: var(--radius-xs);
}
.ms-btn--link:hover { text-decoration: underline; text-underline-offset: 0.18em; }

/* ---------------------------------------------------------- IconButton */
.ms-iconbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.5rem; height: 2.5rem; flex: none;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent; color: var(--text-secondary);
  cursor: pointer;
  transition: background 140ms var(--ease-standard),
              color 140ms var(--ease-standard),
              border-color 140ms var(--ease-standard);
}
.ms-iconbtn:hover { background: var(--surface-sunken); color: var(--text-primary); }
.ms-iconbtn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.ms-iconbtn--sm { width: 2rem; height: 2rem; border-radius: var(--radius-sm); }
.ms-iconbtn--bordered { border-color: var(--border-strong); background: var(--surface-elevated); }
.ms-iconbtn svg { width: 1.1rem; height: 1.1rem; display: block; }

/* ---------------------------------------------------------- Tag (chip) */
.ms-tag {
  display: inline-flex; align-items: center; gap: var(--space-2);
  height: 1.625rem; padding-inline: var(--space-3);
  font-family: var(--font-mono); font-size: var(--text-xs); font-weight: var(--weight-medium);
  letter-spacing: 0.01em;
  color: var(--text-secondary);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  white-space: nowrap;
}
.ms-tag--accent { color: var(--accent-text); background: var(--accent-subtle); border-color: transparent; }
.ms-tag--solid { color: var(--text-on-inverse); background: var(--surface-inverse); border-color: transparent; }
.ms-tag__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.ms-tag--removable { padding-inline-end: var(--space-2); }
.ms-tag__x { display: inline-flex; cursor: pointer; opacity: 0.6; }
.ms-tag__x:hover { opacity: 1; }
.ms-tag__x svg { width: 0.85rem; height: 0.85rem; }

/* ---------------------------------------------------------- Badge */
.ms-badge {
  display: inline-flex; align-items: center; gap: 0.375rem;
  height: 1.375rem; padding-inline: var(--space-2);
  font-family: var(--font-mono); font-size: 0.6875rem; font-weight: var(--weight-medium);
  letter-spacing: 0.04em; text-transform: uppercase;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
}
.ms-badge__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.ms-badge--neutral { color: var(--text-secondary); background: var(--surface-sunken); border-color: var(--border); }
.ms-badge--success { color: var(--success); background: var(--success-subtle); }
.ms-badge--warning { color: var(--warning); background: var(--warning-subtle); }
.ms-badge--danger  { color: var(--danger);  background: var(--danger-subtle); }
.ms-badge--info    { color: var(--info);    background: var(--info-subtle); }
.ms-badge--accent  { color: var(--accent-text); background: var(--accent-subtle); }

/* ---------------------------------------------------------- StatusDot */
.ms-statusdot { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); color: var(--text-secondary); }
.ms-statusdot__dot { width: 8px; height: 8px; border-radius: 50%; flex: none; position: relative; }
.ms-statusdot--success .ms-statusdot__dot { background: var(--success); }
.ms-statusdot--warning .ms-statusdot__dot { background: var(--warning); }
.ms-statusdot--danger  .ms-statusdot__dot { background: var(--danger); }
.ms-statusdot--neutral .ms-statusdot__dot { background: var(--text-faint); }
.ms-statusdot--live .ms-statusdot__dot::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%;
  background: currentColor; opacity: 0.25;
}
@media (prefers-reduced-motion: no-preference) {
  .ms-statusdot--live .ms-statusdot__dot::after { animation: ms-pulse 2s var(--ease-out) infinite; }
}
@keyframes ms-pulse { 0% { transform: scale(0.7); opacity: 0.35; } 70%,100% { transform: scale(1.8); opacity: 0; } }

/* ---------------------------------------------------------- Card */
.ms-card {
  display: flex; flex-direction: column;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: clip;
}
.ms-card--flat { box-shadow: none; }
.ms-card--raised { box-shadow: var(--shadow-md); border-color: var(--border-faint); }
.ms-card--pad { padding: var(--space-6); }
.ms-card--interactive { cursor: pointer; transition: transform 220ms var(--ease-standard), box-shadow 220ms var(--ease-standard), border-color 220ms var(--ease-standard); }
.ms-card--interactive:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--border-faint); }
.ms-card--interactive:active { transform: translateY(0); box-shadow: var(--shadow-sm); }
.ms-card__media { display: block; width: 100%; }
.ms-card__body { padding: var(--space-6); display: flex; flex-direction: column; gap: var(--space-2); }
.ms-card__title { font-size: var(--text-h4); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-tight); }
.ms-card__text { font-size: var(--text-sm); color: var(--text-secondary); line-height: var(--leading-normal); }
.ms-card__footer { padding: var(--space-4) var(--space-6); border-top: 1px solid var(--border); display: flex; align-items: center; gap: var(--space-3); }

/* ---------------------------------------------------------- Field / Input */
.ms-field { display: flex; flex-direction: column; gap: var(--space-2); }
.ms-field__label { font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--text-primary); }
.ms-field__hint { font-size: var(--text-xs); color: var(--text-muted); }
.ms-field__error { font-size: var(--text-xs); color: var(--danger); }
.ms-input {
  width: 100%; height: 2.625rem;
  padding: 0 var(--space-3);
  font-family: var(--font-sans); font-size: var(--text-base); color: var(--text-primary);
  background: var(--surface-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  transition: border-color 140ms var(--ease-standard), box-shadow 140ms var(--ease-standard);
}
.ms-input::placeholder { color: var(--text-faint); }
.ms-input:hover { border-color: var(--text-faint); }
.ms-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.ms-input[aria-invalid="true"] { border-color: var(--danger); }
.ms-input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px var(--danger-subtle); }
.ms-input:disabled { background: var(--surface-sunken); color: var(--text-muted); cursor: not-allowed; }
textarea.ms-input { height: auto; min-height: 5.5rem; padding: var(--space-3); resize: vertical; line-height: var(--leading-normal); }
.ms-input--mono { font-family: var(--font-mono); font-size: var(--text-sm); }

/* ---------------------------------------------------------- Switch */
.ms-switch { display: inline-flex; align-items: center; gap: var(--space-3); cursor: pointer; user-select: none; }
.ms-switch__track {
  position: relative; width: 2.5rem; height: 1.5rem; flex: none;
  background: var(--border-strong); border-radius: var(--radius-pill);
  transition: background 220ms var(--ease-standard);
}
.ms-switch__thumb {
  position: absolute; top: 3px; left: 3px; width: 1.125rem; height: 1.125rem;
  background: var(--grey-0); border-radius: 50%; box-shadow: var(--shadow-sm);
  transition: transform 220ms var(--ease-spring);
}
.ms-switch[aria-checked="true"] .ms-switch__track { background: var(--accent); }
.ms-switch[aria-checked="true"] .ms-switch__thumb { transform: translateX(1rem); }
.ms-switch:focus-visible .ms-switch__track { box-shadow: 0 0 0 3px var(--ring); }
.ms-switch[aria-disabled="true"] { opacity: 0.5; pointer-events: none; }
.ms-switch__label { font-size: var(--text-sm); color: var(--text-primary); }

/* ---------------------------------------------------------- Tabs */
.ms-tabs { display: inline-flex; gap: 0; border-bottom: 1px solid var(--border); }
.ms-tab {
  position: relative; appearance: none; background: none; border: none; cursor: pointer;
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-sans); font-size: var(--text-sm); font-weight: var(--weight-medium);
  color: var(--text-muted);
  transition: color 140ms var(--ease-standard);
}
.ms-tab:hover { color: var(--text-primary); }
.ms-tab[aria-selected="true"] { color: var(--text-primary); }
.ms-tab[aria-selected="true"]::after {
  content: ""; position: absolute; left: var(--space-4); right: var(--space-4); bottom: -1px; height: 2px;
  background: var(--accent); border-radius: var(--radius-pill);
}
.ms-tab:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); border-radius: var(--radius-sm); }

/* pill variant */
.ms-tabs--pill { border: none; background: var(--surface-sunken); padding: var(--space-1); border-radius: var(--radius-md); gap: var(--space-1); }
.ms-tabs--pill .ms-tab { border-radius: var(--radius-sm); }
.ms-tabs--pill .ms-tab[aria-selected="true"] { color: var(--text-primary); background: var(--surface-elevated); box-shadow: var(--shadow-xs); }
.ms-tabs--pill .ms-tab[aria-selected="true"]::after { display: none; }
