/* ============================================
   3D Printer Prices — Design System
   ============================================ */

:root {
  /* Colors — Dark Theme (default) */
  --bg-primary: #0a0f1a;
  --bg-secondary: #111827;
  --bg-card: #1a2332;
  --bg-hover: #243044;
  --text-primary: #f0f4f8;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #06b6d4;
  --accent-hover: #22d3ee;
  --accent-glow: rgba(6, 182, 212, 0.15);
  --border: #1e293b;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  --radius: 12px;
  --radius-sm: 8px;
}

[data-theme="light"] {
  --bg-primary: #f1f5f9;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-hover: #f8fafc;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --accent: #0891b2;
  --accent-hover: #06b6d4;
  --accent-glow: rgba(8, 145, 178, 0.1);
  --border: #e2e8f0;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

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

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

/* ============================================
   Header
   ============================================ */
.header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 1rem 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.header-content {
  max-width: 1600px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

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

.logo h1 {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.tagline {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.btn-icon {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem;
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.2s;
}

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

/* ============================================
   Stats Bar
   ============================================ */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  padding: 1.25rem 2rem;
  max-width: 1600px;
  margin: 0 auto;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  transition: all 0.2s;
}

.stat-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ============================================
   Use-Case Chips
   ============================================ */
.use-cases {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0.5rem 2rem 0.75rem;
}

.use-case-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.use-case-row::-webkit-scrollbar {
  display: none;
}

.uc-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  font-weight: 500;
}

.use-case-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.85rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
}

.use-case-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}

.use-case-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px var(--accent-glow);
}

/* ============================================
   Layout
   ============================================ */
.main-layout {
  max-width: 1600px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 1.5rem;
  padding: 0 2rem 2rem;
}

/* ============================================
   Sidebar Filters
   ============================================ */
.sidebar {
  position: sticky;
  top: 80px;
  height: fit-content;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.filter-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.filter-section h3 {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--text-secondary);
}

.filter-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s;
}

.filter-input:focus {
  border-color: var(--accent);
}

.filter-input.small {
  width: 45%;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 200px;
  overflow-y: auto;
}

.filter-group label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.2rem 0;
}

.filter-group label:hover {
  color: var(--text-primary);
}

.filter-group input[type="checkbox"] {
  accent-color: var(--accent);
}

.price-range {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.price-range span {
  color: var(--text-muted);
}

/* ============================================
   Buttons
   ============================================ */
.btn {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}

.btn-secondary {
  width: 100%;
  text-align: center;
  color: var(--text-muted);
}

/* ============================================
   Content Area
   ============================================ */
.table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

#result-count {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.sort-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sort-controls label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.sort-controls select {
  padding: 0.35rem 0.6rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.8rem;
}

/* ============================================
   Table
   ============================================ */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

thead th {
  background: var(--bg-card);
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
}

thead th.sortable {
  cursor: pointer;
}

thead th.sortable:hover {
  color: var(--accent);
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

tbody tr:hover {
  background: var(--bg-hover);
}

td {
  padding: 0.65rem 1rem;
  vertical-align: middle;
}

.product-name {
  max-width: 350px;
  font-weight: 500;
}

.product-name a {
  color: var(--text-primary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-name a:hover {
  color: var(--accent);
}

.price-cell {
  font-weight: 700;
  color: var(--success);
  font-size: 0.95rem;
  white-space: nowrap;
}

.brand-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  background: var(--accent-glow);
  border: 1px solid var(--accent);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--accent);
  white-space: nowrap;
}

.rating-cell {
  white-space: nowrap;
  color: var(--warning);
  font-weight: 500;
}

.type-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  white-space: nowrap;
}

.condition-new {
  color: var(--success);
}

.condition-used {
  color: var(--warning);
}

td.loading {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ============================================
   Pagination
   ============================================ */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem 0;
}

#page-info {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ============================================
   Ad Containers
   ============================================ */
.ad-container {
  max-width: 1600px;
  margin: 0 auto;
  text-align: center;
  overflow: hidden;
}

.ad-banner {
  padding: 0.5rem 2rem;
  min-height: 90px;
}

.ad-sidebar {
  margin-top: 0.5rem;
  min-height: 250px;
  border-radius: var(--radius);
  overflow: hidden;
}

.ad-in-feed {
  padding: 0.75rem 0;
  min-height: 100px;
}

/* Hide ads on very small screens if needed */
@media (max-width: 600px) {
  .ad-banner {
    padding: 0.25rem 1rem;
    min-height: 50px;
  }
}

/* ============================================
   Footer
   ============================================ */
.footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: 0.75rem;
  border-top: 1px solid var(--border);
  margin-top: 1rem;
}

.footer-links {
  margin-top: 0.5rem;
}

.footer-links a {
  color: var(--text-muted);
  transition: color 0.2s;
}

.footer-links a:hover {
  color: var(--accent);
  text-decoration: none;
}

/* ============================================
   Policy Pages
   ============================================ */
.policy-page {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem;
  line-height: 1.8;
}

.policy-page h2 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.policy-page h3 {
  font-size: 1.05rem;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--accent);
}

.policy-page p,
.policy-page li {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.policy-page ul {
  padding-left: 1.5rem;
  margin: 0.5rem 0;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 900px) {
  .main-layout {
    grid-template-columns: 1fr;
    padding: 0 1rem 1rem;
  }

  .sidebar {
    position: static;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
  }

  .header {
    padding: 0.75rem 1rem;
  }

  .stats-bar,
  .use-cases {
    padding: 0.75rem 1rem;
  }

  .use-case-chip {
    font-size: 0.72rem;
    padding: 0.3rem 0.65rem;
  }
}

@media (max-width: 600px) {
  .stats-bar {
    grid-template-columns: repeat(2, 1fr);
  }

  .product-name {
    max-width: 200px;
  }

  td,
  th {
    padding: 0.5rem 0.6rem;
    font-size: 0.78rem;
  }
}