.toolbar {
  position: absolute;
  display: flex;
  flex-direction: row;
  bottom: 0;
  left: 0;
  width: 100vw;
  max-width: 100vw;
  background-color: #ffffff;
  border-top: 1px solid #cccccc;
}

.toolbar-select {
  display: inline-block;
  vertical-align: middle;
  margin-left: 8px;
}

#unit-select-wrapper {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  padding: 4px;
}

#unit-select {
  background: transparent;
  border: none;
  color: white;
  font-size: 14px;
  padding: 4px 8px;
  cursor: pointer;
  outline: none;
}

#unit-select option {
  background: #2a2a2a;
  color: white;
}

button {
  display: inline-block;
  outline: 0;
  border: none;
  cursor: pointer;
  background-color: #ffffff;
  padding: 5px 10px;
}

button:hover {
  background-color: #e6e6e6;
  transition: background-color 0.2s ease-in;
}

.unit-option {
  display: flex; 
  align-items: center;
  padding: 5px; 
  color: #000000; 
  font-family: "Inter", sans-serif;
}

.unit-option:hover {
  background-color: #e6e6e6;
}

.tooltip {
  position: relative;
  display: inline-block;
}

.tooltip .tooltiptext {
  visibility: hidden;
  width: 120px;
  background-color: rgb(40, 40, 40);
  color: #fff;
  text-align: center;
  border-radius: 6px;
  padding: 5px 0;
  font-family: "Inter", sans-serif;
  font-size: 14px;

  /* Position the tooltip */
  position: absolute;
  z-index: 1;
  bottom: 100%;
  left: 50%;
  margin-left: -60px;
}

.tooltip:hover .tooltiptext {
  visibility: visible;
}

body {
  /* background: var(--bg); */
  display: grid;
  font: 1em/1.5 sans-serif;
  height: 100vh;
  place-items: center;
}

.hourglass,
.hourglass:before,
.hourglass:after {
  animation-duration: 4s;
  animation-iteration-count: infinite;
}
.hourglass {
  --polygonH: polygon(
    0% 0%,
    100% 0%,
    100% 5.55%,
    95% 5.55%,
    95% 28%,
    60% 46%,
    60% 54%,
    95% 72%,
    95% 94.45%,
    100% 94.45%,
    100% 100%,
    0% 100%,
    0% 94.45%,
    5% 94.45%,
    5% 72%,
    40% 54%,
    40% 46%,
    5% 28%,
    5% 5.55%,
    0% 5.55%
  );
  animation-name: flip;
  animation-timing-function: ease-in-out;
  background-image: linear-gradient(
    #505050 0.5em,
    #3d3d3d 0.5em 8.5em,
    #555555 8.5em
  );
  clip-path: var(--polygonH);
  -webkit-clip-path: var(--polygonH);
  overflow: hidden;
  position: relative;
  width: 5em;
  height: 9em;
  z-index: 0;
}
.hourglass:before,
.hourglass:after {
  animation-timing-function: linear;
  content: "";
  display: block;
  position: absolute;
}
.hourglass:before {
  --polygonB1: polygon(
    0% 0%,
    100% 0%,
    100% 24%,
    50% 47%,
    50% 47%,
    50% 47%,
    50% 47%,
    50% 47%,
    50% 47%,
    50% 47%,
    50% 47%,
    0% 24%
  );
  --polygonB2: polygon(
    0% 4%,
    100% 4%,
    100% 24%,
    55% 45%,
    55% 100%,
    55% 100%,
    55% 100%,
    45% 100%,
    45% 100%,
    45% 100%,
    45% 45%,
    0% 24%
  );
  --polygonB3: polygon(
    0% 24%,
    100% 24%,
    100% 24%,
    55% 45%,
    55% 80%,
    100% 100%,
    100% 100%,
    0% 100%,
    0% 100%,
    45% 80%,
    45% 45%,
    0% 24%
  );
  --polygonB4: polygon(
    45% 45%,
    55% 45%,
    55% 45%,
    55% 45%,
    55% 58%,
    100% 76%,
    100% 100%,
    0% 100%,
    0% 76%,
    45% 58%,
    45% 45%,
    45% 45%
  );
  --polygonB5: polygon(
    50% 53%,
    50% 53%,
    50% 53%,
    50% 53%,
    50% 53%,
    100% 76%,
    100% 100%,
    0% 100%,
    0% 76%,
    50% 53%,
    50% 53%,
    50% 53%
  );
  animation-name: fill;
  background-color: #808080;
  background-size: 100% 3.6em;
  clip-path: var(--polygonB1);
  -webkit-clip-path: var(--polygonB1);
  top: 0.5em;
  left: 0.5em;
  width: 4em;
  height: 8em;
  z-index: 1;
}
.hourglass:after {
  animation-name: glare;
  background: linear-gradient(
        90deg,
        #0000 0.5em,
        #0003 0.5em 1.5em,
        #0000 1.5em 3.5em,
        #fff3 3.5em 4.5em,
        #fff0 4.5em 6.5em,
        #0003 6.5em 7.5em,
        #0000 7.5em
      )
      0 0 / 100% 0.5em,
    linear-gradient(
        90deg,
        #0000 0.75em,
        #0003 0.75em 1.25em,
        #0000 1.25em 3.75em,
        #fff3 3.75em 4.25em,
        #fff0 4.25em 6.75em,
        #0003 6.75em 7.25em,
        #0000 7.25em
      )
      0 0.5em / 100% 8em,
    linear-gradient(
        90deg,
        #0000 0.5em,
        #0003 0.5em 1.5em,
        #0000 1.5em 3.5em,
        #fff3 3.5em 4.5em,
        #fff0 4.5em 6.5em,
        #0003 6.5em 7.5em,
        #0000 7.5em
      )
      0 100% / 100% 0.5em;
  background-repeat: repeat-x;
  top: 0;
  left: -3em;
  width: 200%;
  height: 100%;
  z-index: 2;
}
/* Animations */
@keyframes fill {
  from {
    clip-path: var(--polygonB1);
    -webkit-clip-path: var(--polygonB1);
  }
  10% {
    clip-path: var(--polygonB2);
    -webkit-clip-path: var(--polygonB2);
  }
  45% {
    clip-path: var(--polygonB3);
    -webkit-clip-path: var(--polygonB3);
  }
  80% {
    clip-path: var(--polygonB4);
    -webkit-clip-path: var(--polygonB4);
  }
  85%,
  to {
    clip-path: var(--polygonB5);
    -webkit-clip-path: var(--polygonB5);
  }
}
@keyframes glare {
  from,
  90% {
    transform: translateX(0);
  }
  to {
    transform: translateX(3em);
  }
}
@keyframes flip {
  from,
  90% {
    transform: rotate(0);
  }
  to {
    transform: rotate(180deg);
  }
}
/* Dark mode */
@media (prefers-color-scheme: light) {
  :root {
    --bg: #17181c;
    --fg: #c7cad1;
  }
}

