/* ===============================================
   MARKET PRODUCTS - BEM METHODOLOGY
   Prefixo: market-
   Layout: Por categorias com scroll horizontal
   =============================================== */

:root {
  --market-primary: var(--padrao);
  --market-background: #f0f0ef;
  --market-white: #fff;
  --market-text-primary: #3e3e3e;
  --market-text-secondary: #717171;
  --market-border: #f2f2f2;
  --market-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  --market-shadow-hover: 0 8px 16px rgba(0, 0, 0, 0.1);
  --market-radius: 12px;
  --market-radius-sm: 8px;
}

/* ===============================================
   WRAPPER E LAYOUT PRINCIPAL
   =============================================== */
.market-wrapper {
  width: 100%;
  margin-top: 10px;
  background-color: var(--market-white);
}

/* Layout flex responsivo: mobile coluna, desktop linha com sidebar -->*/
.market-container {
  display: flex;
  gap: 0;
  max-width: 90%;
  margin: 0 auto;
}

/* ===============================================
   SEARCH SECTION - FIXA NO TOPO
   =============================================== */
.market-search-section {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--market-white);
  padding: 8px 0;
  transition: box-shadow 0.3s ease;
}
.market-search-input {
  width: 100%;
  padding: 10px 14px 10px 40px;
  font-size: 12px;
  border: 1px solid var(--market-border);
  border-radius: var(--market-radius);
  background-color: var(--market-background);
  color: var(--market-text-primary);
  font-family: Poppins, sans-serif;
  transition: all 0.3s ease;
  max-width: 100%;
}
.market-search-input:focus {
  outline: none;
  border-color: var(--market-primary);
  box-shadow: 0 0 0 3px rgba(var(--padrao-rgb), 0.05);
}
.market-search-input::placeholder {
  color: var(--market-text-secondary);
}
.market-search-icon {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--market-primary);
  font-size: 18px;
  pointer-events: none;
}

/* ===============================================
   SIDEBAR - APENAS DESKTOP
   =============================================== */
.market-sidebar {
  display: none;
  width: 220px;
  padding: 12px 8px;
  background-color: var(--market-white);
  border-right: 1px solid var(--market-border);
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
  overflow-y: auto;
  flex-shrink: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--market-border) transparent;
}
.market-categories-sidebar {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-right: 4px;
}
.market-category-link {
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 500;
  color: var(--market-text-primary);
  background-color: transparent;
  border: none;
  border-radius: var(--market-radius-sm);
  cursor: pointer;
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background-color 0.2s ease, color 0.2s ease, transform 0.15s ease;
}
.market-category-link:hover {
  background-color: #fafafa;
  color: var(--market-primary);
  transform: translateX(2px);
}
.market-category-link--active {
  background-color: var(--market-primary);
  color: var(--market-white);
  box-shadow: var(--market-shadow);
}
.market-category-badge {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 12px;
  background-color: #f0f0f0;
  color: var(--market-text-secondary);
  font-weight: 500;
}
.market-category-link--active .market-category-badge {
  background-color: rgba(255, 255, 255, 0.25);
  color: var(--market-white);
}

/* ===============================================
   MAIN CONTENT
   =============================================== */
.market-main {
  flex: 1;
  margin: auto;
  padding: 20px 16px;
  padding-top: 70px;
  width: 100%;
}

/* ===============================================
   ABAS DE CATEGORIAS - MOBILE (ESTILO MENU FIXO)
   =============================================== */
.market-categories-tabs {
  position: sticky;
  top: 38px;
  z-index: 4;
  width: 100%;
  display: flex;
  align-items: center;
  overflow-x: auto;
  white-space: nowrap;
  background-color: var(--background-white);
  border-bottom: 1px solid var(--market-border);
  box-shadow: 0 4px 4px -2px rgba(0, 0, 0, 0.05);
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  gap: 0;
  margin: 0;
  left: 0;  /* ← garante alinhamento total à esquerda */
  right: 0; /* ← garante alinhamento total à direita */
}
.market-categories-tabs::-webkit-scrollbar {
  display: none;
}

/* Cada aba */
.market-tab {
  display: inline-block;
  padding: 14px 12px;
  font-family: var(--fonte);
  font-size: 14px;
  font-weight: 400;
  color: var(--market-text-secondary);
  background: none;
  border: none;
  border-radius: 0;
  cursor: pointer;
  transition: color 0.2s ease;
  position: relative;
  white-space: nowrap;
  flex-shrink: 0;
}
.market-tab:hover {
  color: var(--market-primary);
}
.market-tab--active {
  color: var(--market-primary);
  font-weight: 600;
}
.market-tab--active::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  width: 100%;
  background-color: var(--market-primary);
  border-radius: 0;
  transition: all 0.3s ease;
}

