/* ============================================
   3D SUPER GENERATOR - Viewport Styles
   Viewport, Toolbars, PM Panel, Export, Toast, Loading
   ============================================ */

/* ===== VIEWPORT ===== */
#viewport {
  position: relative; overflow: hidden; background: var(--bg);
}
#viewport canvas { display: block; width: 100% !important; height: 100% !important; }
body.in-generator #viewport { animation: slideInRight .3s ease; }

/* ===== VIEWPORT TOOLBAR (consolidated) ===== */
.vp-toolbar {
  position: absolute; top: 10px; right: 10px;
  display: flex; align-items: center; gap: 3px; z-index: 10;
  background: rgba(17,24,32,.85);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  max-width: calc(100% - 20px);
  box-shadow: 0 4px 16px rgba(0,0,0,.3);
}
.vp-toolbar button {
  height: 26px; min-width: 26px; padding: 0 5px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid var(--border); border-radius: 6px;
  color: var(--text-dim); cursor: pointer; font-size: 11px; font-weight: 500;
  transition: all .2s cubic-bezier(.22,.61,.36,1); white-space: nowrap;
  flex-shrink: 0;
}
.vp-toolbar button:hover { color: var(--accent); border-color: var(--accent); box-shadow: var(--glow-sm); transform: translateY(-1px); }
.vp-toolbar button.active {
  background: var(--accent) !important; color: var(--bg) !important;
  border-color: var(--accent) !important;
}

.vp-sep {
  display: inline-block; width: 1px; height: 18px; background: var(--border);
  margin: 0 2px; vertical-align: middle; flex-shrink: 0;
}

.vp-toolbar input[type="number"] {
  width: 46px; height: 26px; background: var(--bg2); border: 1px solid var(--border);
  color: var(--text); border-radius: 4px; padding: 2px 4px; font-size: 11px;
  text-align: center; outline: none; flex-shrink: 0;
}
.vp-toolbar input[type="number"]:focus { border-color: var(--accent); }
.vp-toolbar select {
  height: 26px; background: var(--bg2); border: 1px solid var(--border); color: var(--text);
  border-radius: 4px; padding: 2px 4px; font-size: 11px; cursor: pointer; outline: none;
  flex-shrink: 0;
}
.vp-toolbar select:focus { border-color: var(--accent); }

.vp-rot-info { font-size: 10px; color: var(--text-muted); white-space: nowrap; font-family: var(--mono); flex-shrink: 0; }

/* ===== VIEWPORT INFO OVERLAY ===== */
.vp-info {
  position: absolute; bottom: 10px; left: 10px; right: 10px;
  display: flex; gap: 12px; padding: 8px 14px;
  background: rgba(17,24,32,.85); border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  font-size: 12px; color: var(--text-dim); z-index: 10;
  flex-wrap: wrap; justify-content: center;
}
.vp-info .val { color: var(--accent); font-weight: 600; font-family: var(--mono); }
.vp-info span { white-space: nowrap; }

/* Export bar (legacy) */
.export-bar { position: absolute; bottom: 10px; right: 10px; display: flex; gap: 6px; z-index: 10; }

/* ===== PART MANIPULATION TOOLBAR ===== */
#pm-toolbar {
  display: none;
  position: absolute;
  top: 36px; left: 0; right: 0;
  z-index: 8;
  background: rgba(10,14,20,0.92);
  border-bottom: 1px solid var(--border);
  padding: 4px 8px;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}
#pm-toolbar .btn.sm { height: 26px; font-size: 11px; }
#pm-toolbar .pm-mode-btn.active {
  background: var(--accent); color: var(--bg); border-color: var(--accent);
}

/* ===== PART MANIPULATION PANEL ===== */
.pm-panel {
  display: none;
  position: absolute;
  bottom: 44px; right: 10px;
  z-index: 9;
  background: rgba(13,17,23,.97);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 12px;
  min-width: 240px; max-width: 280px;
  box-shadow: 0 8px 32px rgba(0,0,0,.5), 0 0 1px rgba(76,201,240,.15);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.pm-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px;
}
.pm-part-name {
  font-weight: 700; color: var(--accent); font-size: 13px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px;
}
.pm-close-btn {
  background: transparent; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 12px; padding: 0 2px; line-height: 1;
  transition: color .15s;
}
.pm-close-btn:hover { color: var(--err); }

