/* ===== GLOBAL STYLING FOR POTREE ===== */

/* Instantly hide Potree’s default sidebar button */
.potree_menu_toggle {
  display: none !important;
}

#potree_sidebar_container {
  display:none;
  
}

#potree_render_area {
  left: 0px !important;
}

#sidebar_potree {
  transform: translateX(-100%);
  z-index: 999;
  display:none;
  flex-direction: column;
  min-height: 0;
}

body.sidebar-visible #sidebar_potree {
  transform: translateX(0);
  display:flex;
  z-index: 1;
}

#sidebar_potree #potree_menu {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
}

#sidebar_potree #potree_menu::-webkit-scrollbar {
  width: 8px;
}

#sidebar_potree #potree_menu::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 999px;
}

#userpanelPotree {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  padding-right: 10px;
  color: white;
  font-family: var(--font-familiy-1) !important;
  font-size: var(--font-size-base) !important;
  font-weight: var(--font-weight-light) !important;
  color: var(--fg) !important;
}

#userpanelPotree #welcomeuserPotree {
  white-space: nowrap;
}


#top-bar .icon-text-btn {
  border: 1px solid var(--border);
}

#top-bar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

#top-bar-left .top-bar-logo-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--btn-padding);
  margin: 0 0.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  text-decoration: none;
  flex-shrink: 0;
  transition: background-color 0.2s ease, color 0.2s ease;
}

#top-bar-left a.top-bar-logo-button:hover {
  background: var(--accent-theme-hover) !important;
}

#top-bar-left .top-bar-logo-button-static {
  cursor: default;
}

#top-bar-left-logoImg {
  width: auto;
  height: var(--btn-icon-size) !important;
  max-height: var(--btn-icon-size) !important;
  display: block;
  object-fit: contain;
}

#sidebar_potree button,
#sidebar_potree input[type="button"],
#sidebar_potree input[type="submit"] {
  border: 1px solid var(--border) !important;
}

#sidebar_potree .ui-button,
#sidebar_potree .ui-widget button,
#sidebar_potree .ui-widget-content .ui-button {
  border: 1px solid var(--fg) !important;
}


/* Potree profile window */
#profile_window {
  background: var(--background-glass) !important;
  font-family: var(--font-familiy-1) !important;
  font-size: var(--font-size-base) !important;
  font-weight: var(--font-weight-light) !important;
  color: var(--fg) !important;
}

#profile_titlebar {
  background: var(--background-glass) !important;
  height: calc(var(--btn-icon-size) + 10px) !important;
  min-height: calc(var(--btn-icon-size) + 10px) !important;
  align-items: center;
}

#sidebar_potree #show_2d_profile,
#profile_window #show_2d_profile {
  background: var(--glass) !important;
  border: 1px solid var(--border) !important;
  color: var(--fg) !important;
  box-shadow: none;
  transform: none;
  border-radius: var(--radius-sm) !important;
  padding: var(--btn-padding) !important;
  height: var(--btn-icon-size) !important;
  min-height: var(--btn-icon-size) !important;
  line-height: 1 !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-familiy-1) !important;
  font-size: var(--font-size-base) !important;
  font-weight: var(--font-weight-light) !important;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

#sidebar_potree #show_2d_profile:hover,
#profile_window #show_2d_profile:hover,
body.profile-titlebar-visible #sidebar_potree #show_2d_profile,
body.profile-titlebar-visible #profile_window #show_2d_profile {
  background: var(--accent-theme) !important;
  background-color: var(--accent-theme) !important;
  color: var(--glass) !important;
  box-shadow: 0 6px 18px var(--hover-accent);
}

#profile_window .text-icon#potree_profile_rotate_cw,
#profile_window .text-icon#potree_profile_rotate_ccw,
#profile_window .text-icon#potree_profile_move_forward,
#profile_window .text-icon#potree_profile_move_backward {
  width: var(--btn-icon-size) !important;
  height: var(--btn-icon-size) !important;
  padding: 6px !important;
  margin: 0 2px !important;
  border-radius: var(--radius-sm) !important;
  border: 1px solid var(--border) !important;
  background: transparent !important;
  background-color: transparent !important;
  box-sizing: border-box;
  cursor: pointer;
  filter: brightness(0) invert(1);
  transition: background-color 0.2s ease, transform 0.2s ease;
}