/* ===============================================
   CATEGORIAS WRAPPER
   =============================================== */
.market-categories-wrapper {
  display: flex;
  flex-direction: column;
  gap: 32px;
  margin-top: 8px;
}

/* ===============================================
   CATEGORIA - market-category
   =============================================== */
.market-category {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.market-category:not(:first-child) {
  border-top: 1px solid var(--market-border, #e0e0e0);
  padding-top: 8px;
}

/* Header da categoria */
.market-category__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.market-category__header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 1;
  gap: 12px;
}

.market-category__expand-btn {
  background: none;
  border: none;
  color: var(--market-primary);
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  padding: 6px 0;
  transition: color 0.2s ease;
  white-space: nowrap;
}
.market-category__expand-btn::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 0;
  height: 2px;
  background-color: currentColor;
  transition: width 0.25s ease;
}
.market-category__expand-btn:hover {
  color: var(--market-primary);
}
.market-category__expand-btn:hover::after {
  width: 100%;
}
.market-category__expand-btn:active {
  opacity: 0.8;
  transform: none;
  box-shadow: none;
}

.market-category__title {
  font-size: 14px;
  font-weight: 700;
  color: var(--market-text-primary);
  margin: 0;
  font-family: Poppins, sans-serif;
}
.market-category__count {
  font-size: 10px;
  color: var(--market-text-secondary);
  background-color: #f5f5f5;
  padding: 4px 12px;
  border-radius: 20px;
}

/* Container com scroll horizontal para produtos */
.market-category__scroll-container {
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  gap: 12px;

  /* o segredo do equilíbrio */
  padding: 8px 16px 8px 16px; /* padding horizontal mais folgado */
  margin: 0 -16px; /* compensa o padding do wrapper externo */
  scroll-padding-left: 16px; /* garante o início alinhado */
  scroll-padding-right: 16px;
}
.market-category__scroll-container::-webkit-scrollbar {
  height: 2px;
}
.market-category__scroll-container::-webkit-scrollbar-track {
  background: transparent;
}
.market-category__scroll-container::-webkit-scrollbar-thumb {
  background: var(--market-background);
  border-radius: 2px;
}
.market-category__scroll-container::-webkit-scrollbar-thumb:hover {
  background: var(--market-text-secondary);
}

/* ===============================================
   PRODUCT CARD MINIMALISTA - market-product-card
   =============================================== */
.market-product-card {
  flex: 0 0 130px;
  display: flex;
  flex-direction: column;
  background-color: var(--market-white);
  border-radius: var(--market-radius-sm);
  overflow: hidden;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  cursor: pointer;
  position: relative;
  border: none; 
  height: auto;
}
.market-product-card:hover {
  transform: translateY(-2px); 
}

/* Image Container */
.market-product-card__image-wrapper {
  position: relative;
  width: 100%;
  height: 120px;
  overflow: hidden;
  border-radius: 10px;
  background-color: var(--market-background);
}
.market-product-card__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}
.market-product-card:hover .market-product-card__image {
  transform: scale(1.02);
}

.market-product-card__badge {
  position: absolute;
  top: 6px;
  right: 6px;
  background-color: #D9FFD1;
  color: #4BC532;
  padding: 1px 5px;
  border-radius: 7px;
  font-size: 10px;
  font-weight: 600;
  z-index: 2;
  letter-spacing: 0.2px;
}
.market-product-card__badge--highlight {
  background-color: #EC1D27;
  color: var(--market-white);
}

/* Content - Minimalista */
.market-product-card__content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 8px;
  justify-content: flex-start;
}
.market-product-card__name {
  font-size: 11px;
  font-weight: 500;
  color: var(--market-text-primary);
  margin: 0;
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.market-product-card__description {
  font-size: 8px;
  color: var(--market-text-secondary);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  font-weight: 300;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Price */
.market-product-card__price-wrapper {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 3px;
  margin-bottom: 4px; 
}
.market-product-card__price {
  font-size: 13px;
  font-weight: 600;
  color: var(--market-text-primary);
}
.market-product-card__price--old {
  font-size: 9px;
  color: var(--market-text-secondary);
  text-decoration: line-through;
}
.market-product-card__unit {
  font-size: 9px;
  color: var(--market-text-secondary);
  opacity: 0.8;
  font-weight: 500;
  line-height: 1.2;
}

/* Add Button */
.market-product-card__button {
  position: absolute;
  top: 83px;
  right: 8px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: var(--market-white);
  color: var(--market-primary);
  border: 1px solid var(--market-border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(var(--padrao-rgb), 0.15);
}
.market-product-card__button:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(var(--padrao-rgb), 0.15);
}
.market-product-card__button:active {
  transform: scale(0.95);
}
.market-product-card__button.is-loading {
  background-color: #eee !important;
  color: #999 !important;
  border-color: #ccc !important;
  cursor: not-allowed;
}
/* Spinner interno do botão */
.market-product-card__spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--market-primary);
  border-top-color: transparent;
  border-radius: 50%;
  display: inline-block;
  animation: market-spin 0.8s linear infinite;
  vertical-align: middle;
}
/* Animação do spinner */
@keyframes market-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ===============================================
   PAGINAÇÃO HORIZONTAL - market-category__pagination
   =============================================== */
