/* ============================================
   COMPARADOR DE PRECIOS - DESIGN SYSTEM
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

/* --- CSS Variables --- */
:root {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-glass: rgba(0, 0, 0, 0.02);
  --bg-glass-hover: rgba(0, 0, 0, 0.04);
  --border-glass: rgba(0, 0, 0, 0.08);
  --border-glass-hover: rgba(0, 0, 0, 0.15);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  --accent-1: #4f46e5;
  --accent-2: #7c3aed;
  --accent-3: #a78bfa;
  --gradient-main: linear-gradient(135deg, #4f46e5, #7c3aed);
  --gradient-hero: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);

  --green: #10b981;
  --green-bg: #ecfdf5;
  --green-border: #d1fae5;
  --red: #ef4444;
  --red-bg: #fef2f2;
  --red-border: #fee2e2;
  --yellow: #f59e0b;
  --yellow-bg: #fffbeb;

  --devoto-color: #e53935;
  --disco-color: #1e88e5;
  --tata-color: #f59e0b;
  --geant-color: #43a047;
  --inglesa-color: #5e35b1;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
  --shadow-glow: 0 0 30px rgba(79, 70, 229, 0.05);

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
  --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* --- Background Orbs --- */
.bg-orbs {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.bg-orbs .orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.08;
  animation: float 20s ease-in-out infinite;
}

.bg-orbs .orb:nth-child(1) {
  width: 500px; height: 500px;
  background: var(--accent-1);
  top: -10%; left: -5%;
  animation-delay: 0s;
}

.bg-orbs .orb:nth-child(2) {
  width: 400px; height: 400px;
  background: var(--accent-2);
  top: 50%; right: -10%;
  animation-delay: -7s;
}

.bg-orbs .orb:nth-child(3) {
  width: 350px; height: 350px;
  background: #06b6d4;
  bottom: -5%; left: 30%;
  animation-delay: -14s;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -30px) scale(1.05); }
  66% { transform: translate(-20px, 20px) scale(0.95); }
}

/* --- Container --- */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  position: relative;
  z-index: 1;
}

/* --- Header / Hero --- */
.hero {
  text-align: center;
  padding: 60px 0 40px;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: 100px;
  padding: 8px 20px;
  font-size: 0.85rem;
  color: var(--accent-3);
  margin-bottom: 24px;
  backdrop-filter: blur(10px);
}

.hero-badge .pulse {
  width: 8px; height: 8px;
  background: var(--green);
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.3); }
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 800;
  background: var(--gradient-main);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 16px;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.hero p {
  font-size: 1.1rem;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto 32px;
}

/* --- Search Bar --- */
.search-container {
  max-width: 600px;
  margin: 0 auto 20px;
  position: relative;
}

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

.search-input {
  width: 100%;
  padding: 16px 180px 16px 50px;
  border-radius: 100px;
  border: 1px solid var(--border-glass);
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  color: var(--text-primary);
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  transition: all var(--transition-normal);
}

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

.search-input:focus {
  border-color: var(--accent-1);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1), var(--shadow-md);
}

.live-search-btn {
  position: absolute;
  right: 6px;
  top: 6px;
  bottom: 6px;
  padding: 0 20px;
  background: var(--accent-1);
  color: white;
  border: none;
  border-radius: 100px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-normal);
  display: flex;
  align-items: center;
  gap: 6px;
}

.live-search-btn:hover {
  background: var(--accent-2);
  transform: scale(1.02);
}
.live-search-btn:disabled {
  background: var(--border-glass-hover);
  cursor: not-allowed;
  transform: none;
}

/* --- Stats Bar --- */
.stats-bar {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 16px 24px;
  backdrop-filter: blur(10px);
  text-align: center;
  min-width: 160px;
  transition: all var(--transition-normal);
}

.stat-card:hover {
  border-color: var(--border-glass-hover);
  transform: translateY(-2px);
}

.stat-card .stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent-1);
}

.stat-card .stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 4px;
}

/* --- Filters --- */
.filters-section {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 24px;
}

.filter-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 8px 18px;
  border-radius: 100px;
  border: 1px solid var(--border-glass);
  background: var(--bg-glass);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  backdrop-filter: blur(10px);
}

