/* Garagem: carros guardados pelo visitante (botões nos cards e no anúncio,
   atalho no topo e as páginas /garagem e /garagem/{código}). */

/* A regra "* { color }" do tema pintava os traços dos ícones de cinza */
.header-garage svg path,
.garage-toggle svg path,
.garage-item-remove svg path {
  color: inherit;
}

/* ===== Atalho no topo ===== */
.header .header-garage {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  flex-shrink: 0;
  color: #fff;
  font-size: clamp(1.2rem, 1.05vw, 1.6rem);
  white-space: nowrap;
  padding: 0.6rem 0.4rem;
  transition: color 0.3s ease;
}

.header .header-garage svg {
  width: 2.4rem;
  height: 2.4rem;
  flex-shrink: 0;
}

.header .header-garage:hover {
  color: #ea3636;
}

.header .header-garage svg,
.header .header-garage span {
  color: inherit;
}

.header-garage-count {
  position: absolute;
  top: -0.2rem;
  left: 1.6rem;
  min-width: 1.9rem;
  height: 1.9rem;
  padding: 0 0.5rem;
  border-radius: 1rem;
  background: #ea3636;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.9rem;
  text-align: center;
  color: #fff !important;
}

.header-garage-count[hidden] {
  display: none;
}

.header-garage-count.is-bumped {
  animation: garage-bump 0.45s ease;
}

@keyframes garage-bump {
  40% { transform: scale(1.35); }
}

/* Celular: só o ícone, à esquerda do menu (☰) */
@media (max-width: 991px) {
  /* sem top: fica centrado na faixa da logo, como o menu (☰) */
  .header .header-garage {
    position: absolute;
    right: 64px;
    min-width: 44px;
    min-height: 44px;
    justify-content: center;
  }

  .header .header-garage-label {
    display: none;
  }

  .header-garage-count {
    top: 0.4rem;
    left: auto;
    right: 0;
  }
}

/* ===== Botões sobre a foto do card: comparar e garagem lado a lado =====
   O grupo é que fica posicionado; ao passar o mouse, a pílula que abre o
   texto empurra a vizinha em vez de passar por cima dela. */
.card-toggles {
  position: absolute;
  top: 2rem;
  left: 2rem;
  right: 2rem;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  pointer-events: none;
}

.card-toggles > * {
  pointer-events: auto;
}

.card-toggles .compare-toggle,
.card-toggles .garage-toggle {
  position: static;
}

/* ===== Botão da garagem nos cards (mesmo estilo de pílula do comparar) ===== */
.garage-toggle-form {
  margin: 0;
}

.garage-toggle {
  all: unset;
  box-sizing: border-box;
  cursor: pointer;
  position: absolute;
  top: 2rem;
  left: 2rem;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 3.6rem;
  height: 3.6rem;
  padding: 0 0.85rem;
  border-radius: 1.8rem;
  background: rgba(255, 255, 255, 0.92);
  color: #2d3643;
  transition: background 0.3s ease, color 0.3s ease;
}

.garage-toggle svg {
  width: 1.9rem;
  height: 1.9rem;
  flex-shrink: 0;
}

.garage-toggle svg,
.garage-toggle span {
  color: inherit;
}

.garage-toggle:hover {
  background: #fff;
  color: #ea3636;
}

.garage-toggle.is-active {
  background: #ea3636;
  color: #fff;
}

.garage-toggle:focus-visible {
  outline: 2px solid #ea3636;
  outline-offset: 2px;
}

.garage-toggle-text {
  display: inline-block;
  max-width: 0;
  margin-left: 0;
  overflow: hidden;
  opacity: 0;
  white-space: nowrap;
  font-size: 1.3rem;
  font-weight: 600;
  line-height: 1;
  transition: max-width 0.35s ease, margin-left 0.35s ease, opacity 0.2s ease;
}

@media (hover: hover) {
  .garage-toggle:hover .garage-toggle-text {
    max-width: 18rem;
    margin-left: 0.6rem;
    opacity: 1;
  }
}

.garage-toggle:focus-visible .garage-toggle-text {
  max-width: 18rem;
  margin-left: 0.6rem;
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  .garage-toggle-text {
    transition: none;
  }
}

@media (max-width: 767px) {
  .garage-toggle:not(.garage-toggle-label) {
    min-width: 4.2rem;
    height: 4.2rem;
    border-radius: 2.1rem;
  }
}

/* ===== Botão com rótulo da página do anúncio ===== */
.veiculo-acoes {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin: 1.2rem 0 2rem;
}

.veiculo-acoes .veiculo-share {
  margin: 0;
}

.garage-toggle.garage-toggle-label {
  position: static;
  gap: 0.8rem;
  height: auto;
  min-height: 3.8rem;
  padding: 0.8rem 1.8rem;
  border-radius: 3rem;
  border: 1px solid #ea3636;
  background: #fff;
  color: #ea3636;
  font-size: 1.4rem;
  font-weight: 600;
}

.garage-toggle.garage-toggle-label:hover {
  background: #ea3636;
  color: #fff;
}

