/*
 * OG Sanchos — web catalog styles.
 * Palette + typography ported from the Android app's theme
 * (app/src/main/java/com/example/ui/theme/Color.kt + Type.kt).
 */

:root {
  /* High-Heat Inventory Engine palette */
  --background: #131313;
  --surface-container: #201f1f;
  --surface-container-high: #2a2a2a;
  --on-surface: #e5e2e1;
  --secondary: #ffffff; /* headings */
  --tertiary: #c7c7c2; /* muted subtitles */
  --primary: #ffb2b7; /* reference ids / accents */
  --volt: #c3f400; /* neon green accent */
  --on-volt: #556d00;
  --chicago-red: #ce1141; /* tags / primary action */
  --outline: #ab8889;
  --outline-variant: #5b3f41;
  --image-bg: #f8f7f2;

  --font-sans: "Helvetica Neue", Arial, system-ui, sans-serif;
  --font-mono: "SF Mono", "Roboto Mono", "Courier New", monospace;

  --radius: 4px;
}

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

html,
body {
  background: var(--background);
  color: var(--on-surface);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  min-height: 100vh;
}

/* ---------- Top identity bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  gap: 8px;
}

.topbar .menu {
  color: var(--primary);
  display: flex;
  align-items: center;
}

.brand-logo {
  font-weight: 900;
  font-size: 22px;
  letter-spacing: -0.02em;
  color: var(--secondary);
  text-transform: uppercase;
}

.unit-count {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 11px;
  color: var(--primary);
  white-space: nowrap;
  padding-bottom: 4px;
  border-bottom: 3px solid var(--volt);
}

.divider {
  height: 1px;
  background: var(--outline-variant);
  width: 100%;
}

/* ---------- Title section ---------- */
.title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 16px 16px 12px;
  gap: 12px;
}

.title-main {
  font-weight: 900;
  font-size: 28px;
  letter-spacing: -0.03em;
  color: var(--secondary);
  line-height: 1;
}

.title-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--tertiary);
  margin-top: 6px;
  text-transform: uppercase;
}

.tool-buttons {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: var(--radius);
  background: var(--surface-container);
  color: var(--secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.icon-btn:hover {
  background: var(--surface-container-high);
}

.icon-btn.active {
  background: var(--volt);
  color: #161e00;
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

/* ---------- Search bar ---------- */
.search-wrap {
  padding: 0 16px 12px;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 52px;
  padding: 0 12px;
  background: var(--surface-container);
  border: 1px solid var(--outline);
  border-radius: var(--radius);
}

.search-field svg {
  width: 20px;
  height: 20px;
  color: var(--secondary);
  flex-shrink: 0;
}

.search-field input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--secondary);
  font-size: 16px;
  font-family: var(--font-sans);
}

.search-field input::placeholder {
  color: var(--outline);
}

.clear-btn {
  background: transparent;
  border: none;
  color: var(--secondary);
  cursor: pointer;
  display: none;
  padding: 4px;
}

.clear-btn.visible {
  display: flex;
}

/* ---------- Brand filter ticker ---------- */
.ticker {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 0 16px 14px;
  scrollbar-width: none;
}

.ticker::-webkit-scrollbar {
  display: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  border-radius: var(--radius);
  background: var(--surface-container);
  border: 1px solid var(--outline-variant);
  color: var(--secondary);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease;
}

.chip .delta {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--primary);
}

.chip.active {
  background: var(--volt);
  border-color: var(--volt);
  color: #161e00;
}

.chip.active .delta {
  color: #161e00;
}

/* ---------- Grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px 12px;
  padding: 4px 16px 60px;
}

@media (min-width: 640px) {
  .grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 900px) {
  .grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.card {
  background: var(--surface-container);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.card-image {
  position: relative;
  width: 100%;
  aspect-ratio: 1.1 / 1;
  background: var(--image-bg);
}

.card-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* fallback silhouette */
.card-image .fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(45deg, transparent 49.5%, #e5e2e1 49.5%, #e5e2e1 50.5%, transparent 50.5%),
    var(--image-bg);
}

.card-image .fallback svg {
  width: 44px;
  height: 44px;
  color: rgba(19, 19, 19, 0.12);
}

/* condition + tag chips overlaid on image */
.badge {
  position: absolute;
  left: 0;
  font-weight: 800;
  font-size: 10px;
  letter-spacing: 0.08em;
  padding: 3px 8px;
  text-transform: uppercase;
}

.badge.condition {
  top: 0;
  background: #e5e2e1;
  color: #131313;
}

.badge.condition.ds {
  background: var(--volt);
  color: #161e00;
}

.badge.tag {
  top: 22px;
  background: var(--chicago-red);
  color: #ffffff;
  font-size: 9px;
}

.card-body {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.card-title {
  font-weight: 700;
  font-size: 13px;
  line-height: 1.25;
  color: var(--secondary);
}

.card-colorway {
  font-size: 11px;
  color: var(--tertiary);
  line-height: 1.3;
}

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 4px;
}

.card-ref {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
}

.card-sku {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--outline);
}

/* ---------- Detail view (slide-in overlay) ---------- */
.detail-view {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--background);
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  -webkit-overflow-scrolling: touch;
}

