:root {
  --primary: #FF6B35;
  --primary-light: #FF9E56;
  --primary-dark: #E65100;
  --text: #2D2D2D;
  --text-light: #6D6D6D;
  --bg: #F8F9FA;
  --card-bg: #FFFFFF;
  --border: #EAEAEA;
  --success: #4CAF50;
  --shadow-sm: 0 2px 12px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --safe-bottom: env(safe-area-inset-bottom, 0px); /* Adicionado para corrigir overlap com barra de navegação mobile */
}

/* Estrutura Base - Modificada para travar scroll da página */
html.modal-open {
  overflow: hidden;
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease;
  overflow: hidden;
  /* Impede scroll na página de fundo */
}

.modal-overlay.active {
  display: block;
  opacity: 1;
  overflow: hidden;
  /* Garante que não terá scroll */
}

.modal-sacola {
  position: fixed;
  top: 0;
  right: -100%;
  width: 100%;
  max-width: 420px;
  height: 100vh;
  background: var(--card-bg);
  box-shadow: var(--shadow-md);
  z-index: 1001;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* Container principal sem scroll */
}

.modal-sacola.active {
  right: 0;
}

.modal-content {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* Container do conteúdo sem scroll */
  max-height: 100vh; /* Adicionado para prevenir overflow além da tela */
}

/* Cabeçalho */
.custom-modal-header {
  padding: 1.25rem 1.5rem;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
  /* Impede que o cabeçalho diminua */
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
  color: white;
  display: flex;
  align-items: center;
}

.btn-close-white {
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  opacity: 0.8;
  transition: var(--transition);
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.btn-close-white:hover {
  opacity: 1;
  transform: rotate(90deg);
}

/* Corpo do Modal - Área rolável */
.modal-body {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
  background: var(--bg);
  scrollbar-width: thin;
  scrollbar-color: var(--primary) transparent;
  display: flex;
  /* Novo */
  flex-direction: column;
  /* Novo */
  position: relative;
  /* Novo */
}

.modal-body::-webkit-scrollbar {
  width: 6px;
}

.modal-body::-webkit-scrollbar-thumb {
  background-color: var(--primary);
  border-radius: 3px;
}

/* Itens da Sacola */
#sacola-items {
  display: flex;
  /* Já estava flex */
  flex-direction: column;
  /* Já estava */
  gap: 1rem;
  /* Já estava */
  flex: 1;
  /* Novo - ocupa espaço disponível */
}

.sacola-item {
  display: flex;
  padding: 1rem;
  background: var(--card-bg);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  gap: 1rem;
  position: relative;
}

.sacola-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.sacola-item img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

.item-info {
  flex: 1;
}

.item-info h6 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.item-info p {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: 0.25rem;
}

.item-actions {
  display: flex;
  align-items: center;
}

.item-actions button {
  display: flex;
  align-items: center;
  justify-content: center;
}

.item-actions .btn-outline-secondary {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  color: var(--text-light);
  transition: var(--transition);
}

.item-actions .btn-outline-secondary:hover {
  background-color: #e0e0e0;
  color: var(--primary);
}

.item-actions .mx-2 {
  min-width: 24px;
  text-align: center;
  font-weight: 500;
}

.item-actions .btn-danger {
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.item-actions .btn-danger:hover {
  background-color: #dc3545;
  border-color: #dc3545;
}

/* Mensagem Sacola Vazia */
#sacola-vazia {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
  color: var(--text-light);
  text-align: center;
  position: absolute;
  /* Novo */
  top: 0;
  /* Novo */
  left: 0;
  /* Novo */
  padding: 1.5rem;
  /* Novo - igual ao modal-body */
}

#sacola-vazia i {
  font-size: 3rem;
  color: var(--primary-light);
  margin-bottom: 1rem;
  opacity: 0.7;
}

#sacola-vazia p {
  font-size: 1.1rem;
  margin-bottom: 1.5rem;
}

/* Rodapé */
.modal-footer {
  padding: 1.5rem;
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  flex-shrink: 0;
  /* Impede que o rodapé diminua */
}

.modal-footer h5 {
  font-size: 1.1rem;
  color: var(--text-light);
  margin-bottom: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#total-sacola {
  color: var(--primary);
  font-weight: 700;
}

.btn-finalizar-compra {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border: none;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 12px rgba(255, 107, 53, 0.3);
  width: 100%;
  text-align: center;
}

.btn-finalizar-compra:hover {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(255, 107, 53, 0.4);
}

.btn-continuar-comprando {
  background: white;
  color: var(--primary);
  border: 1px solid var(--primary);
  padding: 0.5rem 1.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  display: none;
  /* Escondido por padrão, visível apenas no mobile */
}

.btn-continuar-comprando:hover {
  background: var(--primary);
  color: white;
}

/* Responsividade */
@media (max-width: 480px) {
  .modal-sacola {
    max-width: 100%;
    border-radius: 0;
  }

  .custom-modal-header {
    padding: 1rem;
    text-align: center;
  }

  .modal-body {
    padding: 1rem;
  }

  .sacola-item {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: center;
    text-align: center;
    padding: 1rem 0.5rem;
  }

  .sacola-item img {
    width: 80px;
    height: 80px;
  }

  .item-info {
    width: 100%;
    text-align: center;
  }

  .item-actions {
    justify-content: center;
    margin-top: 0.5rem;
    width: 100%;
  }

  .item-actions .btn-outline-secondary,
  .item-actions .btn-danger {
    margin: 0 4px;
  }

  .modal-footer {
    padding: 1rem;
    padding-bottom: calc(1rem + var(--safe-bottom)); /* Adicionado para corrigir overlap com barra de navegação mobile */
    text-align: center;
  }

  .modal-footer h5 {
    justify-content: space-around;
  }

  .btn-finalizar-compra {
    max-width: 90%;
    margin: 0 auto;
    margin-bottom: var(--safe-bottom); /* Adicionado opcionalmente para espaçamento extra no botão */
  }

  .btn-continuar-comprando {
    display: block;
    max-width: 90%;
    margin: 0 auto;
    margin-bottom: var(--safe-bottom); /* Adicionado para o botão continuar comprando */
  }
}

/* Animações */
@keyframes slideIn {
  from {
    transform: translateX(100%);
  }

  to {
    transform: translateX(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.modal-sacola.active {
  animation: slideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.active {
  animation: fadeIn 0.3s ease-out;
}

