/* Variables de colores - Diseño oscuro minimalista */
:root {
  --bg-primary: #0d0d0d;
  --bg-secondary: #1a1a1a;
  --bg-card: #242424;
  --bg-card-hover: #2d2d2d;
  --text-primary: #ffffff;
  --text-secondary: #b0b0b0;
  --text-muted: #666666;
  --accent: #00d4ff;
  --accent-hover: #00b8e6;
  --accent-glow: rgba(0, 212, 255, 0.3);
  --border-color: #333333;
  --success: #00ff88;
  --warning: #ffaa00;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  --transition: all 0.3s ease;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
}

/* Header */
.header {
  background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
  padding: 2rem;
  text-align: center;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header h1 {
  font-size: 2.5rem;
  font-weight: 700;
  background: linear-gradient(90deg, var(--accent), #ffffff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.5rem;
}

.header .subtitle {
  color: var(--text-secondary);
  font-size: 1rem;
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 2rem;
  flex-wrap: wrap;
}

.header-text {
  flex: 1;
  min-width: 250px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Botón de recarga */
.reload-btn {
  padding: 0.75rem 1.5rem;
  border: 2px solid var(--accent);
  border-radius: 10px;
  background: transparent;
  color: var(--accent);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
}

.reload-btn:hover {
  background: var(--accent);
  color: var(--bg-primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 15px var(--accent-glow);
}

.reload-btn svg {
  transition: transform 0.3s ease;
}

.reload-btn:hover svg {
  transform: rotate(180deg);
}

/* Indicador de carga */
.loading-indicator {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}


/* Container principal */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
}

/* Sección de filtros */
.filters-section {
  background: var(--bg-secondary);
  border-radius: 16px;
  padding: 1.5rem;
  margin-bottom: 2rem;
  border: 1px solid var(--border-color);
}

.filters-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
}

/* Barra de búsqueda */
.search-container {
  flex: 1;
  min-width: 250px;
  position: relative;
}

.search-container input {
  width: 100%;
  padding: 0.875rem 1rem 0.875rem 3rem;
  border: 2px solid var(--border-color);
  border-radius: 12px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 1rem;
  transition: var(--transition);
}

.search-container input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-container input::placeholder {
  color: var(--text-muted);
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  width: 20px;
  height: 20px;
}

/* Filtros desplegables */
.filter-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 0.75rem 1.25rem;
  border: 2px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-primary);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.filter-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg-primary);
}

.reset-btn {
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #ff4444, #cc0000);
  color: white;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.reset-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(255, 68, 68, 0.4);
}

/* Contador de resultados */
.results-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: var(--bg-secondary);
  border-radius: 10px;
  border: 1px solid var(--border-color);
}

.results-count {
  font-size: 1.1rem;
  color: var(--text-secondary);
}

.results-count span {
  color: var(--accent);
  font-weight: 700;
  font-size: 1.3rem;
}

/* Botón exportar PDF */
.pdf-btn {
  padding: 0.6rem 1.25rem;
  border: 2px solid #ff6b35;
  border-radius: 10px;
  background: transparent;
  color: #ff6b35;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
}

.pdf-btn:hover:not(:disabled) {
  background: #ff6b35;
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(255, 107, 53, 0.4);
}

.pdf-btn:disabled {
  opacity: 0.5;
  cursor: wait;
}


/* Grid de productos */
.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

/* Tarjeta de producto */
.product-card {
  background: var(--bg-card);
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  transition: var(--transition);
  cursor: pointer;
}

.product-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow);
  border-color: var(--accent);
}

.product-image-container {
  position: relative;
  height: 220px;
  background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.product-image {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
  transition: var(--transition);
}

.product-card:hover .product-image {
  transform: scale(1.05);
}

.no-image-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  gap: 0.5rem;
}

.no-image-placeholder svg {
  width: 60px;
  height: 60px;
  opacity: 0.5;
}

.no-image-placeholder span {
  font-size: 0.875rem;
}

.product-category-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 0.25rem 0.75rem;
  background: rgba(0, 212, 255, 0.9);
  color: var(--bg-primary);
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 20px;
  text-transform: uppercase;
}

.product-info {
  padding: 1.25rem;
}

.product-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.8em;
}

.product-price {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--success);
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 2rem;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: var(--bg-secondary);
  border-radius: 20px;
  max-width: 700px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  animation: modalIn 0.3s ease;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: var(--bg-card);
  border: none;
  color: var(--text-primary);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  z-index: 10;
}

