@import url("https://fonts.googleapis.com/css2?family=Jost:wght@400;500;600&display=swap");

:root {
  --color1: #364A73;
  --color2: #8C3037;
  --color3: #533745;
  --color4: #9d9171;
  --color5: #c4a287;
  --color6: #4a646c;
  --color7: #333;
  --color8: #fff;
  --transition: all 0.3s ease-in-out;
}

* {
  font-family: "Jost", sans-serif;
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}

body {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 30px;
  min-height: 100vh;
}

/* prevent body scroll when cart is open */
body:has(.show) {
  overflow: hidden;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 3px;
  padding: 3px 10px;
  transition: var(--transition);
}

img {
  width: 100%;
  height: auto;
  display: block;
}

nav {
  background: var(--color1);
  color: var(--color8);
  padding-block: 20px;
}

nav > .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  text-transform: uppercase;
}

.cart-btn {
  padding: 3px 8px;
  background: transparent;
  color: inherit;
  position: relative;
}

.cart-btn .bi {
  font-size: 1.5rem;
}

.cart-btn:hover {
  background: var(--color5);
}

.cart-qty {
  position: absolute;
  top: 0;
  right: 0;
  transform: translate(50%, -50%);
  background: var(--color7);
  padding: 0 5px;
  border-radius: 3px;
  display: none;
}

.cart-qty.visible {
  display: block;
}

.container {
  max-width: 1200px;
  width: 90%;
  margin: auto;
}

.products {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
}

.product {
  text-align: center;
  position: relative;
}

.product img {
  height: 250px;
  object-fit: contain;
}

.product:hover img {
  opacity: 0.75;
}

.product h3 {
  margin-top: 10px;
  color: var(--color4);
  font-size: 1rem;
}

.product h5 {
  margin-top: 5px;
  color: var(--color6);
}

.product button {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--color1);
  color: var(--color8);
  padding: 5px 10px;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 5px;
  opacity: 0;
}

.product:hover button {
  opacity: 1;
}

.product button::before {
  font-family: "bootstrap-icons";
  font-size: 1.5rem;
  content: "\F23F";
}

.product button:disabled::before {
  content: "\F23A";
}

.product button:hover {
  background: var(--color2);
}

.product button:disabled {
  background: var(--color3);
  filter: brightness(1.75);
}

/* cart */

.cart-overlay {
  position: fixed;
  inset: 0;
  opacity: 0.5;
  visibility: hidden;
  cursor: pointer;
  background: var(--color7);
  transition: var(--transition);
}

.cart-overlay.show {
  visibility: visible;
}

.cart {
  position: fixed;
  top: 0;
  inset-block: 0;
  right: 0;
  width: 100%;
  max-width: 420px;
  padding: 20px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  transform: translateX(100%);
  transition: var(--transition);
  background: var(--color8);
}

.cart.show {
  transform: none;
}

.cart-header {
  position: relative;
  text-align: center;
  padding-block: 10px;
  border-bottom: 1px solid #ddd;
}

.cart-close {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.5rem;
  cursor: pointer;
}

.cart-body {
  display: grid;
  align-content: start;
  gap: 20px;
  padding-block: 20px;
  overflow: auto;
}

/* hide footer if the cart is empty */
.cart-body:has(.cart-empty) + .cart-footer {
  display: none;
}

.cart-empty {
  text-align: center;
  padding-block: 20px;
  font-size: 1.25rem;
  color: var(--color6);
}

.cart-item {
  display: flex;
  gap: 10px;
}

.cart-item img {
  width: 100px;
  height: 100px;
  object-fit: contain;
}

