/* Selfie redesenhada (selfie-client-v1.js): status primeiro, estoque em seguida,
   fotos recolhidas. Cores pelos tokens --fx-* (temas claro e escuro). */

.selfie-page.sfx-on > :is(.selfie-toolbar, .live-status-panel),
.selfie-page.sfx-on .selfie-hero-stats,
.selfie-page.sfx-on .selfie-stock-panel > :is(.selfie-panel-head, .selfie-alert, .selfie-reference-card) {
  display: none !important;
}

/* Fotos: só aparecem quando a pessoa abre. */
.selfie-page.sfx-on:not(.sfx-photos-open) .selfie-stock-panel > .selfie-grid {
  display: none !important;
}

.selfie-page.sfx-on:not(.sfx-photos-open) .selfie-stock-panel:not(:has(> .selfie-history-strip)) {
  display: none !important;
}

.sfx-root {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 18px;
  color: var(--fx-text);
}

.sfx-root svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sfx-root button {
  font: inherit;
  cursor: pointer;
}

.sfx-root button:focus-visible {
  outline: 2px solid var(--fx-accent);
  outline-offset: 2px;
}

/* ── Ações do topo ── */
.sfx-bar {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: -6px;
}

.sfx-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--fx-line-2);
  background: var(--fx-surface);
  color: var(--fx-text);
  font-size: 13px !important;
  font-weight: 600 !important;
  white-space: nowrap;
}

.sfx-btn svg {
  width: 16px;
  height: 16px;
}

.sfx-btn:hover:not(:disabled) {
  border-color: var(--fx-line-3);
  background: var(--fx-surface-2);
}

.sfx-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

.sfx-btn.sfx-primary {
  border-color: var(--fx-btn-ring, var(--fx-accent));
  background: var(--fx-btn, var(--fx-accent));
  color: #ffffff;
}

.sfx-btn.sfx-primary:hover:not(:disabled) {
  filter: brightness(1.08);
  background: var(--fx-btn, var(--fx-accent));
}

/* ── Cartões ── */
.sfx-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.sfx-card {
  --sfx-tone: var(--fx-faint);
  --sfx-soft: var(--fx-surface-3);
  --sfx-text: var(--fx-text);
  position: relative;
  padding: 20px 22px 18px;
  border-radius: 18px;
  border: 1px solid var(--fx-line);
  background: var(--fx-surface);
  box-shadow: var(--fx-hair);
  overflow: hidden;
}

html[data-af-theme=light] .sfx-card {
  box-shadow: var(--fx-lift);
}

.sfx-tone-ok { --sfx-tone: var(--fx-ok); --sfx-soft: var(--fx-ok-soft); --sfx-text: var(--fx-ok-text); }
.sfx-tone-warn { --sfx-tone: var(--fx-warn); --sfx-soft: var(--fx-warn-soft); --sfx-text: var(--fx-warn-text); }
.sfx-tone-crit { --sfx-tone: var(--fx-crit); --sfx-soft: var(--fx-crit-soft); --sfx-text: var(--fx-crit-text); }

/* Faixa de cor no topo do cartão de status: o estado se lê de longe. */
.sfx-status::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: var(--sfx-tone);
  opacity: 0.85;
}

.sfx-tone-idle.sfx-status::before {
  opacity: 0.35;
}

.sfx-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.sfx-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--sfx-soft);
  color: var(--sfx-tone);
}

.sfx-icon svg {
  width: 18px;
  height: 18px;
}

.sfx-kicker {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--fx-faint);
}

.sfx-label {
  display: block;
  font-size: clamp(24px, 2.4vw, 30px);
  font-weight: 300;
  line-height: 1.15;
  color: var(--sfx-text);
}

.sfx-tone-idle .sfx-label {
  color: var(--fx-text);
}

.sfx-detail {
  margin: 6px 0 0;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--fx-muted);
}

.sfx-facts {
  display: grid;
  margin: 16px 0 0;
  border-top: 1px solid var(--fx-line);
}

