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

:root {
  --primary-color: #2563eb;
  --primary-dark: #1e40af;
  --primary-light: #60a5fa;
  --success-color: #10b981;
  --success-light: #34d399;
  --error-color: #ef4444;
  --warning-color: #f59e0b;
  --amazon-color: #ff9900;
  --flipkart-color: #2874f0;
  --bg-gradient-start: #667eea;
  --bg-gradient-end: #764ba2;
  --card-bg: #ffffff;
  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --border-color: #e5e7eb;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.15);
  --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.2);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  padding: 20px;
  overflow-x: hidden;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  animation: fadeIn 0.5s ease-in;
}

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

/* ==================== HEADER ==================== */
header {
  text-align: center;
  margin-bottom: 40px;
  color: white;
  animation: slideDown 0.6s ease-out;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-30px); }
  to { opacity: 1; transform: translateY(0); }
}

header h1 {
  font-size: 3rem;
  margin-bottom: 15px;
  text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.3);
  font-weight: 800;
  letter-spacing: -1px;
}

.subtitle {
  font-size: 1.3rem;
  opacity: 0.95;
  margin-bottom: 8px;
  font-weight: 500;
}

.subtitle-small {
  font-size: 1rem;
  opacity: 0.85;
  font-weight: 400;
}

/* ==================== SEARCH SECTION ==================== */
.search-section {
  background: var(--card-bg);
  padding: 40px;
  border-radius: 16px;
  box-shadow: var(--shadow-xl);
  margin-bottom: 40px;
  animation: scaleIn 0.5s ease-out;
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.search-box {
  display: flex;
  gap: 15px;
  margin-bottom: 15px;
}

#searchInput {
  flex: 1;
  padding: 18px 24px;
  font-size: 1.05rem;
  border: 2px solid var(--border-color);
  border-radius: 12px;
  outline: none;
  transition: all 0.3s ease;
  font-family: inherit;
}

#searchInput:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

#searchInput::placeholder {
  color: var(--text-secondary);
}

.btn-primary {
  padding: 18px 36px;
  font-size: 1.05rem;
  font-weight: 700;
  color: white;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  min-width: 140px;
  box-shadow: var(--shadow-md);
  font-family: inherit;
}

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

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-loader {
  animation: spin 1s linear infinite;
  display: inline-block;
}

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

.search-tips {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.search-tips strong {
  color: var(--primary-color);
}

/* ==================== LOWEST PRICE BANNER ==================== */
.lowest-price-banner {
  background: linear-gradient(135deg, var(--success-color) 0%, var(--success-light) 100%);
  color: white;
  padding: 25px 30px;
  border-radius: 16px;
  margin-bottom: 30px;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.5s ease-out;
}

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

.banner-content {
  display: flex;
  align-items: center;
  gap: 20px;
}

.banner-icon {
  font-size: 3rem;
  animation: bounce 2s infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.banner-text h3 {
  font-size: 1.4rem;
  margin-bottom: 8px;
  font-weight: 700;
}

.banner-text p {
  font-size: 1.1rem;
  opacity: 0.95;
  line-height: 1.5;
}

/* ==================== RESULTS SECTION ==================== */
.results-section {
  background: var(--card-bg);
  padding: 40px;
  border-radius: 16px;
  box-shadow: var(--shadow-xl);
  animation: fadeIn 0.6s ease-out;
}

.products-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 3px solid var(--border-color);
}

.products-header h2 {
  color: var(--text-primary);
  font-size: 1.8rem;
  font-weight: 700;
}

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

/* ==================== PRODUCTS GRID ==================== */
.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 25px;
}

.product-card {
  background: white;
  border: 2px solid var(--border-color);
  border-radius: 16px;
  padding: 24px;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  animation: cardFadeIn 0.5s ease-out backwards;
}

.product-card:nth-child(1) { animation-delay: 0.1s; }
.product-card:nth-child(2) { animation-delay: 0.2s; }
.product-card:nth-child(3) { animation-delay: 0.3s; }
.product-card:nth-child(4) { animation-delay: 0.4s; }
.product-card:nth-child(5) { animation-delay: 0.5s; }

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

.product-card:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-xl);
  border-color: var(--primary-light);
}

