/* ==================== CSS Variables ==================== */
:root {
  /* Colors */
  --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  --success-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  --warning-gradient: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
  --danger-gradient: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);

  --bg-primary: #0f0f23;
  --bg-secondary: #1a1a2e;
  --bg-card: rgba(255, 255, 255, 0.05);
  --bg-card-hover: rgba(255, 255, 255, 0.08);

  --text-primary: #ffffff;
  --text-secondary: #b8b8d1;
  --text-muted: #7a7a9d;

  --border-color: rgba(255, 255, 255, 0.1);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.3);

  /* Spacing */
  --spacing-xs: 0.5rem;
  --spacing-sm: 1rem;
  --spacing-md: 1.5rem;
  --spacing-lg: 2rem;
  --spacing-xl: 3rem;

  /* Border Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  /* Transitions */
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s ease;
  --transition-slow: 0.5s ease;
}

/* ==================== Reset & Base Styles ==================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

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

/* ==================== Container ==================== */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--spacing-md);
  width: 100%;
}

/* ==================== Header ==================== */
.header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: var(--spacing-lg) 0;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
  background: rgba(26, 26, 46, 0.9);
}

.header-content {
  text-align: center;
}

.logo {
  font-size: 2.5rem;
  font-weight: 700;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: var(--spacing-xs);
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.logo-icon {
  font-size: 2.5rem;
  filter: drop-shadow(0 0 20px rgba(102, 126, 234, 0.5));
}

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

/* ==================== Main Content ==================== */
.main-content {
  flex: 1;
  padding: var(--spacing-xl) 0;
}

/* ==================== Store Section ==================== */
.store-section {
  margin-bottom: var(--spacing-xl);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-md);
}

.section-header h2 {
  font-size: 1.5rem;
  font-weight: 600;
}

.refresh-indicator {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  color: var(--text-muted);
  font-size: 0.875rem;
}

.refresh-dot {
  width: 8px;
  height: 8px;
  background: #4facfe;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

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

.store-selector-wrapper {
  position: relative;
  max-width: 500px;
}

.store-selector {
  width: 100%;
  padding: var(--spacing-md);
  padding-right: 3rem;
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 1rem;
  cursor: pointer;
  transition: all var(--transition-normal);
  appearance: none;
  backdrop-filter: blur(10px);
}

.store-selector:hover {
  background: var(--bg-card-hover);
  border-color: rgba(102, 126, 234, 0.5);
}

.store-selector:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

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

.selector-icon {
  position: absolute;
  right: var(--spacing-md);
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--text-secondary);
}

/* ==================== Search Section ==================== */
.search-section {
  margin-bottom: var(--spacing-lg);
}

.search-wrapper {
  position: relative;
  max-width: 600px;
}

.search-input {
  width: 100%;
  padding: var(--spacing-md);
  padding-right: 3rem;
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 1rem;
  transition: all var(--transition-normal);
  backdrop-filter: blur(10px);
}

.search-input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

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

.clear-search {
  position: absolute;
  right: var(--spacing-sm);
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: var(--text-primary);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.clear-search:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ==================== Products Section ==================== */
.products-section {
  min-height: 400px;
}

/* Loading State */
.loading-state {
  text-align: center;
  padding: var(--spacing-xl);
}

.spinner {
  width: 60px;
  height: 60px;
  margin: 0 auto var(--spacing-md);
  border: 4px solid var(--border-color);
  border-top-color: #667eea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Empty State */
.empty-state {
  text-align: center;
  padding: var(--spacing-xl);
}

.empty-icon {
  font-size: 4rem;
  margin-bottom: var(--spacing-md);
  opacity: 0.5;
}

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

.empty-state p {
  color: var(--text-secondary);
}

/* Error State */
.error-state {
  text-align: center;
  padding: var(--spacing-xl);
}

.error-icon {
  font-size: 4rem;
  margin-bottom: var(--spacing-md);
}

.error-state h3 {
  font-size: 1.5rem;
  margin-bottom: var(--spacing-sm);
  color: #ff6b6b;
}

.error-state p {
  color: var(--text-secondary);
  margin-bottom: var(--spacing-md);
}

.retry-button {
  padding: var(--spacing-sm) var(--spacing-lg);
  background: var(--primary-gradient);
  border: none;
  border-radius: var(--radius-md);
  color: white;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-normal);
  box-shadow: var(--shadow-md);
}

.retry-button:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* Products Grid */
.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--spacing-lg);
}

/* Product Card */
.product-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all var(--transition-normal);
  backdrop-filter: blur(10px);
  cursor: pointer;
}

.product-card:hover {
  transform: translateY(-8px);
  background: var(--bg-card-hover);
  box-shadow: var(--shadow-lg);
  border-color: rgba(102, 126, 234, 0.3);
}

.product-image-wrapper {
  position: relative;
  width: 100%;
  height: 200px;
  background: linear-gradient(
    135deg,
    rgba(102, 126, 234, 0.1) 0%,
    rgba(118, 75, 162, 0.1) 100%
  );
  overflow: hidden;
}

.product-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-slow);
}

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

.product-image-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  opacity: 0.3;
}

.product-info {
  padding: var(--spacing-md);
}

