/* =====================================================================
   Estilos de la tienda pública (EshopIA)
   ===================================================================== */

:root {
  --tienda-primary: #0066cc;
  --tienda-secondary: #666;
  --tienda-light-bg: #f9f9f9;
  --tienda-border: #ddd;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
  color: #333;
}

/* Contenedor general */
.tienda-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header */
.tienda-header {
  background: #fff;
  border-bottom: 1px solid var(--tienda-border);
  padding: 16px 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.tienda-header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  gap: 24px;
  align-items: center;
}

.tienda-logo {
  flex-shrink: 0;
}

.tienda-logo a {
  text-decoration: none;
  color: #333;
  font-size: 20px;
  font-weight: bold;
}

.tienda-buscar {
  flex: 1;
  display: flex;
  gap: 8px;
}

.tienda-buscar-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--tienda-border);
  border-radius: 4px;
  font-size: 14px;
}

.tienda-buscar-btn {
  padding: 8px 16px;
  background: var(--tienda-primary);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}

.tienda-buscar-btn:hover {
  background: #0052a3;
}

.tienda-nav-right {
  display: flex;
  gap: 12px;
  flex-shrink: 0;
}

/* Main content */
.tienda-main {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  padding: 32px 16px;
}

.tienda-content {
  width: 100%;
}

/* Título */
.tienda-content h1 {
  margin-top: 0;
  margin-bottom: 24px;
  font-size: 28px;
}

.tienda-content h2 {
  margin-top: 32px;
  margin-bottom: 16px;
  font-size: 20px;
}

/* Grid de productos */
.tienda-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 24px;
  margin-bottom: 24px;
}

.tienda-producto-card {
  border: 1px solid var(--tienda-border);
  border-radius: 8px;
  overflow: hidden;
  transition: box-shadow 0.2s;
}

