/* nexlevel Design System — web/css/components.css
   Implementação de referência em CSS puro, consumindo os tokens gerados em
   tokens/design.tokens.css. Consumido diretamente pelo
   design_system_preview_standalone.html e disponível para uso em produto. */

@import url("./design.tokens.css");

* { box-sizing: border-box; }

body.ds {
  background: var(--ds-color-background);
  color: var(--ds-color-text);
  font-family: var(--ds-font-family, "Fahkwang", -apple-system, "Segoe UI", Helvetica, Arial, sans-serif);
}

.icon { width: 20px; height: 20px; display: inline-block; vertical-align: middle; }
.icon--sm { width: 16px; height: 16px; }
.icon--lg { width: 24px; height: 24px; }

/* ---------- Button ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 500 13px/1.15 var(--ds-font-body, inherit);
  letter-spacing: 0.02em;
  border-radius: var(--ds-radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--ds-motion-duration-fast) var(--ds-motion-easing-standard),
              border-color var(--ds-motion-duration-fast) var(--ds-motion-easing-standard),
              color var(--ds-motion-duration-fast) var(--ds-motion-easing-standard);
  padding: 0 16px;
  height: 40px;
}
.btn:focus-visible { outline: 2px solid var(--ds-color-focus); outline-offset: 2px; }
.btn--sm { height: 32px; padding: 0 12px; font-size: 12.5px; }
.btn--lg { height: 48px; padding: 0 20px; font-size: 14px; }
.btn--primary { background: var(--ds-color-accent); color: var(--ds-color-on-accent); }
.btn--primary:hover { background: var(--ds-color-accent-hover); }
.btn--primary:active { background: var(--ds-color-accent-active); }
.btn--secondary { background: transparent; color: var(--ds-color-text); border-color: var(--ds-color-border); }
.btn--secondary:hover { background: var(--ds-color-surface-elevated); }
.btn--ghost { background: transparent; color: var(--ds-color-accent); }
.btn--ghost:hover { background: var(--ds-color-surface-elevated); }
.btn--destructive { background: var(--ds-color-error); color: var(--ds-color-on-error); }
.btn--icon { width: 40px; padding: 0; }
.btn:disabled { background: var(--ds-color-disabled); color: var(--ds-color-disabled-text); border-color: transparent; cursor: not-allowed; }

/* ---------- Input ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font: 500 13px/1.3 inherit; letter-spacing: 0.02em; color: var(--ds-color-text); }
.input, .select__trigger, textarea.input {
  background: var(--ds-color-surface);
  border: 1px solid var(--ds-color-border);
  color: var(--ds-color-text);
  border-radius: var(--ds-radius-md);
  padding: 0 12px;
  height: 40px;
  font: 400 15px/1.5 inherit;
  width: 100%;
  transition: border-color var(--ds-motion-duration-fast) var(--ds-motion-easing-standard);
}
textarea.input { height: auto; padding: 10px 12px; min-height: 96px; resize: vertical; }
.input::placeholder { color: var(--ds-color-text-muted); }
.input:focus, .select__trigger:focus { outline: none; border-color: var(--ds-color-focus); }
.input[disabled] { background: var(--ds-color-surface-elevated); color: var(--ds-color-disabled-text); }
.input--error { border-color: var(--ds-color-error); }
.field__helper { font-size: 12px; color: var(--ds-color-text-secondary); }
.field__error { font-size: 12px; color: var(--ds-color-error); }

/* ---------- Select ---------- */
.select { position: relative; display: inline-block; width: 100%; }
.select__trigger { display: flex; align-items: center; justify-content: space-between; cursor: pointer; text-align: left; }
.select__panel {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--ds-color-surface); border: 1px solid var(--ds-color-border);
  border-radius: var(--ds-radius-md); box-shadow: var(--ds-elevation-2);
  padding: 4px; z-index: 100;
}
.select__item { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; border-radius: var(--ds-radius-sm); cursor: pointer; font-size: 14px; }
.select__item:hover, .select__item--active { background: var(--ds-color-surface-elevated); }

/* ---------- Checkbox / Radio / Switch ---------- */
.checkbox, .radio { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; }
.checkbox input, .radio input { position: absolute; opacity: 0; width: 20px; height: 20px; margin: 0; cursor: pointer; }
.checkbox__box, .radio__dot {
  width: 20px; height: 20px; border: 1.5px solid var(--ds-color-border);
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  background: transparent; color: var(--ds-color-on-accent);
}
.checkbox__box { border-radius: 4px; }
.radio__dot { border-radius: 999px; }
.checkbox input:checked + .checkbox__box,
.radio input:checked + .radio__dot { background: var(--ds-color-accent); border-color: var(--ds-color-accent); }
.checkbox input:focus-visible + .checkbox__box,
.radio input:focus-visible + .radio__dot { outline: 2px solid var(--ds-color-focus); outline-offset: 2px; }
.checkbox__box svg, .radio__dot svg { width: 13px; height: 13px; }
.radio__dot::after { content: ""; width: 8px; height: 8px; border-radius: 999px; background: transparent; }
.radio input:checked + .radio__dot::after { background: var(--ds-color-on-accent); }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; }
.switch input { position: absolute; opacity: 0; }
.switch__track { width: 40px; height: 24px; border-radius: 999px; background: var(--ds-color-surface-elevated); border: 1px solid var(--ds-color-border); position: relative; transition: background var(--ds-motion-duration-fast); flex: none; }
.switch__thumb { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 999px; background: var(--ds-color-text-secondary); transition: transform var(--ds-motion-duration-fast) var(--ds-motion-easing-standard); }
.switch input:checked ~ .switch__track { background: var(--ds-color-accent); border-color: var(--ds-color-accent); }
.switch input:checked ~ .switch__track .switch__thumb { transform: translateX(16px); background: var(--ds-color-on-accent); }
.switch input:focus-visible ~ .switch__track { outline: 2px solid var(--ds-color-focus); outline-offset: 2px; }

