/* Dashboard layout — extends theme.css tokens */

/* === NAV ADDITIONS === */
.nav-cta {
  color: var(--accent) !important;
  border: 1px solid var(--border-bright);
  border-radius: 6px;
  padding: 6px 14px !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  transition: background 0.2s, color 0.2s !important;
}
.nav-cta:hover {
  background: var(--accent-dim);
}
.nav-active {
  color: var(--text) !important;
}

/* === DASH BODY & LAYOUT === */
.dash-body {
  background: var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
}

.dash-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  min-height: 100vh;
  padding-top: 60px; /* nav height */
}

/* === SIDEBAR === */
.dash-sidebar {
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
  max-height: calc(100vh - 60px);
  position: sticky;
  top: 60px;
}

.sidebar-header {
  padding: 28px 28px 0;
}

.sidebar-title {
  font-family: var(--font-head);
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  margin-top: 6px;
}

/* === GENERATOR FORM === */
.gen-form {
  padding: 20px 28px 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  border-bottom: 1px solid var(--border);
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.field-textarea {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  padding: 12px 14px;
  resize: none;
  transition: border-color 0.2s;
  outline: none;
}
.field-textarea:focus {
  border-color: var(--border-bright);
}
.field-textarea::placeholder { color: var(--text-dim); }

.field-hint {
  font-size: 11px;
  color: var(--text-dim);
  text-align: right;
}

/* Chip selectors (style) */
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 100px;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  padding: 5px 12px;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.chip:hover {
  border-color: var(--border-bright);
  color: var(--text);
}
.chip-active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

/* Radio group (detail level) */
.radio-group {
  display: flex;
  gap: 12px;
}
.radio-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
}
.radio-item input[type="radio"] { accent-color: var(--accent); }
.radio-hint {
  font-size: 11px;
  color: var(--text-dim);
}

/* Select */
.field-select {
  appearance: none;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
  outline: none;
  padding: 10px 14px;
  transition: border-color 0.2s;
  cursor: pointer;
}
.field-select:focus { border-color: var(--border-bright); }

