/* ── Variables ─────────────────────────────────────────────────── */
:root {
  --primary: #0066cc;
  --primary-hover: #0052a3;
  --bg: #f5f7fa;
  --card-bg: #ffffff;
  --text: #333333;
  --text-secondary: #666666;
  --border: #e0e4e8;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.12);
  --radius: 8px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ── Loading overlay ──────────────────────────────────────────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  gap: 16px;
  font-size: 18px;
  color: var(--text-secondary);
}

.loading-overlay[hidden] {
  display: none;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ── Header ───────────────────────────────────────────────────── */
.header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 24px 0;
  margin-bottom: 32px;
}

.header h1 {
  font-size: 24px;
  font-weight: 700;
}

.header .subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 4px;
}

/* ── Search & filters ─────────────────────────────────────────── */
.search-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.search-bar input[type="search"] {
  flex: 1;
  padding: 10px 16px;
  font-size: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  outline: none;
  transition: border-color 0.2s;
}

.search-bar input[type="search"]:focus {
  border-color: var(--primary);
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1 1 0;
}

.filter-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.filter-group select {
  padding: 8px 10px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  cursor: pointer;
}

.results-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  font-size: 14px;
  color: var(--text-secondary);
}

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
  padding: 8px 16px;
  font-size: 14px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--card-bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg);
}

.btn-secondary.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.results-bar-actions {
  display: flex;
  gap: 8px;
}

/* ── Star / Favorites ─────────────────────────────────────────── */
.result-star {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  opacity: 0.3;
  transition: opacity 0.15s, transform 0.15s;
}

.result-star:hover {
  opacity: 0.7;
  transform: scale(1.2);
}

.result-star.starred {
  opacity: 1;
}

/* ── Results ──────────────────────────────────────────────────── */
.results[hidden] {
  display: none;
}

.results {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.result-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
}

.result-row:nth-child(even) {
  background: #fafbfc;
}

.result-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.result-model {
  font-weight: 600;
  font-size: 15px;
}

.result-desc {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-specs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 13px;
}

.spec-tag {
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
}

.result-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.result-price {
  font-weight: 700;
  font-size: 16px;
  white-space: nowrap;
}

.result-price-inc {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.result-link {
  display: inline-block;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--primary);
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  text-decoration: none;
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
}

.result-link:hover {
  background: var(--primary);
  color: #fff;
}

/* ── Show more ────────────────────────────────────────────────── */
.show-more-container {
  text-align: center;
  padding: 24px 0;
}

.show-more-container[hidden] {
  display: none;
}

/* ── Empty state ──────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-secondary);
}

/* ── Footer ───────────────────────────────────────────────────── */
.footer {
  margin-top: 48px;
  padding: 24px 0;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 13px;
  color: var(--text-secondary);
}

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 768px) {
  .family-cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .filter-row {
    flex-direction: column;
  }

  .filter-group {
    min-width: 100%;
  }

  .search-bar {
    flex-direction: column;
  }

  .result-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .result-right {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}
