/* ============================================================
   PREÇO AGORA - FRONT-END V3
   Objetivo: simples, compacto e fácil de manter.
   ============================================================ */

:root{
  --bg:#f4f6f9;
  --surface:#ffffff;
  --text:#111827;
  --muted:#6b7280;
  --line:#e5e7eb;
  --navy:#16233c;
  --navy-2:#223657;
  --yellow:#ffe000;
  --yellow-hover:#f4d500;
  --danger:#c2413a;
  --danger-bg:#fff0ee;
  --soft:#eef1f5;
  --green:#0a7f51;
  --shadow:0 8px 24px rgba(15,23,42,.055);
  --radius:20px;
}

*{box-sizing:border-box}
html{background:var(--bg)}
body{
  margin:0;
  background:var(--bg);
  color:var(--text);
  font-family:Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  -webkit-font-smoothing:antialiased;
}
button,input{font:inherit}
button{cursor:pointer}

.app-shell{
  width:min(100% - 28px, 980px);
  margin:0 auto;
  padding:18px 0 48px;
}

/* ---------------- HEADER ---------------- */
.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  background:linear-gradient(135deg,var(--navy),var(--navy-2));
  color:#fff;
  padding:18px 20px;
  border-radius:24px;
  box-shadow:var(--shadow);
}

.brand{display:flex;align-items:center;gap:13px;min-width:0}
.brand-icon{
  width:50px;height:50px;border-radius:15px;
  display:grid;place-items:center;
  background:var(--yellow);color:#111827;
  font-weight:950;font-size:21px;flex:none;
}
.brand h1{margin:0;font-size:24px;letter-spacing:-.035em;line-height:1.05}
.brand p{margin:5px 0 0;font-size:13px;color:rgba(255,255,255,.72)}

/* ---------------- COMMON ---------------- */
.card{
  background:var(--surface);
  border:1px solid var(--line);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
}

