/* ==========================================================
   CARRINHO LATERAL
========================================================== */

.cart {
  position: fixed;
  top: 0;
  right: 0;

  width: 390px;
  max-width: 100%;
  height: 100vh;
  height: 100dvh;
  height: var(--cart-viewport-height, 100dvh);

  display: flex;
  flex-direction: column;

  background: #ffffff;

  border-left: 1px solid var(--borda);

  box-shadow:
    -18px 0 50px
    rgba(15, 23, 42, 0.12);

  transform:
    translate3d(
      105%,
      0,
      0
    );

  visibility: hidden;
  pointer-events: none;

  transition:
    transform 0.35s ease,
    visibility 0.35s ease;

  will-change: transform;

  z-index: 9999;
}

.cart.open {
  transform:
    translate3d(
      0,
      0,
      0
    );

  visibility: visible;
  pointer-events: auto;
}

body.cart-is-open {
  overflow: hidden;
}


/* ==========================================================
   TOPO DO CARRINHO
========================================================== */

.cart-top {
  display: flex;
  align-items: center;
  justify-content: space-between;

  gap: 16px;

  flex-shrink: 0;

  padding:
    22px
    20px
    18px;

  background: #ffffff;

  border-bottom:
    1px solid
    var(--borda);
}

.cart-title-main {
  margin: 0;

  color:
    var(--cor-texto-escuro);

  font-size: 21px;
  font-weight: 800;
  line-height: 1.2;
}

.cart-close {
  width: 42px;
  min-width: 42px;
  height: 42px;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  background: #f8fafc;
  color: #64748b;

  border:
    1px solid
    var(--borda);

  border-radius: 14px;

  cursor: pointer;

  transition:
    background-color 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease,
    transform 0.2s ease;
}

.cart-close:hover {
  background:
    var(--cor-principal);

  color: #ffffff;

  border-color:
    var(--cor-principal);

  transform:
    rotate(90deg);
}


/* ==========================================================
   LISTA DE ITENS
========================================================== */

#cartItems {
  flex: 1;

  min-height: 0;

  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;

  padding: 18px;

  background: #f8fafc;
}

#cartItems::-webkit-scrollbar {
  width: 6px;
}

#cartItems::-webkit-scrollbar-track {
  background: transparent;
}

#cartItems::-webkit-scrollbar-thumb {
  background: #cbd5e1;

  border-radius: 999px;
}

#cartItems::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}


/* ==========================================================
   CARD DO ITEM
========================================================== */

.cart-item {
  width: 100%;

  margin-bottom: 14px;

  padding: 16px;

  background: #ffffff;

  border:
    1px solid
    var(--borda);

  border-radius: 18px;

  box-shadow:
    0 7px 20px
    rgba(15, 23, 42, 0.05);

  overflow: hidden;

  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.2s ease;
}

.cart-item:last-child {
  margin-bottom: 0;
}

.cart-item:hover {
  border-color: #cbd5e1;

  box-shadow:
    0 12px 28px
    rgba(15, 23, 42, 0.08);

  transform:
    translateY(-1px);
}

.cart-item-offer {
  border-color:
    rgba(0, 163, 224, 0.22);

  background:
    linear-gradient(
      180deg,
      #ffffff 0%,
      #fbfdff 100%
    );
}


/* ==========================================================
   PARTE SUPERIOR DO ITEM
========================================================== */

.cart-item-top {
  display: grid;

  grid-template-columns:
    78px
    minmax(0, 1fr)
    38px;

  align-items: start;

  column-gap: 14px;
  row-gap: 10px;

  width: 100%;
}


/* ==========================================================
   IMAGEM
========================================================== */

.cart-thumb {
  position: relative;

  width: 78px;
  min-width: 78px;
  height: 78px;

  display: block;

  overflow: hidden;

  background: #eef2f7;

  border:
    1px solid
    var(--borda);

  border-radius: 16px;

  flex-shrink: 0;
}

.cart-thumb-single {
  width: 100%;
  height: 100%;
}

.cart-thumb-single img {
  width: 100%;
  height: 100%;

  display: block;

  object-fit: cover;
}


/* ==========================================================
   MOSAICO DO COMBO
========================================================== */

.cart-combo-images {
  position: absolute;

  inset: 0;

  width: 100%;
  height: 100%;

  display: grid;

  gap: 2px;

  background: #ffffff;
}

