/* ===== CSS Custom Properties ===== */
:root {
  /* Colors */
  --color-bg: #f8f9fc;
  --color-surface: #ffffff;
  --color-surface-alt: #f1f3f8;
  --color-text: #1a1d2e;
  --color-text-secondary: #6b7194;
  --color-text-muted: #9da3c0;
  --color-border: #e2e5f1;
  --color-border-light: #eef0f7;

  /* Accent gradient */
  --color-accent: #6366f1;
  --color-accent-dark: #4f46e5;
  --color-accent-light: #a5b4fc;
  --gradient-accent: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a78bfa 100%);
  --gradient-hero: linear-gradient(160deg, #f8f9fc 0%, #eef0f7 40%, #e8e4f8 100%);

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(99, 102, 241, 0.06);
  --shadow-md: 0 4px 16px rgba(99, 102, 241, 0.08);
  --shadow-lg: 0 8px 32px rgba(99, 102, 241, 0.12);
  --shadow-xl: 0 16px 48px rgba(99, 102, 241, 0.16);
  --shadow-glow: 0 0 0 3px rgba(99, 102, 241, 0.15);

  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --font-size-3xl: 2rem;
  --font-size-4xl: 2.5rem;
  --font-size-5xl: 3.5rem;

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;

  /* Borders */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-2xl: 1.5rem;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 400ms ease;
}

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

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

body {
  font-family: var(--font-family);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--color-accent);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-accent-dark);
}

img {
  max-width: 100%;
  display: block;
}

button {
  font-family: var(--font-family);
  cursor: pointer;
  border: none;
  background: none;
}

ul, ol {
  list-style: none;
}

/* ===== Utility Classes ===== */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-6);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ===== Landing Page Hero ===== */
.hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 80px);
  background: var(--gradient-hero);
  padding: var(--space-8);
  text-align: center;
}

.hero__logo {
  margin-bottom: var(--space-6);
  animation: fadeInDown 0.6s ease-out;
}

.hero__logo img,
.hero__logo svg {
  height: 56px;
  width: auto;
}

.hero__brand {
  font-size: var(--font-size-5xl);
  font-weight: 800;
  letter-spacing: -0.03em;
  background: var(--gradient-accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: var(--space-3);
  animation: fadeInDown 0.6s ease-out 0.1s both;
}

.hero__tagline {
  font-size: var(--font-size-xl);
  color: var(--color-text-secondary);
  font-weight: 400;
  margin-bottom: var(--space-12);
  animation: fadeInDown 0.6s ease-out 0.2s both;
}

/* ===== Search Bar ===== */
.search-wrapper {
  width: 100%;
  max-width: 680px;
  animation: fadeInUp 0.6s ease-out 0.3s both;
}

.search-bar {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: var(--space-2) var(--space-3);
  box-shadow: var(--shadow-md);
  transition: all var(--transition-base);
}

.search-bar:focus-within {
  border-color: var(--color-accent);
  box-shadow: var(--shadow-glow), var(--shadow-lg);
  transform: translateY(-1px);
}

.search-bar__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.search-bar__icon svg {
  width: 22px;
  height: 22px;
}

.search-bar__input {
  flex: 1;
  border: none;
  outline: none;
  font-size: var(--font-size-lg);
  font-family: var(--font-family);
  color: var(--color-text);
  background: transparent;
  padding: var(--space-3) var(--space-2);
}

.search-bar__input::placeholder {
  color: var(--color-text-muted);
  transition: opacity var(--transition-fast);
}

.search-bar__input:focus::placeholder {
  opacity: 0.5;
}

.search-bar__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: var(--gradient-accent);
  color: white;
  flex-shrink: 0;
  transition: all var(--transition-base);
  box-shadow: var(--shadow-sm);
}

.search-bar__btn:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-md);
}

.search-bar__btn:active {
  transform: scale(0.97);
}

.search-bar__btn svg {
  width: 20px;
  height: 20px;
}

/* ===== Category Chips ===== */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  justify-content: center;
  margin-top: var(--space-8);
  animation: fadeInUp 0.6s ease-out 0.45s both;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-5);
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text-secondary);
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.chip:hover {
  color: var(--color-accent);
  border-color: var(--color-accent-light);
  background: white;
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.chip__icon {
  font-size: var(--font-size-base);
}

/* ===== Navbar (Product Page) ===== */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: var(--space-6);
  padding: var(--space-3) var(--space-6);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--color-border-light);
  box-shadow: var(--shadow-sm);
}

.navbar__logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
  flex-shrink: 0;
}

.navbar__logo svg,
.navbar__logo img {
  height: 32px;
  width: auto;
}

