.FreetextHighlight {
  position: absolute;
  z-index: 30;
  isolation: isolate;
}

.FreetextHighlight--editing,
.FreetextHighlight:hover {
  z-index: 40;
}

.FreetextHighlight--collapsed {
  z-index: 35;
}

.FreetextHighlight__container {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  border-radius: 4px;
  box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.2);
  overflow: visible;
  transition: box-shadow 0.2s ease;
}

.FreetextHighlight__rnd {
  z-index: inherit;
}

.FreetextHighlight__container:hover {
  box-shadow: 2px 2px 12px rgba(0, 0, 0, 0.3);
}

.FreetextHighlight__toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 4px;
  position: absolute;
  top: 4px;
  left: 4px;
  z-index: 10;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.FreetextHighlight__container:hover .FreetextHighlight__toolbar {
  opacity: 1;
}

.FreetextHighlight__drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  cursor: grab;
  user-select: none;
  color: white;
  border-radius: 3px;
  transition: background 0.2s;
}

.FreetextHighlight__drag-handle:hover {
  background: rgba(255, 255, 255, 0.2);
}

.FreetextHighlight__drag-handle:active {
  cursor: grabbing;
}

.FreetextHighlight__edit-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: white;
  border-radius: 3px;
  padding: 0;
  transition: background 0.2s;
}

.FreetextHighlight__edit-button:hover {
  background: rgba(255, 255, 255, 0.2);
}

.FreetextHighlight__content {
  flex: 1;
  padding: 8px;
  overflow: hidden;
  position: relative;
  z-index: 1;
}

.FreetextHighlight__text {
  width: 100%;
  height: 100%;
  cursor: text;
  overflow: auto;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.FreetextHighlight__input {
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
  font: inherit;
  color: inherit;
  resize: none;
  outline: none;
  padding: 0;
  margin: 0;
}

.FreetextHighlight--scrolledTo .FreetextHighlight__container {
  box-shadow: 0 0 0 3px #ff4141, 2px 2px 8px rgba(0, 0, 0, 0.2);
}

.FreetextHighlight--editing .FreetextHighlight__container {
  box-shadow: 0 0 0 2px #4a90d9, 2px 2px 8px rgba(0, 0, 0, 0.2);
}

.FreetextHighlight__style-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: white;
  border-radius: 3px;
  padding: 0;
  transition: background 0.2s;
}

.FreetextHighlight__style-button:hover {
  background: rgba(255, 255, 255, 0.2);
}

.FreetextHighlight__style-panel {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  padding: 8px;
  z-index: 9999;
  margin-top: 2px;
}

.FreetextHighlight__style-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  margin-bottom: 8px;
}

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

.FreetextHighlight__style-row label {
  font-size: 11px;
  color: #555;
  white-space: nowrap;
}

.FreetextHighlight__style-row input[type="color"] {
  width: 28px;
  height: 24px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 3px;
  padding: 0;
  cursor: pointer;
}

.FreetextHighlight__style-row select {
  padding: 4px 6px;
  font-size: 11px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 3px;
  background: white;
  cursor: pointer;
  min-width: 80px;
}

.FreetextHighlight__color-options {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  width: 100%;
}

.FreetextHighlight__color-presets {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.FreetextHighlight__color-preset {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(0, 0, 0, 0.15);
  border-radius: 3px;
  cursor: pointer;
  padding: 0;
  transition: transform 0.15s, border-color 0.15s;
}

.FreetextHighlight__color-preset:hover {
  transform: scale(1.15);
  border-color: rgba(0, 0, 0, 0.3);
}

.FreetextHighlight__color-preset.active {
  border-color: #333;
  box-shadow: 0 0 0 1px white, 0 0 0 2px #333;
}

.FreetextHighlight__color-preset--transparent {
  background:
    linear-gradient(45deg, #ccc 25%, transparent 25%),
    linear-gradient(-45deg, #ccc 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #ccc 75%),
    linear-gradient(-45deg, transparent 75%, #ccc 75%);
  background-size: 8px 8px;
  background-position: 0 0, 0 4px, 4px -4px, -4px 0px;
  background-color: white;
}

.FreetextHighlight__delete-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: white;
  border-radius: 3px;
  padding: 0;
  transition: background 0.2s;
}

.FreetextHighlight__delete-button:hover {
  background: rgba(255, 100, 100, 0.6);
}

.FreetextHighlight__collapse-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: white;
  border-radius: 3px;
  padding: 0;
  transition: background 0.2s;
}

.FreetextHighlight__collapse-button:hover {
  background: rgba(255, 255, 255, 0.2);
}

.FreetextHighlight--collapsed .FreetextHighlight__container {
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.24);
  overflow: hidden;
}

.FreetextHighlight__compact-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  border: none;
  border-radius: inherit;
  background: transparent;
  color: inherit;
  cursor: pointer;
  padding: 0;
}

.FreetextHighlight__compact-button:hover {
  background: rgba(0, 0, 0, 0.08);
}
