/* ─────────────────────────────────────────────────────────────────────────────
   craft.youin3d.com — YOUin3D GmbH Berlin · SolidCraft Photo-to-3D CAD Studio
   Design System: Precision Industrial CAD Workbench
   Brand Palette: Graphite #262729 / #3b3b3b · Vermilion Accent #ed422c · Slate
   ───────────────────────────────────────────────────────────────────────────── */

:root {
  --y3d-bg-dark: #18191b;
  --y3d-bg-panel: #222428;
  --y3d-bg-card: #2a2d32;
  --y3d-bg-input: #151719;
  --y3d-header: #2d2f34;
  --y3d-border: #383c44;
  --y3d-border-subtle: #2f3239;
  --y3d-accent: #ed422c;
  --y3d-accent-hover: #ff543e;
  --y3d-accent-soft: rgba(237, 66, 44, 0.14);
  --y3d-cyan: #22b8cf;
  --y3d-green: #2fb344;
  --y3d-amber: #f59f00;
  --y3d-text: #f1f3f5;
  --y3d-text-secondary: #adb5bd;
  --y3d-text-muted: #868e96;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --shadow-panel: 0 8px 24px rgba(0, 0, 0, 0.35);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--y3d-bg-dark);
  color: var(--y3d-text);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* ── Top Application Bar ──────────────────────────────────────────────────── */
.app-header {
  height: 52px;
  background-color: var(--y3d-header);
  border-bottom: 1px solid var(--y3d-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 16px;
  user-select: none;
  z-index: 20;
}

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

.brand-logo {
  height: 30px;
  width: auto;
  border-radius: var(--radius-sm);
  background: #ffffff;
  padding: 2px 6px;
  object-fit: contain;
}

.brand-titles {
  display: flex;
  flex-direction: column;
}

.brand-titles h1 {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--y3d-text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.domain-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--y3d-accent);
  background: var(--y3d-accent-soft);
  padding: 1px 7px;
  border-radius: var(--radius-sm);
}

.brand-subtitle {
  font-size: 11px;
  color: var(--y3d-text-secondary);
}

/* ── View Mode Switcher ───────────────────────────────────────────────────── */
.view-switcher {
  display: flex;
  align-items: center;
  background: var(--y3d-bg-input);
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--y3d-border);
  gap: 2px;
}

.view-tab {
  background: transparent;
  color: var(--y3d-text-secondary);
  border: none;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.view-tab:hover {
  color: var(--y3d-text);
  background: rgba(255, 255, 255, 0.04);
}

.view-tab.active {
  background: var(--y3d-bg-card);
  color: var(--y3d-text);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* ── Header Right Actions ─────────────────────────────────────────────────── */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.engine-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--y3d-text-secondary);
  background: var(--y3d-bg-input);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--y3d-border-subtle);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--y3d-amber);
  transition: background-color 0.2s ease;
}

.status-dot.ready {
  background-color: var(--y3d-green);
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 12px;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid var(--y3d-border);
  background-color: var(--y3d-bg-card);
  color: var(--y3d-text);
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover {
  background-color: #34383f;
  border-color: #4b505a;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background-color: var(--y3d-accent);
  border-color: var(--y3d-accent);
  color: #ffffff;
}

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

.btn-block {
  width: 100%;
  padding: 10px 14px;
  font-size: 13px;
}

.btn-sm {
  padding: 4px 9px;
  font-size: 11px;
}

/* ── Main Workbench Grid ──────────────────────────────────────────────────── */
.workbench {
  display: grid;
  grid-template-columns: 360px 1fr;
  height: calc(100vh - 52px);
  width: 100%;
  overflow: hidden;
}

/* ── Left Sidebar (Photo Input & Parametric Controls) ─────────────────────── */
.craft-sidebar {
  background-color: var(--y3d-bg-panel);
  border-right: 1px solid var(--y3d-border);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-section {
  padding: 14px 16px;
  border-bottom: 1px solid var(--y3d-border-subtle);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--y3d-text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--y3d-accent);
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
}

/* ── Upload Dropzone ──────────────────────────────────────────────────────── */
.upload-dropzone {
  border: 1.5px dashed var(--y3d-border);
  border-radius: var(--radius-md);
  background-color: var(--y3d-bg-input);
  padding: 14px 12px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
  position: relative;
}

.upload-dropzone:hover,
.upload-dropzone.drag-over {
  border-color: var(--y3d-accent);
  background-color: rgba(237, 66, 44, 0.06);
}

.upload-dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.dropzone-icon {
  color: var(--y3d-accent);
  margin-bottom: 6px;
}

.dropzone-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--y3d-text);
  margin-bottom: 2px;
}

.dropzone-hint {
  font-size: 11px;
  color: var(--y3d-text-muted);
}

/* ── Sample Object Thumbnails ─────────────────────────────────────────────── */
.samples-label {
  font-size: 11px;
  color: var(--y3d-text-secondary);
  margin-top: 10px;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
}