.modal-close:hover {
  background: var(--accent);
  color: var(--bg-primary);
}

.modal-image-container {
  height: 350px;
  background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-card) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.modal-image {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
}

.modal-info {
  padding: 2rem;
}

.modal-category {
  display: inline-block;
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: var(--bg-primary);
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: 20px;
  text-transform: uppercase;
  margin-bottom: 1rem;
}

.modal-name {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 1rem;
  line-height: 1.4;
}

.modal-price {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--success);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
}

.empty-state svg {
  width: 80px;
  height: 80px;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 768px) {
  .header h1 {
    font-size: 1.8rem;
  }

  .container {
    padding: 1rem;
  }

  .filters-row {
    flex-direction: column;
    align-items: stretch;
  }

  .search-container {
    min-width: 100%;
  }

  .filter-group {
    justify-content: center;
  }

  .filter-btn {
    flex: 1;
    text-align: center;
    min-width: calc(50% - 0.25rem);
  }

  .products-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
  }

  .product-image-container {
    height: 160px;
  }

  .product-info {
    padding: 1rem;
  }

  .product-name {
    font-size: 0.85rem;
  }

  .product-price {
    font-size: 1.2rem;
  }

  .modal-content {
    max-height: 95vh;
    border-radius: 16px;
  }

  .modal-image-container {
    height: 250px;
  }

  .modal-name {
    font-size: 1.2rem;
  }

  .modal-price {
    font-size: 2rem;
  }

  .results-info {
    flex-direction: column;
    gap: 0.5rem;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .filter-btn {
    padding: 0.6rem 0.8rem;
    font-size: 0.75rem;
  }

  .products-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Scrollbar personalizada */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

/* ========== MODAL DE CARGA ========== */
.upload-modal-content {
  padding: 2.5rem;
  position: relative;
  max-width: 540px;
}

.upload-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}

.upload-subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 2rem;
  line-height: 1.6;
}

.upload-field {
  margin-bottom: 1.25rem;
}

.upload-label {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border: 2px dashed var(--border-color);
  border-radius: 14px;
  cursor: pointer;
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 500;
  transition: var(--transition);
}

.upload-label:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(0, 212, 255, 0.05);
}

.upload-label svg {
  flex-shrink: 0;
  color: var(--accent);
}

.upload-info {
  padding: 0.875rem 1.25rem;
  background: rgba(0, 212, 255, 0.08);
  border: 1px solid rgba(0, 212, 255, 0.2);
  border-radius: 10px;
  color: var(--accent);
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
}

.upload-confirm-btn {
  width: 100%;
  padding: 1rem 2rem;
  background: linear-gradient(135deg, var(--accent), #0099cc);
  border: none;
  border-radius: 12px;
  color: var(--bg-primary);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: var(--transition);
}

.upload-confirm-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px var(--accent-glow);
}

.upload-confirm-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Progress bar */
.upload-progress-bar {
  width: 100%;
  height: 10px;
  background: var(--bg-card);
  border-radius: 10px;
  overflow: hidden;
  margin: 1.5rem 0 0.5rem;
}

.upload-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #00ff88);
  border-radius: 10px;
  width: 0%;
  transition: width 0.4s ease;
}

.upload-progress-label {
  text-align: center;
  color: var(--accent);
  font-weight: 600;
  font-size: 1.25rem;
}

/* Resultado */
.upload-success,
.upload-error {
  text-align: center;
  padding: 1rem 0;
}

.upload-success-icon,
.upload-error-icon {
  font-size: 3.5rem;
  margin-bottom: 1rem;
}

.upload-success h3 {
  font-size: 1.5rem;
  color: var(--success);
  margin-bottom: 0.5rem;
}

.upload-error h3 {
  font-size: 1.5rem;
  color: #ff4444;
  margin-bottom: 0.5rem;
}

.upload-success p,
.upload-error p {
  color: var(--text-secondary);
  font-size: 1rem;
}

.upload-detail {
  font-size: 0.875rem !important;
  color: var(--text-muted) !important;
  margin-top: 0.25rem;
}

/* ========== TOGGLE DE PRECIO (Público / Mayoreo) ========== */
.price-toggle-container {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  gap: 0;
}

.price-toggle-btn {
  padding: 0.6rem 1.1rem;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  line-height: 1.3;
}

.price-toggle-btn:hover:not(.active-price) {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.price-toggle-btn.active-price {
  background: linear-gradient(135deg, #ff8c00, #ffaa00);
  color: #0d0d0d;
  border-radius: 9px;
}