/* Look1M — Armário do Marcos
   Só o que o Tailwind não cobre. Estética: neutra, sóbria, muita foto, pouco texto.

   As classes aqui são as que js/ui.js REALMENTE emite e as que index.html usa.
   Se for renomear classe num dos dois lados, renomeie no outro — este arquivo e o
   ui.js já divergiram uma vez e o app inteiro renderizou sem estilo. */

:root {
  --bg:        #F4F2EE;
  --bg-soft:   #EAE7E1;
  --card:      #FFFFFF;
  --ink:       #1A1917;
  --ink-2:     #45423C;
  --ink-3:     #78746C;
  --ink-4:     #A8A399;
  --line:      rgba(26,25,23,0.12);
  --line-soft: rgba(26,25,23,0.07);
  --scrim:     rgba(0,0,0,0.55);
  --perigo:    #A3372B;
  --ok:        #2F6B45;
  --r-card: 14px;
  --r-btn:  10px;
  --ui-font: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --nav-h: calc(58px + env(safe-area-inset-bottom, 0px));
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #121210;
    --bg-soft:   #1D1C19;
    --card:      #1A1917;
    --ink:       #EDEBE6;
    --ink-2:     #C4C0B8;
    --ink-3:     #8C877E;
    --ink-4:     #625E57;
    --line:      rgba(237,235,230,0.14);
    --line-soft: rgba(237,235,230,0.08);
    --scrim:     rgba(0,0,0,0.62);
    --perigo:    #E0806F;
    --ok:        #7FBE97;
  }
}

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--ui-font);
  -webkit-font-smoothing: antialiased;
}
body {
  padding-bottom: calc(var(--nav-h) + 12px);  /* bottom tab bar não cobre conteúdo */
  overscroll-behavior-y: contain;
}

/* ---------- Header ---------- */
header {
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(18px) saturate(160%);
  border-bottom: 1px solid var(--line-soft);
  padding-top: env(safe-area-inset-top, 0px);
}
header h1 { color: var(--ink); letter-spacing: -0.01em; }
#auth-status { color: var(--ink-3); }

/* Headers internos de tela (.look-topo, .armario-topo...) não são a barra do app:
   herdam do <header> global, então zeram o vidro e a borda. */
.tela header {
  background: none;
  backdrop-filter: none;
  border-bottom: 0;
  padding-top: 0;
}

/* ---------- Telas ---------- */
.tela { padding: 1rem 1.15rem 1.5rem; }
.tela.hidden { display: none; }
.tela h1 { font-size: 20px; font-weight: 650; letter-spacing: -0.02em; }

/* ---------- Bottom tab bar ---------- */
nav.fixed {
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(20px) saturate(160%);
  border-top: 1px solid var(--line-soft);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 2px 8px;
  min-height: 46px;
  font-size: 10px;
  font-weight: 500;
  font-family: var(--ui-font);
  color: var(--ink-4);
  background: none;
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.tab-btn.tab-ativo { color: var(--ink); }
.tab-btn:active { opacity: 0.6; }

/* ---------- Modais ----------
   Sem listener de clique no backdrop: fecha só no X e no ESC (ver index.html). */
.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0,0,0,0.5);
  animation: fadein 0.15s ease;
}
.modal.hidden { display: none; }
@media (min-width: 640px) { .modal { align-items: center; } }

