/* ===========================================================================
   components.css — cards suaves, formulário, botões, modal de QR, theme toggle
   Direção: minimal calmo (sem ruído).
   =========================================================================== */

/* ---------- ícone-botão ---------- */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition:
    background 160ms ease,
    color 160ms ease,
    transform 140ms var(--ease-out);
}
.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}
/* feedback de toque: o botão "afunda" de leve ao ser pressionado */
.icon-btn:active {
  transform: scale(0.9);
}
.icon-btn svg {
  width: 19px;
  height: 19px;
}

/* graça no toggle de tema: o ícone gira de leve no hover */
.theme-toggle svg {
  transition: transform 400ms cubic-bezier(0.22, 0.61, 0.36, 1);
}
.theme-toggle:hover svg {
  transform: rotate(35deg);
}

/* theme toggle (mostra ícone conforme o tema) */
.theme-toggle .ic-moon {
  display: none;
}
[data-theme="dark"] .theme-toggle .ic-sun {
  display: none;
}
[data-theme="dark"] .theme-toggle .ic-moon {
  display: inline-flex;
}

/* ---------- lista de cards (suaves) ---------- */
.cards {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.card {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  transition:
    transform 200ms ease,
    box-shadow 200ms ease,
    border-color 200ms ease,
    background-color 350ms ease;
  animation: riseIn 500ms cubic-bezier(0.22, 0.61, 0.36, 1) both;
}
.card:hover,
.card:focus-within {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-2);
}
/* pressionar o card (link inteiro) o afunda de leve — confirma o toque */
.card:active {
  transform: scale(0.985);
  transition-duration: 120ms;
}

.card__order {
  flex: none;
  width: 1.6em;
  font-size: var(--fs-sm);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  transition: color 200ms ease;
}
.card:hover .card__order,
.card:focus-within .card__order {
  color: var(--accent);
}

.card__body {
  flex: 1;
  min-width: 0;
}
.card__link {
  display: block;
}
/* stretched link: card inteiro vira alvo de toque */
.card__link::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: var(--z-card-link);
}
.card__title {
  display: inline-block;
  font-weight: 600;
  font-size: var(--fs-md);
  /* sublinhado teal que cresce no hover */
  background-image: linear-gradient(var(--accent), var(--accent));
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 0% 1.5px;
  transition: background-size 280ms ease;
}
.card:hover .card__title,
.card:focus-within .card__title {
  background-size: 100% 1.5px;
}
.card__subtitle {
  display: block;
  margin-top: 1px;
  font-size: var(--fs-sm);
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* seta (afordância principal, discreta) */
.card__arrow {
  flex: none;
  display: flex;
  color: var(--text-muted);
  transition:
    transform 200ms ease,
    color 200ms ease;
}
.card__arrow svg {
  width: 18px;
  height: 18px;
}
.card:hover .card__arrow,
.card:focus-within .card__arrow {
  color: var(--accent);
  transform: translateX(3px);
}

/* ações (acima do stretched link) — discretas */
.card__actions {
  position: relative;
  z-index: var(--z-card-actions);
  display: flex;
  gap: 2px;
  flex: none;
}
.card__actions .icon-btn:hover {
  color: var(--accent);
  background: var(--accent-weak);
}
.card__actions .icon-btn--danger:hover {
  color: var(--danger);
  background: transparent;
}

/* ---------- card em destaque ("comece por aqui") ---------- */
/* 1 accent com parcimônia: leve wash + borda accent + selo textual (não só cor) */
.card--featured {
  background: var(--accent-weak);
  border-color: var(--accent);
}
.card--featured:hover,
.card--featured:focus-within {
  border-color: var(--accent);
}
.card--featured .card__title {
  font-size: var(--fs-lg);
}
/* selo: estrela + rótulo, acima do título (estado por texto, não só cor) */
.card__badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 2px;
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--accent);
}
.card__badge svg {
  width: 13px;
  height: 13px;
}
/* estrela de favorito (admin): ativa = accent + preenchida */
.card__actions .icon-btn--star.is-active {
  color: var(--accent);
}
.card__actions .icon-btn--star.is-active svg {
  fill: currentColor;
}

/* ---------- pasta (accordion) ---------- */
.folder {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  transition:
    border-color 200ms ease,
    box-shadow 200ms ease,
    background-color 350ms ease;
  animation: riseIn 500ms cubic-bezier(0.22, 0.61, 0.36, 1) both;
}
.folder.is-open {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-2);
}

.folder__row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