#profile_window .text-icon#potree_profile_rotate_cw:hover,
#profile_window .text-icon#potree_profile_rotate_ccw:hover,
#profile_window .text-icon#potree_profile_move_forward:hover,
#profile_window .text-icon#potree_profile_move_backward:hover {
  background: var(--accent-theme) !important;
  background-color: var(--accent-theme) !important;
  transform: scale(1.1);
}

#profile_window .pw_content,
#profile_window .pw_content * {
  color: var(--fg) !important;
}

#profile_window [data-i18n="profile.nb_points"],
#profile_window #profile_num_points {
  display: inline-block;
  padding-top: 12px;
}

#height-profile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-familiy-1) !important;
  font-size: var(--font-size-base) !important;
  font-weight: var(--font-weight-light) !important;
  color: var(--fg) !important;
}

#profile_window .pv-main-color {
  margin-top: 12px !important;
}

#profile_window #closeProfileContainer {
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-sm) !important;
  background: transparent !important;
  padding: 4px !important;
  box-sizing: border-box;
  filter: brightness(0) invert(1);
}

#profile_window #closeProfileContainer:hover {
  background: var(--accent-theme) !important;
  background-color: var(--accent-theme) !important;
}

/* Sidebar accordion indicator */
#sidebar_potree details.section summary {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  list-style: none;
}

#sidebar_potree details.section summary:hover {
  border-color: var(--border);
  transform: translateY(-1px);
  box-shadow: 0 0 0 2px var(--hover-accent) inset;
  color: var(--accent-theme) !important;
}

#sidebar_potree details.section summary::-webkit-details-marker {
  display: none;
}

#sidebar_potree details.section .arrow {
  display: inline-block;
  transition: transform 0.2s ease-in-out;
}

#sidebar_potree details.section[open] summary .arrow {
  transform: rotate(90deg);
}

#sidebar_potree details.section .section-content {
  overflow: hidden;
}

/* Hide point size type, shape, and opacity controls */
#sidebar_potree li:has(> label[data-i18n="appearance.point_size_type"]),
#sidebar_potree li:has(> label[data-i18n="appearance.point_shape"]),
#sidebar_potree li:has(> span[data-i18n="appearance.point_opacity"]) {
  display: none !important;
}

/* Potree buttons*/
#sidebar_potree selectgroup label.ui-button {
  height: var(--btn-icon-size) !important;
  transition: transform 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--glass) !important;
  color: var(--btn-color) !important;
  cursor: pointer;
  padding: var(--btn-padding) !important;
  border-radius: var(--radius-sm) !important;
  position: relative;
  transition: background-color 0.2s ease, color 0.2s ease;
  margin: 0 0.25rem !important;
}

#sidebar_potree selectgroup label.ui-button:hover,
#sidebar_potree selectgroup label.ui-button.ui-state-hover {
  background: var(--accent-theme) !important;
  background-color: var(--accent-theme) !important;
  color: var(--glass) !important;
}


/* Potree buttons with the state of active */
#sidebar_potree selectgroup label.ui-button.ui-state-active {
  background: var(--accent-theme) !important;
  border:1px solid var(--border) !important;
  color: var(--glass) !important;
  box-shadow: 0 6px 18px var(--hover-accent);
  transform: none;
}

/* Potree sliders */
#sidebar_potree .ui-slider:hover span {
  background: var(--acent-theme, var(--accent-theme)) !important;
  border-color: var(--acent-theme, var(--accent-theme)) !important;
}

/* Background: fuerza 2x2 y evita overflow del sidebar */
#sidebar_potree #background_options fieldset,
#sidebar_potree #background_options fieldset > span {
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}

/* Potree suele meter spans internos; este target es “a prueba de DOM” */
#sidebar_potree #background_options fieldset > span {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important; /* 2 columnas */
  grid-auto-rows: auto !important;                            /* 2 filas si hay 4 */
  gap: 0.5rem !important;
  align-items: stretch !important;
}

/* Cada celda del grid debe poder encoger (CLAVE para que no se salga) */
#sidebar_potree #background_options fieldset > span > span,
#sidebar_potree #background_options label.ui-button {
  min-width: 0 !important;
}

