/* GS-WOW Suite — Modern Glassmorphic UI & Flight Studio */

:root {
  --gswow-accent: #ff4757;
  --gswow-primary: #3b82f6;
  --gswow-success: #10b981;
  --gswow-warning: #f59e0b;
  --gswow-bg-glass: rgba(15, 23, 42, 0.78);
  --gswow-bg-glass-card: rgba(30, 41, 59, 0.75);
  --gswow-border: rgba(255, 255, 255, 0.12);
  --gswow-border-active: rgba(59, 130, 246, 0.6);
  --gswow-text: #f8fafc;
  --gswow-text-muted: #94a3b8;
  --gswow-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --gswow-radius: 12px;
  --gswow-radius-sm: 8px;
  --gswow-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.08);
}

/* Base HUD Container */
#gswow-hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  font-family: var(--gswow-font);
  color: var(--gswow-text);
  z-index: 1000;
  user-select: none;
  overflow: hidden;
}

#gswow-hud * {
  box-sizing: border-box;
}

#gswow-hud button, 
#gswow-hud input, 
#gswow-hud select {
  pointer-events: auto;
  font-family: inherit;
}

/* ========================================================
   Aspect Ratio Mask Overlay (Social Framing)
   ======================================================== */
#gswow-mask-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 5;
}

#gswow-mask-frame {
  position: relative;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.75);
  border: 1px dashed rgba(255, 255, 255, 0.35);
  transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1), height 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  justify-content: center;
}

.gswow-mask-tag {
  position: absolute;
  top: 12px;
  left: 14px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  background: rgba(0, 0, 0, 0.6);
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #e2e8f0;
}

/* Safe Zone & Rule of Thirds Grid */
.gswow-grid-thirds {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr 1fr;
  border: 1px solid rgba(255, 255, 255, 0.15);
  pointer-events: none;
  opacity: 0.5;
}

.gswow-grid-thirds > div {
  border: 0.5px solid rgba(255, 255, 255, 0.08);
}

.gswow-tiktok-safezone {
  position: absolute;
  right: 12px;
  bottom: 80px;
  width: 50px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
  opacity: 0.45;
  pointer-events: none;
}

.gswow-tiktok-safezone .safe-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

/* ========================================================
   Top Navigation Bar
   ======================================================== */
#gswow-top-bar {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  pointer-events: auto;
  z-index: 20;
  flex-wrap: wrap;
  padding: 8px;
  border-radius: 16px;
  background: var(--gswow-bg-glass);
  backdrop-filter: blur(16px);
}

.gswow-bar-left, .gswow-bar-center, .gswow-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  max-width: 100%;
}

/* Pill Badge */
.gswow-brand-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--gswow-bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--gswow-border);
  padding: 6px 14px;
  border-radius: 30px;
  box-shadow: var(--gswow-shadow);
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}

.gswow-brand-badge:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.3);
}

.gswow-brand-logo {
  font-weight: 900;
  font-size: 13px;
  letter-spacing: 1px;
  background: linear-gradient(135deg, #ff4757, #ffa502, #3742fa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.gswow-scene-tag {
  font-size: 11px;
  color: var(--gswow-text-muted);
  font-weight: 500;
  padding-left: 6px;
  border-left: 1px solid rgba(255, 255, 255, 0.15);
}

/* Glass Pill Buttons */
.gswow-btn-group {
  display: flex;
  align-items: center;
  background: var(--gswow-bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--gswow-border);
  padding: 3px;
  border-radius: 30px;
  box-shadow: var(--gswow-shadow);
}

.gswow-btn {
  background: transparent;
  color: var(--gswow-text-muted);
  border: none;
  outline: none;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.gswow-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

.gswow-btn.active {
  background: var(--gswow-primary);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

.gswow-btn-accent {
  background: rgba(255, 71, 87, 0.15);
  color: #ff6b81;
  border: 1px solid rgba(255, 71, 87, 0.3);
}

.gswow-btn-accent:hover {
  background: #ff4757;
  color: white;
}

.gswow-btn-record {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.4);
  font-weight: 700;
}

.gswow-btn-record:hover {
  background: #ef4444;
  color: #ffffff;
}

.gswow-btn-record.recording {
  background: #ef4444;
  color: #ffffff;
  animation: pulse-rec 1.2s infinite ease-in-out;
}

@keyframes pulse-rec {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* ========================================================
   Floating Studio Panels
   ======================================================== */
.gswow-panel {
  position: absolute;
  background: var(--gswow-bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--gswow-border);
  border-radius: var(--gswow-radius);
  box-shadow: var(--gswow-shadow);
  padding: 18px;
  pointer-events: auto;
  z-index: 30;
  max-width: 420px;
  width: calc(100% - 32px);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s;
}

.gswow-panel.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px) scale(0.97);
}

/* Flight Studio Panel (Bottom Left) */
#gswow-flight-panel {
  bottom: 24px;
  left: 20px;
}

