/* ==========================================================================
   FleckMart — Estilos da biblioteca de componentes (js/core/ui.js)
   Consome apenas os tokens de css/tokens.css.
   ========================================================================== */

/* ---------- toast ---------- */
.toast {
  position: fixed;
  z-index: 100;
  right: 20px;
  bottom: 20px;
  max-width: 400px;
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--surface-3);
  color: var(--ink);
  border: 1px solid var(--border-strong);
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: 0.2s;
}
.toast.show { opacity: 1; transform: none; }
.toast.error { background: var(--danger); border-color: transparent; color: #fff; }
.toast.success { background: var(--success); border-color: transparent; color: oklch(0.2 0.03 160); }

/* ---------- skeleton ---------- */
.ui-skeleton-lines { display: grid; gap: 9px; }
.ui-skeleton {
  height: 13px;
  border-radius: 7px;
  background: linear-gradient(100deg, var(--surface-2) 40%, var(--surface-3) 50%, var(--surface-2) 60%);
  background-size: 200% 100%;
  animation: ui-shimmer 1.2s infinite;
}
.ui-skeleton.block { height: auto; border-radius: var(--radius); border: 1px solid var(--border); }
@keyframes ui-shimmer { to { background-position: -200% 0; } }

/* ---------- select custom ---------- */
.ui-select { position: relative; min-width: 0; }
.ui-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.ui-select-trigger:focus-visible { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.ui-select-trigger .icon { width: 15px; height: 15px; color: var(--faint); }
.ui-select-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ui-select-pop {
  position: absolute;
  z-index: 40;
  top: calc(100% + 5px);
  left: 0;
  right: 0;
  max-height: 260px;
  overflow-y: auto;
  padding: 5px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface-3);
  box-shadow: var(--shadow-2);
}
.ui-select-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  text-align: left;
}
.ui-select-option:hover, .ui-select-option.focus { background: rgba(255, 255, 255, 0.07); }
.ui-select-option.active { color: var(--primary-bright); font-weight: 600; }
.ui-select-option small { display: block; color: var(--muted); font-size: 11.5px; font-weight: 400; }
.ui-select-option .icon { width: 15px; height: 15px; flex: none; }

/* ---------- stepper ---------- */
.ui-stepper {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.ui-step-btn {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 17px;
  line-height: 1;
  transition: background 0.14s, color 0.14s;
}
.ui-step-btn:hover:not(:disabled) { background: var(--surface-3); color: var(--ink); }
.ui-step-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.ui-step-value { min-width: 44px; text-align: center; font-weight: 620; font-variant-numeric: tabular-nums; }

/* ---------- tags ---------- */
.ui-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: text;
}
.ui-tags:focus-within { border-color: var(--primary); box-shadow: var(--ring); }
.ui-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 6px 3px 10px;
  border-radius: 99px;
  background: var(--primary-soft);
  color: var(--primary-soft-ink);
  font-size: 12.5px;
  font-weight: 550;
}
.ui-tag button { display: grid; place-items: center; width: 18px; height: 18px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: inherit; }
.ui-tag button:hover { background: rgba(255, 255, 255, 0.14); }
.ui-tag .icon { width: 11px; height: 11px; }
.ui-tags-input { flex: 1; min-width: 110px; padding: 4px 2px; border: 0; outline: none; background: transparent; color: var(--ink); }
.ui-tags-input::placeholder { color: var(--faint); }

/* ---------- upload ---------- */
.ui-upload { display: grid; gap: 9px; }
.ui-upload-drop {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 26px 18px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.ui-upload-drop:hover, .ui-upload-drop.over { border-color: var(--primary); background: var(--primary-soft); }
.ui-upload-drop .icon { width: 24px; height: 24px; color: var(--faint); }
.ui-upload-hint { font-size: 12.5px; }
.ui-upload-file {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.ui-upload-preview { width: 52px; height: 52px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.ui-upload-meta { flex: 1; min-width: 0; display: grid; gap: 1px; }
.ui-upload-meta strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ui-upload-meta small { color: var(--muted); font-size: 11.5px; }

/* ---------- wizard ---------- */
.ui-wizard { display: grid; gap: 18px; }
.ui-wizard-rail { display: flex; gap: 4px; }
.ui-wizard-step {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  border-radius: 9px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--faint);
}
.ui-wizard-step.active { border-color: var(--primary); color: var(--ink); background: var(--primary-soft); }
.ui-wizard-step.done { color: var(--muted); }
.ui-wizard-dot {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: 50%;
  background: var(--surface-3);
  font-size: 11.5px;
  font-weight: 700;
}
.ui-wizard-step.active .ui-wizard-dot { background: var(--primary); color: #fff; }
.ui-wizard-step.done .ui-wizard-dot { background: var(--success-soft); color: var(--success); }
.ui-wizard-dot .icon { width: 12px; height: 12px; }
.ui-wizard-title { font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ui-wizard-actions { display: flex; justify-content: space-between; gap: 10px; }

/* ---------- edição inline autosave ---------- */
.ui-inline {
  border-radius: 7px;
  padding: 2px 6px;
  margin: -2px -6px;
  cursor: text;
  transition: background 0.14s, box-shadow 0.14s;
}
.ui-inline:hover:not(.editing) { background: rgba(255, 255, 255, 0.06); box-shadow: inset 0 0 0 1px var(--border); }
.ui-inline:focus-visible { outline: none; box-shadow: var(--ring); }
/* --faint (4,12:1 em 13,5px) reprovava no AA para texto pequeno e este texto
   é instrução de preenchimento, não decoração: --muted passa com folga e o
   itálico continua diferenciando o campo vazio. */
.ui-inline.is-empty { color: var(--muted); font-style: italic; }
.ui-inline.editing { padding: 0; margin: 0; cursor: auto; background: transparent; box-shadow: none; }
.ui-inline-field { font: inherit; }
.ui-save-state { margin-left: 8px; font-size: 11.5px; font-weight: 600; }
.ui-save-state.saving { color: var(--muted); }
.ui-save-state.saved { color: var(--success); }
.ui-save-state.error { color: var(--danger); }

/* ---------- gráficos (js/core/charts.js) ---------- */
.chart { position: relative; min-width: 0; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .axis-label { fill: var(--faint); font: 500 10.5px var(--font); }
.chart .line-path { fill: none; stroke: var(--primary-bright); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.chart .area-path { fill: url(#chart-area-fill); stroke: none; }
.chart .point-dot { fill: var(--primary-bright); stroke: var(--surface); stroke-width: 2; }
.chart .guide-line { stroke: var(--border-strong); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .bar-rect { fill: var(--primary); transition: fill 0.12s; }
.chart .bar-rect:hover, .chart .bar-rect.hot { fill: var(--primary-bright); }
.chart .donut-seg { transition: opacity 0.12s; }
.chart .donut-seg.dim { opacity: 0.35; }
.chart .donut-center { fill: var(--ink); font: 700 20px var(--font); }
.chart .donut-center-sub { fill: var(--muted); font: 500 11px var(--font); }
.chart-tip {
  position: absolute;
  z-index: 30;
  padding: 7px 10px;
  border-radius: 8px;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-2);
  color: var(--ink);
  font-size: 12px;
  font-weight: 550;
  white-space: nowrap;
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 9px));
}
.chart-tip small { display: block; color: var(--muted); font-weight: 500; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.chart-legend i { width: 9px; height: 9px; border-radius: 3px; flex: none; }