.cart-combo-image-item {
  position: relative;

  min-width: 0;
  min-height: 0;

  overflow: hidden;

  background: #e2e8f0;
}

.cart-combo-image-item img {
  width: 100%;
  height: 100%;

  display: block;

  object-fit: cover;
}


/* UMA IMAGEM */

.cart-combo-images-1 {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
}


/* DUAS IMAGENS */

.cart-combo-images-2 {
  grid-template-columns:
    repeat(
      2,
      minmax(0, 1fr)
    );

  grid-template-rows: 1fr;
}


/* TRÊS IMAGENS */

.cart-combo-images-3 {
  grid-template-columns:
    minmax(0, 1.15fr)
    minmax(0, 0.85fr);

  grid-template-rows:
    repeat(
      2,
      minmax(0, 1fr)
    );
}

.cart-combo-images-3
.cart-combo-image-position-1 {
  grid-row: 1 / 3;
}


/* QUATRO IMAGENS */

.cart-combo-images-4 {
  grid-template-columns:
    repeat(
      2,
      minmax(0, 1fr)
    );

  grid-template-rows:
    repeat(
      2,
      minmax(0, 1fr)
    );
}


/* PLACEHOLDER */

.cart-thumb-placeholder {
  width: 100%;
  height: 100%;

  display: flex;
  align-items: center;
  justify-content: center;

  background:
    linear-gradient(
      145deg,
      #f8fafc,
      #e2e8f0
    );

  color: #94a3b8;

  font-size: 20px;
}


/* QUANTIDADE RESTANTE */

.cart-combo-more {
  position: absolute;

  right: 5px;
  bottom: 5px;

  min-width: 25px;
  height: 25px;

  padding:
    0
    6px;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  border:
    1px solid
    #ffffff;

  border-radius: 999px;

  background:
    rgba(15, 23, 42, 0.88);

  color: #ffffff;

  font-size: 9px;
  font-weight: 900;

  z-index: 5;
}


/* ==========================================================
   INFORMAÇÕES DO PRODUTO
========================================================== */

.cart-item-info {
  min-width: 0;

  display: flex;
  flex-direction: column;
  align-items: flex-start;

  gap: 7px;

  padding-top: 2px;
  padding-right: 2px;
}