/* Environment / Settings Panel (Top Right) */
#gswow-env-panel {
  top: 68px;
  right: 20px;
}

/* Tour Panel (Bottom Center) */
#gswow-tour-panel {
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 580px;
}

#gswow-tour-panel.hidden {
  transform: translate(-50%, 14px) scale(0.97);
}

/* Panel Header */
.gswow-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.gswow-panel-title {
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #f1f5f9;
}

.gswow-close-btn {
  background: transparent;
  border: none;
  color: var(--gswow-text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
}

.gswow-close-btn:hover {
  color: white;
  background: rgba(255, 255, 255, 0.1);
}

/* Tab Navigation */
.gswow-tabs {
  display: flex;
  gap: 6px;
  background: rgba(0, 0, 0, 0.25);
  padding: 3px;
  border-radius: 8px;
  margin-bottom: 14px;
}

.gswow-tab {
  flex: 1;
  text-align: center;
  background: transparent;
  color: var(--gswow-text-muted);
  border: none;
  font-size: 11px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.gswow-tab.active {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

/* Card Section */
.gswow-section {
  background: var(--gswow-bg-glass-card);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--gswow-radius-sm);
  padding: 12px;
  margin-bottom: 12px;
}

.gswow-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 12px;
}

.gswow-row:last-child {
  margin-bottom: 0;
}

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

.gswow-value {
  font-weight: 600;
  color: #e2e8f0;
}

/* Sliders */
.gswow-slider-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.gswow-slider {
  flex: 1;
  accent-color: var(--gswow-primary);
  cursor: pointer;
}

/* Recording HUD Indicator */
#gswow-rec-badge {
  position: absolute;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(220, 38, 38, 0.9);
  backdrop-filter: blur(12px);
  color: white;
  padding: 6px 18px;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 4px 20px rgba(220, 38, 38, 0.5);
  z-index: 25;
  pointer-events: auto;
}

#gswow-rec-badge.hidden {
  display: none;
}

.gswow-rec-dot {
  width: 10px;
  height: 10px;
  background: #ffffff;
  border-radius: 50%;
  animation: blink 1s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}

/* Button Bars */
.gswow-actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.gswow-action-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #f1f5f9;
  padding: 8px 12px;
  border-radius: var(--gswow-radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s;
}

.gswow-action-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.gswow-action-btn.primary {
  background: var(--gswow-primary);
  border-color: rgba(59, 130, 246, 0.5);
  color: white;
}

.gswow-action-btn.primary:hover {
  background: #2563eb;
}

.gswow-action-btn.blender {
  background: #e87a24;
  border-color: rgba(232, 122, 36, 0.6);
  color: white;
  grid-column: span 2;
}

.gswow-action-btn.blender:hover {
  background: #d46b19;
}

/* Waypoints List */
.gswow-waypoint-list {
  max-height: 180px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 10px 0;
  padding-right: 4px;
}

.gswow-waypoint-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.25);
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 11px;
}

.gswow-waypoint-item:hover {
  border-color: rgba(59, 130, 246, 0.4);
}

/* Measurement Ruler Badge */
#gswow-ruler-badge {
  position: absolute;
  top: 70px;
  right: 20px;
  background: var(--gswow-bg-glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--gswow-border);
  padding: 10px 16px;
  border-radius: var(--gswow-radius-sm);
  font-size: 12px;
  box-shadow: var(--gswow-shadow);
  pointer-events: auto;
  z-index: 25;
}

#gswow-ruler-badge.hidden {
  display: none;
}

/* QR Code Modal */
#gswow-modal-overlay,
.gswow-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  pointer-events: auto;
}

#gswow-modal-overlay.hidden,
.gswow-modal-overlay.hidden {
  display: none;
}

.gswow-modal-card {
  background: #0f172a;
  border: 1px solid var(--gswow-border);
  border-radius: var(--gswow-radius);
  padding: 24px;
  max-width: 380px;
  width: 90%;
  box-shadow: var(--gswow-shadow);
  text-align: center;
}

.gswow-qr-box {
  background: white;
  padding: 12px;
  border-radius: 8px;
  display: inline-block;
  margin: 16px 0;
}

.gswow-qr-box canvas {
  position: static !important;
  display: block;
}

/* Toast Notification */
#gswow-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--gswow-border-active);
  color: #ffffff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  box-shadow: var(--gswow-shadow);
  z-index: 10001;
  pointer-events: none;
  transform: translateY(20px);
  opacity: 0;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

