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

:root {
  --bg: #1a1b23;
  --bg-card: #24252f;
  --bg-hover: #2d2e3a;
  --text: #f0f0f5;
  --muted: #8a8a9a;
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, 0.15);
  --green: #22c55e;
  --border: rgba(255,255,255,0.06);
  --r: 5rem;
  --speed-idle: 7s;
  --speed-hover: 2.2s;
}

@property --a { syntax: "<angle>"; inherits: false; initial-value: 0deg; }

* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 62.5%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Montserrat", -apple-system, sans-serif;
  font-size: 1.4rem;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Layout */
.container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
  transition: all 0.4s ease;
}
.container.collapsed { justify-content: flex-start; padding-top: 2rem; }

/* Form */
.form { display: flex; flex-direction: column; width: 100%; transition: all 0.4s ease; }
.container.collapsed .form { transform: scale(0.7); margin-bottom: -2rem; }

.form__label {
  font-size: 5.5rem;
  font-weight: 800;
  text-align: center;
  margin-bottom: 2.5rem;
  letter-spacing: -1px;
}
.container.collapsed .form__label { font-size: 2.5rem; margin-bottom: 1rem; }

.search-wrapper { position: relative; width: 90%; max-width: 700px; margin: 0 auto; }

.form__input {
  width: 100%;
  height: 5.5rem;
  padding: 0 2.5rem;
  background: var(--bg-card);
  border: 2px solid transparent;
  border-radius: 3rem;
  color: var(--text);
  font-size: 1.8rem;
  font-family: inherit;
  outline: none;
  transition: all 0.2s;
}
.form__input:hover, .form__input:focus { border-color: var(--accent); background: var(--bg-hover); }
.form__input::placeholder { color: var(--muted); }
.container.collapsed .form__input { height: 4.5rem; font-size: 1.5rem; }

/* Autocomplete */
.autocomplete-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0; right: 0;
  background: var(--bg-card);
  border-radius: 1.5rem;
  border: 1px solid var(--border);
  max-height: 450px;
  overflow-y: auto;
  z-index: 100;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  display: none;
}
.autocomplete-dropdown.active { display: block; }

.autocomplete-item {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  padding: 1rem 1.5rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover, .autocomplete-item.active { background: var(--accent-soft); }

.autocomplete-thumb {
  width: 50px;
  height: 50px;
  border-radius: 8px;
  object-fit: contain;
  background: var(--bg);
  flex-shrink: 0;
}
.autocomplete-thumb-placeholder {
  width: 50px;
  height: 50px;
  border-radius: 8px;
  background: var(--bg);
  flex-shrink: 0;
}

.autocomplete-content { flex: 1; min-width: 0; }
.autocomplete-header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.autocomplete-name { font-size: 1.4rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.autocomplete-price { font-size: 1.4rem; font-weight: 700; color: var(--green); white-space: nowrap; }
.autocomplete-specs { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.5rem; }
.ac-pill { font-size: 1.1rem; padding: 0.2rem 0.6rem; background: var(--bg); border-radius: 4px; color: var(--muted); }

/* Button */
.priceit-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 4.8rem;
  padding: 0 3rem;
  margin: 2rem auto;
  border-radius: var(--r);
  border: none;
  background: var(--accent);
  color: white;
  font-size: 1.5rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.15s;
}
.container.collapsed .priceit-btn { height: 3.8rem; font-size: 1.3rem; margin: 1rem auto; }
.priceit-btn .label { position: relative; z-index: 2; }
.priceit-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--r);
  padding: 2px;
  background: conic-gradient(from var(--a), #f43f5e, #f97316, #eab308, #22c55e, #06b6d4, #8b5cf6, #f43f5e);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: spin var(--speed-idle) linear infinite;
}
.priceit-btn:hover::before { animation-duration: var(--speed-hover); }
.priceit-btn:hover { transform: translateY(-2px); }
.priceit-btn:active { transform: scale(0.98); }
@keyframes spin { to { --a: 360deg; } }

