/* CATÁLOGO DIGITAL - Estilos Optimizados */

/* Se importa la fuente Poppins desde index.html */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-color: #F8FAFC; /* Gris casi blanco */
  color: #1E293B; /* Azul muy oscuro */
}

/* [NUEVO] Estilos para Modo Oscuro */
.dark body {
  background: #0F172A; /* slate-900 */
  color: #E2E8F0; /* slate-200 */
}

.dark .product-card {
  background: #1f2937; /* gray-800 */
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
}

.dark .product-card:hover {
  border-color: #F97316;
  box-shadow: 0 0 15px rgba(249, 115, 22, 0.5);
}

.dark .product-card h3 {
  color: #F8FAFC; /* slate-50 */
}
.dark .product-card p, .dark .product-card span {
  color: #94A3B8; /* slate-400 */
}

.dark .dept-button {
  background: #374151; /* gray-700 */
  color: #d1d5db; /* gray-300 */
  border-color: #4b5563; /* gray-600 */
}

.dark .dept-button:hover {
  background: #4b5563; /* gray-600 */
  border-color: #dc2626;
  color: #fef2f2; /* red-50 */
}

.dark .dept-button.active {
  background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
  color: white;
  border-color: #dc2626;
}

.dark .cart-item {
  background: #1f2937; /* gray-800 */
  border-color: #374151; /* gray-700 */
}
.dark .cart-item h4, .dark .cart-item span {
  color: #f9fafb; /* gray-50 */
}

/* Glassmorphism */
.glass-card {
  background: rgba(255, 255, 255, 0.7); /* bg-white/70 */
  backdrop-filter: blur(12px); /* backdrop-blur-md */
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

/* 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: 20px;
  overflow: hidden;
  box-shadow: 0 10px 25px -5px rgba(30, 41, 59, 0.07);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: none;
  animation: fadeIn 0.4s ease-out;
  will-change: transform, box-shadow;
}

.product-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 20px 35px -10px rgba(30, 41, 59, 0.15);
}

.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;
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
}

.product-card:hover .product-image {
  transform: scale(1.08);
}

.product-image-container {
  overflow: hidden;
  position: relative;
  background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
}

/* 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);
}

/* Grid de Productos - 2 columnas en móvil para ver más productos */
.product-grid-container {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)); /* 2 columnas en móvil */
  gap: 12px;
}
@media (min-width: 640px) {
  .product-grid-container { 
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
  }
}
@media (min-width: 1024px) {
  .product-grid-container { 
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 25px;
  }
}
@media (min-width: 1280px) {
  .product-grid-container { 
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 25px;
  }
}

/* [NUEVO] Skeleton para tarjetas de producto */
.product-skeleton-card {
  background: white;
  border-radius: 1.5rem;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.06);
}
.dark .product-skeleton-card {
  background: #1f2937; /* gray-800 */
  border-color: rgba(255, 255, 255, 0.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: transparent;
  color: #475569; /* slate-600 */
  border: 2px solid transparent;
  transition: all 0.2s ease;
  font-weight: 600;
}

.dept-button:hover {
  background: #fef2f2; /* red-50 */
  color: #EF4444; /* red-500 */
}

.dept-button.active {
  background: #EF4444;
  color: white;
  border-color: transparent;
  box-shadow: 0 4px 14px 0 rgba(239, 68, 68, 0.38);
  transform: translateY(-2px);
}
.dark .dept-button.active {
  background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
  color: white;
  border-color: #ef4444;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 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 - Estilo Profesional */
[class^="role-badge-"] {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px; /* pill shape */
  font-size: 0.75rem; /* 12px */
  font-weight: 700; /* bold */
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  vertical-align: middle;
}

.role-badge-cliente {
  background-color: #e5e7eb; /* gray-200 */
  color: #4b5563; /* gray-600 */
}

.role-badge-distribuidor {
  background-color: #fef3c7; /* amber-100 */
  color: #92400e; /* amber-800 */
}

.role-badge-gestor {
  background-color: #dbeafe; /* blue-100 */
  color: #1e40af; /* blue-800 */
}

.role-badge-admin {
  background-color: #1f2937; /* gray-800 */
  color: #f9fafb; /* gray-50 */
}

.role-badge-inventario {
  background-color: #d1fae5; /* green-100 */
  color: #065f46; /* green-800 */
}

/* Estilos para modo oscuro */
.dark .role-badge-cliente {
  background-color: #374151; /* gray-700 */
  color: #d1d5db; /* gray-300 */
}
.dark .role-badge-distribuidor {
  background-color: #78350f; /* amber-900 */
  color: #fef3c7; /* amber-100 */
}
.dark .role-badge-gestor {
  background-color: #1e3a8a; /* blue-900 */
  color: #dbeafe; /* blue-100 */
}
.dark .role-badge-admin {
  background-color: #f9fafb; /* gray-50 */
  color: #1f2937; /* gray-800 */
}
.dark .role-badge-inventario {
  background-color: #064e3b; /* green-900 */
  color: #d1fae5; /* green-100 */
}

/* 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;
  background: linear-gradient(135deg, #DC2626, #F97316, #B91c1c);
  transition: all 0.3s ease;
}

.add-to-cart-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 7px 20px rgba(239, 68, 68, 0.25);
  filter: brightness(1.05);
}

/* [NUEVO] Badge de "Bajó de Precio" */
.price-drop-badge {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%); /* green-500 to green-600 */
  color: black;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-weight: 800;
  font-size: 0.75rem;
  display: inline-block;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.4);
  animation: pulse 1.5s infinite;
}
.dark .price-drop-badge {
  color: black;
}

