/* ============================================================
   Annotation Tool -- Styles
   Lumen-style floating glass-morphism bars over canvas.
   Dark theme default with light theme overrides.
   ============================================================ */

/* -- Glass-morphism shared base -- */
.ann-glass {
  background: rgba(18, 18, 22, 0.88);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
}

[data-theme="light"] .ann-glass {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(0, 0, 0, 0.1);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.04) inset;
}

/* -- Wrapper: fills the tool overlay container -- */
.ann-wrapper {
  position: relative;
  height: 100%;
  width: 100%;
  overflow: hidden;
}

/* -- Canvas area: fills everything -- */
.ann-canvas-area {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #0a0a0c;
}

[data-theme="light"] .ann-canvas-area {
  background: #e0e0e4;
}

.ann-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ============================================================
   Close Button (top-right X)
   ============================================================ */
.ann-close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 10;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.7);
  border: none;
  padding: 0;
  transition: background 0.15s, color 0.15s;
}

.ann-close-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

[data-theme="light"] .ann-close-btn {
  color: rgba(0, 0, 0, 0.5);
}

[data-theme="light"] .ann-close-btn:hover {
  background: rgba(0, 0, 0, 0.08);
  color: rgba(0, 0, 0, 0.9);
}

/* ============================================================
   Tool Palette (vertical, left side)
   ============================================================ */
.ann-toolbar {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 5px;
  gap: 1px;
  width: 42px;
  overflow-y: auto;
  overflow-x: hidden;
  max-height: calc(100% - 32px);
  user-select: none;
}

.ann-toolbar::-webkit-scrollbar { width: 0; display: none; }

.ann-tool-btn {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  flex-shrink: 0;
  background: transparent;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.55);
  transition: background 0.15s, color 0.15s;
  padding: 0;
}

.ann-tool-btn:hover {
  background: rgba(255, 255, 255, 0.07);
  color: rgba(255, 255, 255, 0.9);
}

.ann-tool-btn.active {
  background: rgba(102, 126, 234, 0.18);
  color: #667eea;
}

[data-theme="light"] .ann-tool-btn {
  color: rgba(0, 0, 0, 0.45);
}

[data-theme="light"] .ann-tool-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  color: rgba(0, 0, 0, 0.8);
}

[data-theme="light"] .ann-tool-btn.active {
  background: rgba(79, 108, 229, 0.15);
  color: #4f6ce5;
}

.ann-tool-sep {
  width: 24px;
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 2px 0;
  flex-shrink: 0;
}

[data-theme="light"] .ann-tool-sep {
  background: rgba(0, 0, 0, 0.08);
}

/* ============================================================
   Properties Bar (floating, bottom center)
   ============================================================ */
.ann-props {
  position: absolute;
  bottom: 52px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 0;
  padding: 5px 10px;
  user-select: none;
  white-space: nowrap;
}

.ann-prop-group {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 6px;
}

.ann-prop-sep {
  width: 1px;
  height: 20px;
  background: rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

[data-theme="light"] .ann-prop-sep {
  background: rgba(0, 0, 0, 0.08);
}

.ann-prop-label {
  font-size: 9px;
  color: rgba(255, 255, 255, 0.45);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  user-select: none;
}

[data-theme="light"] .ann-prop-label {
  color: rgba(0, 0, 0, 0.4);
}

/* Color swatch (single, clickable to open picker) */
.ann-swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.12s;
  flex-shrink: 0;
}

.ann-swatch:hover {
  border-color: rgba(255, 255, 255, 0.4);
}

.ann-swatch.active {
  border-color: rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
}

[data-theme="light"] .ann-swatch:hover {
  border-color: rgba(0, 0, 0, 0.3);
}

[data-theme="light"] .ann-swatch.active {
  border-color: rgba(0, 0, 0, 0.7);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15);
}

/* Spinner (stroke width, font size) */
.ann-spinner {
  display: flex;
  align-items: center;
  gap: 0;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 0;
  height: 26px;
}

[data-theme="light"] .ann-spinner {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.1);
}

.ann-spin-step {
  width: 22px;
  height: 26px;
  border-radius: 6px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s;
  padding: 0;
}

.ann-spin-step:hover {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.9);
}