.tienda-producto-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.tienda-producto-foto {
  width: 100%;
  aspect-ratio: 1;
  background: var(--tienda-light-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.tienda-producto-foto img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tienda-sin-foto {
  color: #999;
  font-size: 12px;
}

.tienda-producto-info {
  padding: 12px;
}

.tienda-producto-info h3 {
  margin: 0 0 8px 0;
  font-size: 16px;
}

.tienda-producto-info h3 a {
  color: var(--tienda-primary);
  text-decoration: none;
}

.tienda-producto-info h3 a:hover {
  text-decoration: underline;
}

.tienda-precio {
  margin: 8px 0;
  font-size: 14px;
  font-weight: bold;
}

.tienda-precio-original {
  text-decoration: line-through;
  color: #999;
  margin-right: 8px;
}

.tienda-precio-vigente {
  color: var(--tienda-primary);
}

.tienda-unidad {
  font-size: 12px;
  color: #666;
  margin-left: 4px;
}

/* Badges */
.tienda-badge {
  display: inline-block;
  padding: 4px 8px;
  font-size: 11px;
  border-radius: 3px;
  margin-right: 4px;
  font-weight: bold;
}

.tienda-oferta {
  background: #ffc107;
  color: #333;
}

.tienda-agotado {
  background: #dc3545;
  color: white;
}

/* Paginación */
.tienda-paginacion {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 24px;
}

/* Categorías */
.tienda-subcategorias {
  margin-bottom: 24px;
}

.tienda-subcategorias ul {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tienda-subcategorias a {
  color: var(--tienda-primary);
  text-decoration: none;
  padding: 4px 8px;
  border: 1px solid var(--tienda-border);
  border-radius: 4px;
  font-size: 14px;
}

.tienda-subcategorias a:hover {
  background: var(--tienda-light-bg);
}

.tienda-familias {
  background: var(--tienda-light-bg);
  padding: 24px;
  border-radius: 8px;
  margin-bottom: 32px;
}

.tienda-familias-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.tienda-familia-link {
  display: block;
  padding: 12px;
  text-decoration: none;
  color: var(--tienda-primary);
  border: 1px solid var(--tienda-border);
  border-radius: 4px;
  text-align: center;
  transition: background 0.2s;
}

.tienda-familia-link:hover {
  background: #fff;
  border-color: var(--tienda-primary);
}

/* Producto detalle */
.tienda-producto-detail {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
}

.tienda-producto-fotos {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.tienda-foto {
  width: 100%;
  border: 1px solid var(--tienda-border);
  border-radius: 4px;
}

.tienda-producto-detalles h1 {
  margin-top: 0;
}

.tienda-precio-detalle {
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 16px;
}

.tienda-disponibilidad {
  margin-bottom: 16px;
}

.tienda-agotado-text {
  color: #dc3545;
  font-weight: bold;
  margin: 0;
}

.tienda-disponible-text {
  color: #28a745;
  font-weight: bold;
  margin: 0;
}

.tienda-descripcion {
  margin: 16px 0;
  line-height: 1.8;
}

.tienda-variantes {
  margin: 24px 0;
}

.tienda-variantes-tabla {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}

.tienda-variantes-tabla th,
.tienda-variantes-tabla td {
  padding: 8px;
  text-align: left;
  border-bottom: 1px solid var(--tienda-border);
}

.tienda-variantes-tabla th {
  background: var(--tienda-light-bg);
  font-weight: bold;
}

/* Footer */
.tienda-footer {
  background: #333;
  color: white;
  margin-top: auto;
  padding: 32px 16px 16px;
}

.tienda-footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 32px;
  margin-bottom: 24px;
}

.tienda-footer-section h3 {
  margin-top: 0;
  margin-bottom: 12px;
  font-size: 16px;
}

.tienda-footer-section p {
  margin: 4px 0;
  font-size: 14px;
  line-height: 1.6;
}

.tienda-footer-section a {
  color: #aaa;
  text-decoration: none;
}

.tienda-footer-section a:hover {
  color: white;
}

.tienda-footer-links {
  list-style: none;
  padding: 0;
  margin: 0;
}

.tienda-footer-links li {
  margin-bottom: 8px;
}

.tienda-footer-bottom {
  max-width: 1200px;
  margin: 0 auto;
  border-top: 1px solid #555;
  padding-top: 16px;
  text-align: center;
  color: #aaa;
  font-size: 12px;
}

/* 404 */
.tienda-notfound {
  text-align: center;
  padding: 48px 0;
}

.tienda-notfound h1 {
  font-size: 48px;
  margin-bottom: 16px;
}

.tienda-notfound p {
  font-size: 16px;
  margin-bottom: 24px;
}

/* Buscador en página */
.tienda-buscar-form {
  margin-bottom: 24px;
  display: flex;
  gap: 8px;
}

.tienda-buscar-form input {
  flex: 1;
  max-width: 400px;
}

/* Legal */
.tienda-legal-texto {
  line-height: 1.8;
  max-width: 800px;
}

.tienda-legal-texto p {
  margin-bottom: 16px;
}

/* Responsivo */
@media (max-width: 768px) {
  .tienda-header-inner {
    flex-direction: column;
    gap: 12px;
  }

  .tienda-buscar {
    width: 100%;
  }

  .tienda-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
  }

  .tienda-producto-detail {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .tienda-main {
    padding: 16px;
  }

  .tienda-footer-inner {
    grid-template-columns: 1fr;
  }
}

/* === F4: carrito, flash y checkout === */
.tienda-carrito-link {
  display: inline-block;
  padding: 8px 14px;
  background: #2c3e50;
  color: #fff;
  border-radius: 4px;
  text-decoration: none;
  font-weight: 600;
}

.tienda-carrito-link:hover {
  background: #1a252f;
}

.tienda-flash {
  margin: 0 0 16px;
  padding: 12px 16px;
  border-radius: 4px;
  border: 1px solid transparent;
}

.tienda-flash-error {
  background: #fdecea;
  border-color: #e74c3c;
  color: #922b21;
}

.tienda-flash-success {
  background: #eafaf1;
  border-color: #27ae60;
  color: #1e8449;
}

.tienda-flash-warning {
  background: #fef9e7;
  border-color: #f1c40f;
  color: #9a7d0a;
}

.tienda-carrito-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 4px;
}

.tienda-carrito-cantidad {
  max-width: 110px;
}

/* === F7: Widget de chat público (burbuja + panel plegable) === */
.chat-burbuja {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--tienda-primary);
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  z-index: 1000;
}

.chat-burbuja.oculta {
  display: none;
}

.chat-widget {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 350px;
  max-height: 500px;
  background: #fff;
  border: 1px solid var(--tienda-border);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  display: none;
  flex-direction: column;
  z-index: 1000;
  overflow: hidden;
}

.chat-widget.open {
  display: flex;
}

.chat-widget-header {
  background: var(--tienda-primary);
  color: #fff;
  padding: 12px 16px;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-widget-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-widget-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  max-height: 350px;
}

.chat-message {
  margin-bottom: 8px;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 14px;
  line-height: 1.4;
}

.chat-message.user {
  background: var(--tienda-primary);
  color: #fff;
  margin-left: 24px;
}

.chat-message.assistant {
  background: var(--tienda-light-bg);
  color: #333;
  margin-right: 24px;
}

.chat-message.error {
  background: #fdecea;
  color: #922b21;
  margin-right: 24px;
}

.chat-widget-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--tienda-border);
}

.chat-widget-form textarea {
  padding: 8px;
  border: 1px solid var(--tienda-border);
  border-radius: 4px;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
  min-height: 60px;
  max-height: 120px;
}

.chat-widget-send {
  background: var(--tienda-primary);
  color: #fff;
  border: none;
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
}

.chat-widget-send:hover {
  background: #0052a3;
}

@media (max-width: 480px) {
  .chat-widget {
    width: calc(100% - 20px);
    max-height: 60vh;
  }
}
