/* Alert "+" button — matches price label height, TradingView style */
.alert-plus-button {
  position: absolute;
  width: 17px;
  height: 17px;
  border-radius: 3px;
  background: var(--bg-button);
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 300;
  display: none;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  user-select: none;
  pointer-events: auto;
  line-height: 17px;
  z-index: 10000;
  border: 1px solid var(--border-light);
  padding: 0;
  box-sizing: border-box;
}

.alert-plus-button:hover {
  background: var(--bg-button-hover);
  color: var(--text);
  border-color: var(--text-muted);
}

/* Alert Edit Modal — unified with chart-position-menu */
.alert-edit-modal {
  position: absolute;
  z-index: 10001;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 8px;
  width: 210px;
  box-shadow: 0 4px 12px var(--shadow, rgba(0, 0, 0, 0.5));
  font-family: var(--app-font), sans-serif;
  font-size: 11px;
  color: var(--text);
  user-select: none;
  pointer-events: auto;
}

.alert-edit-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
  cursor: grab;
}

.alert-edit-header:active {
  cursor: grabbing;
}

.alert-edit-symbol {
  font-weight: 700;
  font-size: 11px;
  color: var(--text);
  margin-right: 4px;
}

.alert-edit-label {
  color: var(--text-muted);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.alert-edit-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  padding: 0;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  font-family: var(--app-font), sans-serif;
  line-height: 1;
}

.alert-edit-close:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.alert-edit-field {
  margin-bottom: 5px;
}

