/* Sidebar Layout Styles */
.sidebar-container {
  position: relative;
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: #1e1e1e;
  border-left: 1px solid #404040;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  min-height: 0;
}

/* Create a wrapper for the main content area */
.main-content-wrapper {
  display: flex;
  flex: 1;
  margin-top: 0; /* No header margin needed */
  margin-bottom: 30px; /* Above footer */
}

.sidebar-container.left {
  border-left: none;
  border-right: 1px solid #404040;
  order: -1;
}

.sidebar-container.collapsed {
  width: var(--sidebar-collapsed-width);
}

.sidebar-container.collapsed .sidebar-content {
  display: none;
}

.sidebar-container.collapsed .sidebar-overview {
  display: none;
}

.sidebar-container.collapsed .sidebar-resizer {
  display: none;
}

.sidebar-container.collapsed .sidebar-position-toggle {
  display: none;
}

.sidebar-container.collapsed .sidebar-tabs {
  justify-content: center;
  padding: 0;
  position: relative;
  height: 48px;
  min-height: 48px;
}

.sidebar-container.collapsed .sidebar-tab {
  display: none;
}

.sidebar-container.collapsed .sidebar-toggle {
  margin: 0;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

/* Ensure SVG rotation works with positioning */
.sidebar-container.collapsed .sidebar-toggle svg {
  transform: rotate(180deg);
}

.sidebar-title {
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  margin: 0;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: #cccccc;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  min-height: 32px;
  margin-right: 8px;
  flex-shrink: 0;
  order: 1; /* Default order for right sidebar */
}

.sidebar-toggle:hover {
  background: #404040;
  color: #ffffff;
  transform: scale(1.1);
}

/* Override hover transform for collapsed state */
.sidebar-container.collapsed .sidebar-toggle:hover {
  transform: translate(-50%, -50%) scale(1.1);
}

.sidebar-toggle:active {
  transform: scale(0.95);
}

.sidebar-toggle svg {
  width: 16px;
  height: 16px;
}

/* Flip toggle SVG when sidebar is on the left */
.sidebar-container.left .sidebar-toggle svg {
  transform: scaleX(-1);
}

/* Handle both left position and collapsed state */
.sidebar-container.left.collapsed .sidebar-toggle svg {
  transform: rotate(180deg) scaleX(-1);
}

/* Adjust toggle button positioning for left sidebar */
.sidebar-container.left .sidebar-toggle {
  margin-right: 0;
  margin-left: 8px;
  order: 3; /* Move to the end (right side) */
}

.sidebar-container.left .sidebar-position-toggle {
  margin-left: 0;
  margin-right: 8px;
  order: 1; /* Move to the beginning (left side) */
}

/* Override positioning for collapsed left sidebar */
.sidebar-container.left.collapsed .sidebar-toggle {
  margin: 0;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.sidebar-container.left.collapsed .sidebar-toggle svg {
  transform: rotate(180deg) scaleX(-1);
}

/* Override hover transform for collapsed left sidebar */
.sidebar-container.left.collapsed .sidebar-toggle:hover {
  transform: translate(-50%, -50%) scale(1.1);
}

/* Sidebar Header Layout - Removed, integrated into tabs */

.sidebar-position-toggle {
  border: none;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  min-height: 32px;
  margin-left: 8px;
  background: no-repeat center/70% url(../icons/sidebar_left.svg);
  flex-shrink: 0;
  order: 3; /* Default order for right sidebar */
}

.sidebar-position-toggle:hover {
  transform: scale(1.1);
}

.sidebar-position-toggle:active {
  transform: scale(0.95);
}
/* Sidebar Tabs */
.sidebar-tabs {
  display: flex;
  align-items: center;
  background: #2d2d2d;
  border-bottom: 1px solid #404040;
  padding: 0 8px;
  min-height: 48px;
}

.sidebar-tab {
  flex: 1;
  padding: 12px 16px;
  background: #2d2d2d;
  border: none;
  color: #cccccc;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  text-align: center;
  margin: 0 2px;
  order: 2; /* Always in the middle */
}

.sidebar-tab:hover {
  background: #404040;
  color: #ffffff;
}

.sidebar-tab.active {
  background: #1e1e1e;
  color: #ffffff;
  border-bottom-color: #04aa6d;
}

/* Sidebar Content */
.sidebar-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0; /* Allow flexbox to shrink */
}

.sidebar-panel {
  display: none;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px;
  min-height: 0; /* Allow flexbox to shrink */
  box-sizing: border-box;
}

.sidebar-panel.active {
  display: block;
}

/* Explorer Panel */
.explorer-panel {
  color: #ffffff;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.explorer-tree {
  background: #1e1e1e;
  border-radius: 6px;
  padding: 0px;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  min-height: 0; /* Allow flexbox to shrink */
  position: relative;
  max-height: 100%;
  height: 0; /* Force flexbox to calculate height properly */
}

.explorer-filter-container {
  position: sticky;
  top: 0;
  background: #1e1e1e;
  border-bottom: 1px solid #333;
  padding: 8px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.explorer-filter-input {
  flex: 1;
  padding: 6px 8px;
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 4px;
  color: #ffffff;
  font-size: 12px;
  outline: none;
  box-sizing: border-box;
}

.explorer-filter-input:focus {
  border-color: #04aa6d;
  box-shadow: 0 0 0 2px rgba(4, 170, 109, 0.2);
}

.explorer-filter-input::placeholder {
  color: #888;
}

.explorer-filter-mode-selector {
  display: flex;
  align-items: center;
  gap: 2px;
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 4px;
  padding: 2px;
}

.explorer-filter-mode-button {
  width: 24px;
  height: 24px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 3px;
  color: #cccccc;
  font-size: 14px;
  cursor: pointer;
  outline: none;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.explorer-filter-mode-button:hover {
  background: #404040;
  color: #ffffff;
}

.explorer-filter-mode-button.active {
  background: #04aa6d;
  color: #ffffff;
}

.explorer-filter-clear {
  width: 20px;
  height: 20px;
  background: #444;
  border: 1px solid #555;
  border-radius: 50%;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  outline: none;
}

.explorer-filter-clear:hover {
  background: #666;
  border-color: #777;
  transform: scale(1.1);
}

.explorer-filter-clear:active {
  transform: scale(0.95);
}

.explorer-tree-node {
  display: flex;
  align-items: center;
  padding: 4px 0;
  cursor: pointer;
  user-select: none;
}

.explorer-tree-node:hover {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.explorer-tree-node.selected {
  background: rgba(4, 170, 109, 0.2);
  border-radius: 4px;
}

.explorer-tree-toggle {
  width: 16px;
  height: 16px;
  margin-right: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #cccccc;
}

.explorer-tree-toggle.expanded {
  transform: rotate(90deg);
}

.explorer-tree-toggle.collapsed {
  transform: rotate(0deg);
}

.explorer-tree-icon {
  width: 16px;
  height: 16px;
  margin-right: 8px;
  opacity: 0.8;
}

.explorer-tree-label {
  flex: 1;
}

.explorer-tree-warning {
  width: 16px;
  height: 16px;
  margin-right: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  opacity: 0.8;
  position: absolute;
  left: 10px;
}

.explorer-tree-warning:hover {
  opacity: 1;
}

.explorer-tree-visibility {
  width: 16px;
  height: 16px;
  margin-left: 8px;
  cursor: pointer;
  opacity: 0.7;
}

.explorer-tree-visibility:hover {
  opacity: 1;
}

.explorer-tree-visibility.visible {
  color: #04aa6d;
}

.explorer-tree-visibility.hidden {
  color: #666666;
}

.explorer-tree-move-up {
  width: 18px;
  height: 18px;
  margin-right: 6px;
  cursor: pointer;
  opacity: 0.8;
  color: #04aa6d;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: bold;
  transition: all 0.2s ease;
  border: 1px solid rgba(4, 170, 109, 0.3);
  border-radius: 3px;
  background: rgba(4, 170, 109, 0.1);
}

.explorer-tree-move-up:hover {
  opacity: 1;
  transform: scale(1.15);
  color: #059669;
  background: rgba(4, 170, 109, 0.2);
  border-color: #04aa6d;
  box-shadow: 0 2px 4px rgba(4, 170, 109, 0.3);
}

.explorer-tree-move-up:active {
  transform: scale(1.05);
  background: rgba(4, 170, 109, 0.3);
}

.explorer-tree-node.warning {
  color: #e97e7e;
}

.explorer-context-menu {
  position: absolute;
  background: #2a2a2a;
  border: 1px solid #404040;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  z-index: 9999;
  padding: 6px;
  pointer-events: auto;
  color: #ffffff;
  display: flex;
  flex-direction: row;
  gap: 4px;
}

.context-menu-option {
  width: 32px;
  height: 32px;
  cursor: pointer;
  color: #ffffff;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  user-select: none;
}

.context-menu-option:hover {
  background: #404040;
  transform: scale(1.1);
}

.explorer-tree-visibility .eye-strikethrough {
  position: relative;
  display: inline-block;
}

.explorer-tree-visibility .eye-strikethrough::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 2px;
  background-color: #ff4444;
  transform: translateY(-50%) rotate(-45deg);
  transform-origin: center;
}

/* Settings Panel */
.settings-panel {
  color: #ffffff;
  font-size: 12px;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px;
}

.settings-group {
  margin-bottom: 12px;
  border: 1px solid #333;
  border-radius: 6px;
  overflow: hidden;
}

.settings-group-title {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.9px;
  color: #ffffff;
  margin: 0;
  padding: 8px 12px;
  background: #2a2a2a;
  border-bottom: 1px solid #404040;
  cursor: pointer;
  display: flex;
  align-items: center;
  user-select: none;
}

.settings-group-title:hover {
  background: #333;
}

.settings-group-toggle {
  margin-right: 8px;
  font-size: 10px;
  transition: transform 0.2s ease;
}

.settings-group-content {
  padding: 8px;
  background: #1e1e1e;
}

.settings-item {
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-item:last-child {
  margin-bottom: 0;
}

.settings-label {
  color: #cccccc;
  font-size: 11px;
  font-weight: 500;
  min-width: 30px;
  flex-shrink: 0;
}

.settings-input {
  flex: 1;
  padding: 6px 8px;
  background: #2d2d2d;
  border: 1px solid #404040;
  border-radius: 3px;
  color: #ffffff;
  font-size: 12px;
  min-width: 0;
}

.settings-input:focus {
  outline: none;
  border-color: #04aa6d;
}

.settings-input[type='color'] {
  height: 28px;
  padding: 2px;
}

.settings-input[type='checkbox'] {
  width: auto;
  margin-right: 6px;
  scale: 0.9;
}

.settings-add-button {
  padding: 6px 12px;
  margin-bottom: 8px;
  font-size: 11px;
  background: #04aa6d;
  border: none;
  border-radius: 3px;
  color: white;
  cursor: pointer;
}

.settings-add-button:hover {
  background: #059669;
}

/* Settings Buttons */
.settings-button {
  flex: 1;
  padding: 8px 12px;
  margin-right: 8px;
  background: #2d2d2d;
  border: 1px solid #404040;
  border-radius: 4px;
  color: #ffffff;
  font-size: 12px;
  cursor: pointer;
}

.settings-button:hover {
  background: #404040;
  border-color: #04aa6d;
}

.settings-button:active {
  transform: scale(1.1);
}

.settings-button:last-child {
  margin-right: 0;
}

/* Configuration buttons container */
.config-buttons-container {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.settings-checkbox-container {
  display: flex;
  align-items: center;
  flex: 1;
}

.settings-checkbox-label {
  margin: 0;
  cursor: pointer;
  font-size: 11px;
}

.settings-range-container {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.settings-range {
  flex: 1;
  height: 4px;
}

.settings-range-value {
  min-width: 40px;
  text-align: center;
  color: #cccccc;
  font-size: 11px;
  font-weight: 500;
  background: #2d2d2d;
  border: 1px solid #404040;
  border-radius: 3px;
  padding: 4px 6px;
}

/* Settings Subgroups */
.settings-subgroup {
  margin-bottom: 12px;
  border: 1px solid #404040;
  border-radius: 6px;
  overflow: hidden;
  background: #252525;
}

.settings-subgroup-title {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.9px;
  color: #ffffff;
  margin: 0;
  padding: 6px 10px;
  background: #333333;
  border-bottom: 1px solid #404040;
  user-select: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.settings-subgroup-content {
  padding: 8px;
  background: #252525;
}

.visibility-toggle:hover {
  opacity: 0.8 !important;
}

.visibility-toggle .eye-strikethrough {
  position: relative;
  display: inline-block;
}

.visibility-toggle .eye-strikethrough::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 2px;
  background-color: #ff4444;
  transform: translateY(-50%) rotate(-45deg);
  transform-origin: center;
}

.gradient-color-control {
  padding: 8px !important;
  margin-bottom: 6px !important;
  border-radius: 3px !important;
  background: #252525 !important;
}

.sidebar-overview {
  background: #2d2d2d;
  border-top: 1px solid #404040;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
  width: 100%;
}

.sidebar-overview-header {
  width: 100%;
  padding: 12px;
  background: #2d2d2d;
  color: white;
  border-bottom: 2px solid #404040;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}

.sidebar-overview-header:hover {
  background: #333;
}

.sidebar-overview-toggle {
  margin-right: 8px;
  font-size: 10px;
}

.sidebar-overview-title {
  font-size: 12px;
  font-weight: 600;
  color: #ffffff;
  margin: 0;
}

.sidebar-overview-content-wrapper {
  height: 300px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 0;
  width: 100%;
}

.sidebar-overview-content-wrapper.collapsed {
  height: 0;
  padding: 0;
  overflow: hidden;
  min-height: 0;
}

.sidebar-overview-content-wrapper.collapsed .sidebar-overview-content {
  opacity: 0;
  pointer-events: none;
}

.sidebar-overview-content {
  flex: 1;
  width: 300px !important;
  max-width: 100%;
  background: black;
  border: 1px solid #404040;
  border-radius: 4px;
  position: relative;
  overflow: hidden;
  height: 100%;
}

.sidebar-overview-content > * {
  width: 100% !important;
  height: 100% !important;
  position: relative !important;
}

/* Ensure scene overview has proper dimensions */
#scene-overview {
  width: 100% !important;
  height: 100% !important;
  min-height: 0;
}

.sidebar-tab {
  font-weight: 600;
  letter-spacing: 0.3px;
}

.sidebar-tab.active {
  background: linear-gradient(135deg, #1e1e1e 0%, #2d2d2d 100%);
  position: relative;
}

.sidebar-tab.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, #04aa6d, #059669);
}

/* Improve explorer tree appearance */
.explorer-tree-node {
  border-radius: 6px;
  position: relative;
}

.explorer-tree-node::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
  transform: translateY(-50%);
  opacity: 0;
}

.explorer-tree-node:hover::before {
  opacity: 1;
}

.explorer-tree-node:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateX(2px);
}

.explorer-tree-node.selected {
  background: linear-gradient(135deg, rgba(4, 170, 109, 0.3) 0%, rgba(4, 170, 109, 0.1) 100%);
  border-left: 3px solid #04aa6d;
}

.settings-input {
  border-radius: 6px;
  font-size: 13px;
}

.settings-input:hover {
  border-color: #666;
}

.settings-input:focus {
  border-color: #04aa6d;
  box-shadow: 0 0 0 2px rgba(4, 170, 109, 0.2);
}

/* Tooltip styles */
.sidebar-tab[title]:hover::after,
.sidebar-toggle[title]:hover::after {
  content: attr(title);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  z-index: 10000;
  pointer-events: none;
  margin-bottom: 8px;
}

.sidebar-tab[title]:hover::before,
.sidebar-toggle[title]:hover::before {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: rgba(0, 0, 0, 0.9);
  z-index: 10000;
  pointer-events: none;
  margin-bottom: 3px;
}

/* Resizer */
.sidebar-resizer {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 4px;
  cursor: col-resize;
  background: transparent;
}

.sidebar-container .sidebar-resizer {
  left: -2px;
}

.sidebar-container.left .sidebar-resizer {
  right: -2px;
  left: auto;
}

.sidebar-resizer:hover,
.sidebar-resizer.resizing {
  background: #04aa6d;
}

/* Main layout structure */
body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  margin: 0;
  padding: 0;
}

/* Ensure all elements use border-box */
* {
  box-sizing: border-box;
}

/* Ensure navbar and footer are properly positioned */
.topnavbar {
  flex-shrink: 0;
  z-index: 1001;
  background: #333;
}

.footer {
  flex-shrink: 0;
  z-index: 1001;
  background: #333;
}

/* CSS Custom Properties for sidebar */
:root {
  --sidebar-width: 350px;
  --sidebar-collapsed-width: 40px;
}

.content-area {
  display: flex;
  flex: 1;
  min-height: 0; /* Allow flexbox to shrink */
}

#viewport {
  flex: 1;
  position: relative;
  background: #000;
  overflow: hidden;
  min-width: 0; /* Allow flexbox to shrink */
  min-height: 0; /* Allow flexbox to shrink */
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Hide old panels when sidebar is active */
#tree-panel,
#control-panel {
  display: none !important;
}

/* Responsive adjustments */
@media (max-width: 1200px) {
  .sidebar-container {
    width: 300px;
  }
}

@media (max-width: 768px) {
  .sidebar-container {
    width: 280px;
  }
}

/* Drag and Drop Styles */
.draggable-survey {
  cursor: grab;
  transition: all 0.2s ease;
}

.draggable-survey:hover {
  background: rgba(4, 170, 109, 0.1) !important;
  transform: translateX(2px);
}

.draggable-survey.dragging {
  opacity: 0.5;
  cursor: grabbing;
  transform: rotate(2deg);
  z-index: 1000;
  position: relative;
}

.drop-indicator {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: #04aa6d;
  z-index: 1000;
  pointer-events: none;
  box-shadow: 0 0 4px rgba(4, 170, 109, 0.5);
  animation: dropIndicatorPulse 1s ease-in-out infinite;
}

.drop-indicator.top {
  top: 0;
}

.drop-indicator.bottom {
  bottom: 0;
}

@keyframes dropIndicatorPulse {
  0%,
  100% {
    opacity: 1;
    transform: scaleY(1);
  }
  50% {
    opacity: 0.7;
    transform: scaleY(1.5);
  }
}

/* Compact layout styles */
.compact-layout {
  padding: 4px !important;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.compact-checkbox-group {
  display: inline-block;
  vertical-align: top;
  margin-right: 0;
  margin-bottom: 0;
  min-width: 120px;
  flex: 1;
  max-width: calc(25% - 6px);
}

.compact-checkbox-group .settings-item {
  margin-bottom: 2px;
  padding: 2px 0;
  height: 20px;
  display: flex;
  align-items: center;
}

.compact-checkbox-group .settings-item:last-child {
  margin-bottom: 0;
}

.compact-checkbox-group .settings-checkbox-container {
  gap: 2px;
  display: flex;
  align-items: center;
  width: 100%;
}

.compact-checkbox-group .settings-checkbox-label {
  font-size: 10px;
  line-height: 1.2;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.compact-checkbox-group .settings-input[type='checkbox'] {
  flex: none;
  width: auto;
  margin-right: 2px;
}