.product-card.lowest-price {
  border-color: var(--success-color);
  border-width: 3px;
  background: linear-gradient(to bottom, #f0fdf4 0%, white 100%);
}

.lowest-price-badge {
  position: absolute;
  top: 15px;
  right: 15px;
  background: linear-gradient(135deg, var(--success-color) 0%, var(--success-light) 100%);
  color: white;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 700;
  box-shadow: var(--shadow-md);
  animation: pulse 2s infinite;
}

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

.product-image {
  width: 100%;
  height: 220px;
  object-fit: contain;
  margin-bottom: 20px;
  background: #f9fafb;
  border-radius: 12px;
  padding: 15px;
  transition: transform 0.3s ease;
}

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

.product-website {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.website-amazon {
  background: #fff3cd;
  color: var(--amazon-color);
}

.website-flipkart {
  background: #e3f2fd;
  color: var(--flipkart-color);
}

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

.product-price {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--primary-color);
  margin-bottom: 12px;
  letter-spacing: -0.5px;
}

.product-rating {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.product-rating span:first-child {
  color: var(--warning-color);
  font-weight: 600;
}

.product-link {
  display: block;
  text-align: center;
  padding: 12px 20px;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
  color: white;
  text-decoration: none;
  border-radius: 10px;
  font-weight: 700;
  transition: all 0.3s ease;
  box-shadow: var(--shadow);
  font-size: 0.95rem;
}

.product-link:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* ==================== LOADING SECTION ==================== */
.loading-section {
  text-align: center;
  padding: 80px 30px;
  background: var(--card-bg);
  border-radius: 16px;
  box-shadow: var(--shadow-xl);
  animation: fadeIn 0.5s ease-out;
}

.loading-spinner {
  width: 60px;
  height: 60px;
  border: 5px solid var(--border-color);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 25px;
}

.loading-text {
  font-size: 1.3rem;
  color: var(--text-primary);
  margin-bottom: 10px;
  font-weight: 600;
}

.loading-section small {
  color: var(--text-secondary);
  display: block;
  margin-bottom: 30px;
}

.loading-progress {
  display: flex;
  justify-content: center;
  gap: 30px;
  margin-top: 30px;
  flex-wrap: wrap;
}

.progress-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  opacity: 0.4;
  transition: opacity 0.3s ease;
}

.progress-step.active {
  opacity: 1;
}

.progress-step .step-icon {
  font-size: 2rem;
  animation: stepBounce 1s ease-in-out infinite;
}

@keyframes stepBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.progress-step .step-text {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ==================== ERROR SECTION ==================== */
.error-section {
  background: var(--card-bg);
  padding: 60px 40px;
  border-radius: 16px;
  box-shadow: var(--shadow-xl);
  text-align: center;
  animation: fadeIn 0.5s ease-out;
}

.error-message {
  color: var(--error-color);
}

.error-icon {
  font-size: 4rem;
  display: block;
  margin-bottom: 20px;
  animation: shake 0.5s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-10px); }
  75% { transform: translateX(10px); }
}

#errorText {
  font-size: 1.2rem;
  margin-bottom: 25px;
  font-weight: 500;
}

.btn-retry {
  padding: 12px 30px;
  font-size: 1rem;
  font-weight: 600;
  color: white;
  background: var(--error-color);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: inherit;
}

.btn-retry:hover {
  background: #dc2626;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* ==================== FOOTER ==================== */
footer {
  text-align: center;
  margin-top: 50px;
  color: white;
  animation: fadeIn 0.8s ease-out;
}

.footer-content p {
  opacity: 0.9;
  font-size: 1rem;
  margin-bottom: 8px;
}

.footer-small {
  opacity: 0.7;
  font-size: 0.85rem;
}

footer strong {
  font-weight: 700;
}

/* ==================== RESPONSIVE DESIGN ==================== */
@media (max-width: 768px) {
  body {
    padding: 15px;
  }

  header h1 {
    font-size: 2.2rem;
  }

  .subtitle {
    font-size: 1.1rem;
  }

  .subtitle-small {
    font-size: 0.9rem;
  }

  .search-section {
    padding: 25px;
  }

  .search-box {
    flex-direction: column;
    gap: 12px;
  }

  #searchInput, .btn-primary {
    width: 100%;
  }

  .products-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .products-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .banner-content {
    gap: 15px;
  }

  .banner-icon {
    font-size: 2.5rem;
  }

  .banner-text h3 {
    font-size: 1.2rem;
  }

  .banner-text p {
    font-size: 1rem;
  }

  .loading-progress {
    gap: 20px;
  }

  .progress-step .step-icon {
    font-size: 1.5rem;
  }

  .results-section,
  .loading-section,
  .error-section {
    padding: 30px 20px;
  }
}

@media (max-width: 480px) {
  header h1 {
    font-size: 1.8rem;
  }

  .products-grid {
    grid-template-columns: 1fr;
  }

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