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

:root {
  /* Brand */
  --charcoal: #2b2b2b;
  --charcoal-deep: #1a1a1a;
  --charcoal-light: #3d3d3d;
  --red: #c8102e;
  --red-hover: #a00d24;
  --red-subtle: #fdf2f4;

  /* Warm neutrals */
  --bg: #f7f6f4;
  --surface: #ffffff;
  --surface-elevated: #fafaf8;
  --border: #e8e6e3;
  --border-strong: #d1cfc9;
  --text: #1a1a1a;
  --text-secondary: #6b6560;
  --text-tertiary: #9e9890;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(43,43,43,0.06);
  --shadow-md: 0 4px 12px rgba(43,43,43,0.08);
  --shadow-lg: 0 8px 30px rgba(43,43,43,0.12);

  /* Layout */
  --radius: 12px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --max-width: 1280px;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 15px;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button { cursor: pointer; border: none; background: none; font: inherit; color: inherit; }

h1, h2, h3, .section-title, .info-content .product-title {
  letter-spacing: -0.02em;
}

:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}

button:focus:not(:focus-visible),
a:focus:not(:focus-visible) {
  outline: none;
}

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

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ========== Header ========== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(232,230,227,0.8);
  padding: 0 32px;
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 72px;
  gap: 16px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.header-logo img {
  height: 38px;
  width: auto;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

/* ========== Language Toggle ========== */
.lang-toggle {
  display: flex;
  gap: 2px;
  background: var(--bg);
  border-radius: 8px;
  padding: 3px;
  border: 1px solid var(--border);
}

.lang-toggle button {
  padding: 5px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  transition: all var(--transition);
}

.lang-toggle button.active {
  background: var(--charcoal);
  color: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

/* ========== Back Button ========== */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition);
}

.back-btn:hover {
  background: var(--bg);
  color: var(--text);
}

.back-btn svg {
  width: 16px;
  height: 16px;
}

/* ========== Search Bar ========== */
.search-container {
  max-width: var(--max-width);
  margin: 32px auto 0;
  padding: 0 32px;
}

.search-bar {
  position: relative;
  max-width: 560px;
  margin: 0 auto;
}

.search-bar input {
  width: 100%;
  padding: 14px 20px 14px 48px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  background: var(--surface);
  color: var(--text);
  transition: all var(--transition);
  outline: none;
  box-shadow: var(--shadow-sm);
}

.search-bar input:focus {
  border-color: var(--charcoal);
  box-shadow: 0 0 0 3px rgba(43,43,43,0.08), var(--shadow-md);
}

.search-bar input::placeholder { color: var(--text-tertiary); }

.search-bar .search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-tertiary);
  pointer-events: none;
}

/* ========== Section Title ========== */
.section-title {
  max-width: var(--max-width);
  margin: 48px auto 20px;
  padding: 0 32px;
  font-size: 22px;
  font-weight: 600;
  color: var(--charcoal);
}

/* ========== Category Grid ========== */
.category-grid {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 32px 40px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.category-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.category-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--red);
  transform: scaleX(0);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.category-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
}

.category-card:hover::before {
  transform: scaleX(1);
}

.category-card.active {
  border-color: var(--red);
  background: var(--red-subtle);
}

.category-card.active::before {
  transform: scaleX(1);
}

.category-card .cat-name {
  font-weight: 600;
  font-size: 14px;
  margin-top: 4px;
  color: var(--text);
}

.category-card .cat-count {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

/* ========== Product Grid ========== */
.product-grid {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 32px 56px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 24px;
}

.product-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-sm);
  position: relative;
  animation: fadeInUp 0.4s ease both;
}

.product-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-lg);
  transform: translateY(-4px);
}

.product-card .product-image {
  width: 100%;
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(145deg, #f8f7f5, #f0efec);
  position: relative;
  overflow: hidden;
}

.product-card .product-image img {
  max-width: 85%;
  max-height: 85%;
  object-fit: contain;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.08));
}

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

/* 3D badge on hover */
.product-card .product-image::after {
  content: '3D';
  position: absolute;
  bottom: 10px;
  right: 10px;
  background: var(--charcoal);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 4px 10px;
  border-radius: 6px;
  opacity: 0;
  transform: translateY(4px);
  transition: all 0.3s ease;
}

.product-card:hover .product-image::after {
  opacity: 1;
  transform: translateY(0);
}

.product-card .product-info {
  padding: 16px 18px;
  border-top: 1px solid var(--border);
}

.product-card .product-name {
  font-weight: 600;
  font-size: 14px;
  line-height: 1.35;
  margin-bottom: 4px;
  color: var(--text);
}

.product-card .product-code {
  font-size: 11px;
  color: var(--text-tertiary);
  font-family: 'JetBrains Mono', 'SF Mono', 'Consolas', monospace;
  letter-spacing: 0.03em;
}

/* ========== Empty State ========== */
.empty-state {
  text-align: center;
  padding: 80px 32px;
  color: var(--text-secondary);
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.3;
}

.empty-state p {
  font-size: 15px;
}

/* ========== Viewer Page ========== */
.viewer-layout {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 72px);
  height: calc(100dvh - 72px);
}

