/* 1:1 TradingView Left Drawing Rail, Flyout Drawer, Floating Style Bar & Settings Modal */

/* Left Vertical Rail (52px wide, exact TradingView proportions) */
.tv-left-rail {
  width: 52px;
  background: var(--tv-rail-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 0;
  gap: 2px;
  overflow-y: auto;
  overflow-x: hidden;
  flex-shrink: 0;
  z-index: 30;
}

.tv-rail-slot {
  position: relative;
  width: 44px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
}
.tv-rail-slot:hover {
  background: var(--surface-hover);
}
.tv-rail-slot.active {
  background: var(--surface-active);
}

.tv-rail-btn {
  width: 34px;
  height: 34px;
  border: none;
  background: transparent;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 3px;
}
.tv-rail-slot.active .tv-rail-btn {
  color: var(--text-strong);
}
.tv-rail-btn svg {
  width: 26px;
  height: 26px;
}

.tv-rail-arrow {
  position: absolute;
  right: 0;
  top: 4px;
  bottom: 4px;
  width: 11px;
  border: none;
  border-radius: 0 5px 5px 0;
  background: transparent;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0.45;
  transition: opacity 0.1s, background 0.1s;
}
.tv-rail-slot:hover .tv-rail-arrow {
  opacity: 1;
}
.tv-rail-arrow:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-strong);
}

.tv-rail-sep {
  width: 26px;
  height: 1px;
  background: var(--border);
  margin: 4px 0;
  flex-shrink: 0;
}

/* Tool Group Flyout Drawer (1:1 TradingView dark drawer) */
.tv-drawer {
  position: fixed;
  min-width: 256px;
  max-height: calc(100vh - 50px);
  overflow-y: auto;
  padding: 6px 0;
  background: rgba(18, 18, 22, 0.78);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid var(--tv-glass-border);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.65);
  z-index: 1400;
  display: none;
  flex-direction: column;
}
.tv-drawer.open {
  display: flex;
}
.tv-drawer-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 34px;
  padding: 0 12px;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  cursor: pointer;
  text-align: left;
  width: 100%;
}
.tv-drawer-item:hover {
  background: var(--surface-hover);
}
.tv-drawer-item.active {
  background: var(--surface-active);
  color: var(--text-strong);
}
.tv-d-ico {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.tv-d-ico svg {
  width: 22px;
  height: 22px;
}
.tv-d-label {
  flex: 1;
  white-space: nowrap;
}
.tv-d-short {
  font-size: 11px;
  color: var(--text-muted);
  margin-right: 4px;
}
.tv-star-btn {
  border: none;
  background: transparent;
  color: var(--text-disabled);
  cursor: pointer;
  font-size: 13px;
  padding: 2px 4px;
  opacity: 0;
  transition: opacity 0.1s, color 0.1s;
}
.tv-drawer-item:hover .tv-star-btn,
.tv-star-btn.fav {
  opacity: 1;
}
.tv-star-btn.fav {
  color: #F59E0B;
}

/* TradingView Draggable Favorites Floating Bar */
.tv-fav-bar {
  position: absolute;
  bottom: 60px;
  left: 14px;
  display: flex;
  align-items: center;
  gap: 2px;
  height: 36px;
  padding: 0 8px 0 6px;
  background: rgba(18, 18, 22, 0.78);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid var(--tv-glass-border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.62);
  z-index: 40;
}
.tv-fav-grip {
  color: var(--text-muted);
  cursor: grab;
  padding: 0 5px 0 2px;
  display: inline-flex;
  align-items: center;
}
.tv-fav-btn {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.tv-fav-btn:hover { background: var(--surface-hover); }
.tv-fav-btn.active { background: var(--surface-active); color: var(--text-strong); }
.tv-fav-btn svg { width: 20px; height: 20px; }

/* TradingView Floating Style Toolbar (appears when a drawing is selected) */
.tv-floating-bar {
  position: absolute;
  top: 40px;
  left: 50%;
  transform: translateX(-50%);
  height: 36px;
  padding: 0 6px;
  background: rgba(18, 18, 22, 0.78);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid var(--tv-glass-border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.58);
  display: none;
  align-items: center;
  gap: 2px;
  z-index: 50;
}
.tv-floating-bar.open {
  display: flex;
}
.tv-float-grip {
  color: var(--text-muted);
  cursor: grab;
  padding: 0 5px 0 3px;
  display: inline-flex;
  align-items: center;
}
.tv-f-btn {
  height: 28px;
  min-width: 28px;
  padding: 0 6px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-family: inherit;
  font-size: 11.5px;
  cursor: pointer;
}
.tv-f-btn:hover { background: var(--surface-hover); }
.tv-f-btn.active { background: var(--surface-active); color: var(--text-strong); }
.tv-f-btn.danger:hover { color: var(--dn); }
.tv-swatch-icon {
  display: inline-flex;
  align-items: center;
  padding-bottom: 1px;
}
.tv-lw-preview {
  width: 14px;
  background: currentColor;
  border-radius: 1px;
}
.tv-f-sep {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 3px;
}

/* Floating Toolbar Popovers (80-color swatch, line width, line style — sits above Settings modal too) */
.tv-float-popover {
  position: fixed;
  padding: 10px;
  background: rgba(18, 18, 22, 0.80);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid var(--tv-glass-border);
  border-radius: 10px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.72);
  z-index: 2250;
  display: none;
}
.tv-float-popover.open {
  display: block;
}
.tv-palette-grid {
  display: grid;
  grid-template-columns: repeat(10, 18px);
  gap: 4px;
}
.tv-pal-cell {
  width: 18px;
  height: 18px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  cursor: pointer;
}
.tv-pal-cell:hover { transform: scale(1.15); }
.tv-pal-cell.selected { outline: 2px solid #FFFFFF; outline-offset: 1px; }
.tv-opacity-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-muted);
}
.tv-opacity-row input[type="range"] { flex: 1; accent-color: var(--accent); }

