/* Tema Mercado Livre — topo amarelo, ação azul, cards brancos com sombra suave.
   Navegação em pilha (home/voltar), sem tab bar: cada tela de lista leva a um
   nível de detalhe, e o detalhe pode levar a outra lista (anúncio → perguntas →
   pergunta; comprador → produto → perguntas → pergunta). */
:root {
  --ml-yellow: #ffe600;
  --ml-yellow-dark: #ffd100;
  --ml-blue: #3483fa;
  --ml-blue-dark: #2968c8;
  --ml-blue-tint: #e3edfd;
  --ml-green: #00a650;
  --ml-green-tint: #e6f6ed;
  --ml-red: #f23d4f;
  --ml-red-tint: #fce8ea;
  --ml-orange: #ff7733;
  --ml-orange-tint: #ffeee3;
  --text-primary: #2b2b2b;
  --text-secondary: #666666;
  --text-tertiary: #999999;
  --bg-page: #eef0f3;
  --bg-card: #ffffff;
  --border-subtle: #e6e6e6;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-card: 0 1px 3px rgba(20, 20, 30, 0.07), 0 1px 1px rgba(20, 20, 30, 0.04);
  --shadow-elevated: 0 6px 20px rgba(20, 20, 30, 0.10);
  --topbar-h: 56px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; min-height: 100%;
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg-page);
  color: var(--text-primary);
}

.hidden { display: none !important; }

/* ---- Login ---- */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-elevated);
  padding: 28px;
  width: 100%;
  max-width: 280px;
  text-align: center;
}
.login-card h1 { font-size: 16px; margin: 0 0 16px; }
.login-card input {
  width: 100%;
  padding: 11px;
  margin-bottom: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid #cccccc;
  font-size: 15px;
}
.login-card button {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--ml-blue);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}
.login-card .error { color: var(--ml-red); font-size: 13px; min-height: 1.2em; margin: 8px 0 0; }

/* ---- App shell ---- */
.app-shell { display: flex; }
.main-col { min-width: 0; flex: 1; }

/* ---- Top App Bar ---- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  height: var(--topbar-h);
  background: linear-gradient(180deg, var(--ml-yellow) 0%, var(--ml-yellow-dark) 100%);
  display: flex; align-items: center; gap: 8px;
  padding: 0 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}
.topbar .page-title { font-size: 16px; font-weight: 700; }
.topbar-logo { width: 24px; height: 24px; border-radius: 6px; object-fit: cover; }
.topbar .spacer { flex: 1; }
.icon-btn, .link-btn {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.08); border: none; color: var(--text-primary); padding: 0; cursor: pointer;
  transition: background 0.15s;
}
.icon-btn:active, .link-btn:active { background: rgba(0, 0, 0, 0.16); }

/* ---- Conteúdo ---- */
.content { padding: 14px 14px 32px 14px; max-width: 640px; margin: 0 auto; }
.page-subtitle { font-size: 12px; color: var(--text-secondary); margin: 2px 0 14px 2px; }
.card { background: var(--bg-card); border-radius: var(--radius-md); box-shadow: var(--shadow-card); margin-bottom: 12px; overflow: hidden; }
.section-label { font-size: 11px; font-weight: 700; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.5px; margin: 4px 2px 8px 2px; }

/* ---- Home: toolbar de ações utilitárias ---- */
.home-toolbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 2px; flex-wrap: wrap; }
.home-toolbar .page-subtitle { margin-bottom: 0; }
.home-actions { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; justify-content: flex-end; }
.icon-action {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: 100px;
  padding: 8px 14px 8px 10px; font-size: 12.5px; font-weight: 700; color: var(--text-primary);
  cursor: pointer; box-shadow: var(--shadow-card); transition: transform 0.12s, box-shadow 0.12s;
}
.icon-action:active { transform: scale(0.97); }
.icon-action-emoji { font-size: 16px; line-height: 1; }

