/* =========================================================
   LIGHT STAGE — Portrait Studio Lighting Simulator
   ========================================================= */

:root {
  --bg-darkest: #eef1f6;
  --bg-darker: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.9);
  --bg-card-hover: rgba(255, 255, 255, 0.98);
  --border-subtle: rgba(15, 23, 42, 0.1);
  --border-hover: rgba(15, 23, 42, 0.22);
  --border-active: rgba(245, 158, 11, 0.6);

  --accent-gold: #d97706;
  --accent-gold-glow: rgba(245, 158, 11, 0.22);
  --accent-cyan: #0284c7;
  --accent-rose: #e11d48;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;

  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'Space Mono', monospace;
  --font-display: 'Syne', sans-serif;

  --header-height: 54px;
  --sidebar-width: 285px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

html, body {
  background: var(--bg-darkest);
  color: var(--text-primary);
  font-family: var(--font-sans);
  height: 100%;
  overflow: hidden;
  user-select: none;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* =========================================================
   TOPBAR
   ========================================================= */

.topbar {
  height: var(--header-height);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  z-index: 50;
  gap: 16px;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 200px;
}

.brand-indicator {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-gold);
  box-shadow: 0 0 10px var(--accent-gold);
  animation: pulse-glow 2.5s infinite ease-in-out;
}

@keyframes pulse-glow {
  0%, 100% { transform: scale(0.9); opacity: 0.8; }
  50% { transform: scale(1.15); opacity: 1; }
}

.brand-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 2px;
  color: var(--text-primary);
}

.brand-title .accent {
  color: var(--accent-gold);
}

.brand-badge {
  display: block;
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 1.2px;
  color: var(--text-muted);
}

/* Presets Bar */
.preset-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 4px 0;
}

.preset-selector::-webkit-scrollbar {
  display: none;
}

.preset-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--text-muted);
  letter-spacing: 1px;
  white-space: nowrap;
}

.preset-pills {
  display: flex;
  align-items: center;
  gap: 6px;
}

.preset-pill {
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 20px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.preset-pill:hover {
  background: rgba(255, 255, 255, 0.9);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.preset-pill.active {
  background: rgba(245, 158, 11, 0.18);
  color: var(--accent-gold);
  border-color: rgba(245, 158, 11, 0.5);
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.2);
}

/* Top Actions */
.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 330px;
  justify-content: flex-end;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.action-btn:hover {
  background: rgba(255, 255, 255, 0.95);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.action-btn.active {
  background: rgba(245, 158, 11, 0.22);
  border-color: rgba(245, 158, 11, 0.55);
  color: var(--accent-gold);
}

.mailto-link {
  text-decoration: none;
}

.btn-highlight {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #0b0b10;
  border: none;
  font-weight: 700;
}

.btn-highlight:hover {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  box-shadow: 0 0 14px rgba(245, 158, 11, 0.4);
}

/* =========================================================
   WORKSPACE LAYOUT
   ========================================================= */

.workspace {
  flex: 1;
  display: flex;
  height: calc(100vh - var(--header-height));
  position: relative;
  overflow: hidden;
}

/* =========================================================
   SIDEBARS
   ========================================================= */

.sidebar {
  width: var(--sidebar-width);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  z-index: 30;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(15, 23, 42, 0.2) transparent;
}

.left-sidebar {
  border-right: 1px solid var(--border-subtle);
}

.right-sidebar {
  border-left: 1px solid var(--border-subtle);
}

/* Setup Info Card (Left sidebar top) */
.setup-info-card {
  padding: 14px 16px;
  background: rgba(245, 158, 11, 0.08);
  border-bottom: 1px solid var(--border-subtle);
}

.setup-badge {
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 1.5px;
  color: var(--accent-gold);
  font-weight: 700;
  display: inline-block;
  margin-bottom: 4px;
}

.setup-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.setup-desc {
  font-size: 11px;
  line-height: 1.45;
  color: var(--text-secondary);
}

.panel-header {
  padding: 12px 16px 8px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-tag {
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  display: block;
  font-weight: 600;
}

.panel-heading {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 1px;
}

.icon-btn-tiny {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  width: 24px;
  height: 24px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: all 0.15s ease;
}

.icon-btn-tiny:hover {
  color: var(--text-primary);
  border-color: var(--border-hover);
}

/* =========================================================
   LIGHTS LIST & CARDS
   ========================================================= */

.lights-list {
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.light-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 9px 11px;
  transition: all 0.18s ease;
}

.light-card:hover {
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
}

.light-card.disabled {
  opacity: 0.5;
}

.light-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 7px;
}

.light-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.light-color-badge {
  width: 17px;
  height: 17px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 8px currentColor;
  cursor: pointer;
  position: relative;
}

.light-color-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.light-title {
  font-weight: 700;
  font-size: 12px;
  color: var(--text-primary);
}

.light-role-text {
  font-size: 9px;
  color: var(--text-muted);
  display: block;
}

.toggle-switch {
  position: relative;
  width: 30px;
  height: 16px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.2);
  transition: 0.2s;
  border-radius: 18px;
}

.switch-slider:before {
  position: absolute;
  content: "";
  height: 10px;
  width: 10px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.2s;
  border-radius: 50%;
}

input:checked + .switch-slider {
  background-color: var(--accent-gold);
}

input:checked + .switch-slider:before {
  transform: translateX(14px);
}

.light-controls {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.mini-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.mini-label {
  font-size: 9.5px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  width: 44px;
  flex-shrink: 0;
}

.slider-input {
  flex: 1;
  height: 4px;
  -webkit-appearance: none;
  background: rgba(15, 23, 42, 0.14);
  border-radius: 4px;
  outline: none;
}

.slider-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--text-primary);
  cursor: pointer;
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
  transition: transform 0.1s ease;
}