.sample-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.sample-card {
  background: var(--y3d-bg-input);
  border: 1px solid var(--y3d-border);
  border-radius: var(--radius-sm);
  padding: 5px;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.sample-card:hover {
  border-color: var(--y3d-text-secondary);
  transform: translateY(-1px);
}

.sample-card.active {
  border-color: var(--y3d-accent);
  background: var(--y3d-accent-soft);
}

.sample-card img {
  width: 100%;
  height: 54px;
  object-fit: cover;
  border-radius: 3px;
  background: #ffffff;
  display: block;
  margin-bottom: 4px;
}

.sample-card span {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--y3d-text);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── 2D Contour & Vector Trace Preview Box ────────────────────────────────── */
.trace-preview-box {
  margin-top: 10px;
  background: var(--y3d-bg-input);
  border: 1px solid var(--y3d-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.trace-preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: var(--y3d-bg-card);
  border-bottom: 1px solid var(--y3d-border-subtle);
  font-size: 11px;
}

.trace-legend {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 10.5px;
  color: var(--y3d-text-secondary);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.legend-swatch {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.trace-canvas-wrap {
  position: relative;
  width: 100%;
  height: 170px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #121316;
}

#contour-canvas {
  max-width: 100%;
  max-height: 170px;
  object-fit: contain;
}

/* ── Parametric Controls ──────────────────────────────────────────────────── */
.control-group {
  margin-bottom: 11px;
}

.control-group:last-child {
  margin-bottom: 0;
}

.control-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 500;
  color: var(--y3d-text);
  margin-bottom: 5px;
}

.control-value {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--y3d-accent);
  font-weight: 600;
}

.form-select {
  width: 100%;
  padding: 7px 10px;
  background-color: var(--y3d-bg-input);
  color: var(--y3d-text);
  border: 1px solid var(--y3d-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 12px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--y3d-accent);
  height: 5px;
  cursor: pointer;
}

.control-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--y3d-text-secondary);
  cursor: pointer;
}

.checkbox-label input {
  accent-color: var(--y3d-accent);
}

/* ── CAD Metrics & Command Console ────────────────────────────────────────── */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.metric-card {
  background: var(--y3d-bg-input);
  border: 1px solid var(--y3d-border-subtle);
  border-radius: var(--radius-sm);
  padding: 7px 9px;
}

.metric-label {
  font-size: 10.5px;
  color: var(--y3d-text-muted);
  display: block;
}

.metric-val {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--y3d-text);
  margin-top: 2px;
  display: block;
}

.command-log {
  background: #111214;
  border: 1px solid var(--y3d-border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: #a5d8ff;
  max-height: 135px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ── Main Dual Workspace (3D Viewport + SolidCraft WASM Editor) ───────────── */
.craft-workspace {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  height: 100%;
  width: 100%;
  background: var(--y3d-bg-dark);
  overflow: hidden;
}

.craft-workspace.mode-preview-only {
  grid-template-columns: 1fr;
}

.craft-workspace.mode-preview-only .pane-solidcraft {
  display: none;
}

.craft-workspace.mode-solidcraft-only {
  grid-template-columns: 1fr;
}

.craft-workspace.mode-solidcraft-only .pane-preview {
  display: none;
}

.workspace-pane {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  overflow: hidden;
  position: relative;
}

.pane-preview {
  border-right: 1px solid var(--y3d-border);
}

.pane-toolbar {
  height: 38px;
  background: var(--y3d-bg-panel);
  border-bottom: 1px solid var(--y3d-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  font-size: 11.5px;
  flex-shrink: 0;
}

.pane-title {
  font-weight: 600;
  color: var(--y3d-text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.pane-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  background: rgba(34, 184, 207, 0.14);
  color: var(--y3d-cyan);
}

.pane-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.viewport-container {
  flex: 1;
  position: relative;
  background: radial-gradient(circle at 50% 45%, #25282e 0%, #15171a 100%);
  overflow: hidden;
}

#preview-3d-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}

#preview-3d-canvas:active {
  cursor: grabbing;
}

.viewport-overlay {
  position: absolute;
  bottom: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}

.viewport-pill {
  background: rgba(21, 23, 25, 0.85);
  backdrop-filter: blur(6px);
  border: 1px solid var(--y3d-border);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-size: 11px;
  color: var(--y3d-text-secondary);
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── SolidCraft Iframe Container ──────────────────────────────────────────── */
.solidcraft-frame-wrap {
  flex: 1;
  position: relative;
  background: #1b1d21;
  width: 100%;
  height: 100%;
}

#solidcraft-frame {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.solidcraft-banner {
  position: absolute;
  bottom: 12px;
  right: 12px;
  background: rgba(21, 23, 25, 0.9);
  border: 1px solid var(--y3d-border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 11px;
  color: var(--y3d-text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 5;
}

/* ── Responsive Breakpoints ───────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .workbench {
    grid-template-columns: 320px 1fr;
  }
  .craft-workspace {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
  }
}

@media (max-width: 768px) {
  html, body {
    overflow: auto;
  }
  .app-header {
    flex-wrap: wrap;
    height: auto;
    padding: 10px 12px;
  }
  .workbench {
    grid-template-columns: 1fr;
    height: auto;
  }
  .craft-workspace {
    height: 750px;
  }
}
