/* Layout principal */
.container-productos {
  padding: 20px;
  margin-top: 80px;
}
.products-container {
  display: flex;
  gap: 10px;
}

/* ===== Barra superior con botón "Filtrar" (visible en móvil) ===== */
.products-toolbar{
  display: none;            /* se muestra solo en móvil */
}
.filter-open-btn{
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: 10px;
  background: linear-gradient(135deg,#059669 0%,#047857 100%);
  color:#fff; border:0; font-weight:700; cursor:pointer;
  box-shadow: 0 6px 16px rgba(5,150,105,.28);
}
.filter-open-btn i{ font-size: 1rem; }

/* Panel de filtros (desktop/tablet) */
.filter-panel {
  width: 250px;
  background: #ffffff;
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 8px 30px rgba(44, 95, 65, 0.1);
  height: fit-content;
  margin-bottom: 20px;
}
.filter-title {
  color: #2c5f41;
  font-size: 1.4rem;
  font-weight: 600;
  margin-bottom: 25px;
  padding-bottom: 15px;
  border-bottom: 2px solid rgba(44, 95, 65, 0.1);
}
.filter-section { margin-bottom: 25px; }
.filter-section-title {
  color: #1f2937;
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 15px;
  display: flex; align-items: center;
}
.filter-section-title i { margin-right: 10px; color: #059669; }
.filter-option { display: flex; align-items: center; margin-bottom: 12px; }
.filter-option input {
  margin-right: 10px; width: 18px; height: 18px; accent-color: #059669;
}
.filter-option label { color: #4b5563; font-size: 0.95rem; cursor: pointer; }
.price-range { display: flex; align-items: center; gap: 10px; margin-bottom: 15px; }
.price-input {
  width: 100%; padding: 10px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 0.9rem;
}
.apply-filters-btn {
  width: 100%; background: linear-gradient(135deg, #059669 0%, #047857 100%);
  color: white; border: none; padding: 12px 20px; border-radius: 10px; font-size: 1rem;
  font-weight: 600; cursor: pointer; transition: all 0.3s ease; margin-top: 15px;
}
.apply-filters-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 15px rgba(5, 150, 105, 0.3); }
.clear-filters-btn {
  width: 100%; background: transparent; color: #6b7280; border: 1px solid #d1d5db;
  padding: 12px 20px; border-radius: 10px; font-size: 1rem; font-weight: 600;
  cursor: pointer; transition: all 0.3s ease; margin-top: 10px;
}
.clear-filters-btn:hover { background: #f3f4f6; }

/* Contenedor de productos */
.products-wrapper { flex: 1; }
.products-grid {
  display: grid; grid-template-columns: repeat(4, minmax(250px, 1fr));
  gap: 15px; padding: 0;
}

/* Header de tarjeta = overlay zone */
.product-card .product-header { position: relative; }
.product-card .product-image img {
  display: block; width: 100%; height: 150px; border-radius: 12px;
}
.badge-descuento{
  position:absolute; top:10px; left:10px;
  background:#047857 !important; color:#fff; font-weight:700;
  font-size:.85rem; padding:4px 8px; border-radius:8px;
}
.price-section { margin-top:6px; display:flex; align-items:center; gap:8px; }
.price-section .current-price{
  color: #059669; font-size: 1.1rem; font-weight: bold;
  margin-bottom: 5px; display: flex; align-items: center;
}
.price-section .original-price{ color:#9aa0a6; text-decoration:line-through; }
.product-card{ position:relative; }

/* Corazón arriba-derecha (overlay) */
.product-card .favorite-button{
  position: absolute; top: 15px; right: 15px;
  background: none; border: none; cursor: pointer;
  font-size: 20px; color: #bdc3c7; transition: color 0.3s ease;
  z-index: 50;
}
.product-card .favorite-button:hover{ color: #e74c3c; }

/* Badge evento */
.badge-evento-top{
  position: absolute; top: 8px; left: 8px; z-index: 3;
  padding: 4px 8px; border-radius: 999px; font-size: .75rem; font-weight: 700;
  color: #fff; background: #059669;
}

/* Textos debajo de imagen */
.brand-marca{
  font-weight: 700;
  color: #1f2937;
  margin-top: 10px;
  font-size: .95rem;
  line-height: 1.4;
  min-height: calc(.95rem * 1.4); /* siempre 1 línea de alto */
}
.brand-cats{ color: #4b5563; margin-top: 2px; }
.evento-text{
  margin-top: 6px; font-size: .85rem; color: #6b7280;
  text-transform: uppercase; letter-spacing: .3px;
}

/* Botón "Seguir viendo" */
.show-more{
  display: block; width: max-content; margin: 20px auto 0;
  padding: 10px 18px; border: 0; border-radius: 10px;
  background: #047857 !important; color: #fff; font-weight: 600; cursor: pointer;
  box-shadow: 0 6px 18px rgba(5,193,8,0.25);
  transition: transform .15s ease, box-shadow .2s ease, opacity .2s ease;
}
.show-more:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(5,193,8,0.30); }

/* Mostrar 3 filas al inicio y +3 por clic (controlado por JS con .visible) */
.products-grid .product-card { display: none; }
.products-grid .product-card.visible { display: block; }

/* ===== Overlay (móvil) ===== */
.filter-overlay{
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 2147483646;
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity .25s ease, visibility .25s ease;
}
.filter-overlay.active{ opacity: 1; visibility: visible; pointer-events: auto; }

.filter-header-mobile,
.filter-footer-mobile{ display: none; }

/* ====== Breakpoints ====== */
@media (max-width: 1200px) {
  .products-grid { grid-template-columns: repeat(3, minmax(250px, 1fr)); }
}
@media (max-width: 992px) {
  .products-grid { grid-template-columns: repeat(2, minmax(250px, 1fr)); }
}

/* ===== Desktop/Tablet (≥769px): panel lateral normal, barra oculta ===== */
@media (min-width: 769px){
  .filter-panel{
    position: static; transform: none; inset: auto;
    width: 250px; border-radius: 20px; box-shadow: 0 8px 30px rgba(44,95,65,.1);
    z-index: auto;
  }
  .products-toolbar{ display: none; }
  .filter-overlay{ display: none; }
}

/* ===== Móvil chico (≤600px): 2 cards por fila ===== */
@media (max-width: 600px) {
  /* Contenedor: un poco menos de padding para ganar ancho útil */
  .container-productos { padding: 16px 5px; }

  /* Grid: 2 columnas, gap más pequeño */
  .products-grid{
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 12px !important;
    padding: 0 !important;
  }

  /* Card compacta */
  .product-card{
    padding: 12px !important;
    border-radius: 12px !important;
  }

  /* Imagen más baja para que quepan 2 sin scroll horizontal */
  .product-card .product-image img{
    height: 120px !important;
    border-radius: 10px !important;
  }

  /* Badges y botón favorito un poco más chicos */
  .badge-descuento{ font-size: .75rem !important; padding: 3px 6px !important; top: 8px !important; left: 8px !important; }
  .product-card .favorite-button{ font-size: 18px !important; top: 10px !important; right: 10px !important; }
  .badge-evento-top{ font-size: .7rem !important; padding: 3px 6px !important; top: 6px !important; left: 6px !important; }

  /* Textos compactos */
  .brand-marca{ font-size: .95rem !important; margin-top: 8px !important; }
  .brand-cats{ font-size: .82rem !important; }
  .evento-text{ font-size: .75rem !important; }

  /* Precios y layout interno */
  .price-section{ gap: 6px !important; margin-top: 4px !important; }
  .price-section .current-price{ font-size: 1rem !important; }
  .price-section .original-price{ font-size: .85rem !important; }

  /* Botón “Seguir viendo” más compacto */
  .show-more{
    padding: 9px 14px !important;
    border-radius: 10px !important;
    font-size: .9rem !important;
    margin-top: 16px !important;
  }

  /* Toolbar y filtros: sin cambios visuales, pero ajusta el contenedor si hace falta */
  .products-toolbar{ display: block; }
  .products-container{ flex-direction: column; gap: 12px; }
  /* .products-grid{ grid-template-columns: 1fr !important; }  <-- NO USAR */
}

/* ===== Móvil (≤768px): drawer lateral izquierdo con scroll interno ===== */
@media (max-width: 768px) {
  .container { padding: 0 10px; }
  h1 { font-size: 2rem; margin-bottom: 30px; }

  .products-toolbar{ display: block; }
  .products-container { flex-direction: column; }

  /* Drawer LEFT: ocupa alto completo, ancho 88vw máx 380px */
  #filterPanel{
    position: fixed;
    top: 0; bottom: 0; left: 0; right: auto;
    width: min(88vw, 380px);
    height: 100dvh;
    background: #fff;
    border-radius: 0 16px 16px 0;
    display: grid; grid-template-rows: auto 1fr auto; /* header | cuerpo | footer */
    transform: translateX(-105%);
    transition: transform .32s cubic-bezier(.22,.61,.36,1);
    overflow: auto;                         /* scroll interno */
    -webkit-overflow-scrolling: touch;      /* inercia iOS */
    z-index: 2147483647;
    pointer-events: none;                   /* no clickeable hasta abrir */
  }
  #filterPanel.active{
    transform: translateX(0);
    pointer-events: auto;
  }

  /* Header y Footer sticky dentro del drawer */
  .filter-header-mobile{
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 20px; position: sticky; top: 0;
    background: #fffffffa; backdrop-filter: blur(6px);
    border-bottom: 1px solid #eef2f7; z-index: 1;
  }
  .filter-close{
    background: none; border: none; font-size: 1.75rem; line-height: 1;
    color: #6b7280; cursor: pointer; padding: 4px 8px;
  }
  .filter-footer-mobile{
    display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
    padding: 12px 20px; position: sticky; bottom: 0;
    background: #fffffffa; border-top: 1px solid #eef2f7; backdrop-filter: blur(6px);
    z-index: 1;
  }

  /* Cuerpo (secciones) */
    .filter-panel{
    padding: 0px !important;
  }
  .filter-panel .filter-section{ padding: 12px 20px; }
  .filter-panel .filter-title{ margin: 0; padding: 0; border: 0; }
  .price-input{ padding: 12px; font-size: 1rem; }
  .filter-option input{ width: 20px; height: 20px; }

  /* Ocultar “limpiar” de desktop si estorba en móvil */
  .clear-filters-btn#clearBtn{ display: none; }

  /* Grid de productos en móvil (1 col por defecto) */
  .products-grid{ grid-template-columns: 1fr !important; gap: 20px; }
  .product-card{ padding: 20px; }
    .brand-cats{
    display: -webkit-box !important;
    -webkit-box-orient: vertical !important;
    -webkit-line-clamp: 2 !important;
    line-clamp: 2 !important;
    overflow: hidden !important;
  }

  /* 🔹 Ajuste extra: pantallas chicas (≤600px) 2 columnas */
  @media (max-width: 600px) {
    .products-grid{
      grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
      gap: 5px !important;
      padding: 1px !important;
    }
    .product-card{
      padding: 12px !important;
    }
    .product-card .product-image img{
      height: 120px !important;
    }
        .brand-cats{
      display: -webkit-box !important;
      -webkit-box-orient: vertical !important;
      -webkit-line-clamp: 2 !important;
      line-clamp: 2 !important;
      overflow: hidden !important;
    }
  }
}
