/* ==========================================================================
   Aba "Ajustes" do painel admin.
   Usa só as variáveis do site (--surface, --border, --text, --muted, --primary...),
   então acompanha qualquer tema (original, Natal, ...).
   ========================================================================== */

/* Título e "Atualizar" sempre na mesma linha (no celular o admin empilha o cabeçalho em coluna) */
#view-admin .admin-tab[data-tab="ajustes"] .panel-head { flex-direction: row; align-items: center; justify-content: space-between; margin-bottom: 0; }
#view-admin .admin-tab[data-tab="ajustes"] .panel-head h2 { margin: 0; }
#view-admin .admin-tab[data-tab="ajustes"] .panel-head .panel-actions { width: auto; justify-content: flex-end; margin-left: auto; }
.aj-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 26px; margin-top: 18px; }
.aj-group, .aj-rows { min-width: 0; }
/* Divisória só entre categorias (Metas semanais / Horas extras / Meta diária), não entre as linhas */
.aj-group + .aj-group { border-top: 1px solid var(--border); padding-top: 26px; }

/* ---------- Grupos ---------- */
.aj-group-title {
  margin: 0 0 6px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}
.aj-group-note {
  margin: 0 0 12px;
  max-width: 64ch;
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
}
.aj-rows { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; }

/* ---------- Linha ---------- */
.aj-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  padding: 12px 4px;
}
/* barrinha lateral = tem alteração ainda não salva */
.aj-row::before {
  content: '';
  position: absolute;
  left: -13px; top: 14px; bottom: 14px;
  width: 3px;
  border-radius: 3px;
  background: var(--primary);
  opacity: 0;
  transform: scaleY(.4);
  transition: opacity .2s ease, transform .25s cubic-bezier(.3,1.3,.5,1);
}
.aj-row.is-dirty::before { opacity: 1; transform: none; }

.aj-text { min-width: 0; flex: 1 1 auto; }
.aj-title {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px;
  font-size: 15px; font-weight: 600; color: var(--text);
  transition: color .2s ease;
}
.aj-row.is-off .aj-title { color: var(--muted); }
.aj-tag {
  display: inline-flex; align-items: center;
  height: 20px; padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: .02em;
  color: var(--muted);
  background: var(--bg);
}
.aj-desc, .aj-live { margin: 4px 0 0; max-width: 56ch; font-size: 13px; line-height: 1.55; color: var(--muted); }
.aj-err { margin: 6px 0 0; font-size: 12.5px; font-weight: 600; color: var(--danger); }
.aj-text [hidden] { display: none !important; }

/* ---------- Controles ---------- */
.aj-ctrl { display: flex; align-items: center; gap: 16px; flex: 0 0 auto; }

.aj-field {
  display: inline-flex; align-items: stretch;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  overflow: hidden;
  transition: border-color .15s ease, box-shadow .15s ease, opacity .2s ease;
}
.aj-field:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.14); }
.aj-row.is-off .aj-field { opacity: .45; }

.aj-step {
  width: 36px; border: 0; background: transparent; color: var(--muted);
  font-size: 18px; line-height: 1; cursor: pointer;
  transition: background .12s ease, color .12s ease;
  /* Celular: sem o atraso de ~300ms do "toque duplo pra zoom" (toques rápidos se perdiam),
     sem selecionar texto e sem o flash azul do toque */
  touch-action: manipulation;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.aj-field { touch-action: manipulation; }
/* hover só em mouse: no iPhone o hover "grudava" no botão depois do toque e parecia travado */
@media (hover: hover) { .aj-step:hover:not(:disabled) { background: var(--bg); color: var(--text); } }
.aj-step:active:not(:disabled), .aj-step.is-pressed { background: var(--border); color: var(--text); }
@media (max-width: 640px) { .aj-step { width: 44px; } }   /* área de toque maior no celular */
.aj-step:disabled { cursor: not-allowed; }
.aj-step:first-child { border-right: 1px solid var(--border); }
.aj-step:last-child { border-left: 1px solid var(--border); }

.aj-input {
  width: 62px; border: 0; outline: 0; background: transparent;
  text-align: right; padding: 0 4px 0 8px;
  /* 16px: abaixo disso o Safari do iPhone dá zoom na página ao tocar no campo */
  font: inherit; font-size: 16px; font-weight: 600; color: var(--text);
  font-variant-numeric: tabular-nums;
}
.aj-input:disabled { cursor: not-allowed; }
.aj-unit {
  display: flex; align-items: center;
  padding: 0 12px 0 2px; min-width: 70px;
  font-size: 12.5px; color: var(--muted); white-space: nowrap;
}


/* campo calculado (meta diária): mesmo visual, mas travado */
.aj-field.is-readonly .aj-step { cursor: not-allowed; opacity: .45; }
.aj-field.is-readonly .aj-input { cursor: default; width: 92px; }   /* cabe "1h10min" */
.aj-field.is-readonly:focus-within { border-color: var(--border); box-shadow: none; }

/* ---------- Chave liga/desliga ---------- */
.aj-switch { position: relative; display: inline-flex; cursor: pointer; flex: 0 0 auto; }
.aj-switch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.aj-track {
  position: relative; width: 46px; height: 26px; border-radius: 999px;
  background: #c7cfdb;
  transition: background .2s ease;
}
.aj-thumb {
  position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15,23,42,.35);
  transition: transform .22s cubic-bezier(.3,1.3,.5,1);
}
.aj-switch input:checked + .aj-track { background: var(--primary); }
.aj-switch input:checked + .aj-track .aj-thumb { transform: translateX(20px); }
.aj-switch--ok input:checked + .aj-track { background: var(--success); }
.aj-switch input:active:not(:disabled) + .aj-track .aj-thumb { width: 24px; }
.aj-switch input:checked:active:not(:disabled) + .aj-track .aj-thumb { transform: translateX(16px); }
.aj-switch input:focus-visible + .aj-track { outline: 2px solid var(--primary); outline-offset: 2px; }
.aj-switch input:disabled { cursor: not-allowed; }
.aj-switch input:disabled + .aj-track { opacity: .55; }