.cart-name {
  display: -webkit-box;

  width: 100%;

  margin: 0;

  overflow: hidden;

  color:
    var(--cor-texto-escuro);

  font-size: 14px;
  font-weight: 800;
  line-height: 1.4;

  overflow-wrap: anywhere;

  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.cart-unit-price {
  display: block;

  margin: 0;

  color:
    var(--cor-principal);

  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
}

.cart-offer-badge {
  display: inline-flex;
  align-items: center;

  gap: 5px;

  width: fit-content;

  padding:
    5px
    8px;

  background:
    var(--cor-principal-light);

  color:
    var(--cor-principal);

  border:
    1px solid
    rgba(0, 163, 224, 0.18);

  border-radius: 999px;

  font-size: 9px;
  font-weight: 800;
  line-height: 1;

  text-transform: uppercase;
  letter-spacing: 0.05em;
}


/* ==========================================================
   BOTÃO REMOVER
========================================================== */

.cart-remove-btn {
  width: 38px;
  min-width: 38px;
  height: 38px;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  background: #fff1f2;
  color: #e11d48;

  border:
    1px solid
    #ffe4e6;

  border-radius: 12px;

  cursor: pointer;

  transition:
    background-color 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease,
    transform 0.2s ease;
}

.cart-remove-btn:hover {
  background: #e11d48;
  color: #ffffff;

  border-color: #e11d48;

  transform:
    translateY(-2px);
}

.cart-remove-btn:active {
  transform:
    translateY(0);
}


/* ==========================================================
   PRODUTOS DA OFERTA
========================================================== */

.cart-offer-products {
  margin-top: 16px;

  padding:
    13px
    14px;

  background: #f8fafc;

  border:
    1px solid
    var(--borda);

  border-radius: 14px;
}

.cart-offer-products
.cart-section-label {
  margin-bottom: 9px;
}

.cart-offer-products-list {
  display: flex;
  flex-direction: column;

  gap: 7px;
}

.cart-offer-product {
  display: flex;
  align-items: flex-start;

  gap: 7px;

  color:
    var(--cor-texto-escuro);

  font-size: 11px;
  font-weight: 650;
  line-height: 1.4;
}

.cart-offer-product i {
  flex-shrink: 0;

  margin-top: 2px;

  color: #16a34a;

  font-size: 10px;
}


/* ==========================================================
   SEÇÃO DAS DATAS
========================================================== */

.cart-dates-section {
  margin-top: 16px;

  padding-top: 14px;

  border-top:
    1px solid
    var(--borda);
}

.cart-dates-header {
  display: flex;
  align-items: center;
  justify-content: space-between;

  gap: 10px;

  margin-bottom: 10px;
}

.cart-section-label {
  display: block;

  margin: 0;

  color:
    var(--cor-texto-mutado);

  font-size: 10px;
  font-weight: 800;

  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.cart-days-count {
  flex-shrink: 0;

  padding:
    4px
    8px;

  background: #fff7ed;
  color:
    var(--cor-laranja);

  border:
    1px solid
    #fed7aa;

  border-radius: 999px;

  font-size: 10px;
  font-weight: 800;
  line-height: 1;
}


/* ==========================================================
   LISTA DE DATAS
========================================================== */

.cart-dates-list {
  display: flex;
  flex-wrap: wrap;

  gap: 7px;

  width: 100%;
  min-width: 0;
}

.cart-date-chip {
  display: inline-flex;
  align-items: center;

  gap: 5px;

  max-width: 100%;

  padding:
    7px
    9px;

  background:
    var(--cor-principal-light);

  color:
    var(--cor-principal);

  border:
    1px solid
    rgba(0, 163, 224, 0.2);

  border-radius: 9px;

  font-size: 10px;
  font-weight: 700;
  line-height: 1;

  white-space: nowrap;
}

.cart-date-chip i {
  flex-shrink: 0;

  font-size: 10px;
}

.cart-date-empty {
  color:
    var(--cor-texto-mutado);

  font-size: 12px;
  font-weight: 500;
}


/* ==========================================================
   PARTE INFERIOR DO ITEM
========================================================== */

.cart-item-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;

  gap: 14px;

  margin-top: 16px;

  padding-top: 15px;

  border-top:
    1px solid
    var(--borda);
}


/* ==========================================================
   CONTROLE DE QUANTIDADE
========================================================== */

.cart-quantity {
  display: inline-flex;
  align-items: center;

  gap: 5px;

  flex-shrink: 0;

  padding: 4px;

  background: #f8fafc;

  border:
    1px solid
    var(--borda);

  border-radius: 13px;
}

.cart-quantity-btn {
  width: 32px;
  min-width: 32px;
  height: 32px;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  background: #ffffff;
  color:
    var(--cor-texto-escuro);

  border:
    1px solid
    var(--borda);

  border-radius: 9px;

  cursor: pointer;

  transition:
    background-color 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease,
    transform 0.2s ease;
}

.cart-quantity-btn:hover {
  background:
    var(--cor-rosa);

  color: #ffffff;

  border-color:
    var(--cor-rosa);

  transform:
    translateY(-1px);
}

.cart-quantity-btn:active {
  transform:
    translateY(0);
}

.cart-quantity-btn i {
  font-size: 10px;
}

.cart-qty-value {
  min-width: 26px;

  color:
    var(--cor-texto-escuro);

  text-align: center;

  font-size: 14px;
  font-weight: 800;
}


/* ==========================================================
   SUBTOTAL DO ITEM
========================================================== */

.cart-item-total {
  min-width: 0;

  text-align: right;
}

.cart-item-total small {
  display: block;

  margin-bottom: 4px;

  color:
    var(--cor-texto-mutado);

  font-size: 10px;
  font-weight: 700;
}

.cart-item-total strong {
  display: block;

  color:
    var(--cor-texto-escuro);

  font-size: 15px;
  font-weight: 900;
  line-height: 1.25;

  white-space: nowrap;
}


/* ==========================================================
   CARRINHO VAZIO
========================================================== */

#cartEmpty {
  flex: 1 1 auto;

  min-height: 0;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  overflow-y: auto;

  padding:
    40px
    28px;

  text-align: center;
}

#cartItems:empty {
  display: none;
}

#cartEmpty[style*="display: none"] {
  flex: 0;
}