.btn{
  border:0;border-radius:12px;
  min-height:43px;padding:0 16px;
  font-weight:850;
  transition:.15s ease;
  white-space:nowrap;
}
.btn:active{transform:translateY(1px)}
.btn-white{background:#fff;color:var(--navy)}
.btn-dark{background:var(--navy);color:#fff}
.btn-yellow{background:var(--yellow);color:#111827}
.btn-yellow:hover{background:var(--yellow-hover)}
.btn-light{background:var(--soft);color:#273142}
.btn-danger{background:var(--danger-bg);color:var(--danger)}

.section-label{
  display:block;
  font-size:11px;
  font-weight:900;
  letter-spacing:.09em;
  color:#687386;
  margin-bottom:3px;
}

.section-head,.products-title-row,.results-head{
  display:flex;align-items:center;justify-content:space-between;gap:12px;
}
.section-head h2,.products-title-row h2,.results-head h2{
  margin:0;font-size:20px;letter-spacing:-.025em;
}
.link-btn{
  border:0;background:transparent;color:#4b5563;
  padding:7px 0;font-size:12px;font-weight:800;
}
.icon-btn{
  border:0;background:var(--soft);color:#374151;
  width:36px;height:36px;border-radius:11px;
  font-size:22px;line-height:1;
}

/* ---------------- TOP ACTIONS ---------------- */
.toolbar{
  display:flex;justify-content:flex-end;gap:9px;
  padding:12px;
  margin-top:14px;
}

/* ---------------- STORES ---------------- */
.stores-card{padding:16px;margin-top:14px}
.store-strip{
  display:flex;
  gap:9px;
  overflow-x:auto;
  padding:13px 1px 2px;
  scrollbar-width:thin;
}
.store-chip{
  flex:0 0 auto;
  display:flex;align-items:center;gap:8px;
  min-height:44px;
  padding:0 13px;
  border:1px solid var(--line);
  border-radius:13px;
  background:#fff;
  color:#374151;
  font-weight:850;
}
.store-chip::before{
  content:"";
  width:9px;height:9px;border-radius:50%;
  background:#d1d5db;
}
.store-chip.active{
  border-color:#c5cad4;
  background:#f8fafc;
  color:#111827;
  box-shadow:inset 0 0 0 1px #eef0f3;
}
.store-chip.active::before{background:var(--green)}

/* ---------------- FORM ---------------- */
.form-card{padding:16px;margin-top:14px}
.form-grid{display:grid;grid-template-columns:1.5fr 1fr;gap:10px;margin-top:14px}
.form-grid label span{display:block;font-size:12px;font-weight:850;color:#374151;margin:0 0 6px}
.form-grid input{
  width:100%;height:46px;border:1px solid #d6dbe3;
  border-radius:13px;padding:0 13px;background:#fff;outline:none;font-size:15px;
}
.form-grid input:focus{border-color:#aeb6c2;box-shadow:0 0 0 3px #f2f4f7}
.form-actions{display:flex;justify-content:flex-end;gap:8px;margin-top:12px}

/* ---------------- PRODUCTS ---------------- */
.products-section{margin-top:24px}
.products-title-row{padding:0 2px 10px}
.product-count{font-size:12px;color:var(--muted);font-weight:800}
.product-list{display:grid;gap:10px}

.product-card{
  background:#fff;
  border:1px solid var(--line);
  border-radius:18px;
  box-shadow:0 5px 18px rgba(15,23,42,.04);
  overflow:hidden;
}

.product-main{
  display:grid;
  grid-template-columns:minmax(0,1fr) auto;
  gap:14px;
  align-items:center;
  padding:15px 16px 11px;
}
.product-name{font-size:17px;font-weight:900;letter-spacing:-.015em;line-height:1.2}
.product-terms{font-size:12px;color:var(--muted);margin-top:4px}
.product-actions{display:flex;gap:7px;align-items:center}
.product-actions .btn{min-height:40px;padding:0 13px}

/* Loja individual por produto */
.product-stores{
  display:flex;
  gap:7px;
  overflow-x:auto;
  padding:10px 16px 13px;
  border-top:1px solid #f0f1f3;
  background:#fbfcfd;
  scrollbar-width:thin;
}
.store-search-btn{
  flex:0 0 auto;
  min-height:34px;
  border:1px solid #e1e4e9;
  border-radius:10px;
  padding:0 10px;
  background:#fff;
  color:#475467;
  font-size:12px;
  font-weight:800;
}
.store-search-btn:hover{border-color:#c9ced7;color:#111827}
.store-search-btn.disabled{opacity:.38;pointer-events:none}

/* ---------------- RESULTS PREVIEW ---------------- */
.results-panel{margin-top:24px}
.results-head{margin-bottom:10px;padding:0 2px}
.results-grid{display:grid;grid-template-columns:repeat(5,minmax(145px,1fr));gap:9px;overflow-x:auto;padding-bottom:4px}
.result-card{
  min-width:145px;background:#fff;border:1px solid var(--line);
  border-radius:16px;padding:12px;box-shadow:0 5px 18px rgba(15,23,42,.04);
}
.result-store{font-size:12px;font-weight:900;color:#475467}
.result-product{font-size:12px;color:#6b7280;margin-top:5px;line-height:1.35;min-height:32px}
.result-price{font-size:22px;font-weight:950;letter-spacing:-.035em;margin-top:12px}
.result-status{font-size:11px;color:#7c8797;margin-top:3px}
.result-open{
  width:100%;margin-top:11px;min-height:34px;border:0;border-radius:10px;
  background:#eef3fb;color:#1d4f91;font-size:12px;font-weight:850;
}

.toast{
  position:fixed;left:50%;bottom:22px;transform:translateX(-50%);
  background:#111827;color:#fff;border-radius:12px;padding:11px 14px;
  font-size:13px;font-weight:750;box-shadow:0 10px 30px rgba(0,0,0,.16);z-index:50;
}

/* ---------------- RESPONSIVE ---------------- */
@media(max-width:760px){
  .app-shell{width:min(100% - 20px,980px);padding-top:10px}
  .topbar{padding:15px;border-radius:20px}
  .brand-icon{width:44px;height:44px;border-radius:13px}
  .brand h1{font-size:21px}
  .brand p{font-size:12px}
  .btn-white{padding:0 12px;min-height:40px}
  .toolbar{display:grid;grid-template-columns:1fr 1fr}
  .toolbar .btn{width:100%}
  .form-grid{grid-template-columns:1fr}
  .product-main{grid-template-columns:1fr;gap:10px}
  .product-actions{display:grid;grid-template-columns:1fr auto auto}
  .product-actions .btn{width:100%}
  .results-grid{grid-template-columns:repeat(5,150px)}
}

@media(max-width:470px){
  .brand p{display:none}
  .brand h1{font-size:20px}
  .topbar{padding:13px}
  .toolbar{padding:10px}
  .section-head h2,.products-title-row h2,.results-head h2{font-size:18px}
  .product-actions{grid-template-columns:1fr 1fr 1fr}
  .product-actions .btn{font-size:12px;padding:0 8px}
}

/* ---------------- RESULTADOS INDEPENDENTES V3 ----------------
   Cada pesquisa possui seu próprio bloco e botão ×.
   A grade interna continua preparada para vários e-commerces.
   -------------------------------------------------------------- */
.result-search-list{
  display:grid;
  gap:14px;
}

.result-search-group{
  background:#fff;
  border:1px solid var(--line);
  border-radius:18px;
  box-shadow:0 5px 18px rgba(15,23,42,.04);
  padding:12px;
}

.result-search-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:1px 1px 11px;
}

.result-search-title{
  font-size:16px;
  font-weight:900;
  line-height:1.25;
  letter-spacing:-.015em;
}

.result-search-meta{
  margin-top:3px;
  font-size:11px;
  color:var(--muted);
  font-weight:750;
}

.result-close-btn{
  flex:none;
  width:34px;
  height:34px;
  display:grid;
  place-items:center;
  border:1px solid #e6e8ec;
  border-radius:10px;
  background:#f7f8fa;
  color:#596273;
  font-size:21px;
  line-height:1;
  font-weight:700;
  transition:.15s ease;
}

.result-close-btn:hover{
  background:var(--danger-bg);
  border-color:#f3d4d0;
  color:var(--danger);
}

.result-search-group .results-grid{
  padding-bottom:1px;
}

@media(max-width:470px){
  .result-search-group{padding:10px}
  .result-search-title{font-size:15px}
}


/* ============================================================
   EDIÇÃO INLINE DO PRODUTO
   O card é substituído pelo formulário no mesmo ponto da lista.
   ============================================================ */
.product-card-editing{
  padding:16px;
  overflow:visible;
}
.inline-edit-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom:12px;
}
.inline-edit-title{
  font-size:18px;
  font-weight:900;
  letter-spacing:-.02em;
}
.inline-edit-close{
  width:34px;
  height:34px;
  flex:none;
  display:grid;
  place-items:center;
  border:0;
  border-radius:10px;
  background:var(--soft);
  color:#596273;
  font-size:21px;
  line-height:1;
}
.inline-edit-grid{
  display:grid;
  grid-template-columns:1.5fr 1fr;
  gap:10px;
}
.inline-edit-grid label span{
  display:block;
  font-size:12px;
  font-weight:850;
  color:#374151;
  margin:0 0 6px;
}
.inline-edit-grid input{
  width:100%;
  height:46px;
  border:1px solid #d6dbe3;
  border-radius:13px;
  padding:0 13px;
  background:#fff;
  outline:none;
  font-size:15px;
}
.inline-edit-grid input:focus{
  border-color:#aeb6c2;
  box-shadow:0 0 0 3px #f2f4f7;
}
.inline-edit-actions{
  display:flex;
  justify-content:flex-end;
  gap:8px;
  margin-top:12px;
}

/* ============================================================
   FECHAR CARD INDIVIDUAL DE RESULTADO
   Cada e-commerce possui seu próprio X no canto superior direito.
   ============================================================ */
.result-card{
  position:relative;
  padding-top:40px;
}
.result-card-close{
  position:absolute;
  top:8px;
  right:8px;
  width:28px;
  height:28px;
  min-width:28px;
  padding:0;
  margin:0;
  border:1px solid #e6e8ec;
  border-radius:9px;
  background:#f7f8fa;
  color:#667085;
  display:grid;
  place-items:center;
  font-size:18px;
  font-weight:750;
  line-height:1;
  z-index:4;
}
.result-card-close:hover{
  background:var(--danger-bg);
  border-color:#f3d4d0;
  color:var(--danger);
}

@media(max-width:760px){
  .inline-edit-grid{grid-template-columns:1fr}
}

/* ============================================================
   V7 - ESTADO DE PESQUISA / CARREGAMENTO
   ============================================================ */
button:disabled{
  cursor:default;
}

.btn.is-loading,
.store-search-btn.is-loading{
  position:relative;
  overflow:hidden;
  pointer-events:none;
  cursor:wait;
}

/* Mantém o botão com aparência ativa enquanto pesquisa. */
.btn-yellow.is-loading{
  opacity:1;
  background:var(--yellow);
  color:#111827;
}

.store-search-btn.is-loading{
  opacity:1;
  background:#f8fafc;
  color:#111827;
  border-color:#cfd5de;
}

/* Linha animada inferior. Não altera a largura nem o texto do botão. */
.btn.is-loading::after,
.store-search-btn.is-loading::after{
  content:"";
  position:absolute;
  left:-45%;
  bottom:0;
  width:45%;
  height:3px;
  border-radius:999px;
  background:currentColor;
  opacity:.42;
  animation:searchButtonProgress 1.05s linear infinite;
}

@keyframes searchButtonProgress{
  from{left:-45%}
  to{left:100%}
}

.result-card.is-loading{
  border-color:#cbd5e1;
}

.result-card.is-loading::after{
  content:"";
  position:absolute;
  left:10px;
  right:10px;
  bottom:0;
  height:3px;
  overflow:hidden;
  border-radius:999px;
  background:linear-gradient(90deg,transparent,#94a3b8,transparent);
  background-size:45% 100%;
  background-repeat:no-repeat;
  animation:resultCardProgress 1.15s linear infinite;
}

@keyframes resultCardProgress{
  from{background-position:-50% 0}
  to{background-position:150% 0}
}

.empty-card{
  padding:22px;
  text-align:center;
  color:#6b7280;
}

/* V8: mantém dimensões do botão estáveis durante o carregamento. */
.btn.is-loading,
.store-search-btn.is-loading{
  white-space:nowrap;
  box-sizing:border-box;
}


/* ============================================================
   V11 - RESPONSIVIDADE E SCROLL DOS RESULTADOS
   ------------------------------------------------------------
   - Desktop: aplicação centralizada.
   - Tela menor: aplicação respeita 100% da largura disponível.
   - Cards de resultado NÃO espremem.
   - A linha de cards possui rolagem horizontal real.
   - A barra logo abaixo é visual, clicável e arrastável.
   ============================================================ */

html,
body{
  width:100%;
  max-width:100%;
  overflow-x:hidden;
}

.app-shell{
  width:min(calc(100% - 32px),1080px);
  max-width:1080px;
  margin-left:auto;
  margin-right:auto;
  box-sizing:border-box;
}

.results-panel,
.result-search-list,
.result-search-group,
.results-scroll-shell{
  width:100%;
  max-width:100%;
  min-width:0;
  box-sizing:border-box;
}

.result-search-group{
  overflow:hidden;
}

/* Linha horizontal dos cards */
.result-search-group .results-grid{
  display:flex;
  flex-wrap:nowrap;
  align-items:stretch;
  gap:10px;
  width:100%;
  max-width:100%;
  min-width:0;
  overflow-x:auto;
  overflow-y:hidden;
  padding:2px 1px 7px;
  scroll-behavior:smooth;
  scroll-snap-type:x proximity;
  overscroll-behavior-x:contain;
  -webkit-overflow-scrolling:touch;

  /* Esconde a barra nativa.
     A barra visual controlada abaixo permanece sempre consistente. */
  scrollbar-width:none;
  -ms-overflow-style:none;
}

.result-search-group .results-grid::-webkit-scrollbar{
  display:none;
}

/* Cards: largura mínima estável.
   Em desktop eles crescem para preencher o espaço;
   em telas menores passam a formar uma faixa horizontal. */
.result-search-group .result-card{
  position:relative;
  flex:1 0 180px;
  min-width:180px;
  max-width:none;
  scroll-snap-align:start;
}

/* Barra visual abaixo de CADA grupo de resultados */
.results-scrollbar{
  position:relative;
  width:100%;
  height:18px;
  margin-top:5px;
  padding:5px 0;
  cursor:pointer;
  touch-action:none;
  user-select:none;
  box-sizing:border-box;
}

.results-scrollbar[hidden]{
  display:none !important;
}

.results-scrollbar-track{
  position:relative;
  width:100%;
  height:7px;
  border-radius:999px;
  background:#e4e7ec;
  overflow:hidden;
}

.results-scrollbar-thumb{
  position:absolute;
  top:0;
  left:0;
  height:7px;
  min-width:44px;
  border-radius:999px;
  background:#98a2b3;
  transform:translateX(0);
  cursor:grab;
  touch-action:none;
  transition:background .15s ease;
  will-change:transform,width;
}

.results-scrollbar-thumb:hover{
  background:#667085;
}

.results-scrollbar-thumb.is-dragging{
  cursor:grabbing;
  background:#667085;
}

/* Tablet / celular */
@media(max-width:760px){
  .app-shell{
    width:calc(100% - 16px);
    max-width:none;
  }

  .result-search-group{
    padding:10px;
  }

  .result-search-group .result-card{
    flex:0 0 210px;
    min-width:210px;
    max-width:210px;
  }

  .results-scrollbar{
    height:20px;
    padding:6px 0 7px;
  }
}

/* Telas muito estreitas */
@media(max-width:420px){
  .app-shell{
    width:calc(100% - 10px);
  }

  .result-search-group .result-card{
    flex-basis:200px;
    min-width:200px;
    max-width:200px;
  }
}