/* ---------- Barra de salvar ---------- */
.aj-bar {
  position: sticky; bottom: 14px; z-index: 5;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 20px;
  margin-top: 26px; padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(15,23,42,.16), 0 2px 6px rgba(15,23,42,.06);
  animation: aj-bar-in .26s cubic-bezier(.2,.9,.3,1) both;
}
.aj-bar[hidden] { display: none; }
@keyframes aj-bar-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.aj-bar-info { min-width: 0; }
.aj-bar-info strong { font-size: 14px; color: var(--text); }
.aj-bar-list { margin: 6px 0 0; padding-left: 17px; font-size: 12.5px; line-height: 1.6; color: var(--muted); }
.aj-bar-actions { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
/* Descartar e Salvar com o mesmo tamanho (só muda a cor) */
.aj-bar-actions > button {
  display: inline-flex; align-items: center; justify-content: center;
  box-sizing: border-box;
  height: 40px; min-width: 160px; padding: 0 18px; margin: 0;
  border-radius: 12px;
  font: inherit; font-size: 14px; font-weight: 600; line-height: 1;
  white-space: nowrap;
}
.aj-save:disabled { opacity: .5; cursor: not-allowed; filter: none; box-shadow: none; }

/* ---------- Estados ---------- */
.aj-state { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; padding: 40px 12px; color: var(--muted); font-size: 14px; }
.aj-state-error { color: var(--danger); }
.aj-readonly-note {
  margin: 0; padding: 10px 14px;
  border: 1px solid var(--border); border-radius: 10px;
  font-size: 13px; color: var(--muted); background: var(--bg);
}

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
  .aj-row { flex-direction: column; align-items: stretch; gap: 14px; }
  .aj-row::before { left: -10px; }
  .aj-text { flex: 0 0 auto; }
  .aj-ctrl { justify-content: space-between; min-width: 0; width: 100%; }
  .aj-field { flex: 1 1 0; min-width: 0; }
  .aj-input { flex: 1 1 0; width: auto; min-width: 0; }
  .aj-unit { min-width: 0; padding-right: 10px; }
  /* Linha só com chave (ex.: Pontuação automática): chave continua à direita do texto */
  .aj-row.aj-row--switch { flex-direction: row; align-items: flex-start; gap: 16px; }
  .aj-row--switch .aj-text { flex: 1 1 auto; }
  .aj-row--switch .aj-ctrl { width: auto; flex: 0 0 auto; padding-top: 2px; }
  .aj-bar { flex-direction: column; align-items: stretch; bottom: 10px; }
  .aj-bar-actions { justify-content: flex-end; }
  .aj-bar-actions > button { flex: 1 1 0; min-width: 0; }
}
@media (max-width: 380px) {
  .aj-bar-actions > button { padding: 0 10px; font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  .aj-row::before, .aj-thumb, .aj-track, .aj-bar { transition: none; animation: none; }
}

/* Cabeçalho do grupo: título + "?" (a explicação do grupo fica no balão) */
.aj-group-head { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; }
.aj-group-head .aj-group-title { margin: 0; }
.aj-title-text { display: inline-flex; align-items: center; gap: 7px; }
