/* SONIMAX MÓVIL - Estilos Optimizados */

@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap");

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Glassmorphism */
.glass-card {
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.25);
}

/* Animaciones Optimizadas */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

.fade-in {
  animation: fadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.slide-in {
  animation: slideIn 0.3s ease-out;
}

.scale-in {
  animation: scaleIn 0.3s ease-out;
}

/* Agregando animación para notificaciones */
@keyframes fade-in-notification {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-fade-in {
  animation: fade-in-notification 0.3s ease-out;
}

/* Tarjetas de Producto Mejoradas */
.product-card {
  background: white;
  border-radius: 1.5rem;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid rgba(0, 0, 0, 0.06);
  animation: fadeIn 0.4s ease-out;
  will-change: transform;
}

.product-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 12px 32px rgba(220, 38, 38, 0.2);
  border-color: rgba(220, 38, 38, 0.3);
}

.product-image {
  width: 100%;
  height: 220px;
  object-fit: cover;
  background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
  transition: transform 0.4s ease, filter 0.5s ease;
}

.product-card:hover .product-image {
  transform: scale(1.08);
}

.product-image-container {
  overflow: hidden;
  position: relative;
  background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
}

/* Efecto blur-up mejorado para carga progresiva de imágenes */
.image-loading {
  filter: blur(20px);
  transform: scale(1.1);
  transition: filter 0.6s ease, transform 0.6s ease;
}

.image-loaded {
  filter: blur(0);
  transform: scale(1);
}

/* Skeleton loading mejorado con gradiente más suave */
.product-skeleton {
  background: linear-gradient(90deg, #f5f5f5 25%, #e8e8e8 50%, #f5f5f5 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite ease-in-out;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Placeholder para imágenes que están cargando */
.product-image-container::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
  z-index: 0;
}

.product-image {
  position: relative;
  z-index: 1;
}

/* Botones de Departamento */
.dept-button {
  background: white;
  color: #6b7280;
  border: 2px solid #e5e7eb;
  transition: all 0.2s ease;
  font-weight: 600;
}

.dept-button:hover {
  background: #fef2f2;
  border-color: #dc2626;
  color: #dc2626;
  transform: translateY(-2px);
}

.dept-button.active {
  background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
  color: white;
  border-color: #dc2626;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.4);
}

/* Tabs de Autenticación */
.auth-tab-active {
  background: rgba(255, 255, 255, 0.25);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Menú Lateral */
.sidebar-dept-btn.active {
  background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

#sidebar-menu.open {
  transform: translateX(0);
}

/* Scrollbar Personalizado */
.scrollbar-hide::-webkit-scrollbar {
  display: none;
}

.scrollbar-hide {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 10px;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, #b91c1c 0%, #7f1d1d 100%);
}

/* Items del Carrito */
.cart-item {
  background: white;
  border-radius: 1rem;
  padding: 1rem;
  margin-bottom: 1rem;
  border: 1px solid #e5e7eb;
  transition: all 0.2s ease;
  animation: slideIn 0.3s ease-out;
}

.cart-item:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transform: translateX(4px);
}

/* Badges de Rol */
.role-badge-cliente {
  background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 0.5rem;
  font-weight: 700;
}

.role-badge-distribuidor {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 0.5rem;
  font-weight: 700;
}

.role-badge-gestor {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 0.5rem;
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}

.role-badge-admin {
  background: linear-gradient(135deg, #1f2937 0%, #000000 100%);
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 0.5rem;
  font-weight: 700;
}

/* Botones de Cantidad */
.quantity-button {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f3f4f6;
  border-radius: 0.75rem;
  transition: all 0.2s ease;
  cursor: pointer;
  user-select: none;
  font-weight: 600;
}

.quantity-button:hover {
  background: #e5e7eb;
  transform: scale(1.1);
}

.quantity-button:active {
  transform: scale(0.95);
}

/* Botón Agregar al Carrito */
.add-to-cart-btn {
  position: relative;
  overflow: hidden;
  font-weight: 600;
}

.add-to-cart-btn::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.5s, height 0.5s;
}

.add-to-cart-btn:hover::before {
  width: 300px;
  height: 300px;
}

/* Badge de Precio */
.price-badge {
  background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 0.75rem;
  font-weight: 800;
  font-size: 1.125rem;
  display: inline-block;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.4);
}

/* Animación de Pulso para Carrito */
.cart-pulse {
  animation: pulse 0.3s ease-in-out;
}

/* Loading Spinner */
.loading-spinner {
  border: 4px solid #f3f3f3;
  border-top: 4px solid #dc2626;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Transiciones Suaves */
.transition-all {
  transition: all 0.3s ease;
}

/* Responsive */
@media (max-width: 640px) {
  .product-card {
    margin-bottom: 1rem;
  }

  .product-image {
    height: 200px;
  }

  h1 {
    font-size: 1.25rem;
  }
}

/* Optimización de Rendimiento - Mejorada con content-visibility */
.product-card,
.dept-button,
.cart-item {
  contain: layout style paint;
  content-visibility: auto;
  contain-intrinsic-size: 0 400px;
}

/* Optimización para imágenes */
img {
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

/* Estilos para botón de retry de imágenes */
.image-retry-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 48px;
  height: 48px;
  background: rgba(220, 38, 38, 0.9);
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.image-retry-btn:hover {
  background: rgba(220, 38, 38, 1);
  transform: translate(-50%, -50%) scale(1.1);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.image-retry-btn:active {
  transform: translate(-50%, -50%) scale(0.95);
}

.image-retry-btn svg {
  width: 24px;
  height: 24px;
  color: white;
}

.image-retry-btn.spinning svg {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Mejora de Accesibilidad */
button:focus-visible,
input:focus-visible {
  outline: 2px solid #dc2626;
  outline-offset: 2px;
}
