/* ----- GLOBAL ----- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Segoe UI', sans-serif;
  background-color: #dff2ff;
  color: #000;
  overflow-x: hidden;
}

a {
  text-decoration: none;
  color: #007bff;
}

a:hover {
  text-decoration: none;
}

/* ----- HEADER ----- */
header {
  background-color: #ffffff;
  padding: 1rem 2rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
}

header h1 {
  font-size: 1.8rem;
  font-weight: bold;
  margin: 0;
  color: #007bff;
  white-space: nowrap;
}

nav ul {
  list-style: none;
  display: flex;
  gap: 2rem;
  margin: 0;
  padding: 0;
}

nav a {
  font-size: 1.1rem;
  font-weight: 500;
  color: #007bff;
}

/* ----- MAIN ----- */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 0.5rem;
}

/* ----- BUSCADOR ----- */
.search-container {
  margin: 2rem auto;
  max-width: 600px;
  display: flex;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  background-color: white;
}

.search-container input {
  flex: 1;
  padding: 1rem 1.2rem;
  border: none;
  font-size: 1rem;
  outline: none;
}

.search-container button {
  background-color: #007bff;
  border: none;
  color: white;
  padding: 0 1.5rem;
  font-size: 1.3rem;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.search-container button:hover {
  background-color: #0056b3;
}

/* ----- CATEGORÍAS ----- */
.category-section {
  background-color: #c8deff;
  padding: 1rem 0;
}

.category-center {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 1rem;
}

.category-center h2 {
  text-align: center;
  margin-bottom: 1rem;
  font-size: 1.3rem;
}

.categoria-scroll-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.categoria-scroll {
  display: flex;
  gap: 1rem;
  padding: 0 1rem 1rem;
  width: max-content;
}

.categoria-scroll::-webkit-scrollbar {
  display: none;
}

.categoria-item {
  flex: 0 0 auto;
  scroll-snap-align: start;
  padding: 0.6rem 1.2rem;
  background-color: #ffffff;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  transition: background-color 0.2s ease;
}

.categoria-item.activo {
  background-color: #007bff;
  color: white;
  font-weight: bold;
  transform: scale(1.05);
}

/* ----- SECCIÓN PRINCIPAL ----- */
main > h2 {
  text-align: center;
  font-size: 1.5rem;
  margin: 2rem auto 1rem;
}

/* ----- PRODUCTOS WRAPPER ----- */
.productos-wrapper {
  max-width: 1000px;
  margin: 2rem auto;
  padding: 1rem;
  background-color: white;
  border-radius: 16px;
  box-shadow: 0 0 10px rgba(0,0,0,0.05);
}

/* ----- CONTENEDOR DE FICHAS ----- */
.productos-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem;
  margin: 0 auto;
  width: 100%;
}

/* ----- FICHA DE PRODUCTO ----- */
.producto {
  display: flex;
  align-items: flex-start;
  background-color: #ffffff;
  border-radius: 12px;
  padding: 0.3rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  gap: 1rem;
  transition: transform 0.2s ease;
  overflow: hidden;  /* evita overflow */
  position: relative; /* para posicionar botones */
}

.producto:hover {
  transform: translateY(-2px);
}

.producto a {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: inherit;
  text-decoration: none;
  width: 100%;
}

.producto img {
  width: 100px;
  height: auto;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
}

.producto-body {
  flex: 1 1 auto;
  min-width: 0;          /* clave para truncado en flexbox */
  overflow: hidden;      /* para evitar que se salga contenido */
}

