/* Videowall Cubs 3D — Broadcast Studio Configurator UI */

:root {
  --bg-root: #0b0d11;
  --bg-panel: rgba(16, 19, 25, 0.94);
  --bg-card: rgba(255, 255, 255, 0.04);
  --bg-card-hover: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.18);
  --text-main: #edf1f7;
  --text-muted: #94a0b2;
  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --danger: #ef4444;
  --sidebar-width: 348px;
  --radius: 10px;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-root);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

.app-shell {
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

/* ===== Stage & Viewport ===== */
.stage-container {
  position: relative;
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, #141821 0%, #090b0f 100%);
  padding: 20px 20px 84px 20px;
  transition: padding 0.25s ease;
}

.app-shell.ui-hidden .stage-container {
  padding: 0;
}

.viewport-frame {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.08);
  background: #000;
}

.app-shell.ui-hidden .viewport-frame {
  border-radius: 0;
  box-shadow: none;
}

#glCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.stage-badge {
  position: absolute;
  top: 14px;
  left: 14px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(11, 14, 20, 0.62);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.88);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.app-shell.ui-hidden .stage-badge {
  opacity: 0;
}

.stage-history-bar {
  position: absolute;
  top: 14px;
  right: 14px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px;
  border-radius: 10px;
  background: rgba(11, 14, 20, 0.68);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  z-index: 10;
  transition: opacity 0.2s ease;
}

.app-shell.ui-hidden .stage-history-bar {
  opacity: 0;
  pointer-events: none;
}

.stage-hist-btn {
  width: 30px;
  height: 28px;
  border-radius: 7px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.06);
  color: #edf1f7;
  font-size: 16px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.stage-hist-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.22);
}

.badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 8px #22c55e;
}

.badge-dot.paused {
  background: #f59e0b;
  box-shadow: 0 0 8px #f59e0b;
}

/* ===== Transport Bar ===== */
.transport-bar {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: min(760px, calc(100% - 36px));
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(15, 18, 25, 0.86);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-strong);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.app-shell.ui-hidden .transport-bar {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 16px);
}

.timeline-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 120px;
}

.timeline-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  flex-shrink: 0;
}

.icon-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
}

.icon-btn.primary-icon {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
}

.icon-btn.primary-icon:hover {
  background: var(--accent-hover);
}

.pill-btn {
  padding: 7px 11px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.pill-btn:hover {
  color: var(--text-main);
  background: var(--bg-card-hover);
}

.pill-btn.active {
  background: rgba(59, 130, 246, 0.22);
  border-color: var(--accent);
  color: #93c5fd;
}

.restore-ui-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(15, 18, 25, 0.75);
  backdrop-filter: blur(10px);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.app-shell.ui-hidden .restore-ui-btn {
  opacity: 0.72;
  pointer-events: auto;
}

.app-shell.ui-hidden .restore-ui-btn:hover {
  opacity: 1;
}

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  transition: width 0.25s ease, opacity 0.2s ease;
}

.app-shell.ui-hidden .sidebar {
  width: 0;
  opacity: 0;
  border-left: none;
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 15px 16px;
  border-bottom: 1px solid var(--border);
}

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

.brand-cube {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: linear-gradient(135deg, #f8fafc 0%, #94a3b8 55%, #334155 100%);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.7), 0 4px 12px rgba(0, 0, 0, 0.4);
  transform: rotate(12deg);
  flex-shrink: 0;
}

.brand h1 {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand p {
  font-size: 11px;
  color: var(--text-muted);
}

.btn-export-top {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 9px;
  border: none;
  background: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
  transition: transform 0.12s ease, filter 0.15s ease;
}

.btn-export-top:hover {
  filter: brightness(1.1);
}

.btn-export-top:active {
  transform: scale(0.97);
}

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px 28px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar-scroll::-webkit-scrollbar {
  width: 6px;
}

.sidebar-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 3px;
}

/* ===== Panel Sections ===== */
.panel-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 12px;
}

.section-title {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #cbd5e1;
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}

details.panel-section > summary.section-title::after {
  content: "▸";
  font-size: 12px;
  color: var(--text-muted);
  transition: transform 0.15s ease;
}

details.panel-section[open] > summary.section-title::after {
  transform: rotate(90deg);
}

.controls-body {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

/* ===== Presets ===== */
.preset-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-top: 10px;
}

.preset-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-main);
  font-size: 11.5px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
}

.preset-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
}

.preset-btn.active {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.16);
}

.preset-swatch {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.quick-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.btn-secondary, .btn-ghost, .btn-primary, .btn-danger {
  flex: 1;
  padding: 8px 11px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-secondary {
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-main);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.12);
}

button:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.btn-ghost {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  color: var(--text-main);
  border-color: var(--border-strong);
}

.btn-primary {
  border: none;
  background: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}

.btn-primary:hover {
  filter: brightness(1.1);
}

.btn-danger {
  border: 1px solid rgba(239, 68, 68, 0.45);
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.28);
}

/* ===== Form Controls ===== */
.control-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.label-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.control-row label {
  font-size: 12px;
  color: #cbd5e1;
}

.val {
  font-size: 11.5px;
  font-weight: 600;
  color: #93c5fd;
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
  transition: transform 0.1s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

select, input[type="number"] {
  width: 100%;
  padding: 7px 9px;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  background: rgba(11, 14, 20, 0.85);
  color: var(--text-main);
  font-size: 12px;
  outline: none;
}

select:focus, input[type="number"]:focus {
  border-color: var(--accent);
}

.inline-seed {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

.seed-input-group {
  display: flex;
  gap: 6px;
  width: 145px;
}

.btn-mini {
  width: 32px;
  flex-shrink: 0;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  font-size: 14px;
  cursor: pointer;
}

.btn-mini:hover {
  background: rgba(255, 255, 255, 0.15);
}

.toggle-row {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

.toggle-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

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

.color-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  font-size: 11.5px;
  color: #cbd5e1;
  cursor: pointer;
}

.color-item input[type="color"] {
  width: 26px;
  height: 22px;
  border: none;
  border-radius: 5px;
  background: transparent;
  cursor: pointer;
}

/* ===== Export Modal ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(5, 7, 11, 0.78);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-card {
  width: min(540px, 100%);
  border-radius: 16px;
  background: #131720;
  border: 1px solid var(--border-strong);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.75);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 16px;
  font-weight: 700;
}

.modal-header p {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
}

.modal-body {
  padding: 18px 20px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.export-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.export-summary {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
}

.export-summary div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.export-summary span {
  font-size: 11px;
  color: var(--text-muted);
}

.export-summary strong {
  font-size: 13px;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
}

.export-note {
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-muted);
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(59, 130, 246, 0.09);
  border: 1px solid rgba(59, 130, 246, 0.25);
}

.export-note.warn {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.35);
  color: #fde68a;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.modal-actions button {
  flex: 0 0 auto;
  padding: 9px 16px;
}

/* Progress UI */
.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

.progress-track {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #38bdf8);
  border-radius: 999px;
  transition: width 0.1s linear;
}

.progress-stats {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 900px) {
  .app-shell {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    height: 46%;
    border-left: none;
    border-top: 1px solid var(--border);
  }
  .stage-container {
    height: 54%;
    padding: 10px 10px 72px 10px;
  }
  .export-grid {
    grid-template-columns: 1fr;
  }
}