.garage-toggle.garage-toggle-label.is-active {
  background: #ea3636;
  color: #fff;
}

/* ===== Páginas da garagem ===== */
.garage-body {
  padding: 2.4rem 0 8rem;
}

.garage-status {
  margin-bottom: 2rem;
  padding: 1.2rem 1.6rem;
  border-radius: 1.2rem;
  background: #eaf6ec;
  color: #1d6b25;
  font-size: 1.5rem;
}

.garage-status a {
  color: inherit;
  font-weight: 700;
  text-decoration: underline;
}

.garage-status-error {
  background: #fdecec;
  color: #b42323;
}

.garage-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34rem;
  gap: 3rem;
  align-items: start;
}

.garage-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1.2rem;
}

.garage-toolbar-count {
  font-size: 1.6rem;
  color: #2d3643;
}

.garage-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 1.6rem;
}

.garage-toolbar-actions form {
  margin: 0;
}

.garage-btn {
  all: unset;
  box-sizing: border-box;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 4rem;
  padding: 0.9rem 2rem;
  border-radius: 3rem;
  background: #ea3636;
  color: #fff;
  font-size: 1.4rem;
  font-weight: 600;
  white-space: nowrap;
  transition: filter 0.3s ease;
}

.garage-btn:hover {
  filter: brightness(1.08);
}

.garage-btn-dark {
  background: #14191d;
}

.garage-btn-link {
  all: unset;
  cursor: pointer;
  font-size: 1.4rem;
  color: #ea3636;
  padding: 1rem 0;
}

.garage-btn-link:hover {
  text-decoration: underline;
}

.garage-btn:focus-visible,
.garage-btn-link:focus-visible {
  outline: 2px solid #ea3636;
  outline-offset: 2px;
}

/* Grade: reaproveita o card da listagem (filters.css) */
.listing.garage-listing {
  padding: 0;
}

