/* components.css — cards, botões, forms, checkoffs, heatmap, dialogs, toast */

/* ── Botões ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 15px;
  transition: transform .12s ease, filter .15s ease, background-color .15s ease;
}
.btn:active { transform: scale(.97); }
.btn-block { width: 100%; }

.btn-primary {
  background: var(--grad);
  color: var(--on-grad);
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { filter: brightness(1.05); }

.btn-accent {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: var(--shadow-sm);
}
.btn-accent:hover { filter: brightness(1.06); }

.btn-ghost { background: var(--surface-2); color: var(--text); }
.btn-ghost:hover { filter: brightness(.96); }
[data-mode="dark"] .btn-ghost:hover { filter: brightness(1.15); }

.btn-danger { background: transparent; color: var(--danger); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); }
.dialog .btn-danger { min-height: 44px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 20px;
  color: inherit;
  transition: background-color .15s ease;
}
.icon-btn:hover { background: rgba(127, 127, 127, .15); }

/* ── Cards ── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 12px;
}
.card-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 12px;
}

/* ── Card de atividade (Hoje) ── */
.activity-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
  margin-bottom: 10px;
  transition: opacity .2s ease;
}
.activity-card.is-done { opacity: .72; }

.activity-body { flex: 1; min-width: 0; }

.activity-title {
  font-weight: 600;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.is-done .activity-title { text-decoration: line-through; text-decoration-thickness: 2px; }

.activity-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--muted);
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  color: #fff;
  background: var(--chip-color, var(--cat-outros));
  white-space: nowrap;
}

/* ── Check button (≥44px, tap-friendly) ── */
.check-btn {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  border: 2px solid var(--border);
  background: var(--surface-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: transparent;
  transition: transform .15s ease, background-color .2s ease, border-color .2s ease, color .2s ease;
}
.check-btn:hover { border-color: var(--primary); }
.check-btn:active { transform: scale(.88); }
.check-btn[aria-pressed="true"] {
  background: var(--grad);
  border-color: transparent;
  color: var(--on-grad);
}
.check-btn.pop { animation: check-pop .3s ease; }
@keyframes check-pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

/* ── Stepper (metas numéricas) ── */
.stepper {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}
.stepper-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 20px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color .15s ease, transform .12s ease;
}
.stepper-btn:hover { background: var(--border); }
.stepper-btn:active { transform: scale(.9); }
.stepper-value {
  min-width: 52px;
  text-align: center;
  font-weight: 700;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.stepper-value small { display: block; font-weight: 500; color: var(--muted); font-size: 11px; }

/* Linha extra do card p/ metas numéricas (stepper + mini barra) */
.activity-stepper-row {
  flex-basis: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 4px;
}
.activity-card { flex-wrap: wrap; }
.mini-track {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}
.mini-track .progress-fill { height: 100%; }

.edit-btn {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: var(--muted);
  transition: background-color .15s ease;
}
.edit-btn:hover { background: var(--surface-2); color: var(--text); }

/* ── Barras de progresso (Semana) ── */
.progress-card { display: flex; flex-direction: column; gap: 8px; }

.progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.progress-head .activity-title { flex: 1; }
.progress-count {
  font-weight: 700;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.progress-count.met { color: var(--pos); }

.progress-track {
  height: 10px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--grad);
  transition: width .35s ease;
}
.progress-fill.over { background: var(--accent); }

.week-dots {
  display: flex;
  gap: 6px;
  margin-top: 2px;
}
.week-dot {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--muted);
}
.week-dot i {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
}
.week-dot.done i { background: var(--primary); border-color: var(--primary); }
.week-dot.today { color: var(--text); }
.week-dot.today i { border-color: var(--accent); }
.week-dot.future i { opacity: .45; }

/* ── Stats (Mês) ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}
.stat-card.stat-hero {
  grid-column: 1 / -1;
  background: var(--grad);
  color: var(--on-grad);
}
.stat-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.stat-hero .stat-value { font-size: 40px; }
.stat-label { font-size: 12.5px; font-weight: 600; opacity: .85; margin-top: 2px; }
.stat-delta-up { color: var(--pos); }
.stat-delta-down { color: var(--danger); }

/* ── Heatmap ── */
.heatmap {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
}
.heatmap-wd {
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  padding-bottom: 2px;
}
.hm {
  aspect-ratio: 1;
  border-radius: 8px;
  background: var(--hm-0);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}
