/* ============================================================
   components.css — Componentes reutilizáveis (botões, cards,
   avatares, tags, inputs, modais, abas, chips, toasts).
   ============================================================ */

/* ---------------- Marcação de texto (App.markup) ---------------- */
.mk-link { color: var(--accent); text-decoration: none; font-weight: var(--fw-semibold); word-break: break-word; }
.mk-link:hover { text-decoration: underline; }
.mk-mention { color: var(--accent); font-weight: var(--fw-semibold); }
.mk-img { display: block; max-width: 100%; height: auto; border-radius: var(--r-md); margin: var(--s-2) 0; }
.mk-img-missing { display: inline-flex; align-items: center; gap: 4px; color: var(--text-mute); font-size: var(--fs-sm); background: var(--surface-2); padding: 2px 8px; border-radius: var(--r-sm, 6px); }
/* tag [C] = código inline */
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; background: var(--surface-2); padding: 1px 6px; border-radius: var(--r-sm, 6px); }

/* ---------------- Botões ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  height: 40px;
  padding: 0 var(--s-4);
  border-radius: var(--r-md);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-sm);
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast), opacity var(--t-fast);
  white-space: nowrap;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.5; pointer-events: none; }
.btn--primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--on-accent);
  border-color: transparent;
}
.btn--primary:hover { filter: brightness(1.05); background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.btn--ghost { background: transparent; border-color: transparent; }
.btn--ghost:hover { background: var(--surface-2); }
.btn--outline { background: transparent; border-color: var(--border-strong); }
.btn--danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.btn--danger:hover { background: var(--danger); color: #fff; }
.btn--sm { height: 34px; padding: 0 var(--s-3); font-size: var(--fs-xs); }
.btn--lg { height: 48px; padding: 0 var(--s-5); font-size: var(--fs-md); }
.btn--block { width: 100%; }
.btn--icon { width: 40px; padding: 0; }
.btn--icon.btn--sm { width: 34px; }

.icon-btn {
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0; border: 0; line-height: 0;
  border-radius: var(--r-md);
  color: var(--text-dim);
  transition: background var(--t-fast), color var(--t-fast);
}
.icon-btn > .icon { margin: 0; flex: none; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ---------------- Cards / superfícies ---------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-soft);
}
.card--pad { padding: var(--s-4); }
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-4);
}

/* ---------------- Avatar ---------------- */
.avatar {
  --av: 44px;
  width: var(--av); height: var(--av);
  border-radius: var(--r-md);
  flex: none;
  display: grid; place-items: center;
  overflow: hidden;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--on-accent);
  font-weight: var(--fw-bold);
  position: relative;
  user-select: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--round { border-radius: 50%; }
.avatar--xs { --av: 28px; font-size: var(--fs-xs); }
.avatar--sm { --av: 36px; font-size: var(--fs-sm); }
.avatar--lg { --av: 64px; font-size: var(--fs-lg); }
.avatar--xl { --av: 104px; font-size: var(--fs-2xl); }
.avatar--ring { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--accent); }

/* ---------------- Tags / chips ---------------- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid transparent;
}
.tag--neutral { background: var(--surface-2); color: var(--text-dim); }
.tag--rep { background: rgba(255, 207, 92, 0.15); color: var(--rep); }
.tag--title { background: var(--surface-3); color: var(--text); }
.tag .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.tag--removable { padding-right: 4px; }
.tag__x {
  width: 18px; height: 18px; display: grid; place-items: center;
  border-radius: 50%; opacity: 0.7;
}
.tag__x:hover { opacity: 1; background: rgba(255,255,255,0.12); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 12px; border-radius: var(--r-pill);
  background: var(--surface-2); color: var(--text-dim);
  font-size: var(--fs-sm); font-weight: var(--fw-medium);
  border: 1px solid var(--border);
}
.chip.is-active { background: var(--accent); color: var(--on-accent); border-color: transparent; }

/* contadores estatísticos (seguidores etc.) */
.stat { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.stat__num { font-weight: var(--fw-bold); font-size: var(--fs-lg); }
.stat__label { color: var(--text-mute); font-size: var(--fs-xs); }
.stat-row { display: flex; gap: var(--s-5); }

/* ---------------- Inputs ---------------- */
.field { display: flex; flex-direction: column; gap: var(--s-2); }
.field__label { font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--text-dim); }
.field__hint { font-size: var(--fs-xs); color: var(--text-mute); }
.input, .textarea, .select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 0 var(--s-3);
  height: 44px;
  color: var(--text);
  transition: border-color var(--t-fast), background var(--t-fast);
}
.textarea { height: auto; min-height: 96px; padding: var(--s-3); resize: vertical; line-height: var(--lh-normal); }
.input:focus, .textarea:focus, .select:focus { border-color: var(--accent); outline: none; }
.input::placeholder, .textarea::placeholder { color: var(--text-mute); }
.select { appearance: none; cursor: pointer; }