.slider-input::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  background: var(--accent-gold);
}

.mini-val {
  font-size: 9px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  width: 30px;
  text-align: right;
  flex-shrink: 0;
}

/* Global Rig Tweaks */
.rig-global-controls {
  padding: 12px 14px 16px;
  border-top: 1px solid var(--border-subtle);
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 7px;
  background: rgba(255, 255, 255, 0.7);
}

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

.control-label {
  font-size: 10.5px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.control-val {
  font-size: 9.5px;
  font-family: var(--font-mono);
  color: var(--accent-gold);
  width: 32px;
  text-align: right;
  flex-shrink: 0;
}

/* =========================================================
   RIGHT SIDEBAR: SOURCE & FIT
   ========================================================= */

.upload-section {
  padding: 12px 14px 10px;
}

.dropzone {
  border: 1.5px dashed var(--border-subtle);
  border-radius: 12px;
  padding: 16px 12px;
  text-align: center;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.7);
  transition: all 0.2s ease;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent-gold);
  background: rgba(245, 158, 11, 0.08);
}

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

.dropzone-title {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

.dropzone-sub {
  display: block;
  font-size: 9.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.file-input-hidden {
  display: none;
}

.source-quick-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-top: 8px;
}

.source-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 7px 8px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.source-btn:hover {
  background: rgba(255, 255, 255, 0.95);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

/* Sample Subjects Grid */
.sample-section {
  padding: 10px 14px;
  border-top: 1px solid var(--border-subtle);
}

.section-tag {
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  margin-bottom: 7px;
  display: block;
}

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

.sample-thumb {
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  background: #eef1f6;
  position: relative;
  transition: all 0.15s ease;
}

.sample-thumb canvas, .sample-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.sample-thumb:hover {
  border-color: var(--accent-gold);
  transform: translateY(-2px);
}

.sample-thumb.active {
  border-color: var(--accent-gold);
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.35);
}

/* Fit Section */
.fit-section {
  padding: 12px 14px 16px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: auto;
  background: rgba(255, 255, 255, 0.7);
}

/* =========================================================
   CENTER VIEWPORT & CANVASES
   ========================================================= */

.viewport-area {
  flex: 1;
  position: relative;
  background: radial-gradient(circle at center, #ffffff 0%, #dfe4ec 100%);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.canvas-wrapper {
  position: relative;
  max-width: 88%;
  max-height: 88%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 16px 50px rgba(15, 23, 42, 0.35), 0 0 0 1px rgba(15, 23, 42, 0.12);
}

#stage-canvas {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - var(--header-height) - 70px);
  object-fit: contain;
}

/* Before / After Compare Divider */
.compare-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.compare-container.hidden {
  display: none;
}

.compare-divider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: #ffffff;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.9);
  pointer-events: auto;
  cursor: ew-resize;
  z-index: 20;
}

.compare-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #ffffff;
  color: #0b0b10;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 800;
  box-shadow: 0 0 16px rgba(0, 0, 0, 0.5);
}

.compare-label {
  position: absolute;
  bottom: 14px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 1.2px;
  padding: 4px 9px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: var(--text-secondary);
}

.label-before {
  left: 14px;
}

.label-after {
  right: 14px;
  color: var(--accent-gold);
}

/* Top-Down Studio Radar Diagram (Overlay) */
.studio-radar-card {
  position: absolute;
  top: 18px;
  left: 18px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 10px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.2);
}

.radar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  font-family: var(--font-mono);
  font-size: 8.5px;
  color: var(--accent-gold);
  font-weight: 700;
  letter-spacing: 1px;
  margin-bottom: 6px;
}

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

#radar-canvas {
  display: block;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.08);
}

.radar-caption {
  font-family: var(--font-mono);
  font-size: 8px;
  color: var(--text-muted);
  margin-top: 5px;
}

/* Viewport HUD */
.viewport-hud {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  padding: 5px 14px;
  border-radius: 20px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  pointer-events: none;
  z-index: 15;
}

.hud-key {
  color: var(--accent-gold);
  font-weight: 700;
}

/* Flash overlay for export SFX */
.flash-overlay {
  position: absolute;
  inset: 0;
  background: #ffffff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease-out;
  z-index: 100;
}

.flash-overlay.active {
  opacity: 0.85;
  transition: opacity 0.05s ease-in;
}

/* =========================================================
   CAMERA MODAL & TOAST
   ========================================================= */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-backdrop.hidden {
  display: none;
}

.modal-box {
  background: var(--bg-darker);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  width: 440px;
  max-width: 90vw;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
}

.modal-header {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-header h3 {
  font-size: 13.5px;
  font-weight: 700;
}

.icon-btn-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
}

.icon-btn-close:hover {
  color: var(--text-primary);
}

.modal-body {
  position: relative;
  background: #000;
  aspect-ratio: 4 / 3;
}

#cam-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.cam-guide {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 55%;
  height: 75%;
  border: 2px dashed rgba(245, 158, 11, 0.5);
  border-radius: 50%;
  pointer-events: none;
}

.modal-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-subtle);
}

.btn-full {
  width: 100%;
  padding: 9px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12.5px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.94);
  border: 1px solid var(--accent-gold);
  color: #f8fafc;
  padding: 9px 20px;
  border-radius: 30px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  z-index: 110;
  transition: all 0.25s ease;
}

.toast.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 15px);
}

/* Responsive */
@media (max-width: 960px) {
  .workspace {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    max-height: 220px;
  }
  .topbar {
    padding: 0 10px;
  }
  .preset-selector {
    display: none;
  }
  .studio-radar-card {
    display: none;
  }
}
