/* Fluica Konfigurator — CI/CD Design
   Brand colors from logo variants:
     Dornblatt:    #e3df00 (yellow/lime)
     Nachtschliff: #302c38 (dark violet)
     Schattenwerk: #8e8ec5 (lavender)
   Font: Outfit (local variable font)
   Aesthetic: fluica.ch — clean, light, Swiss design */

/* ── Font ──────────────────────────────────── */

@font-face {
  font-family: 'Outfit';
  src: url('/static/fonts/Outfit-VariableFont_wght.ttf') format('truetype');
  font-weight: 100 900;
  font-display: swap;
}

/* ── Variables ─────────────────────────────── */

:root {
  --brand-dark:     #302c38;
  --brand-yellow:   #e3df00;
  --brand-lavender: #8e8ec5;

  --bg-primary:     #302c38;
  --bg-surface:     #3a3642;
  --bg-elevated:    #433f4c;
  --border:         #4e4a57;
  --border-light:   #4e4a57;

  --text-primary:   #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.65);
  --text-muted:     rgba(255, 255, 255, 0.4);

  --accent:         #e3df00;
  --accent-hover:   #f0ec20;
  --accent-yellow:  #e3df00;
  --accent-yellow-hover: #f0ec20;

  --success:        #2e7d5b;
  --error:          #c0392b;

  --font-sans:      'Outfit', 'Helvetica Neue', Arial, sans-serif;
  --font-mono:      'JetBrains Mono', 'Fira Code', 'Courier New', monospace;

  --radius:         6px;
  --radius-lg:      12px;
  --shadow-sm:      0 1px 3px rgba(48, 44, 56, 0.06);
  --shadow-md:      0 4px 12px rgba(48, 44, 56, 0.08);
  --shadow-lg:      0 8px 24px rgba(48, 44, 56, 0.10);
  --transition:     200ms ease;
}

/* ── Reset ─────────────────────────────────── */

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