.searchbar {
  display: flex; align-items: center; gap: var(--s-2);
  height: 42px; padding: 0 var(--s-3);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  color: var(--text-mute);
  min-width: 0;
}
.searchbar input { background: none; border: none; outline: none; width: 100%; color: var(--text); }

.switch {
  width: 46px; height: 28px; border-radius: var(--r-pill);
  background: var(--surface-3); position: relative; flex: none;
  transition: background var(--t-fast);
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 22px; height: 22px; border-radius: 50%; background: #fff;
  transition: transform var(--t-fast);
}
.switch.is-on { background: var(--accent); }
.switch.is-on::after { transform: translateX(18px); }

/* upload de imagem (capa/painel/avatar/ícone) */
.upload {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3); border: 1px dashed var(--border-strong);
  border-radius: var(--r-md); background: var(--surface-2);
}
.upload__preview {
  width: 56px; height: 56px; border-radius: var(--r-md);
  background: var(--surface-3) center/cover; flex: none;
}

/* ---------------- Abas ---------------- */
.tabs {
  display: flex; gap: var(--s-1);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.tabs__item {
  padding: var(--s-3) var(--s-4);
  color: var(--text-mute);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-sm);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color var(--t-fast);
}
.tabs__item:hover { color: var(--text); }
.tabs__item.is-active { color: var(--accent); border-bottom-color: var(--accent); }

/* segmented control */
.segmented {
  display: inline-flex; padding: 4px; gap: 2px;
  background: var(--surface-2); border-radius: var(--r-pill);
  border: 1px solid var(--border);
}
.segmented__item {
  padding: 6px 14px; border-radius: var(--r-pill);
  font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--text-mute);
}
.segmented__item.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-soft); }

/* ---------------- Listas / itens ---------------- */
.list-item {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3);
  border-radius: var(--r-md);
  transition: background var(--t-fast);
}
.list-item:hover { background: var(--surface-2); }
.list-item__body { min-width: 0; flex: 1; }
.list-item__title { font-weight: var(--fw-semibold); }
.list-item__sub { color: var(--text-mute); font-size: var(--fs-sm); }

/* ---------------- Modal / sheet ---------------- */
.scrim {
  position: fixed; inset: 0;
  background: var(--scrim);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: var(--z-overlay);
  display: grid; place-items: center;
  padding: var(--s-4);
  animation: fade var(--t-mid);
}
.modal {
  width: min(560px, 100%);
  max-height: 90vh;
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-pop);
  z-index: var(--z-modal);
  animation: pop var(--t-mid);
  overflow: hidden;
}
.modal__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--border);
}
.modal__title { font-size: var(--fs-lg); font-weight: var(--fw-bold); }
.modal__body { padding: var(--s-5); overflow-y: auto; display: flex; flex-direction: column; gap: var(--s-4); }
.modal__foot {
  display: flex; justify-content: flex-end; gap: var(--s-3);
  padding: var(--s-4) var(--s-5); border-top: 1px solid var(--border);
}

/* ---------- Action sheet (bottom-sheet) ---------- */
.scrim--sheet { align-items: flex-end; padding: var(--s-4); }
.action-sheet {
  width: min(520px, 100%); margin: 0 auto;
  display: flex; flex-direction: column; gap: var(--s-3);
  z-index: var(--z-modal);
  animation: sheet var(--t-mid);
}
.action-sheet__title {
  text-align: center; color: var(--text-mute);
  font-size: var(--fs-sm); font-weight: var(--fw-semibold);
  padding-bottom: var(--s-1);
}
.action-sheet__group, .action-sheet__cancel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.action-sheet__item {
  display: flex; align-items: center; gap: var(--s-3);
  width: 100%; padding: var(--s-4);
  font-weight: var(--fw-semibold); color: var(--text);
  border-bottom: 1px solid var(--border);
}
.action-sheet__item:last-child { border-bottom: none; }
.action-sheet__item:hover { background: var(--surface-2); }
.action-sheet__item--danger { color: var(--danger); }
.action-sheet__cancel {
  padding: var(--s-4); text-align: center;
  font-weight: var(--fw-bold); color: var(--danger);
}
.action-sheet__cancel:hover { background: var(--surface-2); }

@media (max-width: 639px) {
  .scrim { align-items: flex-end; padding: 0; }
  .modal {
    width: 100%;
    max-height: 92vh;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    animation: sheet var(--t-mid);
  }
}

/* ---------------- Toast ---------------- */
.toast-host {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: var(--s-2);
  z-index: var(--z-toast); pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: var(--s-2);
  padding: var(--s-3) var(--s-4);
  background: var(--surface-3); color: var(--text);
  border-radius: var(--r-pill); box-shadow: var(--shadow-pop);
  border: 1px solid var(--border);
  animation: pop var(--t-mid);
}
.toast--ok { color: var(--ok); }
.toast--danger { color: var(--danger); }

@media (max-width: 639px) { .toast-host { bottom: calc(var(--bottomnav-h) + 16px); } }

