/* static/css/product_list.css */

:root {
  --zr-orange: #f47a20;
}

/* ===========================
   PANEL DE FILTROS REDISEÑADO
   =========================== */
.filter-panel {
  background: #fafafa;
  border: 1px solid #ddd;
  border-radius: .5rem;
  padding: 1rem 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  align-items: center;
}

/* Grupo de búsqueda */
.filter-panel .search-group {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.filter-panel .search-group label {
  margin-bottom: .25rem;
  font-weight: 600;
  color: #333;
}

.filter-panel .search-group input {
  padding: .5rem 1rem;
  border: 1px solid #ccc;
  border-radius: .25rem;
  background: #fff;
  font-size: .95rem;
}

/* Grupo de descuento */
.filter-panel .discount-group {
  display: flex;
  flex-direction: column;
  /* etiqueta arriba, input abajo */
  align-items: center;
  /* centra horizontalmente ambos */
  gap: .25rem;
  /* un poquito de espacio entre label y checkbox */
}

.filter-panel .discount-group label {
  margin-bottom: .25rem;
  font-weight: 600;
  color: #333;
}

.filter-panel .discount-group .form-check-input {
  width: 1.2rem;
  height: 1.2rem;
  border: 1px solid #666;
  border-radius: .2rem;
  background: #fff;
}

.filter-panel .discount-group .form-check-input:checked {
  background-color: #000;
  border-color: #000;
}

.filter-panel .discount-group .form-check-input:focus {
  box-shadow: 0 0 0 .2rem rgba(0, 0, 0, 0.25);
}

/* ===========================
   CONTROLES SUPERIORES
   =========================== */
.controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.controls .center button.active {
  background: var(--zr-orange);
  color: #fff;
  border-color: var(--zr-orange);
}

/* ===========================
   VISTA DE PRODUCTOS
   =========================== */
#table-view {
  padding: 1rem 0;
}

#card-view {
  display: none;
  padding: 1rem 0;
}

/* ===========================
   TABLA
   =========================== */
.table {
  width: 100%;
  table-layout: auto;
}

.table thead {
  background-color: var(--zr-orange);
  color: #fff;
}

.table th,
.table td {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

.td-ver {
  text-align: center;
  vertical-align: middle;
}

.no-photo {
  opacity: .3;
  font-size: 1.2rem;
}

/* ===========================
   CARDS (Grid)
   =========================== */
.cards-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

/* Las tarjetas mantienen tamaño consistente sin importar cuántas hay */
.cards-container .card {
  display: flex;
  flex-direction: column;
  border: 1px solid #ddd;
  border-radius: .25rem;
  overflow: hidden;
  background: #fff;
  max-width: 300px;
  /* Tamaño máximo para evitar tarjetas muy grandes */
}

.cards-container .img-wrapper {
  width: 100%;
  height: 150px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
}

.cards-container .img-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cards-container .img-wrapper i {
  font-size: 2rem;
  color: #ccc;
}

.cards-container .card-body {
  padding: .5rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.cards-container .desc-wrapper {
  min-height: 4.5rem;
  margin-bottom: .5rem;
  overflow: hidden;
}

.cards-container h5 {
  margin: 0 0 .25rem;
}

.cards-container a {
  font-size: .9rem;
  color: var(--zr-orange);
  text-decoration: none;
  display: block;
}

.cards-container p {
  margin-top: auto;
  margin-bottom: .5rem;
}

.cards-container .add-cart-btn {
  width: 100%;
}

/* ===========================
   FOOTER PAGINACIÓN + INFO
   =========================== */
.footer-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
}

#info {
  font-size: .9rem;
  color: #555;
}

@media (max-width: 768px) {

  #table-view table,
  #table-view tbody,
  #table-view tr,
  #table-view td {
    display: block;
    width: 100%;
  }

  #table-view thead {
    display: none;
  }

  #table-view tr {
    border: 1px solid #ddd;
    margin-bottom: 1rem;
    padding: .5rem;
  }

  #table-view td {
    border: none;
    padding: .25rem 0;
  }

  #table-view td:nth-child(5) {
    order: -1;
    margin-bottom: .5rem;
  }

  #table-view td:nth-child(3) {
    order: 1;
  }

  #table-view td:nth-child(6) {
    order: 2;
  }
}

/* ===========================
   PAGINACIÓN ESTILO MERCADO LIBRE
   =========================== */
.pagination-ml {
  display: flex;
  align-items: center;
  list-style: none;
  padding: 0;
  gap: .5rem;
  margin: 0;
}

.pagination-ml li {
  display: inline-block;
}

.pagination-ml a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 .5rem;
  border: 1px solid #ddd;
  border-radius: 2px;
  text-decoration: none;
  color: #333;
  font-size: .9rem;
}

.pagination-ml a:hover {
  border-color: #999;
  background: #f5f5f5;
}

.pagination-ml .active a {
  background: #3483fa;
  border-color: #3483fa;
  color: #fff;
}

.pagination-ml .disabled a {
  color: #ccc;
  border-color: #eee;
  cursor: not-allowed;
}

.pagination-ml .arrow {
  font-weight: bold;
}

/* ===========================
   RESPONSIVE
   =========================== */
@media (max-width: 576px) {
  #card-view {
    display: block;
  }

  .cards-container {
    grid-template-columns: 1fr;
  }

  .cards-container .card {
    max-width: 100%;
    /* En móviles las tarjetas pueden ocupar todo el ancho */
  }
}