/* Format chips (radio) */
.format-chips {
  display: flex;
  gap: 8px;
}
.format-chip {
  cursor: pointer;
}
.format-chip input[type="radio"] { display: none; }
.format-chip span {
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-family: var(--font-head);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 8px 18px;
  transition: all 0.15s;
}
.format-chip input:checked + span {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

/* Generate button */
.btn-generate {
  align-items: center;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: var(--bg);
  cursor: pointer;
  display: flex;
  font-family: var(--font-head);
  font-size: 14px;
  font-weight: 700;
  gap: 8px;
  justify-content: center;
  letter-spacing: 0.02em;
  padding: 14px;
  transition: opacity 0.2s, transform 0.15s;
  width: 100%;
  margin-top: 4px;
}
.btn-generate:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-generate:active { transform: translateY(0); }
.btn-generate:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* === PROJECT HISTORY === */
.project-history {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px 28px;
  gap: 12px;
  overflow-y: auto;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.history-refresh {
  background: none;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 5px 7px;
  transition: border-color 0.2s, color 0.2s;
  display: flex;
  align-items: center;
}
.history-refresh:hover { border-color: var(--border-bright); color: var(--text); }

.project-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.project-empty {
  font-size: 13px;
  color: var(--text-dim);
  padding: 16px 0;
  text-align: center;
}

.project-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  transition: border-color 0.15s, background 0.15s;
}
.project-card:hover {
  border-color: var(--border-bright);
  background: var(--bg-card-hover);
}
.project-card.active {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.project-card-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-queued    { background: var(--text-dim); }
.status-generating { background: var(--accent); animation: pulse-dot 1.2s infinite; }
.status-finished  { background: #22c55e; }
.status-failed    { background: #ef4444; }

.project-card-body {
  flex: 1;
  min-width: 0;
}
.project-card-name {
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.project-card-meta {
  color: var(--text-dim);
  font-size: 11px;
  margin-top: 2px;
}

.project-card-format {
  color: var(--accent);
  font-family: var(--font-head);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

/* === MAIN VIEWER AREA === */
.dash-main {
  display: flex;
  flex-direction: column;
  padding: 28px;
  gap: 20px;
  min-height: calc(100vh - 60px);
}

.viewer-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  flex: 1;
  min-height: 480px;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Idle */
.viewer-idle {
  align-items: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: center;
}
.viewer-idle-text {
  color: var(--text-muted);
  font-size: 16px;
  font-weight: 500;
}
.viewer-idle-hint {
  color: var(--text-dim);
  font-size: 13px;
}

/* Generating */
.viewer-generating {
  align-items: center;
  display: flex;
  flex-direction: column;
  gap: 32px;
  width: 100%;
  padding: 40px;
}

.gen-progress {
  align-items: center;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.gen-spinner {
  width: 48px;
  height: 48px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.gen-status-text {
  color: var(--text);
  font-family: var(--font-head);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.gen-sub {
  color: var(--text-muted);
  font-size: 13px;
}

.gen-pipeline-vis {
  align-items: center;
  display: flex;
  gap: 12px;
}

.pipeline-pill {
  align-items: center;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 100px;
  color: var(--text-dim);
  display: flex;
  font-size: 12px;
  font-weight: 500;
  gap: 8px;
  padding: 6px 14px;
  transition: all 0.3s;
}
.pipeline-pill.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}
.pipeline-pill.done {
  background: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.4);
  color: #22c55e;
}

.pill-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.pipeline-pill.active .pill-dot { animation: pulse-dot 1s infinite; }

.pipeline-arrow {
  color: var(--text-dim);
  font-size: 12px;
}

/* Canvas viewer */
.viewer-canvas {
  position: absolute;
  inset: 0;
}
.viewer-canvas canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.viewer-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 16px 20px;
  background: linear-gradient(transparent, rgba(7,11,20,0.8));
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  pointer-events: none;
}
.viewer-model-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.model-name {
  font-family: var(--font-head);
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.model-meta {
  font-size: 11px;
  color: var(--text-muted);
}
.viewer-controls-hint {
  font-size: 11px;
  color: var(--text-dim);
}

.viewer-actions {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  gap: 8px;
}

.btn-download, .btn-printable {
  align-items: center;
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  gap: 6px;
  padding: 8px 14px;
  transition: all 0.2s;
}
.btn-download {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.btn-download:hover {
  border-color: var(--border-bright);
  color: var(--text);
}
.btn-printable {
  background: var(--accent);
  border: none;
  color: var(--bg);
  font-weight: 600;
}
.btn-printable:hover { opacity: 0.88; }

/* Failed */
.viewer-failed {
  align-items: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: center;
}
.viewer-failed-text {
  color: #ef4444;
  font-size: 16px;
  font-weight: 500;
}
.viewer-failed-hint {
  color: var(--text-dim);
  font-size: 13px;
}

/* === PRINTABLE PANEL === */
.printable-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: relative;
}

.printable-header {
  align-items: center;
  display: flex;
  gap: 10px;
}
.printable-header h3 {
  color: var(--text);
  flex: 1;
  font-family: var(--font-head);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.printable-close {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  padding: 0;
  transition: color 0.2s;
}
.printable-close:hover { color: var(--text); }

.printable-checks {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.check-row {
  align-items: center;
  display: flex;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.check-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.check-ok { background: rgba(34,197,94,0.1); color: #22c55e; border: 1px solid rgba(34,197,94,0.3); }
.check-warn { background: rgba(251,191,36,0.1); color: #fbbf24; border: 1px solid rgba(251,191,36,0.3); }
.check-neutral { background: var(--accent-dim); color: var(--accent); border: 1px solid var(--border-bright); }

.check-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.check-name { font-size: 13px; font-weight: 500; color: var(--text); }
.check-desc { font-size: 11px; color: var(--text-muted); }
.check-desc strong { color: var(--text); }

/* Toggle switch */
.toggle { position: relative; display: inline-block; width: 38px; height: 22px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 100px;
  cursor: pointer;
  transition: background 0.2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  left: 3px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  background: var(--text-dim);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}
.toggle input:checked + .toggle-slider { background: var(--accent-dim); border-color: var(--accent); }
.toggle input:checked + .toggle-slider::before {
  transform: translate(16px, -50%);
  background: var(--accent);
}

.mini-select {
  appearance: none;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 12px;
  padding: 5px 10px;
  outline: none;
  cursor: pointer;
}

.drain-row { transition: opacity 0.2s; }
.drain-row.hidden { display: none; }

/* Support estimate bar */
.support-estimate {
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.support-label { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-dim); }
.support-bar {
  background: var(--bg-panel);
  border-radius: 100px;
  height: 6px;
  overflow: hidden;
}
.support-fill {
  background: linear-gradient(90deg, var(--accent), rgba(0,212,255,0.4));
  border-radius: 100px;
  height: 100%;
  transition: width 0.4s ease;
}
.support-desc { font-size: 12px; color: var(--text-muted); }

.btn-apply-print {
  align-items: center;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: var(--bg);
  cursor: pointer;
  display: flex;
  font-family: var(--font-head);
  font-size: 14px;
  font-weight: 700;
  gap: 8px;
  justify-content: center;
  padding: 13px;
  transition: opacity 0.2s, transform 0.15s;
  width: 100%;
}
.btn-apply-print:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-apply-print:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.printable-status {
  background: rgba(34,197,94,0.1);
  border: 1px solid rgba(34,197,94,0.3);
  border-radius: var(--radius);
  color: #22c55e;
  font-size: 13px;
  padding: 10px 14px;
  text-align: center;
}

/* === UTILITIES === */
.hidden { display: none !important; }

/* === CREDITS COUNTER === */
.nav-credits {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  margin-right: 16px;
}

.credits-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-dim);
  border: 1px solid var(--border-bright);
  border-radius: 100px;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  font-family: var(--font-head);
}

.credits-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
}

.credits-topup {
  font-size: 12px;
  color: var(--text-dim);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}
.credits-topup:hover { color: var(--accent); }

/* === FORMAT DOWNLOAD BUTTONS === */
.viewer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.dl-formats {
  display: flex;
  align-items: center;
  gap: 4px;
}

.dl-label {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 500;
  margin-right: 2px;
  font-family: var(--font-head);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.btn-dl-format {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-dim);
  cursor: pointer;
  font-family: var(--font-head);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 5px 10px;
  transition: all 0.15s;
}
.btn-dl-format:hover { border-color: var(--border-bright); color: var(--text); }
.btn-dl-format.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

.btn-download-primary {
  align-items: center;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  gap: 6px;
  padding: 8px 14px;
  transition: all 0.2s;
}
.btn-download-primary:hover { border-color: var(--border-bright); color: var(--text); }

/* === PRINTABILITY SCORE === */
.printability-score {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.score-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.score-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
  font-family: var(--font-head);
}

.score-value {
  font-family: var(--font-head);
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.03em;
}

.score-bar-container {
  position: relative;
}

.score-bar-track {
  background: var(--bg-panel);
  border-radius: 100px;
  height: 8px;
  overflow: hidden;
}

.score-bar-fill {
  background: linear-gradient(90deg, #22c55e, #4ade80);
  border-radius: 100px;
  height: 100%;
  transition: width 0.6s ease, background 0.4s ease;
  min-width: 8px;
}

.score-glow {
  position: absolute;
  top: 0;
  left: 0;
  height: 8px;
  border-radius: 100px;
  opacity: 0.3;
  filter: blur(4px);
  pointer-events: none;
}

.score-status {
  display: flex;
  justify-content: flex-end;
}

.score-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: rgba(34,197,94,0.15);
  border: 1px solid rgba(34,197,94,0.3);
  color: #22c55e;
  font-family: var(--font-head);
}

/* === WALL THICKNESS ANALYSIS === */
.wall-analysis {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.wall-analysis-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.wall-analysis-btn {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s;
  font-family: var(--font-body);
}
.wall-analysis-btn:hover { border-color: var(--border-bright); color: var(--text); }

.wall-legend {
  display: flex;
  gap: 12px;
}

.wall-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-muted);
}

.wall-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.wall-good .wall-dot { background: #22c55e; }
.wall-warn .wall-dot { background: #fbbf24; }
.wall-bad .wall-dot { background: #ef4444; }

.wall-histogram {
  display: flex;
  gap: 2px;
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
}

.histogram-bar {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}

#histGood  { background: #22c55e; }
#histWarn  { background: #fbbf24; }
#histBad   { background: #ef4444; }

/* === VIEWER ACTIONS AREA === */
.viewer-actions {
  position: absolute;
  top: 16px;
  right: 16px;
}

/* === RESPONSIVE === */
@media (max-width: 900px) {
  .dash-layout { grid-template-columns: 1fr; }
  .dash-sidebar { max-height: none; position: static; border-right: none; border-bottom: 1px solid var(--border); }
  .dash-main { padding: 16px; }
}