.product-name {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: var(--spacing-xs);
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-barcode {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: var(--spacing-sm);
  font-family: "Courier New", monospace;
}

.product-price {
  font-size: 1.5rem;
  font-weight: 700;
  background: var(--success-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: var(--spacing-sm);
}

.product-stock {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-xs);
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
}

.stock-in-stock {
  background: rgba(79, 172, 254, 0.2);
  color: #4facfe;
  border: 1px solid rgba(79, 172, 254, 0.3);
}

.stock-low-stock {
  background: rgba(250, 112, 154, 0.2);
  color: #fa709a;
  border: 1px solid rgba(250, 112, 154, 0.3);
}

.stock-out-of-stock {
  background: rgba(255, 107, 107, 0.2);
  color: #ff6b6b;
  border: 1px solid rgba(255, 107, 107, 0.3);
}

.stock-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

/* ==================== Footer ==================== */
.footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  padding: var(--spacing-lg) 0;
  text-align: center;
  color: var(--text-muted);
  margin-top: auto;
}

/* ==================== Responsive Design ==================== */
@media (max-width: 768px) {
  .logo {
    font-size: 2rem;
  }

  .logo-icon {
    font-size: 2rem;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--spacing-sm);
  }

  .products-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: var(--spacing-md);
  }

  .product-image-wrapper {
    height: 180px;
  }
}

@media (max-width: 480px) {
  .products-grid {
    grid-template-columns: 1fr;
  }

  .product-image-wrapper {
    height: 220px;
  }
}

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

.product-card {
  animation: fadeIn 0.5s ease forwards;
}

.product-card:nth-child(1) {
  animation-delay: 0.05s;
}
.product-card:nth-child(2) {
  animation-delay: 0.1s;
}
.product-card:nth-child(3) {
  animation-delay: 0.15s;
}
.product-card:nth-child(4) {
  animation-delay: 0.2s;
}
.product-card:nth-child(5) {
  animation-delay: 0.25s;
}
.product-card:nth-child(6) {
  animation-delay: 0.3s;
}

/* ==================== Cart Button ==================== */
.cart-button {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--primary-gradient);
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  transition: all var(--transition-normal);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cart-button:hover {
  transform: scale(1.1) translateY(-2px);
  box-shadow: 0 12px 40px rgba(102, 126, 234, 0.4);
}

.cart-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ff6b6b;
  color: white;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  border: 2px solid var(--bg-primary);
}

/* Cart Modal */
.cart-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-normal);
}

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

.cart-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.cart-content {
  position: absolute;
  top: 0;
  right: 0;
  width: 100%;
  max-width: 450px;
  height: 100%;
  background: var(--bg-secondary);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--transition-normal);
}

.cart-modal.active .cart-content {
  transform: translateX(0);
}

.cart-header {
  padding: var(--spacing-lg);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card);
}

.close-cart {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: var(--text-primary);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.25rem;
  transition: all var(--transition-fast);
}

.close-cart:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: rotate(90deg);
}

.cart-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-md);
}

.cart-empty {
  text-align: center;
  padding: var(--spacing-xl);
  color: var(--text-secondary);
}

.empty-cart-icon {
  font-size: 4rem;
  opacity: 0.3;
  margin-bottom: var(--spacing-md);
}

.cart-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-md);
  display: flex;
  gap: var(--spacing-md);
}

.cart-item-image {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-sm);
  object-fit: cover;
}

.cart-item-placeholder {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  opacity: 0.3;
}

.cart-item-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
}

.cart-item-name {
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.cart-item-price {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.cart-item-controls {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  margin-top: auto;
}

.qty-button {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: var(--bg-card-hover);
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.qty-button:hover {
  background: rgba(102, 126, 234, 0.2);
  border-color: #667eea;
}

.qty-button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.qty-value {
  min-width: 32px;
  text-align: center;
  font-weight: 600;
}

.remove-item {
  background: rgba(255, 107, 107, 0.1);
  border: 1px solid rgba(255, 107, 107, 0.3);
  color: #ff6b6b;
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.875rem;
  transition: all var(--transition-fast);
  margin-left: auto;
}

.remove-item:hover {
  background: rgba(255, 107, 107, 0.2);
}

.cart-footer {
  padding: var(--spacing-lg);
  border-top: 1px solid var(--border-color);
  background: var(--bg-card);
}

.cart-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-md);
  font-size: 1.25rem;
  font-weight: 600;
}

.total-price {
  background: var(--success-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-size: 1.5rem;
}

.whatsapp-button {
  width: 100%;
  padding: var(--spacing-md);
  background: #25D366;
  border: none;
  border-radius: var(--radius-md);
  color: white;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-normal);
  box-shadow: var(--shadow-md);
}

.whatsapp-button:hover {
  background: #20BA5A;
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.add-to-cart-btn {
  width: 100%;
  padding: var(--spacing-sm);
  background: var(--primary-gradient);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-normal);
  margin-top: var(--spacing-sm);
}

.add-to-cart-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.add-to-cart-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.add-to-cart-btn.in-cart {
  background: rgba(79, 172, 254, 0.2);
  color: #4facfe;
  border: 1px solid rgba(79, 172, 254, 0.3);
}

@media (max-width: 768px) {
  .cart-content {
    max-width: 100%;
  }
  
  .cart-button {
    bottom: 1.5rem;
    right: 1.5rem;
    width: 56px;
    height: 56px;
  }
}