/* Botones: ocupar toda la celda y cortar texto */
#sidebar_potree #background_options label.ui-button {
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;

  /* opcional: compactar un poco para que quepan mejor */
  padding: 0.45rem 0.5rem !important;
  margin: 0 !important;
  font-size: 0.9rem !important;
}

/* Potree login section */
.welcomeuser {
  color: var(--fg) !important;
    font-family: var(--font-familiy-1) !important;
    font-size: var(--font-size-base) !important;
    font-weight: var(--font-weight-light) !important;
}

/* Menu desplegale potree */
.ui-selectmenu-button {
  background: var(--background-glass) !important;
  color: var(--fg) !important;
  font-family: var(--font-familiy-1) !important;
  font-size: var(--font-size-sm) !important;
  font-weight: var(--font-weight-light) !important;
}

.ui-selectmenu-text {
  text-transform: lowercase !important;
}

.ui-selectmenu-text::first-letter {
  text-transform: uppercase !important;
}

.ui-selectmenu-menu {
  z-index: 1100;
}

.ui-selectmenu-menu .ui-menu-item-wrapper {
  text-transform: lowercase !important;
}

.ui-selectmenu-menu .ui-menu-item-wrapper::first-letter {
  text-transform: uppercase !important;
}

.material-attribute-filters .filter-controls {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.material-attribute-filters .filter-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.material-attribute-filters .material-filter-values {
  width: 100%;
  padding: 0.25rem 0.5rem;
}

#materials\\.extra_container {
  display: none !important;
}

/* Responsive adjustments for touch/tablet/mobile */
@media (max-width: 1024px) {
  #camera_toggle,
  #fly_toggle,
  #first_person_toggle,
  #orbit_toggle {
    display: none !important;
  }

  #top-bar {
    min-height: 44px !important;
    padding: 6px 8px !important;
  }

  #top-bar-left,
  #top-bar-right {
    padding: 4px 6px !important;
  }

  #top-bar-left {
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 4px !important;
  }

  #top-bar-left .top-bar-logo-button {
    padding: 0.2rem !important;
    margin: 0 0.1rem !important;
  }

  #top-bar-left-logoImg {
    height: 30px !important;
    max-height: 30px !important;
  }

  #top-bar-left-text {
    font-size: var(--font-size-xs) !important;
    line-height: 1 !important;
    margin-top: 0 !important;
  }

  #top-bar-right {
    padding-right: 48px !important;
  }

  #top-bar .icon-text-btn {
    padding: 0.2rem !important;
    margin: 0 0.1rem !important;
  }

  #top-bar .icon-text-btn img,
  #top-bar .icon-text-btn svg {
    width: 30px !important;
    height: 30px !important;
  }

  #top-bar .sep-btn {
    height: 28px !important;
    margin: 0 0.25rem !important;
  }

  #top-bar .icon-text-text,
  #top-bar .icon-text-btn.icon-text-btn-active .icon-text-text {
    opacity: 0 !important;
    max-width: 0 !important;
    margin-left: 0 !important;
    display: none !important;
  }

  #userpanelPotree.userpanel {
    margin-right: 6px !important;
    gap: 0 !important;
  }

  #userpanelPotree #logoutBtn {
    width: 34px !important;
    height: 34px !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  #userpanelPotree #logoutBtn img {
    width: 22px !important;
    height: 22px !important;
  }

  #userpanelPotree #welcomeuserPotree {
    display: none !important;
  }

  #sidebar_potree {
    left: 0 !important;
    right: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    margin: 0 !important;
    border-radius: 0 !important;
  }

  #sidebar_potree #scene_object_properties,
  #sidebar_potree #scene_object_properties .propertypanel_content,
  #sidebar_potree #scene_object_properties .measurement_value_table,
  #sidebar_potree #scene_object_properties .coordinates_table_container table {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  #sidebar_potree #scene_object_properties .propertypanel_content {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  #sidebar_potree #scene_object_properties .pv-menu-list > * {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  body.sidebar-visible .secondary-top-bar-button-bar,
  body.sidebar-visible .secondary-left-bar-button-bar {
    display: none !important;
  }
}