/* ---------------- Menu de contexto (dropdown) ---------------- */
.menu {
  position: fixed;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-pop);
  padding: var(--s-2);
  z-index: var(--z-modal);
  display: flex; flex-direction: column; gap: 2px;
  animation: pop var(--t-fast);
}
.menu__item {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3); border-radius: var(--r-sm);
  font-size: var(--fs-sm); color: var(--text-dim);
}
.menu__item:hover { background: var(--surface-2); color: var(--text); }
.menu__item--danger { color: var(--danger); }
.menu__sep { height: 1px; background: var(--border); margin: var(--s-1) 0; }

/* ---------------- Skeleton ---------------- */
.skeleton {
  background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2));
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: var(--r-sm);
}

/* badges de moderação */
.mod-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: var(--fs-xs); font-weight: var(--fw-bold);
  padding: 2px 8px; border-radius: var(--r-pill);
}
.mod-badge--ban { background: var(--danger-soft); color: var(--danger); }
.mod-badge--mute { background: rgba(255,180,84,0.16); color: var(--warn); }
.mod-badge--hide { background: var(--surface-3); color: var(--text-mute); }

/* guia de boas-vindas (onboarding) */
.scrim.onb { display: grid; place-items: center; padding: var(--s-4); }
.onb.is-closing { animation: fade .2s ease reverse forwards; }
.onb__card {
  width: min(420px, 100%); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-xl); padding: var(--s-6) var(--s-5); text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: var(--s-3);
  box-shadow: var(--shadow-strong, 0 20px 60px rgba(0,0,0,.4)); animation: pop .25s ease both;
}
.onb__icon {
  width: 72px; height: 72px; border-radius: var(--r-lg); display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}
.onb__title { font-size: var(--fs-xl); }
.onb__text { color: var(--text-mute); font-size: var(--fs-sm); line-height: var(--lh-normal); }
.onb__dots { display: flex; gap: 6px; margin: var(--s-2) 0; }
.onb__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--surface-3); transition: background .2s, transform .2s; }
.onb__dot.is-on { background: var(--accent); transform: scale(1.2); }
.onb__nav { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); width: 100%; margin-top: var(--s-2); }
.onb__skip { background: none; border: none; color: var(--text-mute); cursor: pointer; font-weight: var(--fw-semibold); padding: var(--s-2); }
.onb__skip:hover { color: var(--text); }
.onb__check { display: flex; flex-direction: column; gap: var(--s-2); width: 100%; }
.onb__checkrow {
  display: flex; align-items: center; gap: var(--s-3); width: 100%; text-align: left;
  padding: var(--s-3); border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface-2); color: var(--text); cursor: pointer;
}
.onb__checkrow:hover { border-color: var(--accent); }
.onb__checkicon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: var(--r-sm); background: var(--accent-soft); color: var(--accent); flex: none; }

/* Contador de caracteres (anti-abuso) */
.char-counter {
  display: inline-block; font-size: var(--fs-xs); color: var(--text-mute);
  font-variant-numeric: tabular-nums; line-height: 1; user-select: none;
}
.char-counter.is-warn { color: var(--warn); }
.char-counter.is-full { color: var(--danger); font-weight: var(--fw-semibold); }

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
@keyframes sheet { from { transform: translateY(100%); } }

/* ---------- Animações de saída (fechar modal / action sheet) ---------- */
.scrim.is-closing { animation: fade var(--t-fast) reverse forwards; }
.scrim.is-closing .modal { animation: pop var(--t-fast) reverse forwards; }
.scrim--sheet.is-closing .action-sheet { animation: sheet var(--t-mid) reverse forwards; }

/* ---------- Switch: animação de ativar/desativar ---------- */
.switch::after { transition: transform var(--t-mid) cubic-bezier(0.2,0.8,0.3,1.2), background var(--t-fast); }
.switch.is-pulse::after { animation: switch-on .3s ease; }
.switch.is-pulse-off::after { animation: switch-off .3s ease; }
@keyframes switch-on { 50% { transform: translateX(18px) scale(1.18); } }
@keyframes switch-off { 50% { transform: translateX(0) scale(0.82); } }

/* ---------- Botão de tema: giro + cross-fade do ícone (lua/sol) ---------- */
/* gira a partir do CENTRO do próprio ícone (SVG usa origem no canto por padrão) */
.theme-toggle .icon { transform-box: fill-box; transform-origin: center center; }
.theme-toggle:not(.is-spin) .icon { transform: none; }
.theme-toggle.is-spin .icon { animation: theme-swap .42s cubic-bezier(0.2,0.8,0.3,1) both; }
@keyframes theme-swap {
  0%   { transform: rotate(-90deg) scale(0.4); opacity: 0; }
  60%  { transform: rotate(12deg) scale(1.08); opacity: 1; }
  100% { transform: rotate(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .switch.is-pulse::after, .switch.is-pulse-off::after,
  .theme-toggle.is-spin .icon { animation: none !important; }
}
@keyframes shimmer { to { background-position: -200% 0; } }