.filter-btn:hover {
  border-color: var(--accent-1);
  color: var(--text-primary);
  background: var(--bg-glass-hover);
}

.filter-btn.active {
  background: var(--accent-1);
  border-color: var(--accent-1);
  color: #fff;
  font-weight: 500;
}

.sort-select {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-glass);
  background: var(--bg-glass);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  backdrop-filter: blur(10px);
  margin-left: auto;
}

.sort-select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

/* --- Product Table --- */
.products-table-wrap {
  background: #ffffff;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  margin-bottom: 40px;
}

.products-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.products-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

.products-table th {
  background: #f8fafc;
  backdrop-filter: blur(10px);
  padding: 14px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-glass);
  white-space: nowrap;
}

.products-table th.price-col {
  text-align: center;
  min-width: 100px;
}

.products-table th .store-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

.products-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-glass);
  vertical-align: middle;
}

.products-table tbody tr {
  transition: background var(--transition-fast);
}

.products-table tbody tr:hover {
  background: var(--bg-glass-hover);
}

/* Product Info Cell */
.product-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.product-img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  mix-blend-mode: multiply;
  background-color: transparent;
}

.product-emoji {
  font-size: 1.5rem;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-glass);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.product-name {
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.3;
}

.product-unit {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Category Badge */
.category-badge {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--bg-glass);
  color: var(--text-secondary);
  border: 1px solid var(--border-glass);
}

/* Price Cells */
.price-cell {
  text-align: center;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 0 !important;
  transition: all var(--transition-fast);
  position: relative;
  height: 100%;
}

.price-cell-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  gap: 4px;
  width: 100%;
  height: 100%;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
}

.price-val {
  flex: 1;
  text-align: center;
}

.store-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  color: var(--text-muted);
  opacity: 0.3;
  transition: all var(--transition-fast);
  text-decoration: none;
  background: transparent;
}

.price-cell-inner:hover .store-link {
  opacity: 1;
  color: var(--text-secondary);
}

.store-link:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--accent-primary) !important;
  transform: scale(1.1);
}

.price-cell-inner:hover {
  background: var(--bg-glass-hover);
  border-color: var(--accent-1);
}

.price-cell-inner.in-cart {
  background: var(--accent-1);
  color: #fff;
  border-color: var(--accent-1);
}

.price-cell-inner.cheapest {
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid var(--green-border);
}
.price-cell-inner.cheapest.in-cart {
  background: var(--green);
  color: #fff;
}

.price-cell-inner.expensive {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid var(--red-border);
}
.price-cell-inner.expensive.in-cart {
  background: var(--red);
  color: #fff;
}

.price-cell .price-na {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 0.8rem;
  cursor: default;
  padding: 8px 12px;
  display: block;
}

/* Savings Badge */
.savings-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid var(--green-border);
}

/* --- Shopping List Panel --- */
.shopping-panel {
  position: fixed;
  right: -420px;
  top: 0;
  width: 400px;
  height: 100vh;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(30px);
  border-left: 1px solid var(--border-glass);
  z-index: 1000;
  transition: right var(--transition-slow);
  display: flex;
  flex-direction: column;
  box-shadow: -10px 0 40px rgba(0,0,0,0.08);
}

.shopping-panel.open {
  right: 0;
}

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

.shopping-panel-title-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.shopping-panel-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
}

.shopping-panel-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.5rem;
  padding: 4px;
  line-height: 1;
}

.shopping-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px;
}

.shopping-list-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 20px;
  font-size: 0.9rem;
}

.shopping-store-group {
  margin-bottom: 24px;
  animation: slideIn 0.2s ease;
}

.shopping-store-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border-glass);
}

.shopping-store-title {
  font-size: 0.95rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.shopping-store-subtotal {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent-3);
}

.shopping-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.02);
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

.shopping-item-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.shopping-item-img {
  width: 30px;
  height: 30px;
  object-fit: contain;
  flex-shrink: 0;
  mix-blend-mode: multiply;
}

.shopping-item-emoji {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-glass);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.shopping-item-name {
  font-size: 0.85rem;
  font-weight: 500;
}