/* ---------- Card ---------- */
.card {
  background: var(--ds-color-surface); border: 1px solid var(--ds-color-border);
  border-radius: var(--ds-radius-lg); padding: 24px; box-shadow: var(--ds-elevation-1);
}
.card--clickable { cursor: pointer; transition: box-shadow var(--ds-motion-duration-normal); }
.card--clickable:hover { box-shadow: var(--ds-elevation-2); }
.card__title { font: 500 16px/1.3 inherit; margin: 0 0 6px; }
.card__body { color: var(--ds-color-text-secondary); font-size: 14px; margin: 0; }

/* ---------- Badge / Chip ---------- */
.badge {
  display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 500; background: var(--ds-color-surface-elevated); color: var(--ds-color-text-secondary);
}
.badge--success { background: color-mix(in srgb, var(--ds-color-success) 20%, transparent); color: var(--ds-color-success); }
.badge--warning { background: color-mix(in srgb, var(--ds-color-warning) 20%, transparent); color: var(--ds-color-warning); }
.badge--error { background: color-mix(in srgb, var(--ds-color-error) 20%, transparent); color: var(--ds-color-error); }

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  font-size: 13px; background: var(--ds-color-surface-elevated); color: var(--ds-color-text); cursor: pointer; border: 1px solid transparent;
}
.chip--selected { background: var(--ds-color-accent); color: var(--ds-color-on-accent); }
.chip__remove { background: none; border: none; color: inherit; cursor: pointer; font-size: 14px; line-height: 1; padding: 0; }

/* ---------- Alert ---------- */
.alert {
  display: flex; gap: 10px; padding: 14px 16px; border-radius: var(--ds-radius-md);
  border-left: 3px solid var(--ds-color-info); background: var(--ds-color-surface-elevated); font-size: 13.5px;
}
.alert svg { flex: none; margin-top: 1px; }
.alert strong { display: block; margin-bottom: 2px; }
.alert p { margin: 0; color: var(--ds-color-text-secondary); }
.alert--success { border-left-color: var(--ds-color-success); }
.alert--warning { border-left-color: var(--ds-color-warning); }
.alert--error { border-left-color: var(--ds-color-error); }

/* ---------- Tooltip ---------- */
.tooltip {
  position: absolute; background: #1D1D20; color: var(--ds-color-foreground);
  font-size: 12px; padding: 5px 10px; border-radius: var(--ds-radius-sm); box-shadow: var(--ds-elevation-2);
  white-space: nowrap; pointer-events: none;
}

/* ---------- Modal / Dialog ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgb(10 10 11 / 0.6); display: flex; align-items: center; justify-content: center; z-index: 500;
}
.modal {
  background: var(--ds-color-surface); border-radius: var(--ds-radius-lg); box-shadow: var(--ds-elevation-3);
  max-width: 480px; width: 92%; padding: 24px; position: relative;
}
.modal header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal header h2 { margin: 0; font-size: 18px; font-weight: 600; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* ---------- Dropdown ---------- */
.dropdown-menu {
  background: var(--ds-color-surface); border: 1px solid var(--ds-color-border); border-radius: var(--ds-radius-md);
  box-shadow: var(--ds-elevation-2); padding: 4px; min-width: 180px; list-style: none; margin: 0;
}
.dropdown-menu li { padding: 9px 12px; border-radius: var(--ds-radius-sm); cursor: pointer; font-size: 13.5px; }
.dropdown-menu li:hover { background: var(--ds-color-surface-elevated); }
.dropdown-menu li.destructive { color: var(--ds-color-error); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--ds-color-border); }
.tabs [role="tab"] {
  background: none; border: none; color: var(--ds-color-text-secondary); font: 500 13px inherit;
  padding: 10px 14px; border-bottom: 2px solid transparent; cursor: pointer; margin-bottom: -1px;
}
.tabs [role="tab"][aria-selected="true"] { color: var(--ds-color-text); border-bottom-color: var(--ds-color-accent); }

/* ---------- Table ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; padding: 10px 16px; background: var(--ds-color-surface-elevated); color: var(--ds-color-text-secondary); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--ds-color-border); }
.table tr:hover td { background: var(--ds-color-surface-elevated); }

/* ---------- List item ---------- */
.list-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--ds-color-border);
  text-decoration: none; color: inherit;
}
.list-item__avatar { width: 36px; height: 36px; border-radius: 999px; background: var(--ds-color-surface-elevated); flex: none; }
.list-item div { display: flex; flex-direction: column; }
.list-item strong { font-size: 14px; font-weight: 500; }
.list-item span { font-size: 12.5px; color: var(--ds-color-text-secondary); }

/* ---------- Progress ---------- */
.progress { height: 4px; background: var(--ds-color-surface-elevated); border-radius: 999px; overflow: hidden; }
.progress__fill { height: 100%; background: var(--ds-color-accent); transition: width var(--ds-motion-duration-normal) var(--ds-motion-easing-standard); }
.spinner { width: 20px; height: 20px; border: 2.5px solid var(--ds-color-surface-elevated); border-top-color: var(--ds-color-accent); border-radius: 999px; animation: ds-spin 0.7s linear infinite; }
@keyframes ds-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