.pm-stats {
  display: flex; align-items: center; gap: 6px;
  font-size: 10px; color: var(--text-muted);
  margin-bottom: 8px; padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.pm-stat { display: flex; align-items: center; gap: 3px; }
.pm-stat-val { color: var(--accent); font-family: var(--mono); font-weight: 600; }
.pm-stat-sep { color: var(--border-light); }

.pm-grid {
  display: grid; grid-template-columns: 28px repeat(3, 1fr);
  gap: 3px 5px; align-items: center; margin-bottom: 8px;
}
.pm-label { color: var(--text-muted); font-size: 10px; font-weight: 600; text-align: right; padding-right: 2px; }
.pm-axis-label {
  color: var(--text-muted); font-size: 9px; text-align: center;
  font-family: var(--mono); font-weight: 600; letter-spacing: .05em;
}
.pm-input {
  width: 100%; height: 24px;
  background: var(--bg2); border: 1px solid var(--border);
  color: var(--text); border-radius: 4px;
  padding: 2px 4px; font-size: 11px; text-align: center; outline: none;
  transition: border-color .15s;
}
.pm-input:focus { border-color: var(--accent); }

.pm-actions { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 6px; }
.pm-actions .btn.sm { flex: 1; min-width: 0; font-size: 10px; height: 24px; padding: 0 4px; }

.pm-hint {
  font-size: 9px; color: var(--text-muted);
  border-top: 1px solid var(--border); padding-top: 5px; line-height: 1.5;
}

/* ===== EXPORT PANEL ===== */
.export-panel {
  position: absolute;
  bottom: 44px; left: 10px;
  z-index: 9;
  background: rgba(13,17,23,.97);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 12px;
  min-width: 200px;
  box-shadow: 0 8px 32px rgba(0,0,0,.5), 0 0 1px rgba(76,201,240,.15);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.export-panel-title {
  font-weight: 700; color: var(--accent); font-size: 12px;
  margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px solid var(--border);
  letter-spacing: .05em; text-transform: uppercase;
}
.export-panel-section { margin-bottom: 8px; }
.export-panel-section:last-child { margin-bottom: 0; }
.export-section-label {
  font-size: 10px; color: var(--text-muted); font-weight: 600;
  margin-bottom: 4px; text-transform: uppercase; letter-spacing: .04em;
}
.export-btn-row { display: flex; gap: 4px; flex-wrap: wrap; }
.export-btn-row .btn.sm { font-size: 11px; height: 26px; padding: 0 8px; }

/* ===== TOAST ===== */
#toast-container {
  position: fixed; top: 60px; right: 16px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 10px 16px; border-radius: 10px; font-size: 12px;
  background: var(--glass); border: 1px solid var(--glass-border); color: var(--text);
  box-shadow: 0 8px 32px rgba(0,0,0,.5); animation: toastIn .4s cubic-bezier(.22,.61,.36,1);
  display: flex; align-items: center; gap: 8px; max-width: 360px;
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
}
.toast.ok { border-color: var(--ok); box-shadow: 0 8px 32px rgba(0,0,0,.5), 0 0 12px rgba(63,185,80,.15); }
.toast.ok::before { content: ''; display: none; }
.toast.err { border-color: var(--err); box-shadow: 0 8px 32px rgba(0,0,0,.5), 0 0 12px rgba(248,81,73,.15); }
.toast.warn { border-color: var(--warn); box-shadow: 0 8px 32px rgba(0,0,0,.5), 0 0 12px rgba(210,153,34,.15); }
.toast.out { animation: toastOut .3s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(40px) scale(.9); } to { opacity: 1; transform: translateX(0) scale(1); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateX(40px) scale(.9); } }

/* ===== LOADING OVERLAY ===== */
#loading-overlay {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(8,11,16,.94); display: none;
  flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
#loading-overlay.show { display: flex; }
body:has(#loading-overlay.show) { overflow: hidden; }
.spinner { width: 44px; height: 44px; position: relative; }
.spinner::before, .spinner::after {
  content: ''; position: absolute; inset: 0; border-radius: 50%;
  border: 3px solid transparent;
}
.spinner::before {
  border-top-color: var(--accent); border-right-color: var(--accent);
  animation: spinDual .8s linear infinite;
}
.spinner::after {
  inset: 6px;
  border-bottom-color: var(--accent2); border-left-color: var(--accent2);
  animation: spinReverse 1.2s linear infinite;
}
#loading-overlay .msg { font-size: 14px; color: var(--text-dim); }

/* ===== KEYBOARD SHORTCUTS OVERLAY ===== */
.shortcuts-overlay {
  position: fixed; inset: 0; z-index: 10001;
  background: rgba(8,11,16,.85);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  display: none; align-items: center; justify-content: center;
}
.shortcuts-overlay.show { display: flex; }
.shortcuts-panel {
  background: var(--panel); border: 1px solid var(--glass-border);
  border-radius: 16px; padding: 28px 32px; max-width: 400px; width: 90%;
  box-shadow: 0 16px 64px rgba(0,0,0,.6);
  animation: fadeInScale .25s ease;
}
.shortcuts-panel h3 { font-size: 16px; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.shortcuts-panel .shortcut-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--glass-border); font-size: 12px;
}
.shortcuts-panel .shortcut-row:last-child { border-bottom: none; }
.shortcuts-panel kbd {
  background: var(--bg2); border: 1px solid var(--border);
  padding: 2px 8px; border-radius: 4px; font-family: var(--mono);
  font-size: 11px; color: var(--accent);
}