.alert-edit-field label {
  display: block;
  font-size: 9px;
  color: var(--text-muted);
  margin-bottom: 2px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.alert-edit-input {
  width: 100%;
  padding: 4px 6px;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 3px;
  font-size: 11px;
  font-family: var(--app-font), sans-serif;
  outline: none;
  box-sizing: border-box;
  user-select: text;
}

.alert-edit-input:focus {
  border-color: var(--border-light);
}

.alert-edit-select {
  width: 100%;
  padding: 4px 6px;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 3px;
  font-size: 11px;
  font-family: var(--app-font), sans-serif;
  outline: none;
  cursor: pointer;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5'%3E%3Cpath d='M0 0l4 5 4-5z' fill='%23666'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  padding-right: 18px;
}

.alert-edit-select:focus {
  border-color: var(--border-light);
}

.alert-edit-select option {
  background: var(--bg-alt);
  color: var(--text);
}

.alert-edit-actions {
  display: flex;
  gap: 3px;
  margin-top: 6px;
}

.alert-edit-save {
  flex: 1;
  padding: 4px 0;
  background: var(--bg-button);
  color: var(--text);
  border: none;
  border-radius: 3px;
  cursor: pointer;
  font-family: var(--app-font), sans-serif;
  font-size: 10px;
  font-weight: 600;
  transition: background 0.1s;
}

.alert-edit-save:hover {
  background: var(--bg-button-hover);
}

.alert-edit-delete {
  padding: 4px 8px;
  background: rgba(255, 72, 0, 0.1);
  color: var(--loss, #ff4800);
  border: none;
  border-radius: 3px;
  cursor: pointer;
  font-family: var(--app-font), sans-serif;
  font-size: 10px;
  transition: background 0.1s;
}

.alert-edit-delete:hover {
  background: rgba(255, 72, 0, 0.2);
}

/* Alert Panel buttons (PositionPanel > Alerts tab) */
.alert-panel-btn {
  padding: 3px 8px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 11px;
  font-family: var(--app-font), sans-serif;
  transition: background 0.15s;
}

.alert-panel-btn-add {
  background: rgba(150, 150, 150, 0.15);
  color: var(--text, #ddd);
  border: 1px solid rgba(150, 150, 150, 0.3);
}

.alert-panel-btn-add:hover {
  background: rgba(150, 150, 150, 0.25);
}

.alert-panel-btn-delete {
  background: rgba(255, 72, 0, 0.1);
  color: #ff4800;
  border: 1px solid rgba(255, 72, 0, 0.25);
  padding: 2px 6px;
  font-size: 10px;
}

.alert-panel-btn-delete:hover {
  background: rgba(255, 72, 0, 0.2);
}

.alert-panel-btn-clear {
  background: none;
  color: var(--text-muted, #888);
  border: 1px solid var(--border, #333);
  font-size: 10px;
  padding: 2px 6px;
}

.alert-panel-btn-clear:hover {
  color: var(--text, #ddd);
  border-color: var(--border-light);
}

/* Drawing Style Settings — unified with chart-position-menu & alert-edit */
.drawing-style-modal {
  position: absolute;
  z-index: 10001;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 8px;
  min-width: 210px;
  box-shadow: 0 4px 12px var(--shadow, rgba(0, 0, 0, 0.5));
  font-family: var(--app-font), sans-serif;
  font-size: 11px;
  color: var(--text);
  user-select: none;
  pointer-events: auto;
}

.drawing-style-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
  cursor: grab;
}

.drawing-style-header:active {
  cursor: grabbing;
}

.drawing-style-title {
  font-weight: 700;
  font-size: 11px;
  color: var(--text);
}

.drawing-style-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  padding: 0;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  font-family: var(--app-font), sans-serif;
  line-height: 1;
}

.drawing-style-close:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.drawing-style-field {
  margin-bottom: 5px;
}

.drawing-style-field label {
  display: block;
  font-size: 9px;
  color: var(--text-muted);
  margin-bottom: 2px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.drawing-style-swatches {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
}

.drawing-style-swatch {
  width: 16px;
  height: 16px;
  border: 1px solid var(--border-light);
  border-radius: 2px;
  cursor: pointer;
  padding: 0;
}

.drawing-style-swatch.active {
  border: 2px solid var(--text);
}

.drawing-style-swatch:hover {
  border-color: var(--text-dim);
}

.drawing-style-range-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.drawing-style-range-row input[type='range'] {
  flex: 1;
  height: 3px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border);
  border-radius: 2px;
  outline: none;
}

.drawing-style-range-row input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-dim);
  cursor: pointer;
}

.drawing-style-range-val {
  font-size: 10px;
  color: var(--text-dim);
  min-width: 28px;
  text-align: right;
}

.drawing-style-select {
  width: 100%;
  padding: 4px 6px;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 3px;
  font-size: 11px;
  font-family: var(--app-font), sans-serif;
  outline: none;
  cursor: pointer;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5'%3E%3Cpath d='M0 0l4 5 4-5z' fill='%23666'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  padding-right: 18px;
}

.drawing-style-select:focus {
  border-color: var(--border-light);
}

.drawing-style-select option {
  background: var(--bg-alt);
  color: var(--text);
}

/* Tabs (Style / Text / Coords) */
.drawing-style-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.drawing-style-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-family: var(--app-font), sans-serif;
  font-size: 11px;
  padding: 3px 8px 5px;
  cursor: pointer;
}

.drawing-style-tab:hover {
  color: var(--text);
}

.drawing-style-tab.active {
  color: var(--text);
  border-bottom-color: var(--accent, #b4b4f9);
}

/* Button rows (thickness / line style / bold-italic) */
.drawing-style-btnrow {
  display: flex;
  gap: 4px;
  align-items: center;
}

.drawing-style-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  padding: 3px 6px;
  background: var(--bg-input);
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
  font-family: var(--app-font), sans-serif;
  font-size: 11px;
}

.drawing-style-btn:hover {
  color: var(--text);
  border-color: var(--border-light);
}

.drawing-style-btn.active {
  color: var(--text);
  background: var(--bg-hover);
  border-color: var(--accent, #b4b4f9);
}

.drawing-style-btn-square {
  flex: 0 0 26px;
}

/* Custom color "+" swatch */
.drawing-style-swatch-custom {
  background: linear-gradient(135deg, #f23645 0%, #ffeb3b 35%, #4caf50 65%, #2962ff 100%);
  color: #fff;
  font-weight: 700;
  font-size: 11px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Inline expanding color picker */
.drawing-style-picker {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.drawing-style-picker .react-colorful {
  width: 100%;
  height: 140px;
}

/* Text inputs / textarea */
.drawing-style-textinput {
  width: 100%;
  padding: 4px 6px;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 3px;
  font-size: 11px;
  font-family: var(--app-font), sans-serif;
  outline: none;
  box-sizing: border-box;
}

.drawing-style-textinput:focus {
  border-color: var(--border-light);
}

.drawing-style-textarea {
  width: 100%;
  padding: 4px 6px;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 3px;
  font-size: 11px;
  font-family: var(--app-font), sans-serif;
  outline: none;
  box-sizing: border-box;
  resize: vertical;
  user-select: text;
  -webkit-user-select: text;
}

.drawing-style-textarea:focus {
  border-color: var(--border-light);
}

.drawing-style-check {
  display: flex !important;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  text-transform: none !important;
}

.drawing-style-check input[type='checkbox'] {
  accent-color: var(--accent, #b4b4f9);
  cursor: pointer;
}

/* News marker tooltip: hover on an all-news dot shows it, click pins it,
   a pinned box drags anywhere. Portaled to body (see NewsMarkerTooltip). */
.news-marker-tooltip {
  position: fixed;
  z-index: 10001;
  width: 380px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 10px;
  box-shadow: 0 4px 12px var(--shadow, rgba(0, 0, 0, 0.5));
  color: var(--text);
  font-size: 12px;
  line-height: 1.4;
  pointer-events: none;
  user-select: none;
}

.news-marker-tooltip--pinned {
  pointer-events: auto;
  cursor: move;
  padding-right: 22px;
}

.news-marker-tooltip-close {
  position: absolute;
  top: 4px;
  right: 6px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  padding: 2px;
}

.news-marker-tooltip-close:hover {
  color: var(--text);
}

.news-marker-tooltip-item + .news-marker-tooltip-item {
  margin-top: 8px;
}

.news-marker-tooltip-meta {
  display: flex;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
}

.news-marker-tooltip-time {
  font-variant-numeric: tabular-nums;
}

.news-marker-tooltip-source {
  color: var(--accent, #4d8dff);
}

.news-marker-tooltip-title {
  user-select: text;
}

.news-marker-tooltip-more {
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 11px;
}

/* ------------------------------------------------ Position panel: Alerts tab */
.alerts-panel {
  padding: 8px 10px;
}
.alerts-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  padding: 8px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.alerts-input {
  height: 24px;
  padding: 0 7px;
  box-sizing: border-box;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-family: inherit;
  font-size: 11.5px;
  outline: none;
  user-select: text;
}
.alerts-input:focus {
  border-color: #45b5ff;
}
.alerts-input-symbol {
  width: 76px;
  text-transform: uppercase;
}
.alerts-input-price {
  width: 84px;
}
.alerts-input-note {
  flex: 1;
  min-width: 90px;
}
.alerts-select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 20px;
  cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position:
    calc(100% - 11px) 10px,
    calc(100% - 7px) 10px;
  background-size: 4px 4px;
  background-repeat: no-repeat;
}
.alerts-error {
  flex-basis: 100%;
  font-size: 11px;
  color: var(--loss);
}
.alerts-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 4px 0 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-muted);
}
.alerts-table {
  width: 100%;
  margin-bottom: 14px;
  border-collapse: collapse;
}
.alerts-table th {
  padding: 3px 6px;
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.alerts-table td {
  padding: 5px 6px;
  font-size: 12px;
  color: var(--text);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  vertical-align: middle;
  white-space: nowrap;
}
.alerts-table.fired td {
  opacity: 0.75;
}
.alerts-table .muted {
  color: var(--text-muted);
  font-size: 11px;
}
.alerts-symbol {
  font-weight: 700;
  cursor: pointer;
}
.alerts-away {
  margin-left: 6px;
  font-size: 10.5px;
  color: var(--text-muted);
}
.alerts-away.near {
  color: var(--tc-fffa9f);
  font-weight: 700;
}
.alerts-note {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: text;
}
.alerts-actions {
  text-align: right;
}

/* Ctrl+drag drawing selection box (pane pixels, in the chart container) */
.drawing-marquee {
  position: absolute;
  border: 1px solid #45b5ff;
  background: rgba(69, 181, 255, 0.1);
  pointer-events: none;
  z-index: 1000;
}