/* Loader */
.loader-container { display: none; padding: 4rem; }
.loader-container.active { display: flex; flex-direction: column; align-items: center; }
.loader { position: relative; width: 80px; height: 80px; }
.loader-ring {
  position: absolute;
  width: 100%; height: 100%;
  border-radius: 50%;
  border: 3px solid transparent;
  animation: loaderSpin 1s linear infinite;
}
.loader-ring:nth-child(1) { border-top-color: #f43f5e; }
.loader-ring:nth-child(2) { width: 70%; height: 70%; top: 15%; left: 15%; border-right-color: #06b6d4; animation-direction: reverse; }
.loader-ring:nth-child(3) { width: 40%; height: 40%; top: 30%; left: 30%; border-bottom-color: #22c55e; }
.loader-text { margin-top: 1.5rem; color: var(--muted); animation: pulse 1.5s infinite; }
@keyframes loaderSpin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 0.5; } 50% { opacity: 1; } }

/* Results */
.results-container { display: none; width: 100%; max-width: 1600px; margin: 0 auto; padding: 0 1.5rem 3rem; }
.results-container.active { display: block; }

.new-search-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1.4rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 2rem;
  color: var(--text);
  font-size: 1.2rem;
  font-family: inherit;
  cursor: pointer;
  margin-bottom: 1.5rem;
  transition: all 0.2s;
}
.new-search-btn:hover { background: var(--accent); border-color: var(--accent); }

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.results-info { display: flex; align-items: center; gap: 1rem; }
.results-query { font-size: 1.6rem; font-weight: 600; }
.results-meta { font-size: 1.2rem; color: var(--muted); }

/* Masonry Grid */
.masonry-grid {
  columns: 4 280px;
  column-gap: 1.5rem;
}

.masonry-item {
  break-inside: avoid;
  background: var(--bg-card);
  border-radius: 1.2rem;
  overflow: hidden;
  margin-bottom: 1.5rem;
  border: 1px solid var(--border);
  transition: transform 0.2s, box-shadow 0.2s;
}
.masonry-item:hover { transform: translateY(-4px); box-shadow: 0 15px 40px rgba(0,0,0,0.3); }

.card-image {
  width: 100%;
  background: linear-gradient(135deg, var(--bg-card), var(--bg));
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
}
.card-image img { width: 100%; height: auto; object-fit: contain; max-height: 250px; }
.card-image.no-image { display: none; }

.card-body { padding: 1.4rem; }

.card-title { font-size: 1.5rem; font-weight: 700; line-height: 1.3; margin-bottom: 0.5rem; }
.card-price { font-size: 2rem; font-weight: 800; color: var(--green); margin-bottom: 1rem; }

.spec-badges { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }
.spec-badge {
  font-size: 1.1rem;
  font-weight: 500;
  padding: 0.35rem 0.8rem;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 2rem;
}

.spec-table {
  background: var(--bg);
  border-radius: 0.8rem;
  padding: 0.8rem 1rem;
  margin-bottom: 1rem;
}
.spec-row {
  display: flex;
  justify-content: space-between;
  padding: 0.35rem 0;
  font-size: 1.15rem;
  border-bottom: 1px solid var(--border);
}
.spec-row:last-child { border-bottom: none; }
.spec-key { color: var(--muted); }
.spec-val { font-weight: 600; text-align: right; }

.card-desc {
  font-size: 1.25rem;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 1rem;
}

.card-links { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.card-link {
  font-size: 1.1rem;
  padding: 0.4rem 1rem;
  background: var(--bg);
  border-radius: 1.5rem;
  color: var(--text);
  text-decoration: none;
  text-transform: capitalize;
  transition: all 0.2s;
}
.card-link:hover { background: var(--accent); }

/* Error */
.error-box { text-align: center; padding: 4rem; color: var(--muted); }
.error-box h3 { font-size: 2rem; color: #f43f5e; margin: 1rem 0 0.5rem; }

/* Responsive */
@media (max-width: 1200px) { .masonry-grid { columns: 3 280px; } }
@media (max-width: 900px) { .masonry-grid { columns: 2 280px; } }
@media (max-width: 600px) {
  .form__label { font-size: 3.5rem; }
  .container.collapsed .form__label { font-size: 2rem; }
  .search-wrapper { width: 100%; }
  .masonry-grid { columns: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .priceit-btn::before, .loader-ring { animation: none !important; }
}

/* Card link wrapper for SEO URLs */
.card-link-wrap {
  display: block;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.card-link-wrap:hover .card-title {
  color: var(--accent);
}

.form__label-link {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.form__label-link {
  display: block;
  text-align: center;
  width: 100%;
}

.ext-icon {
  display: inline-block;
  vertical-align: middle;
  margin-right: 4px;
}

.card-link {
  display: inline-flex;
  align-items: center;
}