.sfx-fact {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 12px;
  align-items: baseline;
  padding: 10px 0;
  border-bottom: 1px solid var(--fx-line);
}

.sfx-fact:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.sfx-fact dt {
  font-size: 12px;
  color: var(--fx-faint);
}

.sfx-fact dd {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 8px;
  margin: 0;
  min-width: 0;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.45;
  color: var(--fx-text);
  overflow-wrap: break-word;
}

.sfx-fact dd svg {
  flex: none;
  width: 15px;
  height: 15px;
  align-self: center;
}

.sfx-fact dd span {
  min-width: 0;
  flex: 1 1 auto;
}

.sfx-fact-ok dd { color: var(--fx-ok-text); }
.sfx-fact-crit dd { color: var(--fx-crit-text); }

.sfx-pill {
  display: inline-flex;
  align-items: center;
  flex: none;
  padding: 3px 10px;
  border-radius: 999px;
  font-style: normal;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--fx-surface-3);
  color: var(--fx-muted);
}

.sfx-pill-ok { background: var(--fx-ok-soft); color: var(--fx-ok-text); }
.sfx-pill-warn { background: var(--fx-warn-soft); color: var(--fx-warn-text); }
.sfx-pill-crit { background: var(--fx-crit-soft); color: var(--fx-crit-text); }

/* ── Estoque ── */
.sfx-stock .sfx-card-head {
  justify-content: space-between;
}

.sfx-stock-body {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 22px;
}

.sfx-ref {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.sfx-ref img {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--fx-surface);
  box-shadow: 0 0 0 2px var(--fx-accent-line);
  background: var(--fx-surface-3);
}

.sfx-ref figcaption {
  font-size: 11px;
  color: var(--fx-faint);
  text-align: center;
  max-width: 96px;
}

.sfx-stock-main {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.sfx-count {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.sfx-count strong {
  font-size: 40px;
  font-weight: 200;
  line-height: 1;
  color: var(--fx-text);
}

.sfx-count span {
  font-size: 14px;
  color: var(--fx-muted);
}

.sfx-empty {
  margin: 0;
  font-size: 13.5px;
  color: var(--fx-muted);
}

.sfx-meter {
  height: 6px;
  border-radius: 999px;
  background: var(--fx-surface-3);
  overflow: hidden;
}

.sfx-meter i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--sfx-tone);
}

.sfx-tone-idle .sfx-meter i {
  background: var(--fx-accent);
}

.sfx-sub {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  font-size: 12.5px;
  color: var(--fx-faint);
}

.sfx-sub b {
  color: var(--fx-text);
  font-weight: 600;
}

.sfx-alert {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 2px 0 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--fx-warn-soft);
  color: var(--fx-warn-text);
  font-size: 13px;
  line-height: 1.45;
}

.sfx-alert svg {
  flex: none;
  width: 16px;
  height: 16px;
  margin-top: 1px;
}

.sfx-stock-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 170px;
}

/* ── Fotos (recolhidas) ── */
.sfx-photos-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 48px;
  padding: 0 16px 0 18px;
  border-radius: 14px;
  border: 1px solid var(--fx-line);
  background: var(--fx-surface);
  color: var(--fx-text);
  font-size: 14px !important;
  font-weight: 500 !important;
  text-align: left;
}

.sfx-photos-toggle:hover {
  border-color: var(--fx-line-3);
}

.sfx-photos-toggle b {
  min-width: 24px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--fx-surface-3);
  color: var(--fx-muted);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}

.sfx-photos-toggle em {
  margin-left: auto;
  font-style: normal;
  font-size: 12.5px;
  color: var(--fx-faint);
}

.sfx-photos-toggle svg {
  width: 16px;
  height: 16px;
  color: var(--fx-faint);
  transition: transform 0.2s ease;
}

.sfx-photos-toggle[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

/* Painel original das fotos: sem caixa, grade compacta. */
.selfie-page.sfx-on .selfie-stock-panel {
  margin-top: 10px !important;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

.selfie-page.sfx-on .selfie-stock-panel > .selfie-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)) !important;
  gap: 10px !important;
  margin-top: 0 !important;
}