/* Nombre producto con máximo 2 líneas, puntos suspensivos si excede */
.producto-body h3 {
  margin: 0;
  font-size: 1rem;
  color: #007bff;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* Precio */
.producto-body .precio {
  margin: 0.3rem 0;
  font-weight: bold;
  color: #000;
}

/* Descripción truncada en una sola línea con puntos suspensivos */
.descripcion {
  white-space: nowrap;         /* evita salto de línea */
  overflow: hidden;            /* oculta texto que no cabe */
  text-overflow: ellipsis;     /* añade puntos suspensivos */
  padding-right: 0.5rem;       /* separa "..." del borde */
  width: 100%;                 /* ocupa todo el ancho disponible */
  display: block;
  box-sizing: border-box;
  font-size: 0.9rem;
  color: #333;
  line-height: 1.4;
}

/* ----- BOTÓN DE FAVORITOS ----- */
.like-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 1.5rem;
  cursor: pointer;
  z-index: 2;
}

/* ----- FOOTER ----- */
.footer {
  background-color: #ffffff;
  padding: 2rem 1rem;
  font-size: 0.95rem;
  color: #333;
}

.footer-container {
  max-width: 1200px;
  margin: auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 2rem;
}

.footer h3 {
  font-size: 1rem;
  margin-bottom: 0.75rem;
  color: #007bff;
  text-align: center;
}

.footer ul {
  list-style: none;
  padding: 0;
  margin: 0;
  text-align: center;
}

.footer ul li {
  margin-bottom: 0.4rem;
}

.footer a {
  color: #007bff;
  text-decoration: none;
  transition: color 0.3s;
}

.footer a:hover {
  color: #0056b3;
}

.footer-buttons {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.2rem;
  margin-bottom: 1rem;
}

.footer-buttons a.footer-btn,
.footer-buttons button.footer-btn {
  background-color: white;
  color: #007bff;
  border: 2px solid #007bff;
  border-radius: 12px;
  padding: 0.4rem 1rem;
  font-size: 0.9rem;
  cursor: pointer;
  text-align: center;
  width: 150px;
  transition: background-color 0.3s, color 0.3s;
}

.footer-buttons a.footer-btn:hover,
.footer-buttons button.footer-btn:hover {
  background-color: #007bff;
  color: white;
}

.footer-copy-bar {
  background-color: #d6ecff;
  padding: 1rem;
  text-align: center;
  color: #007bff;
  font-size: 0.9rem;
  font-weight: 500;
}

/* ----- RESPONSIVE COMPLETO MEJORADO ----- */

/* Teléfonos pequeños (≤ 480px) */
@media (max-width: 480px) {
  header h1 {
    font-size: 1.3rem;
  }

  .producto {
    flex-direction: column;
    padding: 0.7rem;
  }

  .producto a {
    flex-direction: column;
    align-items: flex-start;
  }

  .producto img {
    width: 100%;
    max-height: 220px;
    height: auto;
  }

  .producto-body {
    padding-top: 0.6rem;
    width: 100%;
  }

  .producto-body h3 {
    font-size: 1rem;
    -webkit-line-clamp: 2;
  }

  .descripcion {
    font-size: 0.85rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
  }

  .productos-wrapper {
    margin: 1rem 0.7rem;
    padding: 0.7rem;
  }

  section a[href="crear-tienda.html"] {
    padding: 0.8rem 1.2rem;
    font-size: 1rem;
  }
}

/* Teléfonos medianos (481px – 767px) */
@media (min-width: 481px) and (max-width: 767px) {
  .producto img {
    width: 100px;
    height: 100px;
  }

  .producto-body h3 {
    font-size: 1rem;
    -webkit-line-clamp: 2;
  }

  .descripcion {
    font-size: 0.9rem;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
  }
}

/* Tablets (768px – 1024px) */
@media (min-width: 768px) and (max-width: 1024px) {
  .producto img {
    width: 110px;
    height: 110px;
  }

  .producto-body h3 {
    font-size: 1.05rem;
    -webkit-line-clamp: 2;
  }

  .descripcion {
    font-size: 0.95rem;
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
  }
}

/* Escritorio (≥ 1025px) */
@media (min-width: 1025px) {
  .producto-body h3 {
    font-size: 1.1rem;
    -webkit-line-clamp: 2;
  }

  .descripcion {
    font-size: 0.95rem;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
  }
}