/* [NUEVO] Botón de Favoritos */
.favorite-btn {
  position: absolute;
  top: 1rem;
  left: 1rem;
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}
.favorite-btn:hover {
  transform: scale(1.1);
  background: white;
}
.favorite-btn svg {
  transition: all 0.2s ease-in-out;
  color: #9CA3AF; /* gray-400 */
}
.favorite-btn:hover svg {
  color: #F87171; /* red-400 */
}
.favorite-btn.active svg {
  fill: #EF4444; /* red-500 */
  color: #EF4444; /* red-500 */
  transform: scale(1.1);
}
.dark .favorite-btn {
  background: rgba(15, 23, 42, 0.7);
}
.dark .favorite-btn svg {
  color: #64748B; /* slate-500 */
}
.dark .favorite-btn.active svg {
  fill: #F87171; /* red-400 */
  color: #F87171; /* red-400 */
}

/* [NUEVO] Estilos de Precios Modernos */
.main-price {
  font-size: 1.5rem; /* 24px */
  font-weight: 800;
}
.main-price-detal {
  color: #EF4444; /* Rojo Vibrante */
}
.main-price-mayor {
  color: #10B981; /* Verde Esmeralda */
}

.price-pill {
  font-size: 0.875rem; /* 14px */
  font-weight: 700;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
}
.pill-green {
  background-color: #D1FAE5; /* green-100 */
  color: #047857; /* green-700 */
}
.pill-blue {
  background-color: #DBEAFE; /* blue-100 */
  color: #1D4ED8; /* blue-700 */
}