[data-theme="light"] .ann-spin-step {
  color: rgba(0, 0, 0, 0.4);
}

[data-theme="light"] .ann-spin-step:hover {
  background: rgba(0, 0, 0, 0.06);
  color: rgba(0, 0, 0, 0.8);
}

.ann-spin-input {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.8);
  min-width: 28px;
  width: 38px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  background: transparent;
  border: none;
  outline: none;
  padding: 0;
  font-family: inherit;
}

.ann-spin-input:focus { color: #fff; }

[data-theme="light"] .ann-spin-input {
  color: rgba(0, 0, 0, 0.7);
}

[data-theme="light"] .ann-spin-input:focus { color: #000; }

/* CSS triangles for spinner arrows */
.ann-arrow-dn, .ann-arrow-up {
  display: block;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
}

.ann-arrow-dn { border-top: 5px solid currentColor; }
.ann-arrow-up { border-bottom: 5px solid currentColor; }

/* Inline tool button (dash style, fill type) */
.ann-prop-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: transparent;
  border-radius: 5px;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  transition: all 0.12s;
  font-size: 10px;
  white-space: nowrap;
}

.ann-prop-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.9);
}

.ann-prop-btn.active {
  background: rgba(102, 126, 234, 0.15);
  border-color: rgba(102, 126, 234, 0.4);
  color: #667eea;
}

[data-theme="light"] .ann-prop-btn {
  border-color: rgba(0, 0, 0, 0.1);
  color: rgba(0, 0, 0, 0.5);
}

[data-theme="light"] .ann-prop-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  color: rgba(0, 0, 0, 0.8);
}

[data-theme="light"] .ann-prop-btn.active {
  background: rgba(79, 108, 229, 0.12);
  border-color: rgba(79, 108, 229, 0.3);
  color: #4f6ce5;
}

/* ============================================================
   Text Properties Bar (slides up above props bar)
   ============================================================ */
.ann-text-props {
  position: absolute;
  bottom: 88px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 0;
  padding: 5px 10px;
  user-select: none;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(8px);
  transition: opacity 0.15s, transform 0.15s;
}

.ann-text-props.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.ann-text-fmt {
  width: 26px;
  height: 24px;
  border-radius: 4px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.12);
  cursor: pointer;
  color: rgba(255, 255, 255, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  padding: 0;
  transition: background 0.15s, color 0.15s;
}

.ann-text-fmt:hover {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.9);
}

.ann-text-fmt.active {
  background: rgba(102, 126, 234, 0.25);
  border-color: rgba(102, 126, 234, 0.4);
  color: #667eea;
}

[data-theme="light"] .ann-text-fmt {
  border-color: rgba(0, 0, 0, 0.1);
  color: rgba(0, 0, 0, 0.5);
}

[data-theme="light"] .ann-text-fmt:hover {
  background: rgba(0, 0, 0, 0.06);
  color: rgba(0, 0, 0, 0.8);
}

[data-theme="light"] .ann-text-fmt.active {
  background: rgba(79, 108, 229, 0.15);
  border-color: rgba(79, 108, 229, 0.3);
  color: #4f6ce5;
}

.ann-text-format, .ann-text-align {
  display: flex;
  gap: 2px;
}

/* Text color button */
.ann-text-color-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  transition: background 0.12s;
}

.ann-text-color-btn:hover { background: rgba(255, 255, 255, 0.07); }

.ann-text-color-btn span {
  font-size: 14px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
  border-bottom: 3px solid #667eea;
  display: inline-block;
  line-height: 1;
}

[data-theme="light"] .ann-text-color-btn:hover {
  background: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .ann-text-color-btn span {
  color: rgba(0, 0, 0, 0.6);
}

/* ============================================================
   Bottom Bar (floating, bottom center)
   ============================================================ */
.ann-bottombar {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 0;
  padding: 5px 10px;
  user-select: none;
}

.ann-bb-group {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
}

.ann-bb-sep {
  width: 1px;
  height: 20px;
  background: rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

[data-theme="light"] .ann-bb-sep {
  background: rgba(0, 0, 0, 0.08);
}

.ann-bb-label {
  font-size: 9px;
  color: rgba(255, 255, 255, 0.4);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  user-select: none;
}

[data-theme="light"] .ann-bb-label {
  color: rgba(0, 0, 0, 0.4);
}

.ann-bb-value {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.7);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

[data-theme="light"] .ann-bb-value {
  color: rgba(0, 0, 0, 0.6);
}

.ann-bb-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.45);
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 5px;
  font-size: 11px;
  transition: all 0.15s;
  white-space: nowrap;
}