.modal-caixa {
  background: var(--card);
  color: var(--ink);
  width: 100%;
  max-width: 28rem;
  max-height: 92vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  border-radius: 20px 20px 0 0;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (min-width: 640px) { .modal-caixa { border-radius: 20px; } }

.modal-topo {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--card);
  border-bottom: 1px solid var(--line-soft);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-topo h2 { font-size: 15px; font-weight: 600; }
.modal-x {
  font-size: 26px;
  line-height: 1;
  width: 36px;
  height: 36px;
  margin: -6px -8px -6px 0;
  color: var(--ink-4);
  background: none;
  border: 0;
  cursor: pointer;
}
.modal-x:hover { color: var(--ink-2); }
.modal-nota { font-size: 12px; color: var(--ink-3); line-height: 1.45; margin: 12px 0; }

@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Peça: foto ou placeholder ----------
   Marcação de js/ui.js (celulaFoto):
     <div class="peca-foto" style="background:#A8C8E8">
       <img data-foto-key="..." style="display:none">     <- só se houver foto
     </div>

   A cor sólida vem INLINE do cor_hex (spec §9: peça sem foto não quebra o layout),
   por isso nada de `background` aqui. Quem nomeia a peça é a legenda de fora
   (.opcao-peca figcaption / .peca-info) — o quadrado é só a cor.
   Quando o blob chega, o ui.js põe o <img> em display:block e ele cobre o quadrado. */
.peca-foto {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: var(--r-card);
  border: 1px solid var(--line);   /* peça branca não some no fundo claro */
  overflow: hidden;
}
.peca-foto img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
/* No modal da peça: foto grande, sangrando até a borda do modal. */
.peca-foto-grande { aspect-ratio: 4 / 3; border-radius: 0; border: 0; border-bottom: 1px solid var(--line-soft); }

/* ---------- Tela 1 — Look ---------- */
.look-topo { margin-bottom: 1.1rem; }
.look-data { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.look-data h1 { text-transform: capitalize; }
.look-rel {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
}
.look-clima { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 7px; font-size: 13px; color: var(--ink-2); }
.look-clima span { white-space: nowrap; }
.look-nota { margin-top: 8px; font-size: 12.5px; color: var(--ink-3); line-height: 1.45; }

.look-opcoes { display: flex; flex-direction: column; gap: 1rem; }  /* empilhado no mobile */

.opcao {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 13px 13px 15px;
}
.opcao-escolhida { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.opcao-cab { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.opcao-n { font-size: 10px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); }
.opcao-tag {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--ink);
  color: var(--bg);
  border-radius: 999px;
  padding: 3px 8px;
}
/* auto-fit: a opção tem de 3 a 5 peças (sobreposição e cinto são opcionais) — largura
   fixa deixaria buraco quando vierem só 3. */
.opcao-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
  gap: 9px;
}
.opcao-peca { margin: 0; min-width: 0; }
.opcao-peca figcaption { margin-top: 5px; display: flex; flex-direction: column; gap: 1px; }
.opcao-peca-nome {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.opcao-peca-cor {
  font-size: 10.5px;
  color: var(--ink-3);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.opcao-just { margin: 11px 0 13px; font-size: 13px; line-height: 1.5; color: var(--ink-2); }
.opcao > button { width: 100%; }

.look-rodape { display: flex; align-items: center; justify-content: space-between; margin-top: 1rem; }
.look-origem { font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-4); }

/* ---------- Tela 2 — Armário ---------- */
.armario-topo { margin-bottom: 1.1rem; }

.progresso-fotos { margin-top: 10px; }
.progresso-txt { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--ink-3); margin-bottom: 5px; }
.progresso-barra { height: 4px; border-radius: 999px; background: var(--bg-soft); overflow: hidden; }
.progresso-fill { height: 100%; background: var(--ink); border-radius: 999px; transition: width 0.3s ease; }

.filtros { display: flex; gap: 7px; margin-top: 12px; overflow-x: auto; padding-bottom: 2px; -webkit-overflow-scrolling: touch; }
.filtros::-webkit-scrollbar { display: none; }
.filtro-cat {
  flex: 0 0 auto;
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-2);
  font-family: var(--ui-font);
  font-size: 12.5px;
  min-height: 34px;
  cursor: pointer;
}
.chip {
  flex: 0 0 auto;
  padding: 7px 13px;
  min-height: 34px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 500;
  font-family: var(--ui-font);
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-2);
  white-space: nowrap;
  cursor: pointer;
}
.chip-on { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.armario-grupo { margin-bottom: 1.4rem; }
.grupo-titulo {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 9px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.grupo-n { color: var(--ink-4); letter-spacing: 0; }
.armario-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
}

/* .peca-card é um <button>: zera a aparência nativa e alinha o texto à esquerda. */
.peca-card {
  display: block;
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  font-family: var(--ui-font);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.peca-card:active { opacity: 0.85; }
.peca-info { display: flex; flex-direction: column; gap: 1px; margin-top: 5px; }
.peca-nome {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.peca-cor { font-size: 10.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.peca-uso { font-size: 10px; color: var(--ink-4); }
.peca-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.peca-badges:empty { display: none; }

.badge {
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--ink-3);
  white-space: nowrap;
}
.badge-viola { border-color: color-mix(in srgb, var(--perigo) 45%, transparent); color: var(--perigo); }
.badge-ressalva { border-color: var(--line); color: var(--ink-3); }
.badge-id { border-style: dashed; color: var(--ink-4); }

/* ---------- Modal da peça ---------- */
.peca-detalhe {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  padding: 12px 16px 0;
  font-size: 12px;
  color: var(--ink-3);
}
.peca-detalhe span:not(:last-child)::after { content: ' ·'; color: var(--ink-4); }
.form-peca { padding: 14px 16px 0; }
.form-peca > button { width: 100%; margin-top: 4px; }
.peca-acoes { display: flex; flex-direction: column; gap: 8px; padding: 12px 16px 18px; }

/* ---------- Formulários ----------
   .campo é o <label> que ENVOLVE o span do rótulo + o controle (ver ui.js campoTexto).
   Quem recebe padding/altura é o controle de dentro, não o wrapper. */
.campo { display: block; margin-bottom: 11px; }
.campo-label { display: block; font-size: 11px; font-weight: 500; color: var(--ink-3); margin-bottom: 4px; }
.campo input,
.campo select,
.campo textarea,
.fila-campos input,
.fila-campos select {
  width: 100%;
  min-height: 44px;              /* alvo de toque */
  padding: 11px 12px;
  background: var(--bg-soft);
  color: var(--ink);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-btn);
  font-family: var(--ui-font);
  font-size: 16px;               /* 16px evita o zoom automático do iOS no focus */
}
.campo input:focus,
.campo select:focus,
.campo textarea:focus,
.fila-campos input:focus,
.fila-campos select:focus {
  outline: 2px solid var(--ink-3);
  outline-offset: 1px;
}
.campo input[type="color"] { padding: 4px; height: 44px; cursor: pointer; }

/* Checkbox: o wrapper vira linha e o input volta ao tamanho natural — as regras acima
   deixariam a caixinha com 100% de largura e 44px de altura. */
.campo-check { display: flex; align-items: center; gap: 9px; }
.campo-check input[type="checkbox"] {
  width: 20px;
  height: 20px;
  min-height: 0;
  flex: 0 0 auto;
  padding: 0;
  accent-color: var(--ink);
}
.campo-check span { font-size: 13.5px; color: var(--ink-2); }

/* ---------- Auth ---------- */
.form-auth { padding: 14px 16px 0; }
.form-auth > button { width: 100%; margin-top: 4px; }
.auth-erro {
  margin: 2px 0 10px;
  font-size: 12.5px;
  color: var(--perigo);
  line-height: 1.4;
}
.auth-erro.hidden { display: none; }
.auth-ou {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 16px 12px;
  color: var(--ink-4);
  font-size: 11px;
}
.auth-ou::before, .auth-ou::after { content: ''; flex: 1; height: 1px; background: var(--line-soft); }
.google-btn { display: flex; justify-content: center; min-height: 44px; padding: 0 16px; }
.form-auth + .auth-ou + .google-btn + .btn-texto,
.modal-caixa > .btn-texto { width: calc(100% - 32px); margin: 8px 16px 18px; }

.conta-box { padding: 16px 16px 0; }
.conta-label { font-size: 10px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); }
.conta-user { font-size: 16px; font-weight: 600; margin-top: 3px; word-break: break-all; }
.conta-email { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; word-break: break-all; }
.conta-aviso { margin-top: 9px; font-size: 12px; color: var(--perigo); line-height: 1.4; }
.conta-box + .modal-nota { padding: 0 16px; }
.conta-box ~ button { width: calc(100% - 32px); margin: 0 16px 8px; }
.conta-box ~ button:last-child { margin-bottom: 18px; }

/* ---------- Tela de bloqueio ---------- */
#tela-bloqueio { display: flex; align-items: center; justify-content: center; min-height: 60vh; }
#tela-bloqueio.hidden { display: none; }
.bloqueio-box { text-align: center; max-width: 20rem; }
.bloqueio-titulo { font-size: 19px; font-weight: 650; letter-spacing: -0.02em; }
.bloqueio-msg { margin-top: 8px; font-size: 13.5px; color: var(--ink-3); line-height: 1.5; }
.bloqueio-acoes { display: flex; flex-direction: column; gap: 8px; margin-top: 20px; }
.bloqueio-versao { margin-top: 22px; font-size: 10.5px; color: var(--ink-4); }

/* ---------- Tela 3 — Cadastro ---------- */
.cadastro-topo { margin-bottom: 1.1rem; display: flex; flex-direction: column; gap: 8px; }
.cadastro-topo h1 { margin-bottom: 2px; }
.cadastro-nota { font-size: 12.5px; color: var(--ink-3); line-height: 1.45; margin-bottom: 4px; }

.fila { display: flex; flex-direction: column; gap: 10px; }
.fila-item {
  display: flex;
  gap: 11px;
  padding: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
}
.fila-item-ok { opacity: 0.6; border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.fila-thumb {
  width: 74px;
  height: 74px;
  flex: 0 0 auto;
  object-fit: cover;
  border-radius: var(--r-btn);
  background: var(--bg-soft);
}
.fila-campos { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.fila-campos input, .fila-campos select { min-height: 38px; padding: 8px 10px; font-size: 16px; }
.fila-rodape { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 24px; }
.fila-ok { font-size: 11px; font-weight: 600; color: var(--ok); }
.fila-enviando { font-size: 11px; color: var(--ink-3); }
.fila-erro { font-size: 11px; color: var(--perigo); line-height: 1.35; }
.fila-acoes { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }

/* ---------- Estados ---------- */
.estado-vazio { color: var(--ink-3); font-size: 13.5px; line-height: 1.5; text-align: center; padding: 2.5rem 1rem; }
.estado-vazio p + p { margin-top: 6px; font-size: 12.5px; color: var(--ink-4); }
.estado-erro { color: var(--perigo); font-size: 13.5px; line-height: 1.5; margin-bottom: 12px; }

/* ---------- Botões ---------- */
.btn-primario, .btn-secundario, .btn-perigo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;              /* alvo de toque: ele usa o app com uma mão */
  padding: 0 18px;
  border-radius: var(--r-btn);
  font-family: var(--ui-font);
  font-size: 14px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn-primario { background: var(--ink); color: var(--bg); border: 0; font-weight: 600; }
.btn-primario:active { opacity: 0.85; }
.btn-secundario { background: transparent; color: var(--ink); border: 1px solid var(--line); font-weight: 500; }
.btn-secundario:active { background: var(--bg-soft); }
.btn-perigo { background: transparent; color: var(--perigo); border: 1px solid color-mix(in srgb, var(--perigo) 40%, transparent); font-weight: 500; }
.btn-perigo:active { background: color-mix(in srgb, var(--perigo) 10%, transparent); }
.btn-primario:disabled, .btn-secundario:disabled, .btn-perigo:disabled, .btn-texto:disabled {
  opacity: 0.45;
  cursor: default;
}

.btn-texto {
  background: none;
  border: 0;
  padding: 10px 4px;
  min-height: 40px;
  color: var(--ink-3);
  font-family: var(--ui-font);
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.btn-texto:active { color: var(--ink); }

/* <label> com <input type=file> escondido dentro: precisa parecer e medir como botão
   (o input nativo de arquivo não é estilizável). */
.btn-arquivo { position: relative; width: 100%; }

/* ---------- Toast ---------- */
#toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--nav-h) + 16px);
  z-index: 40;
  max-width: calc(100vw - 2rem);
  background: var(--ink);
  color: var(--bg);
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 13px;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0,0,0,0.22);
}
#toast.hidden { display: none; }
