/* ==========================================================================
   Interações — painel de orçamento, visualização rápida, foto da peça,
   compatibilidade, buscas recentes, lista/grade e transições
   ========================================================================== */

/* Transição de página (termina sempre visível) */
@media (prefers-reduced-motion: no-preference) {
  .page-enter { animation: page-in .35s ease both; }
  @keyframes page-in { from { opacity: .001; transform: translateY(8px); } to { opacity: 1; transform: none; } }
  .product-card { animation: card-in .3s ease both; }
  @keyframes card-in { from { opacity: .001; transform: translateY(6px); } to { opacity: 1; transform: none; } }
}

/* Cabeçalho com sombra ao rolar */
.header { transition: box-shadow .2s; }
.header.is-scrolled { box-shadow: 0 6px 18px rgba(0, 0, 0, .08); }

/* Overlay comum */
.overlay { position: fixed; inset: 0; z-index: 70; background: rgba(0, 0, 0, .45); }
@media (prefers-reduced-motion: no-preference) {
  .overlay { animation: fade-in .2s ease both; }
  .sheet { animation: sheet-in .25s ease both; }
  .modal { animation: modal-in .22s ease both; }
  @keyframes fade-in { from { opacity: .001; } to { opacity: 1; } }
  @keyframes sheet-in { from { transform: translateX(24px); opacity: .001; } to { transform: none; opacity: 1; } }
  @keyframes modal-in { from { transform: translateY(12px); opacity: .001; } to { transform: none; opacity: 1; } }
}

/* Painel lateral do orçamento */
.sheet {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 71; width: min(420px, 100%);
  display: grid; grid-template-rows: auto 1fr auto; background: #fff; box-shadow: -12px 0 40px rgba(0, 0, 0, .18);
  padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); padding-right: env(safe-area-inset-right, 0px);
}
.sheet__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 24px; border-bottom: 1px solid var(--line); }
.sheet__head h2 { font-size: 22px; }
.sheet__body { overflow: auto; padding: 8px 24px; }
.sheet__item { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line); }
.sheet__item.is-new { background: linear-gradient(90deg, #FFF8DD, transparent); }
.sheet__thumb { width: 64px; height: 64px; padding: 10px; background: var(--soft); border-radius: var(--r); }
.sheet__name { font-weight: 600; line-height: 1.3; }
.sheet__meta { font-size: 14px; color: var(--muted); }
.sheet__foot { display: grid; gap: 10px; padding: 18px 24px 22px; border-top: 1px solid var(--line); background: var(--soft); }
.sheet__foot small { font-size: 14px; color: var(--muted); }
.qty--sm button { width: 34px; height: 36px; font-size: 16px; }
.qty--sm output { min-width: 26px; font-size: 15px; }

/* Visualização rápida */
.modal-wrap { position: fixed; inset: 0; z-index: 71; display: grid; place-items: center; padding: 16px; pointer-events: none; }
.modal {
  pointer-events: auto; position: relative; width: min(880px, 100%); max-height: calc(100vh - 32px); overflow: auto;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); background: #fff; border-radius: var(--r); box-shadow: var(--shadow-md);
}
.modal__img { background: var(--soft); padding: 14%; display: grid; place-items: center; }
.modal__img img { width: 100%; height: auto; }
.modal__body { display: grid; gap: 16px; align-content: start; padding: 32px 28px; }
.modal__body h2 { font-size: 30px; }
.modal__close { position: absolute; top: 12px; right: 12px; }
.modal__eq { font-size: 15px; color: var(--muted); }
.modal__eq strong { color: var(--ink); font-weight: 500; letter-spacing: .02em; }

.quick-btn {
  position: absolute; right: 10px; bottom: 10px; z-index: 1; display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--r); background: #fff; font-size: 13px; font-weight: 600;
  opacity: 0; transform: translateY(4px); transition: opacity .15s, transform .15s;
}
.product-card__img:hover .quick-btn, .product-card__img:focus-within .quick-btn, .quick-btn:focus-visible { opacity: 1; transform: none; }
@media (hover: none) { .quick-btn { opacity: 1; transform: none; } }