.ann-bb-btn:hover {
  color: rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.07);
}

[data-theme="light"] .ann-bb-btn {
  color: rgba(0, 0, 0, 0.4);
}

[data-theme="light"] .ann-bb-btn:hover {
  color: rgba(0, 0, 0, 0.8);
  background: rgba(0, 0, 0, 0.06);
}

/* Done/Cancel action buttons in bottom bar */
.ann-bb-action {
  font-size: 11px;
  font-weight: 500;
  padding: 4px 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  transition: all 0.15s;
}

.ann-bb-action:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.ann-bb-action.ann-bb-done {
  background: rgba(102, 126, 234, 0.2);
  border-color: rgba(102, 126, 234, 0.4);
  color: #667eea;
}

.ann-bb-action.ann-bb-done:hover {
  background: rgba(102, 126, 234, 0.35);
  color: #fff;
}

[data-theme="light"] .ann-bb-action {
  border-color: rgba(0, 0, 0, 0.1);
  color: rgba(0, 0, 0, 0.6);
}

[data-theme="light"] .ann-bb-action:hover {
  background: rgba(0, 0, 0, 0.06);
  color: #000;
}

[data-theme="light"] .ann-bb-action.ann-bb-done {
  background: rgba(79, 108, 229, 0.15);
  border-color: rgba(79, 108, 229, 0.3);
  color: #4f6ce5;
}

[data-theme="light"] .ann-bb-action.ann-bb-done:hover {
  background: rgba(79, 108, 229, 0.25);
}

/* ============================================================
   Color Picker Popup
   ============================================================ */
.ann-cpk {
  position: fixed;
  z-index: 8500;
  width: 192px;
  padding: 8px;
  background: rgba(22, 22, 26, 0.97);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  gap: 5px;
  user-select: none;
}

[data-theme="light"] .ann-cpk {
  background: rgba(255, 255, 255, 0.97);
  border-color: rgba(0, 0, 0, 0.12);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.04) inset;
}

.ann-cpk-presets {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 3px;
}

.ann-cpk-sw {
  aspect-ratio: 1;
  border-radius: 3px;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: border-color 0.1s;
}

.ann-cpk-sw:hover { border-color: rgba(255, 255, 255, 0.5); }
.ann-cpk-sw.active { border-color: rgba(255, 255, 255, 0.95); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6); }

[data-theme="light"] .ann-cpk-sw:hover { border-color: rgba(0, 0, 0, 0.4); }
[data-theme="light"] .ann-cpk-sw.active { border-color: rgba(0, 0, 0, 0.8); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15); }

/* Action buttons in swatch grid (Custom Color, Eyedropper) */
.ann-cpk-action {
  background: rgba(255, 255, 255, 0.06);
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.1s;
}

.ann-cpk-action:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.3);
  color: rgba(255, 255, 255, 0.9);
}

[data-theme="light"] .ann-cpk-action {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.1);
  color: rgba(0, 0, 0, 0.4);
}

[data-theme="light"] .ann-cpk-action:hover {
  background: rgba(0, 0, 0, 0.08);
  border-color: rgba(0, 0, 0, 0.2);
  color: rgba(0, 0, 0, 0.8);
}

/* Hue strip */
.ann-cpk-hue-wrap {
  position: relative;
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
  cursor: crosshair;
  background: linear-gradient(to right,
    hsl(0, 100%, 50%), hsl(60, 100%, 50%), hsl(120, 100%, 50%),
    hsl(180, 100%, 50%), hsl(240, 100%, 50%), hsl(300, 100%, 50%), hsl(360, 100%, 50%));
}

.ann-cpk-hue-thumb {
  position: absolute;
  top: 0;
  width: 4px;
  height: 10px;
  border: 1.5px solid #fff;
  border-radius: 2px;
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  transform: translateX(-2px);
}