.navbar__logo-text {
  font-size: var(--font-size-xl);
  font-weight: 700;
  background: var(--gradient-accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.navbar .search-bar {
  max-width: 520px;
  flex: 1;
  padding: var(--space-1) var(--space-2);
}

.navbar .search-bar__input {
  font-size: var(--font-size-base);
  padding: var(--space-2) var(--space-2);
}

.navbar .search-bar__icon {
  width: 36px;
  height: 36px;
}

.navbar .search-bar__icon svg {
  width: 18px;
  height: 18px;
}

.navbar .search-bar__btn {
  width: 38px;
  height: 38px;
}

.navbar .search-bar__btn svg {
  width: 16px;
  height: 16px;
}

/* ===== Product Page Content ===== */
.product-page {
  flex: 1;
  padding: var(--space-8) 0;
}

/* Product Info Card */
.product-info {
  display: flex;
  gap: var(--space-8);
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  box-shadow: var(--shadow-md);
  margin-bottom: var(--space-8);
  animation: fadeInUp 0.5s ease-out;
}

.product-info__image {
  width: 200px;
  height: 200px;
  flex-shrink: 0;
  border-radius: var(--radius-lg);
  background: var(--color-surface-alt);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.product-info__image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: var(--space-4);
}

.product-info__details {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.product-info__category {
  font-size: var(--font-size-sm);
  color: var(--color-accent);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.product-info__title {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  line-height: 1.3;
  color: var(--color-text);
}

.product-info__identifiers {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.product-info__id-tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--font-size-xs);
  font-weight: 500;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--color-surface-alt);
  color: var(--color-text-secondary);
}

.product-info__id-tag strong {
  color: var(--color-text);
}

.product-info__best-price {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: auto;
}

.best-price__label {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

.best-price__value {
  font-size: var(--font-size-3xl);
  font-weight: 800;
  color: #10b981;
}

.best-price__badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--font-size-xs);
  font-weight: 600;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  background: #ecfdf5;
  color: #059669;
}

/* ===== Chart Section ===== */
.chart-section {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  box-shadow: var(--shadow-md);
  margin-bottom: var(--space-8);
  animation: fadeInUp 0.5s ease-out 0.1s both;
}

.chart-section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
  gap: var(--space-4);
}

.chart-section__title {
  font-size: var(--font-size-xl);
  font-weight: 700;
}

.time-range-btns {
  display: flex;
  gap: var(--space-1);
  background: var(--color-surface-alt);
  border-radius: var(--radius-full);
  padding: var(--space-1);
}

.time-range-btn {
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text-secondary);
  transition: all var(--transition-fast);
}

.time-range-btn:hover {
  color: var(--color-text);
}

.time-range-btn.active {
  background: var(--color-surface);
  color: var(--color-accent);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}

#price-chart {
  width: 100%;
  min-height: 380px;
}

/* ===== Shop Comparison Table ===== */
.comparison-section {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  box-shadow: var(--shadow-md);
  animation: fadeInUp 0.5s ease-out 0.2s both;
}

.comparison-section__title {
  font-size: var(--font-size-xl);
  font-weight: 700;
  margin-bottom: var(--space-6);
}

.shop-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.shop-table thead th {
  text-align: left;
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  padding: var(--space-3) var(--space-4);
  border-bottom: 2px solid var(--color-border-light);
}

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

.shop-table tbody tr:hover {
  background: var(--color-surface-alt);
}

.shop-table tbody td {
  padding: var(--space-4);
  border-bottom: 1px solid var(--color-border-light);
  vertical-align: middle;
}

.shop-table tbody tr:last-child td {
  border-bottom: none;
}

.shop-cell {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.shop-cell__logo {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--color-surface-alt);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-lg);
  flex-shrink: 0;
}

.shop-cell__name {
  font-weight: 600;
  font-size: var(--font-size-base);
}

.price-cell {
  font-weight: 700;
  font-size: var(--font-size-lg);
}

.price-cell--best {
  color: #10b981;
}

.stock-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--font-size-sm);
  font-weight: 500;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
}

.stock-badge--in-stock {
  background: #ecfdf5;
  color: #059669;
}

.stock-badge--low-stock {
  background: #fffbeb;
  color: #d97706;
}

.stock-badge--out-of-stock {
  background: #fef2f2;
  color: #dc2626;
}

.shop-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-5);
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-accent);
  border: 1.5px solid var(--color-accent-light);
  background: transparent;
  transition: all var(--transition-fast);
}

.shop-btn:hover {
  background: var(--color-accent);
  color: white;
  border-color: var(--color-accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.shop-btn svg {
  width: 14px;
  height: 14px;
}

/* ===== Footer ===== */
.footer {
  background: var(--color-surface);
  border-top: 1px solid var(--color-border-light);
  padding: var(--space-8) 0;
  margin-top: auto;
}

.footer__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-4);
}

.footer__links {
  display: flex;
  gap: var(--space-6);
}

.footer__link {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text-secondary);
  transition: color var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.footer__link:hover {
  color: var(--color-accent);
}

.footer__link svg {
  width: 16px;
  height: 16px;
}

.footer__link--api {
  color: var(--color-accent);
  font-weight: 600;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  border: 1.5px solid var(--color-accent-light);
  transition: all var(--transition-fast);
}

.footer__link--api:hover {
  background: var(--color-accent);
  color: white;
  border-color: var(--color-accent);
}

.footer__copy {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

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

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

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .hero__brand {
    font-size: var(--font-size-3xl);
  }

  .hero__tagline {
    font-size: var(--font-size-base);
  }

  .search-bar {
    padding: var(--space-1) var(--space-2);
  }

  .search-bar__input {
    font-size: var(--font-size-base);
    padding: var(--space-2);
  }

  .search-bar__btn {
    width: 40px;
    height: 40px;
  }

  .product-info {
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: var(--space-6);
  }

  .product-info__image {
    width: 160px;
    height: 160px;
  }

  .product-info__identifiers {
    justify-content: center;
  }

  .product-info__best-price {
    justify-content: center;
  }

  .chart-section__header {
    flex-direction: column;
    align-items: flex-start;
  }

  .navbar {
    padding: var(--space-3) var(--space-4);
    gap: var(--space-3);
  }

  .navbar__logo-text {
    display: none;
  }

  .shop-table {
    display: block;
    overflow-x: auto;
  }

  .footer__inner {
    flex-direction: column;
    text-align: center;
  }

  .footer__links {
    flex-wrap: wrap;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .hero__brand {
    font-size: var(--font-size-2xl);
  }

  .chips {
    gap: var(--space-2);
  }

  .chip {
    font-size: var(--font-size-xs);
    padding: var(--space-1) var(--space-3);
  }

  .time-range-btns {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}