.tv-list-pop {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 140px;
}
.tv-list-opt {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 30px;
  padding: 0 8px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
}
.tv-list-opt:hover { background: var(--surface-hover); }
.tv-list-opt.active { background: var(--surface-active); color: var(--text-strong); }
.tv-lw-line { width: 38px; background: currentColor; border-radius: 1px; }

/* Settings Modal & Inline Text Editor (Dark Frosted Glassmorphism) */
.tv-settings-overlay,
.tv-text-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.28);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2100;
}
.tv-settings-overlay.open,
.tv-text-modal.open {
  display: flex;
}
.tv-settings-card,
.tv-text-box {
  width: 400px;
  max-width: 92vw;
  background: var(--tv-glass-bg);
  backdrop-filter: var(--tv-glass-blur);
  -webkit-backdrop-filter: var(--tv-glass-blur);
  border: 1px solid var(--tv-glass-border);
  border-radius: 14px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.78);
  overflow: hidden;
}
.tv-set-hdr,
.tv-text-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  font-weight: 700;
}
.tv-set-hdr button,
.tv-text-hdr button {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
}
.tv-set-tabs {
  display: flex;
  gap: 16px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
}
.tv-set-tabs button {
  height: 36px;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.tv-set-tabs button.active {
  color: var(--text-strong);
  border-bottom-color: var(--text-strong);
}
.tv-set-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  max-height: 480px;
  overflow-y: auto;
}
.tv-set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12.5px;
  color: var(--text);
}
.tv-set-row input[type="number"],
.tv-set-row input[type="datetime-local"],
.tv-set-row select,
.tv-set-row textarea,
.tv-text-box textarea {
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(14, 14, 18, 0.75);
  color: var(--text-strong);
  font-family: inherit;
  font-size: 12.5px;
  outline: none;
}
.tv-set-row select,
.tv-set-row input[type="number"],
.tv-set-row input[type="datetime-local"] {
  height: 32px;
}
.tv-set-row select option {
  background: #141418;
  color: #FFFFFF;
}
.tv-set-row select:focus,
.tv-set-row input:focus,
.tv-set-row textarea:focus {
  border-color: var(--text-strong);
}

/* Custom TradingView White-Check Checkboxes */
.tv-vis-chk input[type="checkbox"],
.tv-chk-lbl input[type="checkbox"],
.tv-fib-chk input[type="checkbox"],
.tv-fib-row input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid #52555E;
  background: transparent;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  display: inline-block;
}
.tv-vis-chk input[type="checkbox"]:checked,
.tv-chk-lbl input[type="checkbox"]:checked,
.tv-fib-chk input[type="checkbox"]:checked,
.tv-fib-row input[type="checkbox"]:checked {
  background: #FFFFFF;
  border-color: #FFFFFF;
}
.tv-vis-chk input[type="checkbox"]:checked::after,
.tv-chk-lbl input[type="checkbox"]:checked::after,
.tv-fib-chk input[type="checkbox"]:checked::after,
.tv-fib-row input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 4.5px;
  top: 1.5px;
  width: 4px;
  height: 8px;
  border-right: 2px solid #000000;
  border-bottom: 2px solid #000000;
  transform: rotate(45deg);
}