.detail-view.open {
  transform: translateX(0);
}

.detail-inner {
  max-width: 1100px;
  margin: 0 auto;
}

.detail-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  position: sticky;
  top: 0;
  background: var(--background);
  z-index: 10;
}

.detail-back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.detail-back-btn svg {
  width: 22px;
  height: 22px;
  color: var(--primary);
  flex-shrink: 0;
}

.detail-hero {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--image-bg);
  overflow: hidden;
}

.detail-hero img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.detail-hero .fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(45deg, transparent 49.5%, #e5e2e1 49.5%, #e5e2e1 50.5%, transparent 50.5%),
    var(--image-bg);
}

.detail-hero .fallback svg {
  width: 72px;
  height: 72px;
  color: rgba(19, 19, 19, 0.12);
}

.badge-auth {
  position: absolute;
  top: 16px;
  left: 16px;
  background: rgba(0, 0, 0, 0.82);
  border: 1px solid var(--outline);
  border-radius: 2px;
  padding: 6px 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: #ffffff;
}

.detail-hero-bottom {
  position: absolute;
  bottom: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.badge-status {
  background: var(--volt);
  color: #161e00;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 6px 12px;
}

.badge-scan {
  background: #000000;
  border: 1px solid var(--outline-variant);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--primary);
  padding: 3px 8px;
}

.detail-body {
  padding: 16px;
}

.detail-name-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.detail-name {
  font-weight: 900;
  font-size: 24px;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--secondary);
  flex: 1;
}

.sku-badge {
  background: var(--surface-container);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--on-surface);
  padding: 4px 8px;
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 4px;
}

.detail-colorway {
  font-size: 15px;
  color: var(--on-surface);
  opacity: 0.65;
  margin-bottom: 18px;
}

.detail-stats {
  display: flex;
  gap: 12px;
}

.stat-card {
  flex: 1;
  background: var(--surface-container);
  padding: 12px;
  border-left: 4px solid var(--outline);
}

.stat-card.volt-accent {
  border-left-color: var(--volt);
}

.stat-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--tertiary);
  margin-bottom: 4px;
}

.stat-value {
  font-weight: 700;
  font-size: 22px;
  color: var(--secondary);
}

.stat-value.volt {
  color: var(--volt);
}

.detail-bento {
  display: flex;
  gap: 12px;
  padding: 0 16px 16px;
}

.cert-card {
  flex: 1;
  background: var(--surface-container);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.cert-img-wrap {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #ffffff;
  padding: 8px;
}

.cert-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.cert-label {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  color: var(--tertiary);
  text-transform: uppercase;
}

.attr-cards {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.attr-card {
  background: var(--surface-container);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius);
  padding: 8px;
}

.attr-label {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--on-surface);
  opacity: 0.55;
  margin-bottom: 3px;
}

.attr-value {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--secondary);
}

.attr-value-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.attr-price {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
}

.price-delta {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 5px;
}

.price-delta.positive {
  background: rgba(195, 244, 0, 0.15);
  color: var(--volt);
}

.price-delta.negative {
  background: rgba(206, 17, 65, 0.15);
  color: var(--chicago-red);
}

.log-section {
  margin: 0 16px 16px;
  background: var(--surface-container-high);
  border: 1px solid rgba(91, 63, 65, 0.3);
  border-radius: var(--radius);
  padding: 16px;
}

.log-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--secondary);
  margin-bottom: 10px;
}

.log-header svg {
  width: 16px;
  height: 16px;
  color: var(--secondary);
  flex-shrink: 0;
}

.log-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
}

.log-key {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--on-surface);
  opacity: 0.65;
}

.log-val {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--tertiary);
}

.log-divider {
  height: 1px;
  background: rgba(91, 63, 65, 0.45);
}

.detail-back-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  margin-bottom: 80px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--on-surface);
  opacity: 0.55;
  text-decoration: underline;
  font-family: var(--font-sans);
}

.detail-back-link svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ---------- Loading state ---------- */
.loading-grid {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px 12px;
}

@media (min-width: 640px) {
  .loading-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 900px) {
  .loading-grid { grid-template-columns: repeat(4, 1fr); }
}

.skeleton-card {
  background: var(--surface-container);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius);
  overflow: hidden;
}

.skeleton-img {
  width: 100%;
  aspect-ratio: 1.1 / 1;
  background: var(--surface-container-high);
  animation: pulse 1.4s ease-in-out infinite;
}

.skeleton-body {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.skeleton-line {
  height: 12px;
  border-radius: 2px;
  background: var(--surface-container-high);
  animation: pulse 1.4s ease-in-out infinite;
}

.skeleton-line.short { width: 55%; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* ---------- Error state ---------- */
.load-error {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
}

.load-error .error-title {
  font-weight: 900;
  font-size: 14px;
  letter-spacing: 0.1em;
  color: #ce1141;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.load-error .error-sub {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--outline);
}

/* ---------- Empty state ---------- */
.empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--tertiary);
}

.empty .empty-title {
  font-weight: 900;
  font-size: 18px;
  color: var(--secondary);
  text-transform: uppercase;
  letter-spacing: -0.01em;
}

.empty .empty-sub {
  font-family: var(--font-mono);
  font-size: 12px;
  margin-top: 8px;
}