.cart-empty-icon {
  width: 110px;
  height: 110px;

  display: flex;
  align-items: center;
  justify-content: center;

  margin-bottom: 22px;

  background:
    linear-gradient(
      135deg,
      rgba(0, 163, 224, 0.12),
      rgba(0, 163, 224, 0.05)
    );

  border:
    2px solid
    rgba(0, 163, 224, 0.15);

  border-radius: 50%;
}

.cart-empty-icon i {
  color:
    var(--cor-principal);

  font-size: 44px;
}

.cart-empty-badge {
  margin-bottom: 14px;

  padding:
    7px
    14px;

  background: #fff7ed;
  color:
    var(--cor-laranja);

  border:
    1px solid
    #fed7aa;

  border-radius: 999px;

  font-size: 11px;
  font-weight: 800;

  letter-spacing: 0.04em;

  text-transform: uppercase;
}

.cart-empty-title {
  margin:
    0
    0
    10px;

  color:
    var(--cor-texto-escuro);

  font-size: 23px;
  font-weight: 800;
}

.cart-empty-text {
  max-width: 270px;

  margin:
    0
    0
    28px;

  color:
    var(--cor-texto-mutado);

  font-size: 14px;
  line-height: 1.7;
}

.cart-empty-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  gap: 10px;

  padding:
    14px
    24px;

  background:
    var(--cor-principal);

  color: #ffffff;

  border: none;

  border-radius: 14px;

  font-size: 14px;
  font-weight: 700;

  cursor: pointer;

  transition:
    transform 0.25s ease,
    box-shadow 0.25s ease;
}

.cart-empty-btn:hover {
  transform:
    translateY(-2px);

  box-shadow:
    0 12px 25px
    rgba(0, 163, 224, 0.25);
}

.cart-empty-btn i {
  font-size: 15px;
}


/* ==========================================================
   RODAPÉ DO CARRINHO
========================================================== */

.cart-footer {
  flex-shrink: 0;

  padding:
    18px
    20px
    calc(
      20px +
      env(safe-area-inset-bottom, 0px)
    );

  background: #ffffff;

  border-top:
    1px solid
    var(--borda);

  box-shadow:
    0 -10px 30px
    rgba(15, 23, 42, 0.05);
}


/* ==========================================================
   TOTAL GERAL
========================================================== */

.cart-total {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;

  gap: 12px;

  margin-bottom: 16px;
}

.cart-total span {
  color:
    var(--cor-texto-mutado);

  font-size: 13px;
  font-weight: 700;
}

.cart-total strong {
  color:
    var(--cor-texto-escuro);

  font-size: 25px;
  font-weight: 900;
  line-height: 1;

  white-space: nowrap;
}


/* ==========================================================
   BOTÃO FINALIZAR
========================================================== */

.send-btn {
  width: 100%;

  min-height: 54px;

  display: flex;
  align-items: center;
  justify-content: center;

  gap: 10px;

  padding:
    12px
    18px;

  background:
    var(--cor-principal);

  color: #ffffff;

  border: none;

  border-radius: 16px;

  box-shadow:
    0 12px 24px
    rgba(0, 163, 224, 0.2);

  font-size: 15px;
  font-weight: 800;

  cursor: pointer;

  transition:
    background-color 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.2s ease;
}

.send-btn:hover {
  box-shadow:
    0 16px 30px
    rgba(0, 163, 224, 0.28);

  transform:
    translateY(-2px);
}

.send-btn:active {
  transform:
    translateY(0);
}

.send-btn:disabled {
  background: #cbd5e1;
  color: #ffffff;

  box-shadow: none;

  cursor: not-allowed;

  opacity: 0.7;

  transform: none;
}

.send-btn i {
  transition:
    transform 0.2s ease;
}

.send-btn:hover i {
  transform:
    translateX(4px);
}


/* ==========================================================
   TABLET
========================================================== */

@media (max-width: 768px) {
  .cart {
    width: 380px;
  }

  #cartItems {
    padding: 16px;
  }
}


/* ==========================================================
   MOBILE
========================================================== */

