/* _common/legend-editor.css — LegendEditor handle + popup panel styles */

/* ── Legend bar: edit-mode container ── */
.legend-bar-vertical.editing {
  position: relative;
}

/* ── Handle on legend bar ── */
.legend-handle {
  position: absolute;
  left: -2px;
  width: 18px;
  height: 8px;
  background: #fff;
  border: 2px solid var(--primary, #4a9eff);
  border-radius: 3px;
  cursor: ns-resize;
  transform: translateY(-50%);
  z-index: 10;
  box-shadow: 0 0 4px rgba(0,0,0,0.4);
  transition: box-shadow 0.1s;
}

.legend-handle:hover,
.legend-handle.dragging {
  box-shadow: 0 0 8px var(--primary, #4a9eff);
  border-color: var(--primary, #4a9eff);
}

.legend-handle.fixed {
  cursor: default;
  opacity: 0.5;
  border-color: #666;
  background: #ccc;
}

/* ── Edit button (below shortened legend bar) ── */
.legend-edit-btn {
  display: block;
  width: 21px;
  margin: 6px 0 0 0;
  padding: 5px 0;
  font-size: 14px;
  line-height: 1;
  border: 1px solid var(--border, #444);
  border-radius: 2px;
  background: var(--card, #1a1a2e);
  color: var(--text-muted, #888);
  cursor: pointer;
  text-align: center;
  font-family: inherit;
  transition: border-color 0.15s, color 0.15s;
}

.legend-edit-btn:hover {
  border-color: var(--primary, #4a9eff);
  color: var(--primary, #4a9eff);
}

.legend-edit-btn.active {
  border-color: var(--primary, #4a9eff);
  color: var(--primary, #4a9eff);
  background: rgba(74,158,255,0.1);
}

/* ── Popup panel (absolute, right of legend strip) ── */
.legend-editor-popup {
  display: none;
  position: fixed;
  z-index: 100;
  width: 210px;
  max-height: 80vh;
  overflow-y: auto;
  padding: 8px;
  border: 1px solid var(--primary, #4a9eff);
  border-radius: 6px;
  background: var(--card, #1a1a2e);
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  font-size: 10px;
  color: var(--text, #ccc);
}

.legend-editor-popup.visible {
  display: block;
}

.legend-editor-popup .popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.legend-editor-popup .popup-title {
  font-size: 11px;
  font-weight: 600;
  margin: 0;
}

.legend-editor-popup .popup-close {
  width: 18px;
  height: 18px;
  padding: 0;
  border: none;
  background: none;
  color: var(--text-muted, #888);
  font-size: 14px;
  cursor: pointer;
  line-height: 1;
}

.legend-editor-popup .popup-close:hover {
  color: var(--text, #ccc);
}

/* Preset select inside popup */
.legend-editor-popup .popup-preset {
  width: 100%;
  margin-bottom: 6px;
  font-size: 11px;
  padding: 3px 4px;
  border: 1px solid var(--border, #444);
  border-radius: 3px;
  background: var(--bg, #0f1a30);
  color: var(--text, #ccc);
  cursor: pointer;
}

/* Point row: label | value | color */
.legend-editor-popup .pt-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 3px;
  overflow: visible;
}

.legend-editor-popup .pt-label {
  width: 20px;
  text-align: right;
  color: var(--text-muted, #888);
  font-family: monospace;
  font-size: 9px;
  flex-shrink: 0;
}

.legend-editor-popup .pt-value {
  width: 62px;
  height: 22px;
  font-size: 12px;
  padding: 0 2px;
  box-sizing: border-box;
  border: 1px solid var(--border, #444);
  border-radius: 2px;
  background: var(--bg, #0f1a30);
  color: var(--text, #ccc);
  font-family: monospace;
  text-align: right;
}

.legend-editor-popup .pt-color {
  width: 24px;
  height: 21px;
  padding: 0;
  border: 1px solid var(--border, #444);
  border-radius: 2px;
  cursor: pointer;
  background: none;
}

.legend-editor-popup .pt-color:disabled {
  cursor: default;
}

/* Footer buttons — 2×2 grid */
.legend-editor-popup .popup-footer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-top: 6px;
}

.legend-editor-popup .popup-footer button {
  font-size: 9px;
  padding: 3px 0;
  border: 1px solid var(--border, #444);
  border-radius: 3px;
  background: var(--card, #1a1a2e);
  color: var(--text, #ccc);
  cursor: pointer;
  font-family: inherit;
}

.legend-editor-popup .popup-footer button:hover {
  border-color: var(--primary, #4a9eff);
}

.legend-editor-popup .popup-footer button.primary {
  border-color: var(--primary, #4a9eff);
  color: var(--primary, #4a9eff);
}

/* ── Day theme overrides ── */
html.day .legend-handle {
  background: #fff;
  border-color: #1976d2;
  box-shadow: 0 0 4px rgba(0,0,0,0.2);
}

html.day .legend-handle.fixed {
  border-color: #999;
  background: #ddd;
}

html.day .legend-edit-btn {
  background: #fff;
  border-color: #ccc;
  color: #666;
}

html.day .legend-edit-btn:hover {
  border-color: #1976d2;
  color: #1976d2;
}

html.day .legend-editor-popup {
  background: #fafafa;
  border-color: #1976d2;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  color: #333;
}

html.day .legend-editor-popup .popup-preset,
html.day .legend-editor-popup .pt-value {
  background: #fff;
  border-color: #ccc;
  color: #333;
}