.shopping-item-price {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.shopping-item-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.qty-controls {
  display: flex;
  align-items: center;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-glass);
  overflow: hidden;
}

.qty-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background var(--transition-fast);
}

.qty-btn:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
}

.qty-value {
  font-size: 0.8rem;
  font-weight: 600;
  width: 20px;
  text-align: center;
}

.shopping-item-remove {
  background: none;
  border: none;
  color: var(--red);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}

.shopping-item-remove:hover {
  background: var(--red-bg);
}

.checkout-btn {
  width: 100%;
  padding: 10px;
  margin-top: 12px;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.checkout-btn:hover {
  background: var(--bg-glass-hover);
  transform: translateY(-1px);
}

.empty-cart-btn {
  background: none;
  border: none;
  color: var(--red);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: color var(--transition-fast);
}

.empty-cart-btn:hover {
  color: #f87171;
  text-decoration: underline;
}

.shopping-totals {
  padding: 20px 24px;
  border-top: 1px solid var(--border-glass);
  background: rgba(0,0,0,0.2);
}

.shopping-totals-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.shopping-totals-header h4 {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.shopping-grand-total {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--green);
}

.store-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  font-size: 0.9rem;
}

.store-total .store-name {
  display: flex;
  align-items: center;
  gap: 8px;
}

.store-total .store-dot-sm {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.store-total.best-total {
  color: var(--green);
  font-weight: 700;
}

.store-total.best-total::after {
  content: '⭐ Mejor precio';
  font-size: 0.7rem;
  margin-left: 8px;
  background: var(--green-bg);
  padding: 2px 8px;
  border-radius: 100px;
}

/* Shopping FAB */
.shopping-fab {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--gradient-main);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: #fff;
  box-shadow: var(--shadow-lg), 0 0 20px rgba(99, 102, 241, 0.3);
  transition: all var(--transition-normal);
  z-index: 999;
}

.shopping-fab:hover {
  transform: scale(1.1);
  box-shadow: var(--shadow-lg), 0 0 40px rgba(99, 102, 241, 0.5);
}

.shopping-fab .badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg-primary);
}

.shopping-fab .badge:empty { display: none; }

/* Removed old add-cart-btn styles as they are replaced by clickable price cells */

/* --- Overlay --- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.overlay.active {
  opacity: 1;
  pointer-events: all;
}

/* --- Results Count --- */
.results-count {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.results-count span {
  color: var(--accent-1);
  font-weight: 600;
}

/* --- No Results --- */
.no-results {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.no-results .no-results-icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

.no-results h3 {
  color: var(--text-secondary);
  margin-bottom: 8px;
}

/* --- Footer --- */
.footer {
  text-align: center;
  padding: 40px 0;
  border-top: 1px solid var(--border-glass);
  color: var(--text-muted);
  font-size: 0.8rem;
}

.footer a {
  color: var(--accent-1);
  text-decoration: none;
}

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.2); }

/* --- Animations --- */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in-up {
  animation: fadeInUp 0.5s ease forwards;
}

/* --- Responsive --- */
@media (max-width: 1200px) {
  .products-table-wrap {
    overflow-x: auto;
  }
}

@media (max-width: 768px) {
  .hero { padding: 40px 0 24px; }
  .hero h1 { font-size: 1.8rem; }
  .hero p { font-size: 0.95rem; }

  .stats-bar { gap: 8px; }
  .stat-card { min-width: 120px; padding: 12px 16px; }
  .stat-card .stat-value { font-size: 1.2rem; }

  .filters-section { gap: 8px; }
  .filter-btn { padding: 6px 14px; font-size: 0.8rem; }

  .products-table { font-size: 0.8rem; }
  .products-table th, .products-table td { padding: 10px 8px; }
  .product-img { width: 32px; height: 32px; }

  .shopping-panel { width: 100%; right: -100%; }
  .shopping-fab { bottom: 20px; right: 20px; width: 52px; height: 52px; }

  .container { padding: 0 16px; }
}

@media (max-width: 480px) {
  .hero h1 { font-size: 1.5rem; }
  .stats-bar { flex-direction: column; align-items: center; }
  .sort-select { margin-left: 0; width: 100%; }
}