.hm.lvl-1 { background: var(--hm-1); }
.hm.lvl-2 { background: var(--hm-2); }
.hm.lvl-3 { background: var(--hm-3); color: #fff; }
.hm.lvl-4 { background: var(--hm-4); color: #fff; }
.hm.today { box-shadow: inset 0 0 0 2px var(--accent); }
.hm.future { opacity: .4; }
.hm.empty { background: transparent; }

.heatmap-legend {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 10px;
  font-size: 11px;
  color: var(--muted);
}
.heatmap-legend .hm { width: 14px; height: 14px; aspect-ratio: auto; border-radius: 4px; }

.month-activity-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.month-activity-list li:last-child { border-bottom: 0; }
.month-activity-list .activity-title { font-size: 14px; }
.month-activity-list .count {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  white-space: nowrap;
  color: var(--muted);
}
.month-activity-list .count.met { color: var(--pos); }

/* ── Forms ── */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }

.field label, .field legend {
  font-size: 13.5px;
  font-weight: 700;
}
.optional { font-weight: 500; color: var(--muted); }

.field input, .field select {
  min-height: 48px;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background-color: var(--surface);
  color: var(--text);
  width: 100%;
  transition: border-color .15s ease;
}
.field input:hover, .field select:hover { border-color: var(--muted); }
.field input:focus-visible, .field select:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent);
}
.field input[aria-invalid="true"] { border-color: var(--danger); }

.field-error { font-size: 13px; color: var(--danger); font-weight: 600; }

/* ── Emoji picker ── */
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
  gap: 8px;
  margin-top: 8px;
}
.emoji-option { position: relative; }
.emoji-option input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}
.emoji-option span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  font-size: 24px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 2px solid var(--border);
  transition: border-color .15s ease, transform .12s ease;
}
.emoji-option input:hover + span { border-color: var(--muted); }
.emoji-option input:checked + span {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  transform: scale(1.05);
}
.emoji-option input:focus-visible + span {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* ── Day picker (dias específicos) ── */
.day-picker {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.day-option { position: relative; flex: 1; }
.day-option input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}
.day-option span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  font-size: 13px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 2px solid transparent;
  transition: background-color .15s ease, border-color .15s ease;
}
.day-option input:hover + span { border-color: var(--muted); }
.day-option input:checked + span {
  background: var(--primary);
  color: #fff;
}
.day-option input:focus-visible + span {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* ── Dialogs ── */
.dialog {
  width: min(480px, calc(100vw - 32px));
  border: 0;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  padding: 20px;
  overscroll-behavior: contain;
}
.dialog::backdrop { background: rgba(10, 18, 14, .55); backdrop-filter: blur(2px); }
.dialog form { display: flex; flex-direction: column; gap: 16px; }
.dialog-title { font-size: 19px; font-weight: 800; }
.dialog-text { color: var(--muted); font-size: 14.5px; margin-top: 8px; }
.dialog-sm .dialog-actions { margin-top: 20px; }

.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}
.dialog-actions-spacer { flex: 1; }

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}
.empty-state .empty-icon { font-size: 44px; }
.empty-state p { margin-top: 8px; font-size: 14.5px; }

/* ── Toggle Dia/Noite (preview da paleta) ── */
.mode-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  color: var(--text);
  font-weight: 700;
  font-size: 14px;
  transition: filter .15s ease, border-color .15s ease;
}
.mode-toggle:hover { border-color: var(--primary); }

/* variante full-width dentro do dialog de perfil */
.mode-toggle-row { width: 100%; justify-content: center; margin-top: 8px; }

.palette-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--grad);
  border: 2px solid color-mix(in srgb, var(--text) 25%, transparent);
  flex-shrink: 0;
}