.cart-item-detail {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.cart-item-detail h3 {
  font-size: 1rem;
  color: var(--color4);
}

.cart-item-detail h5 {
  color: var(--color6);
}

.cart-item-amount {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.25rem;
}

.cart-item-amount .bi {
  cursor: pointer;
  opacity: 0.25;
}

.cart-item-amount .bi:hover {
  opacity: 1;
}

.cart-item-amount .qty {
  width: 2rem;
  text-align: center;
}

.cart-item-price {
  margin-left: auto;
}

.cart-footer {
  border-top: 1px solid #ddd;
  padding-block: 10px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.cart-footer div {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 1.25rem;
}

.cart-footer strong {
  font-weight: 500;
  color: var(--color4);
}

.cart-footer button {
  padding-block: 10px;
  text-transform: uppercase;
}

.cart-clear {
  background: var(--color7);
  color: var(--color8);
}

.cart-clear:hover {
  filter: brightness(1.75);
}

.checkout {
  background: var(--color1);
  color: var(--color8);
}

.checkout:hover {
  background: var(--color2);
}

/* ================== Product Detail Page ================== */

.product-detail {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
  max-width: 1000px;
  margin: 40px auto;
}

.product-detail .gallery {
  display: grid;
  gap: 10px;
}

.product-detail .main-img {
  width: 100%;
  max-height: 500px;
  object-fit: contain;
  border: 1px solid #eee;
  border-radius: 8px;
  padding: 10px;
}

.product-detail .thumbs {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.product-detail .thumbs img {
  width: 80px;
  height: 80px;
  object-fit: contain;
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: 4px;
  transition: var(--transition);
}

.product-detail .thumbs img:hover {
  border-color: var(--color1);
}

.product-info {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.product-info h1 {
  font-size: 1.8rem;
  color: var(--color4);
}

.product-info h3 {
  font-size: 1.4rem;
  color: var(--color6);
}

.product-info label {
  font-weight: 500;
  margin-top: 10px;
}

.product-info select,
.product-info input {
  padding: 8px;
  border-radius: 4px;
  border: 1px solid #ccc;
  width: 150px;
}

.product-info button {
  background: var(--color1);
  color: var(--color8);
  padding: 10px;
  font-size: 1rem;
  text-transform: uppercase;
  margin-top: 15px;
  width: 200px;
  display: flex;
  align-items: center;
  gap: 5px;
  justify-content: center;
}

.product-info button:hover {
  background: var(--color2);
}

/* Responsividade */
@media (max-width: 900px) {
  .product-detail {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  .product-info button {
    width: 100%;
  }
  .product-info select,
  .product-info input {
    width: 100%;
  }
}
 /* Correção para abrir o carrinho */
    .cart, .cart-overlay {
      opacity: 0;
      visibility: hidden;
      transition: all 0.3s ease;
    }
    .cart.show, .cart-overlay.show {
      opacity: 1;
      visibility: visible;
    }
    .cart {
      position: fixed;
      top: 0;
      right: -400px;
      width: 350px;
      height: 100%;
      background: #fff;
      box-shadow: -2px 0 6px rgba(0,0,0,0.2);
      transition: right 0.3s ease, opacity 0.3s ease;
      z-index: 1001;
      display: flex;
      flex-direction: column;
    }
    .cart.show { right: 0; }
    .cart-overlay {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: rgba(0,0,0,0.5);
      z-index: 1000;
    }
    .cart-header, .cart-footer { padding: 15px; border-bottom: 1px solid #ddd; }
    .cart-body { flex: 1; overflow-y: auto; padding: 15px; }
    .cart-item { display: flex; align-items: center; margin-bottom: 15px; }
    .cart-item img { width: 60px; height: 60px; object-fit: cover; margin-right: 10px; border-radius: 6px; }
    .cart-item-detail h3 { font-size: 14px; margin: 0 0 5px; }
    .cart-item-detail h5 { font-size: 13px; margin: 0 0 8px; }
    .cart-item-amount { display: flex; align-items: center; gap: 6px; }
    .cart-item-amount i { cursor: pointer; font-size: 16px; }
    .cart-empty { text-align: center; color: #777; padding: 30px 0; }
    .cart-qty.visible { display: inline-block; }
    
    /* ============================
   Checkout form (dentro do cart)
   ===========================*/

/* garante que o form ocupe a linha inteira do grid do cart-footer */
.cart-footer .checkout-form {
  grid-column: 1 / -1;
  display: block;
  margin-top: 12px;
  padding: 12px;
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #fafafa 100%);
  box-shadow: 0 6px 18px rgba(20,20,20,0.06);
  border: 1px solid rgba(0,0,0,0.04);
}

/* cabeçalho pequeno do form */
.cart-footer .checkout-form h5 {
  margin: 0 0 8px 0;
  font-size: 0.95rem;
  color: var(--color7);
  font-weight: 600;
  text-align: left;
}

/* inputs — estilo consistente com .product-info, porém mais compacto */
.cart-footer .checkout-form .form-control,
.cart-footer .checkout-form input {
  width: 100%;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid #e6e6e6;
  background: #fff;
  color: #222;
  font-size: 0.95rem;
  margin-bottom: 8px;
  box-sizing: border-box;
}

/* destaque ao focar */
.cart-footer .checkout-form .form-control:focus,
.cart-footer .checkout-form input:focus {
  outline: none;
  border-color: rgba(54,74,115,0.9); /* var(--color1) */
  box-shadow: 0 4px 10px rgba(54,74,115,0.06);
}

/* campos em linha — nome/telefone e email/cep ficam lado a lado em telas largas */
.cart-footer .checkout-form .row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 4px;
}

/* botão de envio */
.cart-footer .checkout-form .btn {
  width: 100%;
  padding: 10px;
  background: var(--color1);
  color: var(--color8);
  border-radius: 6px;
  font-weight: 600;
  border: none;
  margin-top: 6px;
  transition: var(--transition);
}

.cart-footer .checkout-form .btn:hover {
  background: var(--color2);
}

/* versão compacta quando o footer está com pouco espaço (ex: mobile) */
@media (max-width: 640px) {
  .cart-footer {
    grid-template-columns: 1fr; /* garante coluna única */
  }
  .cart-footer .checkout-form .row {
    grid-template-columns: 1fr;
  }
  .cart-footer .checkout-form {
    padding: 10px;
  }
}

/* pequenos ajustes que não interferem em outros componentes */
.cart-footer .checkout-form .hint {
  font-size: 0.85rem;
  color: #666;
  margin-top: 6px;
  display: block;
  text-align: center;
}

/* ============================
   🛒 CARRINHO AJUSTADO E UNIFICADO
   ===========================*/

.cart-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  z-index: 1000;
}

.cart-overlay.show {
  opacity: 1;
  visibility: visible;
}

.cart {
  position: fixed;
  top: 0;
  right: -400px;
  width: 350px;
  height: 100%;
  background: #fff;
  box-shadow: -2px 0 6px rgba(0,0,0,0.2);
  transition: right 0.3s ease, opacity 0.3s ease;
  z-index: 1001;

  /* NOVO: rolagem total */
  overflow-y: auto;
  overflow-x: hidden;

  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
}

.cart.show {
  right: 0;
  opacity: 1;
  visibility: visible;
}

/* barra de rolagem estilizada */
.cart::-webkit-scrollbar {
  width: 8px;
}

.cart::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.cart::-webkit-scrollbar-thumb {
  background-color: #bbb;
  border-radius: 6px;
}

.cart::-webkit-scrollbar-thumb:hover {
  background-color: #888;
}

/* estrutura interna */
.cart-header, .cart-footer {
  padding: 15px;
  border-bottom: 1px solid #ddd;
}

.cart-body {
  padding: 15px;
}

.cart-item {
  display: flex;
  align-items: center;
  margin-bottom: 15px;
}

.cart-item img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  margin-right: 10px;
  border-radius: 6px;
}

.cart-item-detail h3 {
  font-size: 14px;
  margin: 0 0 5px;
  color: var(--color4);
}

.cart-item-detail h5 {
  font-size: 13px;
  margin: 0 0 8px;
  color: var(--color6);
}

.cart-item-amount {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cart-item-amount i {
  cursor: pointer;
  font-size: 16px;
  opacity: 0.5;
  transition: opacity 0.2s;
}

.cart-item-amount i:hover {
  opacity: 1;
}

.cart-empty {
  text-align: center;
  color: #777;
  padding: 30px 0;
  font-size: 1.1rem;
}

.cart-qty.visible {
  display: inline-block;
}