/* Custom Settings Swatch Pill & Glassy 2-Col Fib Controls */
.tv-swatch-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 9px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-strong);
  cursor: pointer;
}
.tv-swatch-pill:hover {
  border-color: rgba(255, 255, 255, 0.28);
}
.tv-swatch-sq {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  flex-shrink: 0;
}
.tv-checker-swatch {
  background-image:
    linear-gradient(45deg, rgba(255,255,255,0.12) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255,255,255,0.12) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255,255,255,0.12) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255,255,255,0.12) 75%);
  background-size: 8px 8px;
  background-position: 0 0, 0 4px, 4px -4px, -4px 0;
  position: relative;
  overflow: hidden;
}
.tv-checker-swatch > span {
  position: absolute;
  inset: 0;
}
.tv-multicolor-swatch {
  background: linear-gradient(135deg, #F23645 50%, #089981 50%) !important;
}
.tv-fib-grid-2col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px 12px;
  padding: 8px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.tv-fib-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.tv-fib-row.is-off .tv-fib-inp {
  opacity: 0.4;
}
.tv-fib-inp {
  flex: 1;
  min-width: 0;
  height: 30px !important;
  padding: 0 8px !important;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(14, 14, 18, 0.78);
  color: #FFFFFF;
  font-family: inherit;
  font-size: 12px;
  outline: none;
}
.tv-fib-inp:focus {
  border-color: #2962FF;
}
.tv-fib-swatch-sq {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  cursor: pointer;
  flex-shrink: 0;
}
.tv-fib-swatch-sq:hover {
  border-color: rgba(255, 255, 255, 0.45);
}
.tv-section-lbl {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.tv-pos-summary {
  display: flex;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12px;
  color: var(--text-muted);
}
.tv-tpl-save-row {
  display: flex;
  gap: 6px;
  padding: 4px 2px;
}
.tv-tpl-save-row input {
  flex: 1;
  min-width: 110px;
  height: 28px;
  padding: 0 8px;
  border-radius: 5px;
  border: 1px solid #3A3A3A;
  background: #0D0D0D;
  color: var(--text-strong);
  font-family: inherit;
  font-size: 12px;
  outline: none;
}
.tv-tpl-save-row input:focus {
  border-color: #FFFFFF;
}
.tv-text-box textarea {
  width: calc(100% - 32px);
  margin: 14px 16px;
}
.tv-fib-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}
.tv-fib-chk {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  cursor: pointer;
}
.tv-fib-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.tv-set-ftr,
.tv-text-ftr {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}
.tv-btn-sec,
.tv-btn-pri {
  height: 30px;
  padding: 0 14px;
  border-radius: 5px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.tv-btn-sec {
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text);
}
.tv-btn-pri {
  border: none;
  background: var(--accent);
  color: #FFFFFF;
}
.tv-btn-pri:hover { background: var(--accent-hover); }

/* New TV Popover, More Submenu & 4-Tab Settings Modal Styles */
.tv-pop-sep {
  height: 1px;
  background: var(--border);
  margin: 4px 2px;
}
.tv-recent-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.tv-custom-color {
  width: 18px;
  height: 18px;
  border-radius: 3px;
  border: 1px dashed var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.tv-custom-color input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.tv-more-menu {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 188px;
}
.tv-more-menu .tv-list-opt {
  justify-content: space-between;
}
.tv-more-menu .tv-list-opt:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.tv-more-subwrap {
  position: relative;
}
.tv-more-submenu {
  position: absolute;
  left: calc(100% + 4px);
  top: -6px;
  min-width: 165px;
  padding: 6px;
  background: rgba(18, 18, 22, 0.80);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid var(--tv-glass-border);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.65);
  display: none;
  flex-direction: column;
  gap: 2px;
  z-index: 1520;
}
.tv-more-subwrap:hover > .tv-more-submenu {
  display: flex;
}
.tv-vis-chk, .tv-chk-lbl {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  padding: 3px 6px;
  cursor: pointer;
  color: var(--text);
}
.tv-vis-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding-top: 6px;
}
.tv-set-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
.tv-set-title-wrap h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-strong);
}
.tv-rename-btn {
  font-size: 13px !important;
  color: var(--text-muted);
}
.tv-rename-inp {
  height: 26px;
  padding: 0 8px;
  border-radius: 4px;
  border: 1px solid var(--text-strong);
  background: var(--win-bg);
  color: var(--text-strong);
  font-size: 14px;
  font-weight: 600;
  outline: none;
}
.tv-inline-ctrl {
  display: flex;
  align-items: center;
  gap: 6px;
}
.tv-fib-val {
  width: 54px;
  height: 24px !important;
  padding: 0 4px !important;
  font-size: 11px !important;
}
.tv-fib-col-btn {
  width: 18px;
  height: 18px;
  padding: 0;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  cursor: pointer;
  flex-shrink: 0;
}
.tv-set-ftr-split {
  justify-content: space-between;
}
.tv-btn-white {
  height: 30px;
  padding: 0 16px;
  border-radius: 5px;
  border: none;
  background: #FFFFFF;
  color: #000000;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
}
.tv-btn-white:hover {
  background: #E5E5E5;
}