.listing.garage-listing .all {
  margin-top: 2rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.garage-body > .container > .garage-listing .all {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.listing .all .garage-item {
  position: relative;
  display: flex;
  flex-direction: column;
}

.listing .all .garage-item > a,
.garage-item-body {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.garage-item-body .desc {
  flex: 1;
}

/* Na garagem do dono o ícone da garagem vira o "x" de remover */
.garage-item-remove {
  position: absolute;
  top: 1.2rem;
  right: 1.2rem;
  z-index: 5;
  margin: 0;
}

.garage-item-remove button {
  all: unset;
  box-sizing: border-box;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3.6rem;
  height: 3.6rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: #2d3643;
  transition: background 0.3s ease, color 0.3s ease;
}

.garage-item-remove button:hover {
  background: #fff;
  color: #ea3636;
}

.garage-item-remove svg {
  width: 1.6rem;
  height: 1.6rem;
  color: inherit;
}

/* No link compartilhado o botão de guardar fica no canto do card */
.garage-listing .garage-toggle:not(.garage-toggle-label) {
  top: 1.2rem;
  left: 1.2rem;
}

.garage-item-flag {
  position: absolute;
  left: 1.2rem;
  bottom: 1.2rem;
  z-index: 2;
  padding: 0.5rem 1.1rem;
  border-radius: 0.6rem;
  background: #14191d;
  color: #fff;
  font-size: 1.25rem;
  font-weight: 700;
}

.garage-item-flag-drop {
  background: #218e2a;
}

.listing .all .item .desc .garage-item-was {
  font-size: 1.3rem;
  color: #218e2a;
  margin-bottom: 0.4rem;
}

.listing .all .garage-item.is-unavailable .cover img {
  filter: grayscale(1);
  opacity: 0.55;
}

.listing .all .garage-item.is-unavailable .desc {
  opacity: 0.6;
}

.garage-item-compare {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  padding: 1.2rem;
  border-top: 1px solid #eef1f3;
  background: #fff;
  cursor: pointer;
  font-size: 1.4rem;
  color: #2d3643;
}

.garage-item-compare input {
  width: 1.8rem;
  height: 1.8rem;
  accent-color: #ea3636;
  cursor: pointer;
}

/* Coluna lateral: nome e compartilhar */
.garage-side {
  position: sticky;
  top: 2rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.garage-name,
.garage-share {
  background: #fff;
  border-radius: 2rem;
  padding: 2.4rem;
}

/* faixa no topo da página: rótulo, campo e Salvar numa linha */
.garage-name {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.8rem 1.6rem;
  margin: 0 0 2.4rem;
  padding: 1.6rem 2.4rem;
}

.garage-name label {
  margin-bottom: 0 !important;
}

.garage-name > div {
  flex: 1;
  min-width: 24rem;
  max-width: 52rem;
}

.garage-name label {
  display: block;
  margin-bottom: 0.8rem;
  font-size: 1.5rem;
  font-weight: 700;
  color: #2d3643;
}

.garage-name > div {
  display: flex;
  gap: 0.8rem;
}

.garage-name input {
  flex: 1;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
  padding: 1rem 1.4rem;
  border: 0;
  border-radius: 0.8rem;
  background: var(--campo-fundo, #f1f3f5);
  color: var(--campo-texto, #2d3643);
  font-family: "Inter", sans-serif;
  font-size: 1.5rem;
  outline: 0;
}

.garage-name input:focus {
  box-shadow: 0 0 0 2px #ea3636;
}

.garage-share-title {
  font-size: 1.8rem;
  font-weight: 700;
  color: #2d3643;
}

.garage-share-hint {
  margin: 0.6rem 0 1.4rem;
  font-size: 1.4rem;
  line-height: 1.5;
  color: #5b6672;
}

.garage-share-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
}

.garage-cta {
  margin-top: 4rem;
  text-align: center;
}

.garage-cta p {
  margin-bottom: 1.6rem;
  font-size: 1.7rem;
  color: #2d3643;
}

@media (max-width: 1199px) {
  .listing.garage-listing .all {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .garage-body > .container > .garage-listing .all {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 991px) {
  .garage-layout {
    grid-template-columns: 1fr;
  }

  /* compartilhar antes dos carros; o nome da garagem vai para o fim */
  .garage-side {
    display: contents;
  }

  .garage-share {
    order: -1;
  }

  .garage-name > div {
    min-width: 100%;
  }

  .garage-body > .container > .garage-listing .all {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 600px) {
  .listing.garage-listing .all,
  .garage-body > .container > .garage-listing .all {
    grid-template-columns: 1fr;
  }

  .garage-toolbar-actions {
    width: 100%;
    justify-content: space-between;
  }
}

/* ===== Animação ao guardar: a foto voa até o ícone do topo ===== */
.garage-fly {
  position: fixed;
  z-index: 10001;
  pointer-events: none;
  border-radius: 50%;
  border: 3px solid #fff;
  background: #ea3636 center / cover no-repeat;
  box-shadow: 0 0.8rem 2.4rem rgba(0, 0, 0, 0.35);
  will-change: transform, opacity;
}

/* ícone do topo "recebe" o carro: pula e acende em vermelho */
.header .header-garage.is-receiving svg {
  animation: garage-receive 0.6s ease;
}

@keyframes garage-receive {
  0% { transform: scale(1); color: #fff; }
  35% { transform: scale(1.35) rotate(-8deg); color: #ea3636; }
  70% { transform: scale(0.92); color: #ea3636; }
  100% { transform: scale(1); color: #fff; }
}

@media (prefers-reduced-motion: reduce) {
  .header .header-garage.is-receiving svg,
  .header-garage-count.is-bumped {
    animation: none;
  }
}

/* ===== Balão de dica (primeiro carro guardado) ===== */
.garage-tip {
  --seta: 50%;
  position: fixed;
  z-index: 10000;
  width: min(32rem, calc(100vw - 2.4rem));
  box-sizing: border-box;
  padding: 1.8rem 2rem;
  border-radius: 1.6rem;
  background: #fff;
  box-shadow: 0 1.2rem 3.6rem rgba(0, 0, 0, 0.28);
  opacity: 0;
  transform: translateY(-0.8rem);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.garage-tip.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* seta apontando para o ícone */
.garage-tip:not(.is-floating)::before {
  content: "";
  position: absolute;
  top: -0.8rem;
  left: calc(var(--seta) - 0.8rem);
  width: 1.6rem;
  height: 1.6rem;
  background: #fff;
  border-radius: 0.3rem;
  transform: rotate(45deg);
}

.garage-tip strong {
  display: block;
  font-size: 1.7rem;
  color: #2d3643;
}

.garage-tip p {
  margin: 0.6rem 0 1.4rem;
  font-size: 1.4rem;
  line-height: 1.5;
  color: #5b6672;
}

.garage-tip-actions {
  display: flex;
  align-items: center;
  gap: 1.2rem;
}

.garage-tip-primary {
  display: inline-flex;
  align-items: center;
  min-height: 4rem;
  padding: 0 2rem;
  border-radius: 3rem;
  background: #ea3636;
  color: #fff !important;
  font-size: 1.4rem;
  font-weight: 600;
}

.garage-tip-primary:hover {
  filter: brightness(1.08);
}

.garage-tip-close {
  all: unset;
  cursor: pointer;
  min-height: 4rem;
  padding: 0 0.8rem;
  font-size: 1.4rem;
  color: #5b6672;
}

.garage-tip-close:hover {
  color: #2d3643;
}

.garage-tip-primary:focus-visible,
.garage-tip-close:focus-visible {
  outline: 2px solid #ea3636;
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .garage-tip {
    transition: none;
  }
}

/* Aviso "Carro guardado" com o atalho para a garagem */
.compare-toast.garage-toast.is-visible {
  pointer-events: auto;
}

.garage-toast a {
  margin-left: 1.2rem;
  color: #ff6b6b;
  font-weight: 700;
  text-decoration: underline;
}

/* balão acima da aba Garagem da barra do celular: seta embaixo */
.garage-tip.is-above {
  transform: translateY(0.8rem);
}

.garage-tip.is-above.is-visible {
  transform: translateY(0);
}

.garage-tip.is-above::before {
  top: auto;
  bottom: -0.8rem;
}