@media (max-width: 480px) {
  .cart {
    width: 100%;
    max-width: none;

    height: 100dvh;
    height: var(
      --cart-viewport-height,
      100dvh
    );

    border-left: none;
  }

  .cart-top {
    padding:
      18px
      16px
      15px;
  }

  .cart-title-main {
    font-size: 19px;
  }

  #cartItems {
    padding: 14px;
  }

  .cart-item {
    padding: 14px;

    border-radius: 16px;
  }

  .cart-item-top {
    grid-template-columns:
      64px
      minmax(0, 1fr)
      36px;

    column-gap: 11px;
  }

  .cart-thumb {
    width: 64px;
    min-width: 64px;
    height: 64px;

    border-radius: 13px;
  }

  .cart-item-info {
    gap: 6px;
  }

  .cart-name {
    font-size: 13px;
    line-height: 1.35;
  }

  .cart-unit-price {
    font-size: 11px;
  }

  .cart-remove-btn {
    width: 36px;
    min-width: 36px;
    height: 36px;
  }

  .cart-offer-products {
    margin-top: 14px;

    padding:
      12px
      13px;
  }

  .cart-date-chip {
    padding:
      6px
      7px;

    font-size: 10px;
  }

  .cart-item-bottom {
    gap: 10px;
  }

  .cart-quantity-btn {
    width: 30px;
    min-width: 30px;
    height: 30px;
  }

  .cart-item-total strong {
    font-size: 14px;
  }

  #cartEmpty {
    justify-content: center;

    padding:
      20px
      20px
      24px;
  }

  .cart-empty-icon {
    width: 82px;
    height: 82px;

    margin-bottom: 14px;
  }

  .cart-empty-icon i {
    font-size: 34px;
  }

  .cart-empty-badge {
    margin-bottom: 10px;

    padding:
      6px
      11px;

    font-size: 9px;
  }

  .cart-empty-title {
    margin-bottom: 7px;

    font-size: 19px;
  }

  .cart-empty-text {
    max-width: 280px;

    margin-bottom: 18px;

    font-size: 13px;
    line-height: 1.5;
  }

  .cart-empty-btn {
    padding:
      12px
      20px;
  }

  .cart-footer {
    padding:
      14px
      16px
      calc(
        14px +
        env(safe-area-inset-bottom, 0px)
      );
  }

  .cart-total strong {
    font-size: 22px;
  }

  .send-btn {
    min-height: 52px;

    font-size: 14px;
  }
}


/* ==========================================================
   CELULARES PEQUENOS
========================================================== */

@media (max-width: 350px) {
  .cart-item-top {
    grid-template-columns:
      56px
      minmax(0, 1fr)
      34px;

    column-gap: 9px;
  }

  .cart-thumb {
    width: 56px;
    min-width: 56px;
    height: 56px;
  }

  .cart-remove-btn {
    width: 34px;
    min-width: 34px;
    height: 34px;
  }

  .cart-dates-header {
    align-items: flex-start;
    flex-direction: column;

    gap: 6px;
  }

  .cart-item-bottom {
    align-items: stretch;
    flex-direction: column;
  }

  .cart-quantity {
    justify-content: space-between;
  }

  .cart-item-total {
    text-align: left;
  }
}


/* ==========================================================
   SEGURANÇA DE ABERTURA E LAYOUT
========================================================== */

.cart,
.cart *,
.cart *::before,
.cart *::after {
  box-sizing: border-box;
}

.cart[aria-hidden="true"] {
  visibility: hidden;
}

.cart[aria-hidden="false"] {
  visibility: visible;
}

.cart-footer {
  position: relative;
  z-index: 2;
}

.cart-empty,
#cartEmpty {
  width: 100%;
}


/* ==========================================================
   AJUSTE PARA BARRAS DO NAVEGADOR MOBILE
========================================================== */

@supports (height: 100dvh) {
  .cart {
    height: 100dvh;
  }
}

@supports not (height: 100dvh) {
  .cart {
    height: var(
      --cart-viewport-height,
      100vh
    );
  }
}

.cart-top,
.cart-footer {
  position: relative;
  flex: 0 0 auto;
}

#cartItems,
#cartEmpty {
  min-height: 0;
}

.cart-footer {
  margin-top: auto;
  padding-bottom:
    max(
      20px,
      calc(
        14px +
        env(
          safe-area-inset-bottom,
          0px
        )
      )
    );
}

@media (max-width: 480px) {
  .cart-footer {
    padding-bottom:
      max(
        14px,
        calc(
          12px +
          env(
            safe-area-inset-bottom,
            0px
          )
        )
      );
  }
}

@media (prefers-reduced-motion: reduce) {
  .cart {
    transition: none;
  }
}