.right-container {
  position: absolute;
  right: 0px;
  top: 0px;
  height: calc(30vh - 20px);
  width: calc(30vh - 20px);
  display: flex;
}

/* Measurement panel styles */
.measurement-panel {
  position: absolute;
  left: 10px;
  top: 10px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #ccc;
  border-radius: 5px;
  padding: 10px;
  width: 220px;
  max-height: 300px;
  overflow-y: auto;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  z-index: 100;
  cursor: default;
}

/* Hidden state */
.measurement-panel-hidden {
  display: none;
}

.measurement-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid #ddd;
}

.measurement-panel-header h3 {
  margin: 0;
  font-family: "Inter", sans-serif;
  font-size: 14px;
  color: #333;
  font-weight: 600;
}

.measurement-clear-all {
  background: #ff4444;
  color: white;
  border: none;
  padding: 3px 6px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 11px;
  font-family: "Inter", sans-serif;
}

.measurement-clear-all:hover {
  background: #ff6666;
}

.measurement-list {
  max-height: 220px;
  overflow-y: auto;
  overflow-x: hidden;
}

.measurement-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid #eee;
  font-family: "Inter", sans-serif;
  white-space: nowrap;
}

.measurement-item:last-child {
  border-bottom: none;
}

.measurement-type {
  font-size: 10px;
  color: #666;
  font-weight: 400;
  margin-right: 2px;
  transition: all 0.3s ease;
}

.measurement-panel:hover .measurement-type {
  font-size: 11px;
  margin-right: 4px;
}

.measurement-value {
  font-size: 11px;
  color: #333;
  font-weight: 500;
  transition: font-size 0.3s ease;
}

.measurement-panel:hover .measurement-value {
  font-size: 13px;
}

.measurement-delete {
  background: none;
  border: none;
  color: #ff0000;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
  opacity: 0.6;
  transition: all 0.3s ease;
}

.measurement-panel:hover .measurement-delete {
  font-size: 18px;
  padding: 0 4px;
}

.measurement-delete:hover {
  opacity: 1;
  background: none;
}

/* Expand hint */
.expand-hint {
  position: absolute;
  bottom: 2px;
  right: 4px;
  font-size: 10px;
  color: #999;
  opacity: 0.6;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.measurement-panel:hover .expand-hint {
  opacity: 0;
}

/* Measurement button active state */
#button-measure.active {
  background-color: #e6e6e6;
  opacity: 1 !important;
}

/* Cursor style when measuring */
body.measuring {
  cursor: crosshair !important;
}

body.measuring * {
  cursor: crosshair !important;
}

/* Bounding box info panel */
.bounding-box-info {
  position: absolute;
  left: 10px;
  bottom: 60px; /* Above the toolbar */
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 4px 6px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
  font-family: "Inter", sans-serif;
  z-index: 50;
  transition: all 0.3s ease;
  cursor: default;
}

/* Hover state for bounding box info */
.bounding-box-info:hover {
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}

.info-row {
  display: flex;
  align-items: center;
  margin-bottom: 2px;
  transition: margin 0.3s ease;
}

.bounding-box-info:hover .info-row {
  margin-bottom: 4px;
}

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

.info-label {
  font-size: 9px;
  color: #888;
  font-weight: 500;
  margin-right: 4px;
  transition: all 0.3s ease;
}

.bounding-box-info:hover .info-label {
  font-size: 11px;
  color: #666;
  margin-right: 6px;
}

.info-value {
  font-size: 10px;
  color: #444;
  font-weight: 600;
  transition: all 0.3s ease;
}

.bounding-box-info:hover .info-value {
  font-size: 13px;
  color: #333;
}