html, body {
  height: 100%;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ────────────────────────────────── */

.app-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.main-content {
  flex: 1;
  display: grid;
  grid-template-columns: 400px 1fr;
  grid-template-rows: 1fr;
  gap: 0;
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
  padding: 32px 32px 48px;
}

@media (max-width: 960px) {
  .main-content {
    grid-template-columns: 1fr;
    grid-template-rows: auto 400px;
    padding: 20px;
  }
  .config-panel {
    border-right: none !important;
    border-bottom: 1px solid var(--border);
    padding-right: 0 !important;
    padding-bottom: 24px !important;
  }
  .viewer-panel {
    padding-left: 0 !important;
    padding-top: 24px !important;
  }
  .viewer-area {
    grid-template-columns: 1fr !important;
  }
  .sketch-panel {
    min-height: 250px;
  }
  .bottom-info {
    grid-template-columns: 1fr;
  }
}

/* ── Header ────────────────────────────────── */

.site-header {
  border-bottom: none;
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 72px;
  background: var(--brand-dark);
}

.logo {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.logo img {
  height: 56px;
  width: auto;
}

.header-tag {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 0.04em;
}

/* ── Config Panel (left) ───────────────────── */

.config-panel {
  padding: 32px 32px 32px 0;
  display: flex;
  flex-direction: column;
  gap: 24px;
  border-right: 1px solid var(--border);
}

.panel-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.panel-heading {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

/* ── Form ──────────────────────────────────── */

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-label strong {
  color: var(--text-primary);
  font-weight: 700;
}

.category-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 8px;
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-3d {
  background: var(--brand-yellow);
  color: var(--brand-dark);
}

.badge-cad {
  background: var(--brand-lavender);
  color: var(--brand-dark);
}

.form-control {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 500;
  padding: 10px 14px;
  width: 100%;
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
}

.form-control:focus {
  outline: none;
  border-color: var(--brand-lavender);
  box-shadow: 0 0 0 3px rgba(142, 142, 197, 0.15);
}

.form-control::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

.input-unit {
  display: flex;
  align-items: center;
  gap: 0;
}

.input-unit .form-control {
  border-right: none;
  border-radius: var(--radius) 0 0 var(--radius);
}

.unit-badge {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7' viewBox='0 0 12 7'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%237a7582' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  cursor: pointer;
}

/* ── Buttons ───────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 12px 24px;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition), transform 100ms ease;
  text-decoration: none;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: var(--brand-dark);
  font-weight: 700;
  width: 100%;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--accent-yellow);
  color: var(--accent-yellow);
  box-shadow: var(--shadow-sm);
}

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

.btn-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── Metadata Card ─────────────────────────── */

.metadata-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow-sm);
}

.meta-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.meta-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.meta-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.price-display {
  border-top: 1px solid var(--border-light);
  padding-top: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.price-amount {
  font-size: 24px;
  font-weight: 800;
  color: var(--accent-yellow);
}

.spec-key-display {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  word-break: break-all;
  padding: 10px 12px;
  background: var(--bg-surface);
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
}

.spec-key-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-top: 10px;
}

.spec-key-fields {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  margin-bottom: 8px;
}

.spec-field-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.spec-field-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.spec-key-raw {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  word-break: break-all;
  padding-top: 6px;
  border-top: 1px solid var(--border-light);
  opacity: 0.7;
}

/* ── Status / Alerts ───────────────────────── */

.status-message {
  font-size: 13px;
  font-weight: 500;
  padding: 12px 16px;
  border-radius: var(--radius);
  border-left: 3px solid;
}

.status-loading {
  background: rgba(142, 142, 197, 0.08);
  border-color: var(--brand-lavender);
  color: var(--brand-dark);
}

.status-error {
  background: rgba(192, 57, 43, 0.06);
  border-color: var(--error);
  color: var(--error);
}

.status-success {
  background: rgba(46, 125, 91, 0.06);
  border-color: var(--success);
  color: var(--success);
}

/* ── 3D Viewer (right) ─────────────────────── */

.viewer-panel {
  padding: 32px 0 32px 32px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bottom-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 4px;
}

.viewer-area {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  min-height: 300px;
  max-height: 500px;
}

.viewer-area.no-sketch {
  grid-template-columns: 1fr;
}

.viewer-container {
  min-height: 300px;
  background: #e8e6ec;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.sketch-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  justify-content: center;
}

.sketch-panel svg {
  width: 100%;
  max-width: 380px;
  height: auto;
}

.sketch-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

#three-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.viewer-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: #9a96a2;
}

.viewer-empty-icon {
  width: 64px;
  height: 64px;
  opacity: 0.25;
}

.viewer-empty-label {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.viewer-controls-hint {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  font-weight: 400;
}

/* ── Download Links ────────────────────────── */

.download-links {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ── Footer ────────────────────────────────── */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 20px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-primary);
}

.footer-text {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

/* ── Divider ───────────────────────────────── */

.divider {
  height: 1px;
  background: var(--border-light);
}

/* ── Spinner ───────────────────────────────── */

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

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* ── Custom Select Dropdown ──────────────────────────────── */

.custom-select {
  position: relative;
}

.custom-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  cursor: pointer;
  user-select: none;
  text-align: left;
}

.custom-select-trigger .select-placeholder {
  color: var(--text-secondary);
}

.custom-select-trigger .select-arrow {
  width: 10px;
  height: 6px;
  flex-shrink: 0;
  color: var(--text-secondary);
  transition: transform 0.15s ease;
}

.custom-select-trigger.is-open .select-arrow {
  transform: rotate(180deg);
}

.custom-select-options {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  list-style: none;
  margin: 0;
  padding: 4px 0;
  z-index: 500;
  max-height: 240px;
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.custom-select-group-label {
  padding: 6px 14px 4px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
  pointer-events: none;
}

.custom-select-option {
  padding: 8px 14px;
  cursor: pointer;
  font-size: var(--font-size-base);
  color: var(--text-primary);
  transition: background 0.1s, color 0.1s;
}

.custom-select-option:hover {
  background: var(--accent);
  color: var(--brand-dark);
}

.custom-select-option.is-selected {
  color: var(--accent);
  background: rgba(227, 223, 0, 0.1);
}

.custom-select-option.is-selected:hover {
  background: var(--accent);
  color: var(--brand-dark);
}