/* Saturation/Lightness square */
.ann-cpk-sl-wrap {
  position: relative;
  height: 70px;
  border-radius: 4px;
  overflow: hidden;
  cursor: crosshair;
}

.ann-cpk-sl-thumb {
  position: absolute;
  width: 10px;
  height: 10px;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  transform: translate(-5px, -5px);
}

/* Hex input + preview */
.ann-cpk-bottom {
  display: flex;
  align-items: center;
  gap: 4px;
}

.ann-cpk-preview {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  flex-shrink: 0;
}

[data-theme="light"] .ann-cpk-preview {
  border-color: rgba(0, 0, 0, 0.15);
}

.ann-cpk-hex {
  flex: 1;
  min-width: 0;
  height: 22px;
  padding: 0 5px;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.85);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  outline: none;
  text-transform: uppercase;
  font-family: inherit;
}

.ann-cpk-hex:focus { border-color: #667eea; }

[data-theme="light"] .ann-cpk-hex {
  color: rgba(0, 0, 0, 0.8);
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.1);
}

/* Custom swatch slots */
.ann-cpk-custom {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 3px;
}

.ann-cpk-csw {
  aspect-ratio: 1;
  border-radius: 3px;
  cursor: pointer;
  border: 1.5px dashed rgba(255, 255, 255, 0.15);
  transition: border-color 0.1s;
  background: transparent;
}

.ann-cpk-csw.filled {
  border-style: solid;
  border-color: transparent;
}

[data-theme="light"] .ann-cpk-csw {
  border-color: rgba(0, 0, 0, 0.12);
}

/* Back button in custom panel */
.ann-cpk-back {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  font-size: 10px;
  padding: 2px 0;
  text-align: left;
  transition: color 0.1s;
}

.ann-cpk-back:hover { color: rgba(255, 255, 255, 0.9); }

[data-theme="light"] .ann-cpk-back {
  color: rgba(0, 0, 0, 0.4);
}

[data-theme="light"] .ann-cpk-back:hover {
  color: rgba(0, 0, 0, 0.8);
}

/* ============================================================
   Fill Type Menu
   ============================================================ */
.ann-fill-menu {
  position: fixed;
  z-index: 8500;
  padding: 4px;
  background: rgba(22, 22, 26, 0.97);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  user-select: none;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

[data-theme="light"] .ann-fill-menu {
  background: rgba(255, 255, 255, 0.97);
  border-color: rgba(0, 0, 0, 0.12);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

.ann-fill-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border: none;
  background: none;
  border-radius: 5px;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.6);
  font-size: 11px;
  white-space: nowrap;
  transition: background 0.1s, color 0.1s;
}

.ann-fill-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.9);
}

.ann-fill-item.active {
  background: rgba(102, 126, 234, 0.15);
  color: #667eea;
}

[data-theme="light"] .ann-fill-item {
  color: rgba(0, 0, 0, 0.5);
}

[data-theme="light"] .ann-fill-item:hover {
  background: rgba(0, 0, 0, 0.06);
  color: rgba(0, 0, 0, 0.8);
}

[data-theme="light"] .ann-fill-item.active {
  background: rgba(79, 108, 229, 0.12);
  color: #4f6ce5;
}

/* ============================================================
   Text Editor Overlay
   ============================================================ */
.ann-text-editor {
  opacity: 0;
  transition: opacity 80ms ease-out;
}

.ann-text-editor.visible {
  opacity: 1;
}

[data-theme="light"] .ann-text-editor {
  background: rgba(255, 255, 255, 0.85) !important;
  border-color: rgba(79, 108, 229, 0.5) !important;
}

.ann-text-editable {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.ann-text-editable:empty::before {
  content: attr(data-placeholder);
  color: rgba(255, 255, 255, 0.35);
  pointer-events: none;
}

[data-theme="light"] .ann-text-editable:empty::before {
  color: rgba(0, 0, 0, 0.3);
}

/* ============================================================
   Animations
   ============================================================ */
@keyframes ann-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes ann-slide-in-left {
  from { opacity: 0; transform: translateX(-12px); }
  to { opacity: 1; transform: translateX(0); }
}