/* cabeçalho é um <button> real (disclosure); ocupa a maior parte da linha */
.folder__head {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  min-height: 56px;
  padding: var(--sp-4) var(--sp-5);
  text-align: left;
  color: var(--text);
  border-radius: var(--radius);
}
.folder__icon {
  display: flex;
  flex: none;
  color: var(--accent);
}
.folder__icon svg {
  width: 18px;
  height: 18px;
}
.folder__body {
  flex: 1;
  min-width: 0;
}
.folder__title {
  display: block;
  font-weight: 600;
  font-size: var(--fs-md);
}
.folder__subtitle {
  display: block;
  margin-top: 1px;
  font-size: var(--fs-sm);
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* contagem de links na pasta — pista discreta do conteúdo (recognition) */
.folder__count {
  flex: none;
  font-size: var(--fs-xs);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.folder__chevron {
  flex: none;
  display: flex;
  color: var(--text-muted);
  transition:
    transform 220ms ease,
    color 220ms ease;
}
.folder__chevron svg {
  width: 20px;
  height: 20px;
}
.folder.is-open .folder__chevron {
  transform: rotate(180deg);
  color: var(--accent);
}
.folder__head:hover .folder__chevron {
  color: var(--accent);
}

.folder__actions {
  display: flex;
  gap: 2px;
  flex: none;
  padding-right: var(--sp-3);
}
.folder__actions .icon-btn:hover {
  color: var(--accent);
  background: var(--accent-weak);
}
.folder__actions .icon-btn--danger:hover {
  color: var(--danger);
  background: transparent;
}

/* painel: expande suave sem saber a altura (grid 0fr -> 1fr) */
.folder__panel {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 240ms ease;
}
.folder.is-open .folder__panel {
  grid-template-rows: 1fr;
}
.folder__panel-inner {
  overflow: hidden;
}

/* filhos: leve recuo + gap menor; cards mais discretos (hierarquia) */
.folder__children {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: 0 var(--sp-4) var(--sp-4) var(--sp-6);
}
.folder__children .card {
  box-shadow: none;
  background: var(--surface-2);
}
.folder__children .card:hover,
.folder__children .card:focus-within {
  box-shadow: var(--shadow-1);
}
.folder__empty {
  padding: var(--sp-2) 0 var(--sp-4);
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

/* link de texto discreto (ex.: voltar à página pública no admin) */
.text-link {
  color: var(--accent);
  font-size: var(--fs-sm);
  border-bottom: 1px solid transparent;
  transition: border-color 160ms ease;
}
.text-link:hover {
  border-color: var(--accent);
}

/* ---------- estado vazio ---------- */
.empty {
  text-align: center;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  padding: var(--sp-8) var(--sp-4);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* ---------- formulário ---------- */
.form-panel {
  padding: var(--sp-6);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  transition:
    background-color 350ms ease,
    border-color 350ms ease;
}
.form-panel__title {
  font-size: var(--fs-lg);
  margin-bottom: var(--sp-5);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: var(--sp-5);
}
.field > label {
  font-size: var(--fs-sm);
  font-weight: 500;
}

/* checkbox "É uma pasta" */
.check {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: 44px;
  cursor: pointer;
  font-size: var(--fs-sm);
  font-weight: 500;
  line-height: 1;
}
.check input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
.check span {
  padding-top: 2px;
}
.field .req {
  color: var(--accent);
}
.field .opt {
  color: var(--text-muted);
  font-weight: 400;
}

.input {
  height: 46px;
  padding: 0 var(--sp-3);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background-color 350ms ease;
}
.input::placeholder {
  color: var(--text-muted);
}
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-weak);
}
.input[aria-invalid="true"] {
  border-color: var(--danger);
}

.helper {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.error {
  display: none;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-xs);
  color: var(--danger);
}
.error.is-visible {
  display: flex;
}
.error svg {
  width: 14px;
  height: 14px;
  flex: none;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-3);
  margin-top: var(--sp-2);
}

/* ---------- botões ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 var(--sp-5);
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: var(--fs-sm);
  transition:
    background 160ms ease,
    border-color 160ms ease,
    opacity 160ms ease,
    transform 160ms var(--ease-out);
}
.btn:hover:not(:disabled) {
  transform: translateY(-1px);
}
.btn:active:not(:disabled) {
  transform: scale(0.97);
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--accent);
  color: var(--accent-ink);
}
.btn--primary:hover:not(:disabled) {
  filter: brightness(0.95);
}
.btn--primary.is-success {
  background: var(--success);
}

.btn--ghost {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text);
}
.btn--ghost:hover {
  background: var(--surface-2);
}
.btn--ghost.is-success {
  border-color: var(--success);
  color: var(--success);
}

/* ---------- painel de publicação (admin) ---------- */
.publish-panel {
  margin-top: var(--sp-8);
}
/* status: ponto + frase — quieto quando publicado, accent quando há pendência */
.pub-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: var(--sp-5);
  font-size: var(--fs-sm);
  color: var(--text-muted);
}
.pub-status .pub-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-strong);
  transition: background-color 200ms ease;
}
.pub-status.is-dirty {
  color: var(--text);
}
.pub-status.is-dirty .pub-dot {
  background: var(--accent);
}
.pub-token-saved {
  margin-bottom: var(--sp-5);
}

/* ---------- modal QR ---------- */
.qr-modal {
  margin: auto;
  width: min(92vw, 360px);
  padding: var(--sp-6);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
}
.qr-modal::backdrop {
  background: rgba(16, 18, 22, 0.45);
}
.qr-modal[open] {
  animation: modalIn 180ms var(--ease-out);
}
/* backdrop entra junto com um fade — entrada coesa (não some seco) */
.qr-modal[open]::backdrop {
  animation: backdropIn 180ms ease-out;
}
@keyframes backdropIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.qr-modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
}
.qr-modal__title {
  font-size: var(--fs-lg);
}

.qr-plate {
  background: var(--qr-plate);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--sp-4);
  margin: var(--sp-4) 0;
  display: grid;
  place-items: center;
}
.qr-plate canvas,
.qr-plate img {
  display: block;
  border-radius: 6px; /* casa os cantos do QR com a placa */
}

/* dark: placa segue branca (escaneável), mas a moldura é suavizada — um
   passe-partout em tom charcoal + sombra macia, pra não bater de chapa no fundo */
[data-theme="dark"] .qr-plate {
  border-color: transparent;
  box-shadow:
    0 0 0 6px var(--surface-2),
    0 8px 22px rgba(0, 0, 0, 0.45);
}

.qr-modal__url {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  text-align: center;
  word-break: break-all;
}
.qr-modal__actions {
  display: flex;
  gap: var(--sp-3);
  margin-top: var(--sp-4);
}
.qr-modal__actions .btn {
  flex: 1;
}