/* Foto da peça (Não sei o código) */
.photo-id { display: grid; gap: 12px; }
.dropzone {
  position: relative; display: grid; grid-template-columns: 64px 1fr; gap: 14px; align-items: center; padding: 14px;
  border: 1px dashed #B9C0C4; border-radius: var(--r); background: var(--soft); cursor: pointer; transition: border-color .15s, background-color .15s;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--ink); background: var(--soft-2); }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone__thumb { width: 64px; height: 64px; display: grid; place-items: center; border-radius: var(--r); background: #fff; color: var(--muted); overflow: hidden; }
.dropzone__thumb img { width: 100%; height: 100%; object-fit: cover; }
.dropzone strong { display: block; font-size: 15px; }
.dropzone span { font-size: 14px; color: var(--muted); }
.photo-id__row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.photo-id select, .photo-id input[type="text"] { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: var(--r); background: #fff; font-size: 15px; }
.msg-preview--sm { font-size: 14px; max-height: 180px; }

/* Compatibilidade */
.compat { display: grid; gap: 12px; padding: 20px; background: var(--soft); border-radius: var(--r); }
.compat h2 { font-size: 19px; }
.compat__row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.compat select { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: var(--r); background: #fff; font-size: 15px; }
.compat__result { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r); font-size: 15px; }
.compat__result--ok { background: var(--wa-soft); color: #0F5C31; }
.compat__result--check { background: #FFF4D6; color: #6B4D00; }
.compat__result a { font-weight: 600; color: inherit; }

/* Buscas recentes */
.suggest__label { display: flex; justify-content: space-between; padding: 10px 14px 4px; font-size: 13px; color: var(--muted); }
.suggest__label button { border: 0; background: none; padding: 0; font-size: 13px; color: var(--muted); text-decoration: underline; }
.suggest a.suggest__recent { grid-template-columns: 20px 1fr; color: var(--ink-2); }
.kbd { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; font-size: 12px; color: var(--muted); background: #fff; }
.search__hint { position: absolute; right: 120px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.search--sm .search__hint { right: 96px; }

/* Lista / grade */
.view-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.view-toggle button { display: grid; place-items: center; width: 44px; height: 44px; border: 0; background: #fff; color: var(--muted); }
.view-toggle button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.grid-products--list { grid-template-columns: 1fr; gap: 0; border-top: 1px solid var(--line); }
.grid-products--list .product-card { display: grid; grid-template-columns: 112px minmax(0, 1fr) auto; gap: 20px; align-items: center; padding: 16px 0; border-bottom: 1px solid var(--line); }
.grid-products--list .product-card__img { padding: 14px; }
.grid-products--list .quick-btn, .grid-products--list .stock { display: none; }
.grid-products--list .add-btn { align-self: center; }

/* Zoom na foto da peça */
.gallery__main { overflow: hidden; cursor: zoom-in; }
.gallery__main img { transition: transform .25s ease; }
.gallery__main.is-zoom img { transform: scale(1.8); }

/* Contador do orçamento pulsa ao mudar */
@media (prefers-reduced-motion: no-preference) {
  .badge.bump { animation: bump .4s ease; }
  @keyframes bump { 40% { transform: scale(1.3); } }
}

@media (max-width: 760px) {
  .modal { grid-template-columns: 1fr; }
  .modal__img { padding: 18% 24%; }
  .modal__body { padding: 22px 20px 26px; }
  .modal__body h2 { font-size: 24px; }
  .search__hint { display: none; }
}
@media (max-width: 600px) {
  .grid-products--list .product-card { grid-template-columns: 72px minmax(0, 1fr); gap: 14px; }
  .grid-products--list .product-card__img { padding: 8px; }
  .grid-products--list .add-btn { grid-column: 2; justify-self: start; }
  .photo-id__row, .compat__row { grid-template-columns: 1fr; }
}

/* Imagem do cartão como bloco clicável */
.product-card__imglink { display: block; width: 100%; height: 100%; }
.product-card__imglink img { width: 100%; height: 100%; object-fit: contain; }

/* ---------- Carrossel ---------- */
.carousel { position: relative; }
.carousel__head { display: flex; justify-content: space-between; align-items: end; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; }
.carousel__head h2 { font-size: var(--fs-h2); margin: 0; }
.carousel__viewport { position: relative; }
.carousel__track {
  display: grid; grid-auto-flow: column; gap: 20px;
  grid-auto-columns: calc((100% - (var(--per, 4) - 1) * 20px) / var(--per, 4));
  overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x mandatory; scroll-behavior: smooth;
  scrollbar-width: none; padding: 4px 2px 8px;
}
.carousel__track::-webkit-scrollbar { display: none; }
.carousel__track > * { scroll-snap-align: start; min-width: 0; }

/* Cartões como slides */
.carousel .product-card {
  padding: 12px 12px 16px; background: #fff; border: 1px solid var(--line); border-radius: 6px;
  transition: border-color .2s, box-shadow .2s, transform .2s;
}
.carousel .product-card:hover { border-color: #C9CFD2; box-shadow: 0 10px 24px rgba(0, 0, 0, .08); transform: translateY(-2px); }
.carousel .product-card__img { border-radius: 4px; }
.carousel .product-card > div:nth-child(2), .carousel .add-btn { margin-inline: 4px; }

/* Setas sobre as laterais */
.carousel__arrow {
  position: absolute; top: var(--arrow-top, 34%); z-index: 2; transform: translateY(-50%);
  width: 48px; height: 48px; display: grid; place-items: center; border-radius: 50%;
  border: 1px solid var(--line); background: #fff; color: var(--ink); box-shadow: 0 6px 18px rgba(0, 0, 0, .14);
  transition: opacity .2s, transform .2s, box-shadow .2s;
}
.carousel__arrow:hover { box-shadow: 0 8px 22px rgba(0, 0, 0, .2); }
.carousel__arrow--prev { left: -22px; }
.carousel__arrow--next { right: -22px; }
.carousel__arrow[hidden] { display: grid !important; opacity: 0; pointer-events: none; }

/* Esmaecido na borda indicando continuação */
.carousel__viewport::after {
  content: ""; position: absolute; top: 0; bottom: 8px; right: 0; width: 56px; pointer-events: none;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0), #fff); opacity: 0; transition: opacity .2s;
}
.carousel__viewport.has-next::after { opacity: 0; } /* cartões inteiros já cabem; esmaecido desligado */

/* Pontos de página */
.carousel__dots { display: flex; justify-content: center; gap: 8px; margin-top: 24px; }
.carousel__dots button { width: 8px; height: 8px; padding: 0; border: 0; border-radius: 4px; background: #CDD3D6; transition: width .2s, background-color .2s; }
.carousel__dots button[aria-current="true"] { width: 24px; background: var(--ink); }
.carousel__dots button::before { content: ""; display: block; margin: -12px -6px; height: 32px; } /* área de toque */

@media (prefers-reduced-motion: reduce) { .carousel__track { scroll-behavior: auto; } .carousel .product-card:hover { transform: none; } }


@media (max-width: 1080px) {
  .carousel__track { grid-auto-columns: calc((100% - (var(--per-md, 3) - 1) * 20px) / var(--per-md, 3)); }
  .carousel__arrow--prev { left: -12px; } .carousel__arrow--next { right: -12px; }
}
@media (max-width: 600px) {
  .carousel__arrow { display: none !important; }
  .carousel__track { grid-auto-columns: var(--per-sm, 74%); gap: 12px; margin-right: calc(-1 * var(--gutter)); padding-right: var(--gutter); }
  .carousel__viewport::after { display: none; }
  .carousel .product-card:hover { transform: none; box-shadow: none; }
}

/* Categorias e marcas no carrossel: mesmo cartão das peças */
.carousel .system-tile, .carousel .brand-tile {
  background: #fff; border: 1px solid var(--line); border-radius: 6px;
  transition: border-color .2s, box-shadow .2s, transform .2s;
}
.carousel .system-tile { padding: 12px 12px 16px; gap: 12px; }
.carousel .system-tile__img { border-radius: 4px; }
.carousel .system-tile__name { padding-inline: 4px; }
.carousel .brand-tile { height: 112px; border-left: 1px solid var(--line); }
.carousel .brand-tile + .brand-tile { border-left: 1px solid var(--line); }
.carousel .system-tile:hover, .carousel .brand-tile:hover { border-color: #C9CFD2; box-shadow: 0 10px 24px rgba(0, 0, 0, .08); transform: translateY(-2px); background: #fff; }
@media (prefers-reduced-motion: reduce) { .carousel .system-tile:hover, .carousel .brand-tile:hover { transform: none; } }
@media (max-width: 600px) {
  .carousel .brand-tile { height: 88px; }
  .carousel .system-tile:hover, .carousel .brand-tile:hover { transform: none; box-shadow: none; }
}