#gswow-toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* 3D Ruler Active Styles */
body.ruler-active canvas,
body.ruler-active #gswow-hud {
  cursor: crosshair !important;
}

@keyframes gswow-pulse-anim {
  0% { r: 8px; opacity: 0.9; }
  100% { r: 24px; opacity: 0; }
}

.gswow-pin-pulse {
  animation: gswow-pulse-anim 1.4s infinite cubic-bezier(0.16, 1, 0.3, 1);
}

@media (max-width: 1500px) {
  #gswow-flight-panel, #gswow-tour-panel, #gswow-env-panel {
    top: 150px;
    bottom: auto;
    max-height: calc(100dvh - 175px);
    overflow-y: auto;
  }
}

#gswow-mobile-tools, #gswow-mobile-display, #gswow-touch-navigation { display: none; }
.gswow-touch-guide { margin: 12px 0; font-size: 14px; line-height: 1.6; }

/* Canvas gestures stay with the renderer; sheets can scroll normally on iOS. */
.gswow-panel, .gswow-panel *, .gswow-modal-card, .gswow-modal-card * {
  touch-action: pan-y;
}
.gswow-panel input[type="range"] { touch-action: none; }
.gswow-modal-card { max-height: 85dvh; overflow-y: auto; }

@media (max-width: 600px), (pointer: coarse) and (max-height: 600px) {
  #gswow-top-bar {
    top: max(8px, env(safe-area-inset-top));
    left: max(8px, env(safe-area-inset-left));
    right: max(8px, env(safe-area-inset-right));
    gap: 8px;
    max-height: calc(100dvh - 140px - env(safe-area-inset-top));
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  #gswow-top-bar, #gswow-top-bar * { touch-action: pan-y; }
  .gswow-bar-left { width: 100%; justify-content: space-between; }
  .gswow-brand-badge { min-width: 0; flex: 1; padding: 6px 8px; display: block; box-shadow: none; background: none; border: 0; }
  .gswow-brand-logo { display: block; font-size: 11px; }
  .gswow-scene-tag { display: block; overflow: hidden; text-overflow: ellipsis; border: 0; padding: 2px 0 0; color: #e2e8f0; font-size: 12px; }
  #gswow-mobile-tools { display: flex; flex-shrink: 0; }
  #gswow-mobile-display { display: flex; }
  #gswow-hud button, #gswow-hud select, .gswow-modal-card button {
    min-height: 44px;
    min-width: 44px;
    font-size: 13px;
    touch-action: manipulation;
  }
  #gswow-hud input[type="range"] { min-height: 44px; }
  #gswow-hud input:not([type="range"]):not([type="checkbox"]), .gswow-modal-card input { font-size: 16px; }
  #gswow-top-bar .gswow-btn { padding: 8px 12px; }
  #gswow-hud:not(.tools-open) .gswow-bar-left > .gswow-btn-group,
  #gswow-hud:not(.tools-open) .gswow-bar-center,
  #gswow-hud:not(.tools-open) .gswow-bar-right { display: none; }
  .tools-open .gswow-bar-left > .gswow-btn-group { width: 100%; justify-content: space-around; }
  .gswow-bar-center, .gswow-bar-right { width: 100%; gap: 6px; }
  .gswow-bar-center > button, .gswow-bar-right > button { flex: 1 1 40%; justify-content: center; }
  #gswow-touch-navigation {
    display: flex;
    position: absolute;
    bottom: max(12px, env(safe-area-inset-bottom));
    left: max(8px, env(safe-area-inset-left));
    right: max(8px, env(safe-area-inset-right));
    align-items: center;
    flex-direction: column;
    gap: 8px;
  }
  #gswow-touch-hint { font-size: 11px; padding: 6px 10px; background: rgba(15,23,42,.9); border-radius: 12px; text-align: center; }
  #gswow-touch-navigation button { min-width: 110px; justify-content: center; }
  #controlsWrap { display: none !important; }
  #gswow-flight-panel, #gswow-tour-panel, #gswow-env-panel {
    top: calc(82px + env(safe-area-inset-top));
    left: max(8px, env(safe-area-inset-left));
    right: max(8px, env(safe-area-inset-right));
    width: auto;
    max-width: none;
    max-height: calc(100dvh - 190px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    overscroll-behavior: contain;
    padding: 14px;
  }
  #gswow-tour-panel { transform: none; }
  #gswow-toast { bottom: calc(108px + env(safe-area-inset-bottom)); left: 12px; right: 12px; }
  #gswow-rec-badge, #gswow-ruler-badge { top: calc(82px + env(safe-area-inset-top)); }
}