/* ---- Anúncios ---- */
.anuncio-item { display: flex; gap: 12px; padding: 13px; border-bottom: 1px solid var(--border-subtle); cursor: pointer; transition: background 0.15s; }
.anuncio-item:last-child { border-bottom: none; }
.anuncio-item:active { background: #f7f9fc; }
.anuncio-thumb-img {
  width: 56px; height: 56px; border-radius: var(--radius-sm);
  object-fit: cover; flex-shrink: 0; background: #f5f5f5;
}
.anuncio-thumb {
  width: 56px; height: 56px; border-radius: var(--radius-sm);
  background: #f5f5f5; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: var(--text-tertiary);
}
.anuncio-info { flex: 1; min-width: 0; }
.anuncio-titulo { font-size: 13.5px; font-weight: 600; line-height: 1.3; margin-bottom: 4px; }
.anuncio-preco { font-size: 15px; font-weight: 700; }
.anuncio-meta { font-size: 11.5px; color: var(--text-secondary); margin-top: 3px; }
.anuncio-indicadores { display: flex; flex-direction: column; align-items: flex-end; justify-content: center; gap: 6px; }
.anuncio-alerta-pergunta { font-size: 14px; line-height: 1; }

.badge { display: inline-flex; align-items: center; gap: 3px; font-size: 10.5px; font-weight: 700; padding: 3px 8px; border-radius: 100px; }
.badge-green { background: var(--ml-green-tint); color: var(--ml-green); }
.badge-orange { background: var(--ml-orange-tint); color: var(--ml-orange); }
.badge-red { background: var(--ml-red-tint); color: var(--ml-red); }
.badge-gray { background: #efefef; color: var(--text-secondary); }
.badge-blue { background: var(--ml-blue-tint); color: var(--ml-blue); }

/* ---- Acessos (cards de navegação — perguntas não respondidas/respondidas) ---- */
.acesso-lista { display: flex; flex-direction: column; gap: 10px; }
.acesso-card {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: var(--bg-card); border: none; border-radius: var(--radius-md);
  box-shadow: var(--shadow-card); padding: 14px; cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s; text-align: left;
}
.acesso-card:active { transform: scale(0.98); }
.acesso-icone {
  width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0; font-size: 19px;
  display: flex; align-items: center; justify-content: center;
}
.acesso-icone-pendente { background: var(--ml-orange-tint); }
.acesso-icone-ok { background: var(--ml-green-tint); }
.acesso-corpo { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.acesso-titulo { font-size: 14px; font-weight: 700; }
.acesso-sub { font-size: 12px; color: var(--text-secondary); }
.acesso-chevron { color: var(--text-tertiary); font-size: 22px; flex-shrink: 0; line-height: 1; }

/* ---- Lista de perguntas (genérica) ---- */
.pergunta-item { display: flex; align-items: flex-start; gap: 12px; padding: 13px; border-bottom: 1px solid var(--border-subtle); cursor: pointer; transition: background 0.15s; }
.pergunta-item:last-child { border-bottom: none; }
.pergunta-item:active { background: #f7f9fc; }
.pergunta-item-icone {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
}
.pergunta-item-info { flex: 1; min-width: 0; }
.pergunta-item-nick { font-size: 12.5px; font-weight: 700; margin-bottom: 3px; }
.pergunta-item-texto { font-size: 13px; line-height: 1.4; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.pergunta-item-meta { font-size: 11px; color: var(--text-tertiary); margin-top: 5px; }
.pergunta-item-chevron { color: var(--text-tertiary); font-size: 20px; flex-shrink: 0; line-height: 1; margin-top: 6px; }

.drill-item { display: flex; align-items: center; gap: 12px; padding: 13px 14px; border-bottom: 1px solid var(--border-subtle); cursor: pointer; transition: background 0.15s; }
.drill-item:last-child { border-bottom: none; }
.drill-item:active { background: #f7f9fc; }
.drill-icon {
  width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0;
  background: var(--ml-blue-tint); color: var(--ml-blue);
  display: flex; align-items: center; justify-content: center; font-size: 19px;
}
.drill-info { flex: 1; min-width: 0; }
.drill-titulo { font-size: 13.5px; font-weight: 700; line-height: 1.3; margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drill-meta { font-size: 11.5px; color: var(--text-secondary); display: flex; align-items: center; gap: 6px; }
.drill-chevron { color: var(--text-tertiary); font-size: 20px; flex-shrink: 0; line-height: 1; }

/* ---- Detalhe de pergunta ---- */
.pergunta-detalhe-card { padding: 16px; }
.pd-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.pd-nick { font-size: 14.5px; font-weight: 700; }
.pd-produto { font-size: 12px; color: var(--text-secondary); margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--border-subtle); }
.pd-texto { font-size: 14px; line-height: 1.55; margin: 2px 0 6px 0; white-space: pre-line; }
.pd-tempo { font-size: 11px; color: var(--text-tertiary); }
.pd-resposta-box { margin-top: 16px; padding: 14px; border-radius: var(--radius-sm); background: var(--ml-green-tint); }
.pd-resposta-label { font-size: 11px; font-weight: 700; color: var(--ml-green); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.pd-resposta-texto { font-size: 13.5px; line-height: 1.55; color: var(--text-primary); white-space: pre-line; margin-bottom: 6px; }

#pd-responder-bloco { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border-subtle); }
#pd-responder-texto {
  width: 100%; font-family: inherit; font-size: 13.5px;
  padding: 12px; border-radius: var(--radius-sm); border: 1px solid #d9d9d9;
  resize: vertical; min-height: 96px; margin-bottom: 10px;
}
#pd-responder-texto:focus { outline: none; border-color: var(--ml-blue); box-shadow: 0 0 0 2px var(--ml-blue-tint); }
.btn-enviar {
  width: 100%;
  background: var(--ml-blue); color: #fff; border: none;
  font-size: 13.5px; font-weight: 700; padding: 12px; border-radius: var(--radius-sm);
  cursor: pointer; min-height: 46px; transition: background 0.15s;
}
.btn-enviar:disabled { opacity: 0.55; cursor: not-allowed; }
.frete-flag { font-size: 10.5px; font-weight: 700; }
.frete-flag.ok { color: var(--ml-orange); }
.frete-flag.ambiguo, .frete-flag.cep_nao_identificado { color: var(--ml-red); }

/* ---- Frete ---- */
.form-section { padding: 14px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 11.5px; font-weight: 700; color: var(--text-secondary); margin-bottom: 4px; }
.field input, .field select {
  width: 100%; font-family: inherit; font-size: 15px;
  padding: 11px 12px; border-radius: var(--radius-sm); border: 1px solid #d9d9d9;
  min-height: 44px; background: #fff;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--ml-blue); box-shadow: 0 0 0 2px var(--ml-blue-tint); }
.field select:disabled { color: var(--text-tertiary); background: #f7f7f7; }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }
.btn-cotar {
  width: 100%; background: var(--ml-blue); color: #fff; border: none;
  font-size: 14px; font-weight: 700; padding: 12px; border-radius: var(--radius-sm);
  cursor: pointer; min-height: 46px;
}
.btn-cotar:disabled { opacity: 0.6; cursor: not-allowed; }

.frete-ordenacao { display: flex; gap: 8px; margin-bottom: 12px; }
.frete-ordenar-btn {
  flex: 1; background: var(--bg-card); border: 1px solid var(--border-subtle); color: var(--text-secondary);
  font-size: 12.5px; font-weight: 700; padding: 9px; border-radius: var(--radius-sm); cursor: pointer;
}
.frete-ordenar-btn.active { background: var(--ml-blue); border-color: var(--ml-blue); color: #fff; }

.banner { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: var(--radius-sm); font-size: 12.5px; margin-bottom: 12px; }
.banner-warning { background: var(--ml-orange-tint); color: #9c4a0f; }
.banner-error { background: var(--ml-red-tint); color: #8a1f2c; }

.frete-opcao { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border-subtle); }
.frete-opcao:last-child { border-bottom: none; }
.carrier-icon {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 800; color: #fff;
}
.carrier-icon-img {
  width: 32px; height: 32px; border-radius: 50%;
  object-fit: cover; flex-shrink: 0; background: #fff;
}
.carrier-melhorEnvio { background: #00c86f; }
.carrier-superFrete { background: #6c3ce9; }
.carrier-frenet { background: #ff6600; }
.frete-opcao-info { flex: 1; }
.frete-opcao-nome { font-size: 13px; font-weight: 700; }
.frete-opcao-servico { font-size: 11.5px; color: var(--text-secondary); }
.frete-opcao-motivo { color: var(--text-tertiary); }

/* ---- Cotar frete a partir de uma pergunta (compacto, dentro do card de detalhe) ---- */
#pd-frete-bloco { margin: 16px 0; padding-top: 16px; border-top: 1px solid var(--border-subtle); }
.frete-form-compacto .field-row { margin-bottom: 10px; }
.frete-form-compacto .field { margin-bottom: 0; }
.frete-form-compacto .field label { font-size: 10.5px; }
.frete-form-compacto .field input { padding: 8px 10px; font-size: 13px; min-height: 36px; }
.frete-form-compacto .btn-cotar { min-height: 40px; font-size: 13px; }
#pd-frete-opcoes .frete-opcao { padding: 10px 0; }
.frete-opcao-valor { text-align: right; }
.frete-opcao-valor .valor { font-size: 14px; font-weight: 700; color: var(--ml-green); }
.frete-opcao-valor .prazo { font-size: 11px; color: var(--text-tertiary); }
.frete-opcao-valor .sem-resposta { font-size: 12px; color: var(--text-tertiary); font-style: italic; }

/* ---- Consulta de CEP (ViaCEP) ---- */
.cep-endereco-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--border-subtle); }
.cep-endereco-item:last-child { border-bottom: none; }
.cep-endereco-cep { font-size: 13px; font-weight: 700; color: var(--ml-blue); flex-shrink: 0; }
.cep-endereco-info { flex: 1; min-width: 0; }
.cep-endereco-logradouro { font-size: 13px; font-weight: 600; }
.cep-endereco-local { font-size: 11.5px; color: var(--text-secondary); margin-top: 2px; }

/* ---- Tabela FIPE ---- */
.fipe-preco-valor { font-size: 26px; font-weight: 800; color: var(--ml-green); text-align: center; padding: 20px 14px 6px; }

/* ---- Detalhe de anúncio ---- */
.detalhe-hero { background: var(--bg-card); border-radius: var(--radius-md); box-shadow: var(--shadow-card); margin-bottom: 16px; overflow: hidden; }
.detalhe-foto {
  height: 220px; background: #f5f5f5; display: flex; align-items: center; justify-content: center;
  font-size: 40px; color: var(--text-tertiary);
}
.detalhe-foto img { width: 100%; height: 100%; object-fit: contain; }
.detalhe-corpo { padding: 14px; }
.detalhe-titulo { font-size: 17px; font-weight: 700; margin-bottom: 6px; line-height: 1.3; }
.detalhe-preco { font-size: 22px; font-weight: 800; margin-bottom: 8px; }
.detalhe-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 4px; }
.detalhe-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 14px; border-top: 1px solid var(--border-subtle); }
.detalhe-campo .label { font-size: 10.5px; color: var(--text-tertiary); font-weight: 700; text-transform: uppercase; }
.detalhe-campo .valor { font-size: 13px; margin-top: 2px; }
.variacoes-lista { padding: 4px 14px 14px 14px; }
.variacao-row { display: flex; justify-content: space-between; padding: 8px 0; font-size: 13px; border-top: 1px solid #f2f2f2; }
.variacao-row:first-child { border-top: none; }
.frete-status-row { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--border-subtle); font-size: 13px; }

.pergunta-frete-loading { padding: 12px 2px; font-size: 12.5px; color: var(--text-tertiary); font-style: italic; }

.view { display: none; }
.view.active { display: block; }

/* ---- Estado vazio ---- */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 56px 24px; background: var(--bg-card);
  border-radius: var(--radius-md); box-shadow: var(--shadow-card);
}
.empty-state .icone { font-size: 34px; margin-bottom: 10px; opacity: 0.55; }
.empty-state .titulo { font-size: 14.5px; font-weight: 700; margin-bottom: 4px; }
.empty-state .msg { font-size: 12.5px; color: var(--text-secondary); max-width: 260px; line-height: 1.5; }

/* ---- Erro de credencial (overlay bloqueante) ---- */
.cred-error-overlay {
  display: none; position: fixed; inset: 0; z-index: 50;
  background: var(--bg-page);
  flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 32px;
}
.cred-error-overlay.active { display: flex; }
.cred-error-icone {
  width: 56px; height: 56px; border-radius: 50%; background: var(--ml-red-tint);
  display: flex; align-items: center; justify-content: center; font-size: 26px; margin-bottom: 16px;
}
.cred-error-titulo { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.cred-error-msg { font-size: 13px; color: var(--text-secondary); max-width: 280px; line-height: 1.5; margin-bottom: 20px; }
.btn-reconectar {
  background: var(--ml-blue); color: #fff; border: none; font-size: 14px; font-weight: 700;
  padding: 12px 28px; border-radius: var(--radius-sm); cursor: pointer; min-height: 46px;
}

/* ---- Breakpoint desktop/tablet (>= 768px) ---- */
@media (min-width: 768px) {
  .content { padding: 24px; max-width: 720px; margin: 0 auto; }
  .topbar { padding: 0 24px; }
}

@media (min-width: 1100px) {
  .content { max-width: 820px; margin: 0 auto; }
}
