/* BIM overlay feature — UI styles. Mirrors objects.css visual language. */

/* ===== Sidebar icon position (slot 6, after activity at slot 5) =====
 * The sidebar uses absolute-positioned icons stacked at hardcoded `top`
 * offsets. Without an explicit slot, #bim-icon collapses to top:auto and
 * visually overlaps the Objects icon (slot 3).
 *
 * Existing slots:
 *   slot 1  Eye / Ansicht          top: 1rem
 *   slot 2  Gear / Anzeigeeinstellungen
 *   slot 3  Objects (#objects-icon)              objects.css:538
 *   slot 4  Objects visibility toggle            objects.css:542
 *   slot 5  Activity (#activity-icon)            activity.css:22
 *   slot 6  BIM Models (#bim-icon)               ← this rule
 */
#bim-icon {
  top: calc(1rem + 5 * 52px) !important;
  margin-top: 0 !important;
}

/* ===== Side panel ===== */
.bim-menu {
  position: fixed;
  top: 0;
  right: 0;
  width: 360px;
  max-width: 100vw;
  height: 100vh;
  background: #fff;
  box-shadow: -2px 0 12px rgba(0, 0, 0, 0.12);
  z-index: 9000;
  display: flex;
  flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #1a1a1a;
}
.bim-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #ececec;
}
.bim-menu-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}
#close-bim-menu {
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: #555;
}
#close-bim-menu:hover {
  color: #000;
}

/* ===== Drop zone ===== */
.bim-dropzone {
  margin: 12px 16px;
  padding: 16px 12px;
  border: 1.5px dashed #c5cad3;
  border-radius: 8px;
  background: #fafbfc;
  text-align: center;
  font-size: 12.5px;
  color: #556070;
  cursor: pointer;
  transition:
    background 0.12s,
    border-color 0.12s,
    color 0.12s;
}
.bim-dropzone strong {
  color: #4f9eff;
  font-weight: 600;
}
.bim-dropzone:hover {
  background: #f4f7ff;
  border-color: #4f9eff;
  color: #1a1a1a;
}
.bim-dropzone.dragging {
  background: #eaf2ff;
  border-color: #4f9eff;
  color: #1a1a1a;
}
.bim-dropzone.uploading {
  cursor: progress;
  background: #fafbfc;
  opacity: 0.7;
}
.bim-dropzone.disabled {
  cursor: not-allowed;
  background: #f5f5f5;
  border-color: #e2e2e2;
  color: #999;
}
.bim-dropzone-hint {
  margin-top: 4px;
  font-size: 11px;
  color: #888;
}

/* ===== Progress bar ===== */
.bim-progress-track {
  margin: 0 16px 8px;
  height: 4px;
  border-radius: 3px;
  background: #eef0f3;
  overflow: hidden;
  display: none;
}
.bim-progress-track.active {
  display: block;
}
.bim-progress-bar {
  height: 100%;
  width: 0%;
  background: #4f9eff;
  transition: width 0.15s ease;
}
/* Indeterminate state — used while the GPU worker is converting. We don't
 * get streaming progress from the worker, so a sliding gradient gives the
 * user feedback that something's still alive. */
.bim-progress-bar.indeterminate {
  width: 40% !important;
  background: linear-gradient(90deg, #4f9eff 0%, #82c0ff 50%, #4f9eff 100%);
  background-size: 200% 100%;
  animation: bim-progress-slide 1.4s linear infinite;
  transition: none;
}
@keyframes bim-progress-slide {
  from {
    background-position: 200% 0;
    transform: translateX(-100%);
  }
  to {
    background-position: 0% 0;
    transform: translateX(250%);
  }
}

/* ===== Toolbar ===== */
.bim-menu-toolbar {
  display: flex;
  gap: 8px;
  padding: 8px 16px 10px;
  border-bottom: 1px solid #f3f3f3;
  align-items: center;
}
.bim-secondary-btn {
  padding: 6px 10px;
  border: 1px solid #d6d6d6;
  background: #fff;
  color: #333;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}
.bim-secondary-btn:hover {
  background: #f7f9fc;
}
.bim-secondary-btn.active {
  background: #ffe5b8;
  border-color: #ffaa33;
  color: #6a3e00;
}
.bim-secondary-btn.active:hover {
  background: #ffd28a;
}

/* ===== View menu — Section box button (independent of the other toggles) ===== */
.section-box-button {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 8px 12px;
  background: #fff;
  color: #1a1a1a;
  border: 1px solid #c5cad3;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition:
    background 0.12s,
    color 0.12s,
    border-color 0.12s;
  text-align: center;
  letter-spacing: 0.2px;
}
.section-box-button:hover {
  background: #f4f5f7;
  border-color: #9ea4af;
}
.section-box-button.active {
  background: #1a1a1a;
  color: #fff;
  border-color: #1a1a1a;
}
.section-box-button.active:hover {
  background: #2c2c2c;
  border-color: #2c2c2c;
}

/* ===== Right-click context menu (BIM elements) ===== */
.bim-context-menu {
  position: fixed;
  background: #fff;
  border: 1px solid #d6d6d6;
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
  z-index: 9500;
  min-width: 150px;
  padding: 4px 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.bim-context-header {
  padding: 6px 12px 4px;
  font-size: 11px;
  color: #888;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  border-bottom: 1px solid #f0f0f0;
}
.bim-context-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 8px 14px;
  font-size: 13px;
  color: #1a1a1a;
  cursor: pointer;
  font-family: inherit;
}
.bim-context-item:hover {
  background: #eaf2ff;
  color: #1a73e8;
}
.bim-context-stats {
  padding: 6px 14px 8px;
  border-bottom: 1px solid #f0f0f0;
  font-size: 11.5px;
  color: #333;
}
.bim-context-stat {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  line-height: 1.6;
}
.bim-context-stat-label {
  color: #888;
  flex-shrink: 0;
}
.bim-context-stat-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: #1a1a1a;
  white-space: nowrap;
}
.bim-context-stat-src {
  color: #aaa;
  font-size: 10px;
}

/* ===== Umkreisen (3D orbit) toggle — mirrors #fly_mode_toggle exactly so the
 *       widget looks identical to the Flugmodus switch in the View menu. */
#orbit_mode_toggle {
  width: 40px;
  height: 12px;
  background-color: rgb(120 162 204 / 0.4);
  border: none;
  border-radius: 12px;
  position: relative;
  cursor: pointer;
}
#orbit_mode_toggle::after {
  content: "";
  width: 16px;
  height: 16px;
  background-color: rgb(120 162 204);
  border-radius: 50%;
  position: absolute;
  left: 0;
  top: -2px;
  transition: 0.3s;
}
#orbit_mode_toggle.active::after {
  left: 24px;
}

