/* NewStore Mira Plugin — Unified Styles */
:root {
  --ns-bg: #FFFFFF;
  --ns-surface: #F9FAFB;
  --ns-text: #111827;
  --ns-text-muted: #6B7280;
  --ns-border: #E5E7EB;
  --ns-accent: #2E5AD1;
  --ns-success: #189A72;
  --ns-danger: #B5002B;
  --ns-radius: 8px;
  --ns-btn-radius: 12px;
  --ns-font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', sans-serif;
  --ns-spacing: 16px;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--ns-font); color: var(--ns-text); background: var(--ns-bg);
  line-height: 1.5; -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
img { max-width: 100%; display: block; }

/* ── Views ── */
.view { display: none; }
.view.active { display: block; }

/* ══════════════════════════════════
   CATALOG VIEW
   ══════════════════════════════════ */
.catalog-header {
  position: sticky; top: 0; z-index: 10; background: var(--ns-bg);
  padding: var(--ns-spacing); border-bottom: 1px solid var(--ns-border);
}
.catalog-title { font-size: 22px; font-weight: 800; }
.catalog-subtitle { font-size: 13px; color: var(--ns-text-muted); margin-bottom: 12px; }

/* Search */
.search-wrap { margin-bottom: 10px; }
.search-input {
  width: 100%; padding: 10px 14px; border: 1.5px solid var(--ns-border);
  border-radius: var(--ns-radius); font-size: 14px; outline: none; transition: border-color .2s;
  background: var(--ns-surface);
}
.search-input:focus { border-color: var(--ns-accent); background: #fff; }

/* Filter chips */
.filter-bar { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
.filter-bar::-webkit-scrollbar { display: none; }
.filter-chip {
  white-space: nowrap; padding: 6px 14px; border-radius: 20px; font-size: 12px;
  font-weight: 600; border: 1.5px solid var(--ns-border); background: #fff;
  color: var(--ns-text-muted); cursor: pointer; transition: all .2s; flex-shrink: 0;
}
.filter-chip.active { background: var(--ns-accent); color: #fff; border-color: var(--ns-accent); }
.filter-chip-3d { display: inline-flex; align-items: center; gap: 4px; }
.chip-count {
  background: rgba(0,0,0,.1); padding: 1px 7px; border-radius: 10px;
  font-size: 11px; font-weight: 700; line-height: 1.4;
}
.filter-chip-3d.active .chip-count { background: rgba(255,255,255,.25); }

/* Product grid */
.catalog-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px;
  padding: var(--ns-spacing);
}
@media (min-width: 600px) { .catalog-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px) { .catalog-grid { grid-template-columns: repeat(4, 1fr); } }

.catalog-card {
  border-radius: var(--ns-radius); overflow: hidden; background: var(--ns-surface);
  cursor: pointer; transition: transform .15s, box-shadow .15s;
  border: 1px solid var(--ns-border);
}
.catalog-card:active { transform: scale(.97); }
.catalog-card-img-wrap { position: relative; aspect-ratio: 3/4; overflow: hidden; background: #f0f0f0; }
.catalog-card-img { width: 100%; height: 100%; object-fit: cover; }

/* 3D Badge */
.badge-3d {
  position: absolute; top: 8px; right: 8px;
  background: var(--ns-accent); color: #fff; font-size: 10px; font-weight: 800;
  padding: 3px 8px; border-radius: 4px; letter-spacing: .5px;
  box-shadow: 0 2px 6px rgba(0,0,0,.15);
}

.catalog-card-info { padding: 10px; }
.catalog-card-cat { font-size: 10px; color: var(--ns-text-muted); text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
.catalog-card-title { font-size: 14px; font-weight: 700; margin: 2px 0; line-height: 1.3; }
.catalog-card-price { font-size: 13px; font-weight: 600; color: var(--ns-success); }
.catalog-empty { grid-column: 1/-1; text-align: center; padding: 48px 16px; color: var(--ns-text-muted); font-size: 15px; }

/* ══════════════════════════════════
   DETAIL VIEW
   ══════════════════════════════════ */
.detail-header {
  position: sticky; top: 0; z-index: 10; background: var(--ns-bg);
  padding: 10px var(--ns-spacing); border-bottom: 1px solid var(--ns-border);
}
.btn-back {
  background: none; border: none; font-size: 15px; font-weight: 600;
  color: var(--ns-accent); cursor: pointer; padding: 4px 0;
}

/* Product header */
.product-header {
  display: flex; gap: 12px; padding: var(--ns-spacing); align-items: center;
  border-bottom: 1px solid var(--ns-border);
}
.product-thumb-img { width: 64px; height: 64px; border-radius: var(--ns-radius); object-fit: cover; }
.product-header-info h2 { font-size: 16px; font-weight: 700; line-height: 1.3; }
.product-header-price { font-size: 15px; font-weight: 600; color: var(--ns-success); }
.product-header-sku { font-size: 11px; color: var(--ns-text-muted); display: block; }

/* Account section */
.account-section { padding: var(--ns-spacing); border-bottom: 1px solid var(--ns-border); }
.account-connected { display: flex; align-items: center; justify-content: space-between; }
.account-badge { font-size: 13px; font-weight: 600; color: var(--ns-success); display: flex; align-items: center; gap: 4px; }
.account-login h3 { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.account-login p { font-size: 13px; color: var(--ns-text-muted); margin-bottom: 12px; }
.input-field {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--ns-border);
  border-radius: var(--ns-radius); font-size: 14px; margin-bottom: 8px; outline: none; transition: border-color .2s;
}
.input-field:focus { border-color: var(--ns-accent); }
.error-msg { color: var(--ns-danger); font-size: 12px; margin-top: 6px; min-height: 16px; }
.expired-msg { background: #FFF3CD; color: #856404; border: 1px solid #FFEEBA; border-radius: 6px; padding: 8px 12px; font-size: 13px; margin-bottom: 12px; }
.account-validating { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ns-text-muted); padding: 8px 0; }
.spinner-sm { width: 16px; height: 16px; border: 2px solid #93C5FD; border-top-color: #2563EB; border-radius: 50%; animation: spin .8s linear infinite; flex-shrink: 0; }

/* Buttons */
.btn-primary-sm {
  width: 100%; padding: 10px; border: none; border-radius: var(--ns-btn-radius);
  background: var(--ns-accent); color: #fff; font-size: 14px; font-weight: 600; cursor: pointer; transition: opacity .2s;
}
.btn-primary-sm:disabled { opacity: .5; cursor: default; }
.btn-sm { padding: 6px 12px; border-radius: 6px; font-size: 12px; font-weight: 600; cursor: pointer; border: none; }
.btn-outline-sm { background: transparent; border: 1.5px solid var(--ns-border); color: var(--ns-text); }
.btn-outline-sm:hover { border-color: var(--ns-danger); color: var(--ns-danger); }
.btn-primary-full {
  width: 100%; padding: 14px; border: none; border-radius: var(--ns-btn-radius);
  background: var(--ns-accent); color: #fff; font-size: 15px; font-weight: 600;
  cursor: pointer; transition: opacity .2s; margin-top: 12px;
}
.btn-primary-full:disabled { opacity: .5; cursor: default; }
.btn-primary-full:active { opacity: .8; }
.btn-outline-full {
  width: 100%; padding: 12px; border: 1.5px solid var(--ns-border); border-radius: var(--ns-btn-radius);
  background: transparent; color: var(--ns-text); font-size: 14px; font-weight: 500; cursor: pointer; margin-top: 8px;
}

/* ══════════════════════════════════
   MIRA SECTION
   ══════════════════════════════════ */
.mira-section { padding: var(--ns-spacing); }
.section-label { font-size: 14px; font-weight: 700; margin-bottom: 12px; }
.hint { font-size: 12px; color: var(--ns-text-muted); margin-top: 8px; }

/* Image selection grid */
.image-select-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.image-select-item {
  position: relative; border-radius: var(--ns-radius); overflow: hidden;
  border: 2px solid var(--ns-border); cursor: pointer; transition: all .2s; aspect-ratio: 1;
}
.image-select-item img { width: 100%; height: 100%; object-fit: cover; }
.image-select-item .image-check {
  position: absolute; top: 4px; right: 4px; width: 22px; height: 22px;
  border-radius: 50%; background: var(--ns-accent); color: #fff;
  font-size: 12px; font-weight: 700; display: none; align-items: center; justify-content: center;
}
.image-select-item.selected { border-color: var(--ns-accent); }
.image-select-item.selected .image-check { display: flex; }
.image-select-item:not(.selected) { opacity: .45; }

/* Pipeline status */
.pipeline-status {
  display: flex; align-items: center; gap: 12px; padding: 16px;
  border-radius: var(--ns-radius); margin-bottom: 12px;
}
.pipeline-processing { background: #EFF6FF; color: #1E40AF; }
.pipeline-completed { background: #ECFDF5; color: #065F46; }
.pipeline-failed { background: #FEF2F2; color: #991B1B; }
.pipeline-status strong { font-size: 14px; }
.pipeline-status p { font-size: 12px; margin-top: 2px; opacity: .8; }
.status-icon { font-size: 20px; flex-shrink: 0; }
.time-elapsed { font-size: 11px; opacity: .6; font-variant-numeric: tabular-nums; }

/* Spinner */
.spinner {
  width: 24px; height: 24px; border: 3px solid #93C5FD; border-top-color: #2563EB;
  border-radius: 50%; animation: spin .8s linear infinite; flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 3D Viewer */
.viewer-wrap { border-radius: var(--ns-radius); background: var(--ns-surface); margin-top: 12px; overflow: hidden; }
.mira-viewer { width: 100%; aspect-ratio: 3/4; border: none; display: block; border-radius: var(--ns-radius); }
.viewer-actions { margin-top: 12px; }

/* Viewer: tablet/desktop — proportional mit quadratischerem Format */
@media (min-width: 768px) {
  .viewer-wrap { max-width: 560px; margin-left: auto; margin-right: auto; }
  .mira-viewer { aspect-ratio: 1/1; }
  .viewer-actions { max-width: 560px; margin-left: auto; margin-right: auto; }
}

/* AR Button */
.btn-ar {
  width: 100%; padding: 14px; border: 2px solid var(--ns-accent); border-radius: var(--ns-btn-radius);
  background: #fff; color: var(--ns-accent); font-size: 15px; font-weight: 600;
  cursor: pointer; transition: all .2s; margin-top: 12px; display: flex; align-items: center;
  justify-content: center; gap: 6px;
}
.btn-ar:active { background: var(--ns-accent); color: #fff; }

/* Loading */
.loading { display: flex; align-items: center; justify-content: center; height: 60vh; color: var(--ns-text-muted); font-size: 15px; }