.market-category__pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0 8px;
  min-height: 28px;
}
.market-category__pagination-button {
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid var(--market-border);
  border-radius: 4px;
  background-color: var(--market-white);
  color: var(--market-text-primary);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}
.market-category__pagination-button:hover:not(:disabled) {
  border-color: var(--market-primary);
  background-color: var(--market-primary);
  color: var(--market-white);
}
.market-category__pagination-button--active {
  background-color: var(--market-primary);
  color: var(--market-white);
  border-color: var(--market-primary);
}
.market-category__pagination-button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.market-category__pagination-info {
  font-size: 11px;
  color: var(--market-text-secondary);
  margin: 0 4px;
  white-space: nowrap;
}

/* ===============================================
   LOADING STATE
   =============================================== */
.market-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  gap: 12px;
}
.market-loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--market-border);
  border-top-color: var(--market-primary);
  border-radius: 50%;
  animation: market-spin 0.8s linear infinite;
}
@keyframes market-spin {
  to {
    transform: rotate(360deg);
  }
}
.market-loading p {
  font-size: 14px;
  color: var(--market-text-secondary);
  margin: 0;
}

/* ===============================================
   EMPTY STATE
   =============================================== */
.market-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  gap: 12px;
  color: var(--market-text-secondary);
}
.market-empty ion-icon {
  font-size: 48px;
  opacity: 0.3;
}
.market-empty p {
  font-size: 16px;
  font-weight: 500;
  margin: 0;
}

/* ===============================================
   MODO LISTA (desktop) - Exibir categoria única
   =============================================== */
.market-category__list-container {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  overflow: visible;
  margin: auto;

  /* muda o alinhamento para preencher a linha toda */
  justify-content: center;

  /* garante que o último item não grude na borda se sobrar espaço */
  align-content: flex-start;
}

/* ===============================================
   RESPONSIVIDADE - MOBILE (padrão)
   =============================================== */
@media (max-width: 767px) {

  
  .market-categories-tabs {
    padding: 0 10px;
    min-height: 48px;
  }

  .market-tab {
    padding: 12px 10px;
    font-size: 14px;
    font-weight: 400;
  }

  .market-tab--active::after {
    height: 3px;
  }  

  .market-categories-wrapper {
    display: flex;
    flex-direction: column;
    gap: 32px;
    margin-top: 8px;
    padding: 20px 16px;
  }

  .market-main {
    padding: 0;
    padding-top: 10px;
  }

  .market-container {
    max-width: 100%;
  }

  .market-search-section {
    padding: 8px 12px; /* menos respiro lateral e vertical */
    box-shadow: 0 4px 4px -2px rgba(0, 0, 0, 0);
  }
  .market-search-input {
    padding: 6px 10px 6px 36px; /* mais compacto */
    font-size: 12px; /* texto menor */
    border-width: 1px; /* borda mais fina */
  }
  .market-search-icon {
    left: 20px; /* ajusta a posição do ícone */
    font-size: 16px; /* reduz o ícone */
  }
  
  .market-category__scroll-container::-webkit-scrollbar {
    display: none;
  }
}

@media (max-width: 1023px) {
  .market-sidebar {
    display: none;
  }

}

/* ===============================================
   RESPONSIVIDADE - DESKTOP (1024px+)
   =============================================== */
@media (min-width: 1024px) {
  .market-sidebar {
    display: block;
  }
  .market-categories-tabs {
    display: none;
  }
  .market-main {
    padding: 24px 20px;
    padding-top: 10px;
  }

  .market-container {
    gap: 0;
  }

  .market-product-card {
    flex: 0 0 160px;
    padding-bottom: 20px;
  }

  .market-product-card__image-wrapper {
    height: 130px;
  }
  .market-category__title {
    font-size: 22px;
  }
  .market-product-card__name {
    font-size: 13px;
  }
  .market-product-card__price {
    font-size: 14px;
  }

  .market-category {
    width: calc(100% - 220px);
    min-width: 600px; /* garante uma base mínima pro desktop */
  }

  .market-category__scroll-container {
    margin: 0;
    padding: 8px 16px;
    
    min-width: 600px; /* impede que encolha demais se tiver poucos produtos */
    gap: 20px;
    scroll-padding-left: 0;
    scroll-padding-right: 0;
    padding-right: 16px;
  }
}

@media (max-width: 1439px) {

}