.dark .main-price-detal { color: #F87171; } /* red-400 */
.dark .main-price-mayor { color: #34D399; } /* green-400 */
.dark .pill-green { background-color: #064E3B; color: #A7F3D0; }
.dark .pill-blue { background-color: #1E3A8A; color: #BFDBFE; }

/* [NUEVO] Estilos para Botones de Admin */
.admin-btn {
  padding: 0.75rem 1.5rem;
  border-radius: 12px;
  color: white;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.3s ease;
  border: none;
}
.admin-btn:hover {
  transform: translateY(-3px);
  filter: brightness(1.1);
}
.btn-green {
  background: linear-gradient(135deg, #10B981, #059669);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}
.btn-orange, .btn-amber {
  background: linear-gradient(135deg, #F97316, #EA580C);
  box-shadow: 0 4px 12px rgba(249, 115, 22, 0.3);
}
.btn-blue, .btn-indigo {
  background: linear-gradient(135deg, #3B82F6, #2563EB);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}
.btn-red {
  background: linear-gradient(135deg, #EF4444, #DC2626);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}
.btn-teal, .btn-cyan {
  background: linear-gradient(135deg, #14B8A6, #0D9488);
  box-shadow: 0 4px 12px rgba(20, 184, 166, 0.3);
}
.btn-purple {
  background: linear-gradient(135deg, #8B5CF6, #7C3AED);
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}
.btn-pink {
  background: linear-gradient(135deg, #EC4899, #DB2777);
  box-shadow: 0 4px 12px rgba(236, 72, 153, 0.3);
}
.btn-gray {
  background: linear-gradient(135deg, #6B7280, #4B5563);
  box-shadow: 0 4px 12px rgba(107, 114, 128, 0.3);
}

/* 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 #EF4444;
  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: 0;
    border-radius: 12px;
  }

  /* En 2 columnas, las imágenes deben ser más pequeñas */
  .product-image {
    height: 125px;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
  }

  .product-image-container {
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
  }

  /* Texto más compacto en las tarjetas de 2 columnas */
  .product-card .p-5 {
    padding: 0.5rem !important;
  }

  /* Título de producto más pequeño en móvil */
  .product-card h3 {
    font-size: 0.85rem !important;
    line-height: 1.15rem !important;
    margin-bottom: 0.15rem !important;
  }

  /* Código de producto más pequeño en móvil */
  .product-card p.text-xs {
    font-size: 0.65rem !important;
    margin-bottom: 0.15rem !important;
  }

  /* Precios más pequeños en móvil */
  .product-card .main-price {
    font-size: 1.05rem !important;
  }

  .product-card .price-pill {
    font-size: 0.7rem !important;
    padding: 0.15rem 0.4rem !important;
  }

  .product-card .space-y-3 > :not([hidden]) ~ :not([hidden]) {
    margin-top: 0.25rem !important;
  }

  /* Badge de departamento más pequeño */
  .product-card span.text-xs {
    font-size: 0.65rem !important;
    padding: 0.1rem 0.3rem !important;
    margin-bottom: 0.35rem !important;
  }

  /* Botón agregar al carrito más pequeño */
  .product-card .add-to-cart-btn {
    padding-top: 0.4rem !important;
    padding-bottom: 0.4rem !important;
    font-size: 0.75rem !important;
    border-radius: 8px !important;
  }

  /* Badges de agotado / nuevo más pequeños y posicionados */
  .product-image-container span.absolute {
    font-size: 0.65rem !important;
    padding: 0.15rem 0.35rem !important;
    bottom: 2px !important;
    right: 2px !important;
    border-radius: 4px !important;
  }

  /* Badge de ¡NUEVO! y ¡BAJÓ DE PRECIO! más pequeños */
  .product-image-container .price-drop-badge,
  .product-image-container span.bg-red-500 {
    font-size: 0.6rem !important;
    padding: 0.1rem 0.3rem !important;
    top: 2px !important;
    border-radius: 4px !important;
  }
  
  .product-image-container .price-drop-badge {
    left: 2px !important;
  }
  
  .product-image-container span.bg-red-500 {
    right: 2px !important;
  }

  /* Botón de favorito en móvil */
  .product-card .favorite-btn {
    top: 2px !important;
    left: 2px !important;
    padding: 0.2rem !important;
  }
  .product-card .favorite-btn svg {
    width: 1.1rem !important;
    height: 1.1rem !important;
  }

  h1 {
    font-size: 1.25rem;
  }

  /* Logo del header más compacto en móvil */
  .header-logo {
    height: 44px !important;
  }

  /* Botones de admin: ancho completo en móvil para que no se junten */
  .admin-btn {
    width: 100%;
    justify-content: center;
    padding: 0.65rem 1rem;
    font-size: 0.875rem;
  }

  /* Banner más alto en móvil para que se vea bien */
  .banner-container {
    min-height: 180px;
    max-height: 220px;
    border-radius: 0.75rem;
  }

  /* Padding de la sección banner */
  section.banner-section {
    padding: 0.5rem 0.75rem;
    margin: 0.5rem 0;
  }
}

/* Tablet y pantallas medianas */
@media (min-width: 641px) {
  .header-logo {
    height: 64px;
  }
}

/* Pantallas grandes */
@media (min-width: 1024px) {
  .header-logo {
    height: 80px;
  }
}

/* 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 #EF4444;
  outline-offset: 2px;
}