/* ===== Status line ===== */
.bim-status {
  padding: 6px 16px 0;
  font-size: 11px;
  color: #888;
  min-height: 14px;
}

/* ===== List ===== */
.bim-list {
  list-style: none;
  margin: 0;
  padding: 4px 0 12px;
  overflow-y: auto;
  flex: 1;
}
.bim-list-item {
  display: flex;
  flex-direction: column;
  padding: 10px 16px;
  border-bottom: 1px solid #f5f5f5;
}
.bim-list-item:hover {
  background: #f7faff;
}
.bim-list-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.bim-list-row input[type="checkbox"] {
  accent-color: #4f9eff;
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
}
/* "Edit" checkbox — toggles the move/rotate gizmo for this row's model. */
.bim-list-edit-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: #666;
  user-select: none;
  cursor: pointer;
  padding: 2px 6px;
  border: 1px solid transparent;
  border-radius: 4px;
}
.bim-list-edit-label:hover {
  border-color: #cfd8dc;
  background: #f5f8ff;
}
.bim-list-edit-cb {
  width: 14px;
  height: 14px;
  accent-color: #ff9800;
  cursor: pointer;
}
.bim-list-edit-cb:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}
.bim-list-edit-cb:disabled + * {
  color: #aaa;
}
/* Highlight the whole row while Edit is active, so the user sees at a glance
 * which models the gizmo deltas will be applied to. */
.bim-list-item.selected .bim-list-edit-label {
  background: #fff3e0;
  border-color: #ffb74d;
  color: #e65100;
}
.bim-list-title {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bim-list-frame-btn,
.bim-list-delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #888;
  font-size: 14px;
  padding: 2px 4px;
  border-radius: 4px;
}
.bim-list-frame-btn:hover {
  color: #4f9eff;
  background: #eaf2ff;
}
.bim-list-delete-btn:hover {
  color: #d04545;
  background: #fdeaea;
}
.bim-list-controls {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 6px 0 0 26px;
  font-size: 11px;
  color: #777;
}
.bim-list-item.loaded .bim-list-controls {
  display: flex;
}
.bim-list-controls input[type="range"] {
  flex: 1;
  accent-color: #4f9eff;
}
.bim-list-controls-value {
  font-size: 11px;
  min-width: 30px;
  text-align: right;
  color: #555;
}
.bim-list-meta {
  font-size: 11px;
  color: #888;
  margin-top: 2px;
  padding-left: 26px;
}
.bim-list-item.loading .bim-list-title::after {
  content: " …";
  color: #4f9eff;
}
.bim-list-empty {
  padding: 24px 16px;
  color: #888;
  text-align: center;
  font-size: 13px;
  line-height: 1.5;
}
.bim-list-empty code {
  background: #f4f5f7;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
}

/* ===== Selected row highlight ===== */
.bim-list-item.selected {
  background: #eaf2ff;
  box-shadow: inset 3px 0 0 #4f9eff;
}
.bim-list-item.selected:hover {
  background: #dceaff;
}

/* ===== Selection / save-alignment bar ===== */
.bim-selection-bar {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 8px 16px 4px;
  padding: 10px 12px;
  background: #f6faff;
  border: 1px solid #cfe1ff;
  border-radius: 8px;
}
.bim-selection-name {
  font-size: 13px;
  font-weight: 600;
  color: #1a1a1a;
}
.bim-selection-hint {
  font-size: 11px;
  color: #666;
  line-height: 1.4;
}
.bim-selection-buttons {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}
.bim-btn-primary {
  flex: 1;
  padding: 7px 12px;
  border: none;
  background: #4f9eff;
  color: #fff;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.bim-btn-primary:hover {
  background: #3d86dc;
}
.bim-btn-primary:disabled {
  background: #b0c8e8;
  cursor: progress;
}
.bim-btn-secondary {
  padding: 7px 12px;
  border: 1px solid #d6d6d6;
  background: #fff;
  color: #333;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}
.bim-btn-secondary:hover {
  background: #f7f9fc;
}