.viewer-container {
  flex: 1;
  position: relative;
  min-height: 0;
  background: linear-gradient(180deg, #f2f1ef 0%, #e8e6e3 100%);
}

.viewer-container model-viewer {
  width: 100%;
  height: 100%;
  --poster-color: transparent;
  --progress-bar-color: var(--red);
}

.viewer-hint {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--charcoal);
  color: rgba(255,255,255,0.9);
  padding: 8px 18px;
  border-radius: 24px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  pointer-events: none;
  transition: opacity 0.6s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 5;
}

.viewer-hint.hidden { opacity: 0; }

/* ========== Product Info Panel ========== */
.info-panel {
  background: var(--surface);
  border-top: 1px solid var(--border);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

/* Dimension note (e.g. "Width x Depth x Height") */
.dimension-note {
  font-size: 12px;
  color: var(--text-tertiary);
  font-style: italic;
  margin-bottom: 10px;
  padding: 6px 12px;
  background: var(--bg);
  border-radius: 6px;
  border: 1px solid var(--border);
}

.info-content {
  padding: 20px 24px 28px;
}

.info-content .product-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--charcoal-deep);
}

.info-content .product-code-display {
  font-size: 12px;
  font-family: 'JetBrains Mono', 'SF Mono', 'Consolas', monospace;
  color: var(--text-tertiary);
  letter-spacing: 0.03em;
  margin-bottom: 8px;
}

.info-content .product-desc {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 20px;
}

.info-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  margin-bottom: 8px;
  margin-top: 20px;
}

/* ========== Specs Table ========== */
.specs-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.specs-table th {
  text-align: left;
  padding: 10px 16px;
  background: var(--bg);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}

.specs-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.specs-table td:first-child {
  font-weight: 500;
  color: var(--text);
}

.specs-table td:last-child {
  font-family: 'JetBrains Mono', 'SF Mono', 'Consolas', monospace;
  font-size: 12px;
  color: var(--text-secondary);
}

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

.specs-table tr:hover td {
  background: rgba(247,246,244,0.6);
}

/* ========== Extras Section ========== */
.extras-section {
  margin-top: 20px;
}

/* ========== Footer ========== */
.footer {
  text-align: center;
  padding: 32px;
  color: var(--text-tertiary);
  font-size: 12px;
  border-top: 1px solid var(--border);
  letter-spacing: 0.02em;
}

/* ========== Loading Spinner ========== */
.viewer-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--text-secondary);
  font-size: 13px;
  z-index: 4;
}

.viewer-loading .spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ========== Responsive ========== */
@media (max-width: 768px) {
  .header { padding: 0 16px; }
  .header-inner { height: 56px; }
  .header-logo img { height: 28px; }
  .header-left { gap: 8px; }

  .lang-toggle button { padding: 4px 10px; font-size: 11px; }

  .search-container { padding: 0 16px; margin-top: 20px; }
  .search-bar input { padding: 12px 16px 12px 42px; font-size: 14px; }

  .section-title { padding: 0 16px; margin: 32px auto 14px; font-size: 18px; }

  .category-grid {
    padding: 0 16px 24px;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 8px;
  }
  .category-card { padding: 14px 12px; }
  .category-card .cat-name { font-size: 13px; }

  .product-grid {
    padding: 0 16px 40px;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  .product-card .product-image { padding: 16px; }
  .product-card .product-info { padding: 10px 12px; }
  .product-card .product-name { font-size: 12px; }
  .product-card .product-code { font-size: 10px; }

  /* 3D badge always visible on mobile (no hover) */
  .product-card .product-image::after {
    opacity: 1;
    transform: translateY(0);
    font-size: 10px;
    padding: 3px 7px;
    bottom: 8px;
    right: 8px;
  }

  /* Viewer page */
  .viewer-layout {
    height: calc(100vh - 56px);
    height: calc(100dvh - 56px);
  }

  .info-content { padding: 16px 16px 24px; }
  .info-content .product-title { font-size: 18px; }
  .info-toggle { padding: 10px 16px; }
  .specs-table th, .specs-table td { padding: 8px 10px; font-size: 12px; }
  .specs-table td:last-child { font-size: 11px; }

  .footer { padding: 24px 16px; }
}

@media (min-width: 1024px) {
  .viewer-layout {
    flex-direction: row;
  }
  .viewer-container {
    flex: 1;
    height: calc(100vh - 72px);
    height: calc(100dvh - 72px);
  }
  .info-panel {
    width: 420px;
    max-height: none;
    height: calc(100vh - 72px);
    height: calc(100dvh - 72px);
    border-top: none;
    border-left: 1px solid var(--border);
    box-shadow: -4px 0 20px rgba(0,0,0,0.04);
  }
  .info-panel.collapsed {
    width: 48px;
    max-height: none;
  }
}

@media (min-width: 1440px) {
  :root { --max-width: 1400px; }
  .header { padding: 0 48px; }
  .search-container,
  .category-grid,
  .product-grid,
  .section-title {
    padding-left: 48px;
    padding-right: 48px;
  }
}