/* ── Radio cards de paleta (👨/👩) ── */
.gender-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 8px;
}
.gender-card { position: relative; }
.gender-card input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}
.gc-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 8px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color .15s ease, background-color .15s ease;
}
.gender-card input:hover + .gc-body { border-color: var(--muted); }
.gender-card input:checked + .gc-body {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 8%, transparent);
}
.gender-card input:focus-visible + .gc-body {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}
.gc-emoji { font-size: 26px; }
.gc-label { font-weight: 700; font-size: 14px; }
.gc-swatches { display: flex; gap: 6px; margin-top: 2px; }
.gc-swatches i {
  width: 28px;
  height: 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.profile-theme-field { margin-top: 16px; }

/* ── Avatares (foto → emoji → inicial) ── */
.avatar-img {
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.avatar-emoji { flex-shrink: 0; line-height: 1; }
.avatar-initial {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: #fff;
  font-weight: 800;
  flex-shrink: 0;
}

.avatar-chip.avatar-img, .avatar-chip.avatar-initial { width: 26px; height: 26px; font-size: 13px; }
.avatar-chip.avatar-emoji { font-size: 18px; }
.avatar-rk.avatar-img, .avatar-rk.avatar-initial { width: 34px; height: 34px; font-size: 15px; }
.avatar-rk.avatar-emoji { font-size: 22px; }
.avatar-podium.avatar-img, .avatar-podium.avatar-initial { width: 44px; height: 44px; font-size: 19px; }
.avatar-podium.avatar-emoji { font-size: 24px; }
.avatar-lg.avatar-img, .avatar-lg.avatar-initial { width: 88px; height: 88px; font-size: 38px; }
.avatar-lg.avatar-emoji { font-size: 64px; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ── Perfil ── */
.profile-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 0 16px;
}
.profile-name { font-size: 17px; font-weight: 800; }
.profile-hint { text-align: center; margin-top: 8px; }
#profile-dialog label.btn { cursor: pointer; }
#profile-dialog label.btn:focus-within {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* ── Edição por dia ── */
.day-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.day-title { font-size: 16.5px; text-align: center; flex: 1; min-width: 0; }

.day-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 48vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  margin-bottom: 12px;
}
.day-list .section-label { margin: 8px 0 0; }

.day-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}
.day-row.is-done .activity-title { text-decoration: line-through; opacity: .75; }
.day-row-body { flex: 1; min-width: 0; }
.day-row .activity-title { font-size: 14px; }
.day-row-meta {
  font-size: 12.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.check-btn.check-sm { width: 44px; height: 44px; border-radius: 12px; font-size: 18px; }
.stepper-sm .stepper-btn { background: var(--surface); }

#day-add { margin-bottom: 8px; }
#day-dialog .dialog-actions { display: block; }

.heatmap-hint { margin-top: 10px; }
button.hm {
  cursor: pointer;
  transition: transform .12s ease, box-shadow .15s ease;
}
button.hm:hover { transform: scale(1.08); box-shadow: var(--shadow-sm); }
button.hm:active { transform: scale(.94); }

/* ── Ranking ── */
.ranking-filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.podium {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  align-items: end;
  margin-bottom: 16px;
}
.podium:empty { display: none; }

.podium-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-align: center;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 8px 12px;
  min-width: 0;
}
.podium-card.place-1 {
  background: var(--grad);
  color: var(--on-grad);
  padding-top: 20px;
  padding-bottom: 20px;
}
.podium-card.is-me { outline: 2px solid var(--accent); outline-offset: 2px; }

.medal {
  font-size: 30px;
  animation: medal-float 2.4s ease-in-out infinite;
}
.place-1 .medal { font-size: 38px; animation-delay: .2s; }
@keyframes medal-float {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-5px) scale(1.08); }
}

.podium-avatar { font-size: 24px; }
.podium-name {
  font-size: 12.5px;
  font-weight: 700;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.podium-score {
  font-size: 17px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.badge-streak {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  color: var(--pos);
  white-space: nowrap;
}
.place-1 .badge-streak { background: color-mix(in srgb, var(--on-grad) 18%, transparent); color: var(--on-grad); }

.badge-active {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  margin-top: 2px;
}
.badge-active.live { color: var(--pos); }
.place-1 .badge-active { color: var(--on-grad); opacity: .85; }

.ranking-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.rk-loading { color: var(--muted); text-align: center; padding: 24px 0; }

.rk-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 10px 14px;
  min-height: 56px;
}
.rk-row.is-me {
  outline: 2px solid var(--primary);
  background: color-mix(in srgb, var(--primary) 8%, transparent);
}

.rk-rank {
  flex-shrink: 0;
  min-width: 34px;
  font-weight: 800;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.rk-avatar { flex-shrink: 0; font-size: 22px; }

.rk-body { flex: 1; min-width: 0; }
.rk-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
}
.rk-name > :first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.rk-you {
  flex-shrink: 0;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.rk-track {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  margin-top: 5px;
}
.rk-track .progress-fill { height: 100%; }

.rk-score {
  flex-shrink: 0;
  font-weight: 800;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ranking-me {
  position: sticky;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 8px);
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  background: var(--text);
  color: var(--bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 16px;
  font-weight: 700;
}
.ranking-me .rk-rank { color: inherit; min-width: auto; }
.ranking-me .rk-me-info { font-size: 13px; font-weight: 600; opacity: .8; }

/* ── Toast ── */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 20px);
  z-index: 50;
  transform: translate(-50%, 16px);
  max-width: min(calc(var(--app-max) - 48px), calc(100vw - 48px));
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ── Confete ── */
.confetti {
  position: fixed;
  z-index: 60;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  pointer-events: none;
  will-change: transform, opacity;
}
