:root {
  --bg: #eef1f5;
  --bg-soft: #ffffff;
  --bg-card: #ffffff;
  --border: #d7dee6;
  --text: #1f2937;
  --text-muted: #64748b;
  --accent: #1d4ed8;
  --accent-dark: #1e3a8a;
  --on-accent: #ffffff;
  --danger: #dc2626;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header: barra de contacto + barra principal */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
}

/* Barra de contacto */
.header-topbar {
  background: var(--accent-dark);
  color: #ffffff;
  font-size: 0.78rem;
}

.header-topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 20px;
}

.header-contacto {
  display: flex;
  align-items: center;
  gap: 20px;
  min-width: 0;
}

.header-ubicacion,
.header-telefono {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  color: #dbe6fb;
  text-decoration: none;
}

.header-telefono {
  color: #ffffff;
  font-weight: 600;
}

.header-telefono:hover {
  text-decoration: underline;
}

.header-ubicacion svg,
.header-telefono svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.header-ubicacion span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-social {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* Barra principal */
.header-bar {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.brand-mark {
  background: var(--accent);
  color: #ffffff;
  font-weight: 800;
  padding: 6px 10px;
  border-radius: 6px;
}

.search-bar {
  flex: 1;
}

.search-bar input {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
}

.cart-toggle {
  background: var(--accent);
  color: #ffffff;
  border: none;
  padding: 10px 18px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.cart-toggle svg {
  width: 20px;
  height: 20px;
}

.cart-count {
  background: var(--accent-dark);
  color: #ffffff;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-size: 0.75rem;
}

/* Carrusel */
.carrusel {
  position: relative;
  overflow: hidden;
  height: 380px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
}

.carrusel-track {
  display: flex;
  height: 100%;
  transition: transform 0.5s ease;
}

.carrusel-slide {
  flex: 0 0 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: flex-end;
}

.carrusel-slide-color {
  background: linear-gradient(135deg, #1e3a8a, #2563eb 60%, #64748b);
}

.carrusel-overlay {
  width: 100%;
  padding: 24px;
  background: linear-gradient(to top, rgba(15, 23, 42, 0.75), transparent);
  color: #ffffff;
}

.carrusel-overlay h3 {
  margin: 0 0 4px;
  font-size: 1.3rem;
}

.carrusel-overlay p {
  margin: 0;
  color: #e5e9f0;
  font-size: 0.95rem;
  max-width: 600px;
}

.carrusel-boton {
  display: inline-block;
  margin-top: 14px;
  padding: 10px 22px;
  background: var(--accent);
  color: #ffffff;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
}

.carrusel-boton:hover {
  background: var(--accent-dark);
}

.carrusel-flecha {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(15, 23, 42, 0.45);
  color: #ffffff;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  z-index: 5;
}

.carrusel-flecha-izq {
  left: 12px;
}

.carrusel-flecha-der {
  right: 12px;
}

.carrusel-dots {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
}

.carrusel-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  padding: 0;
}

.carrusel-dot.activo {
  background: #ffffff;
}

@media (max-width: 600px) {
  .carrusel {
    height: 220px;
  }
}

/* Filtros */
.filtros {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 24px 0 16px;
}

.filtros select {
  padding: 8px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
}

/* Grilla de productos */
.grilla-productos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
  padding-bottom: 60px;
}

.cargando,
.sin-resultados {
  color: var(--text-muted);
}

.producto-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.producto-imagen {
  width: 100%;
  height: 160px;
  object-fit: cover;
  background: #eef1f5;
}

.producto-info {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.producto-categoria {
  font-size: 0.75rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.producto-nombre {
  font-weight: 600;
  margin: 0;
}

.producto-descripcion {
  font-size: 0.85rem;
  color: var(--text-muted);
  flex: 1;
}

.producto-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}

.producto-precio {
  font-weight: 700;
  font-size: 1.05rem;
}

.producto-stock {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.btn-agregar {
  background: var(--accent);
  color: var(--on-accent);
  border: none;
  padding: 8px 12px;
  border-radius: var(--radius);
  font-weight: 600;
  cursor: pointer;
}

.btn-agregar:disabled {
  background: var(--border);
  color: var(--text-muted);
  cursor: not-allowed;
}

.btn-eliminar {
  background: none;
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 7px 11px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
}

.btn-eliminar:hover {
  background: var(--danger);
  color: #ffffff;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 20px 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  background: var(--bg-soft);
}

/* Carrito lateral */
.carrito {
  position: fixed;
  top: 0;
  right: -380px;
  width: 360px;
  height: 100%;
  background: var(--bg-soft);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: right 0.25s ease;
  z-index: 40;
  box-shadow: -4px 0 12px rgba(15, 23, 42, 0.08);
}

.carrito.abierto {
  right: 0;
}

.carrito-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.carrito-items {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.carrito-vacio {
  color: var(--text-muted);
}

.carrito-item {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.carrito-item-info {
  flex: 1;
}

.carrito-item-nombre {
  font-weight: 600;
  font-size: 0.9rem;
}

.carrito-item-precio {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.carrito-item-cantidad {
  display: flex;
  align-items: center;
  gap: 6px;
}

.carrito-item-cantidad button {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  width: 26px;
  height: 26px;
  border-radius: 6px;
  cursor: pointer;
}

.carrito-item-quitar {
  color: var(--danger);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.8rem;
}

.carrito-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}

.carrito-total {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 1.05rem;
}

.btn-primario {
  width: 100%;
  background: var(--accent);
  color: var(--on-accent);
  border: none;
  padding: 12px;
  border-radius: var(--radius);
  font-weight: 700;
  cursor: pointer;
}

.btn-primario:disabled {
  background: var(--border);
  color: var(--text-muted);
  cursor: not-allowed;
}

.cerrar {
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.4rem;
  cursor: pointer;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 30;
}

.overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

/* Modales */
.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.5);
  z-index: 50;
}

.modal.abierto {
  display: flex;
}

.modal-contenido {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 420px;
  position: relative;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.15);
}

.modal-contenido form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.modal-contenido label {
  font-size: 0.85rem;
  margin-top: 8px;
}

.modal-contenido input {
  padding: 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
}

.error-mensaje {
  color: var(--danger);
  font-size: 0.85rem;
  min-height: 1em;
}

@media (max-width: 600px) {
  .header-contacto {
    flex: 1 1 0;
    min-width: 0;
  }

  .header-ubicacion {
    min-width: 0;
    flex: 1;
  }

  .header-telefono {
    display: none;
  }

  .header-social {
    flex-shrink: 0;
  }

  .header-inner {
    flex-wrap: wrap;
  }

  .brand {
    flex: 1 1 100%;
    justify-content: center;
    order: 1;
  }

  .search-bar {
    order: 2;
    flex: 1 1 auto;
  }

  .cart-toggle {
    order: 3;
  }

  .cart-toggle span:not(.cart-count) {
    display: none;
  }

  .carrito {
    width: 100%;
    right: -100%;
  }
}

/* Iconos de redes sociales (en el header) */
.social-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease;
}

.social-btn:hover {
  transform: scale(1.08);
}

.social-btn img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Botón cerrar sesión (panel admin) */
.btn-cerrar-sesion {
  background: transparent;
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: var(--radius);
  padding: 4px 12px;
  font-size: 0.78rem;
  cursor: pointer;
}

.btn-cerrar-sesion:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Página de login */
.pagina-login {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #1e3a8a, #1d4ed8);
}

.login-card {
  background: #ffffff;
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 380px;
  margin: 20px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.25);
}

.login-brand {
  justify-content: center;
  margin-bottom: 18px;
}

.login-card h1 {
  font-size: 1.3rem;
  margin: 0 0 4px;
  text-align: center;
}

.login-subtitulo {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
  margin: 0 0 20px;
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login-card label {
  font-size: 0.85rem;
  margin-top: 8px;
}

.login-card input {
  padding: 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
}

.login-volver {
  display: block;
  text-align: center;
  margin-top: 16px;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-decoration: none;
}

.login-volver:hover {
  text-decoration: underline;
}