.selfie-page.sfx-on .selfie-card {
  padding: 8px !important;
  border-radius: 14px !important;
}

.selfie-page.sfx-on .selfie-card .selfie-thumb-wrap {
  aspect-ratio: 1 / 1;
  border-radius: 10px !important;
  overflow: hidden;
}

.selfie-page.sfx-on .selfie-card .selfie-info {
  gap: 3px !important;
  padding: 8px 2px 2px !important;
  font-size: 11.5px !important;
}

/* Upload manual: linha discreta no fim. */
.selfie-page.sfx-on .selfie-action-grid.emergency {
  margin-top: 14px !important;
}

.selfie-page.sfx-on .selfie-action-box {
  padding: 16px 18px !important;
  border-radius: 16px !important;
  border: 1px dashed var(--fx-line-2) !important;
  background: transparent !important;
  box-shadow: none !important;
}

/* ── Celular ── */
@media (max-width: 900px) {
  .sfx-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  .sfx-root {
    gap: 12px;
    margin-top: 14px;
  }

  .sfx-bar {
    margin-top: 0;
  }

  .sfx-bar .sfx-btn {
    flex: 1;
  }

  .sfx-card {
    padding: 18px 16px 16px;
  }

  .sfx-fact {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
  }

  .sfx-stock-body {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 16px;
  }

  .sfx-ref img {
    width: 60px;
    height: 60px;
  }

  .sfx-stock-actions {
    grid-column: 1 / -1;
    flex-direction: row;
    min-width: 0;
  }

  .sfx-stock-actions .sfx-btn {
    flex: 1;
  }

  .selfie-page.sfx-on .selfie-stock-panel > .selfie-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sfx-photos-toggle svg {
    transition: none;
  }
}

/* Computador: as ações ficam à direita do título, onde ficavam os números. */
@media (min-width: 641px) {
  .selfie-page.sfx-on {
    position: relative;
  }

  .selfie-page.sfx-on .sfx-bar {
    position: absolute;
    top: 38px;
    right: 0;
    margin: 0;
  }

  .selfie-page.sfx-on .selfie-hero {
    padding-right: 340px !important;
  }
}

.selfie-page.sfx-on .selfie-action-box .section-title {
  margin-top: 0 !important;
}

.selfie-page.sfx-on .selfie-action-box > div:first-child {
  display: grid;
  gap: 6px;
}

.selfie-page.sfx-on .selfie-action-box p {
  margin: 0 !important;
}

/* Bloco atual e janela de check-in: uma faixa acima dos dois status. */
.sfx-block {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 28px;
  padding: 14px 18px;
  border-radius: 14px;
  border: 1px solid var(--fx-line);
  background: var(--fx-surface-2);
}

.sfx-block > div {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  min-width: 0;
}

.sfx-block span {
  font-size: 12px;
  color: var(--fx-faint);
}

.sfx-block strong {
  font-size: 14px;
  font-weight: 600;
  color: var(--fx-text);
}

/* O título da tela não é um cartão aqui (no claro ele ganhava fundo). */
.shell .main .selfie-page.sfx-on .selfie-hero {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  padding-left: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}

.selfie-page.sfx-on .sfx-status .sfx-facts:empty {
  display: none;
}

/* Último retorno do envio (sucesso ou erro, com o texto que o servidor mandou). */
.sfx-reply {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--fx-surface-3);
  color: var(--fx-text);
}

.sfx-reply > svg {
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 1px;
}

.sfx-reply span {
  display: block;
  font-size: 11.5px;
  font-weight: 500;
  opacity: 0.8;
}

.sfx-reply p {
  margin: 3px 0 0;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.45;
  overflow-wrap: break-word;
}

.sfx-reply-ok { background: var(--fx-ok-soft); color: var(--fx-ok-text); }
.sfx-reply-crit { background: var(--fx-crit-soft); color: var(--fx-crit-text); }

.sfx-root :is(.sfx-reply, .sfx-alert) p {
  color: inherit !important;
}
