/* ══════════════════════════════════════════════════════════════
   TradingView-Style Drawing Toolbar v2
   Split-button design: [tool icon | ▾ chevron] per row
   ══════════════════════════════════════════════════════════════ */

/* ── Toolbar Container ──────────────────────────────────────── */
.tv-drawing-toolbar {
    width: 48px;
    min-width: 48px;
    flex-shrink: 0;
    background: #131722;
    border-right: 1px solid #2a2e39;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px 0;
    overflow-y: auto;
    overflow-x: visible;
    z-index: 20;
    position: relative;
    user-select: none;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.tv-drawing-toolbar::-webkit-scrollbar { display: none; }

/* ── Cursor / Cross Button (top) uses standard .tv-toolbar-row ── */

.tv-toolbar-cursor-btn .tv-tbico img {
    width: 18px;
    height: 18px;
    display: block;
    filter: brightness(0) invert(0.75);
    transition: filter 0.12s;
}

.tv-toolbar-cursor-btn:hover .tv-tbico img {
    filter: brightness(0) invert(0.92);
}

/* ── Split-button row (tool + chevron) ──────────────────────────── */
.tv-toolbar-row {
    display: flex;
    align-items: center;
    width: 44px;
    height: 30px;
    margin: 0 auto;
    border-radius: 6px;
    overflow: visible;
    flex-shrink: 0;
    position: relative;
    box-sizing: border-box;
    transition: background 0.15s ease;
}

.tv-toolbar-row:hover {
    background: #2a2e39;
}

.tv-toolbar-row.active {
    background: rgba(41, 98, 255, 0.15) !important;
    outline: 1px solid #2962ff !important;
    outline-offset: 0px !important;
    border-radius: 6px !important;
}

.tv-toolbar-row .tv-tb-tool,
.tv-toolbar-row .tv-tb-chevron {
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
}

.tv-toolbar-row.active .tv-tb-tool,
.tv-toolbar-row.active .tv-tb-chevron {
    background: transparent !important;
    color: #93c5fd !important;  /* light blue — high contrast on dark navy active bg */
}

/* Left part: tool icon button — fills full row so icon centers like toggle buttons */
.tv-tb-tool {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%;
    border: none;
    background: transparent;
    cursor: pointer;
    color: #b2b5be;
    padding: 0;
    transition: color 0.12s;
    min-width: 0;
    border-radius: 6px;
}

.tv-tb-tool:hover {
    color: #e0e3eb;
    background: transparent;
}

.tv-toolbar-row.active .tv-tb-tool {
    color: #93c5fd;
}

.tv-tb-tool .tv-tbico img {
    width: 16px;
    height: 16px;
    display: block;
    filter: brightness(0) invert(0.72);
    transition: filter 0.12s;
}

.tv-toolbar-row:hover .tv-tb-tool .tv-tbico img {
    filter: brightness(0) invert(0.90);
}

.tv-toolbar-row.active .tv-tb-tool .tv-tbico img {
    /* light blue tint — high contrast on dark navy active background */
    filter: brightness(0) saturate(100%) invert(68%) sepia(55%) saturate(800%)
            hue-rotate(195deg) brightness(115%) contrast(100%);
}

/* Right part: chevron — absolute positioned over the right edge, does NOT affect icon centering */
.tv-tb-chevron {
    position: absolute;
    right: 0;
    top: 0;
    width: 14px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    cursor: pointer;
    color: #545e77;
    padding: 0;
    flex-shrink: 0;
    transition: color 0.12s;
    border-radius: 0 6px 6px 0;
    z-index: 2;
}

.tv-toolbar-row:hover .tv-tb-chevron {
    color: #787b86;
}

.tv-toolbar-row.dropdown-open .tv-tb-chevron {
    color: #b2b5be;
}

/* Chevron SVG icon */
.tv-tb-chevron svg {
    width: 8px;
    height: 8px;
    display: block;
    transition: transform 0.18s ease;
}

.tv-toolbar-row.dropdown-open .tv-tb-chevron svg {
    transform: rotate(180deg);
}

/* ── Separator ──────────────────────────────────────────────── */
.tv-toolbar-separator {
    width: 32px;
    height: 1px;
    background: #2a2e39;
    margin: 4px auto;
    flex-shrink: 0;
}

/* ── Toggle buttons (below separator) ──────────────────────── */
.tv-toolbar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 30px;
    margin: 0 auto;
    padding: 0;
    box-sizing: border-box;
    border: none;
    background: transparent;
    color: #787b86;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.15s ease, color 0.12s;
    flex-shrink: 0;
}

.tv-toolbar-toggle:hover {
    background: #2a2e39;
    color: #d1d4dc;
}

.tv-toolbar-toggle.active {
    background: rgba(41, 98, 255, 0.15) !important;
    outline: 1px solid #2962ff !important;
    outline-offset: 0px !important;
    color: #93c5fd !important;  /* light blue — high contrast on dark navy active bg */
}

.tv-tbico {
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    overflow: visible;
}

.tv-tbico svg {
    overflow: visible;
    display: block;
}

.tv-tbico img {
    display: block;
}

/* ══════════════════════════════════════════════════════════════
   Flyout Dropdown
   ══════════════════════════════════════════════════════════════ */
.tv-toolbar-dropdown {
    position: fixed;
    background: #1e222d;
    border: 1px solid #363a45;
    border-radius: 6px;
    box-shadow: 0 4px 28px rgba(0, 0, 0, 0.6), 0 1px 6px rgba(0, 0, 0, 0.4);
    width: 290px;
    max-height: 75vh;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 200;
    padding: 4px 0;
    scrollbar-width: thin;
    scrollbar-color: #363a45 transparent;

    opacity: 0;
    transform: translateX(-6px);
    transition: opacity 0.15s ease-out, transform 0.15s ease-out;
    pointer-events: none;
}

.tv-toolbar-dropdown.visible {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

.tv-toolbar-dropdown::-webkit-scrollbar { width: 4px; }
.tv-toolbar-dropdown::-webkit-scrollbar-track { background: transparent; }
.tv-toolbar-dropdown::-webkit-scrollbar-thumb { background: #363a45; border-radius: 3px; }

/* ── Section Header ─────────────────────────────────────────── */
.tv-dropdown-section {
    padding: 10px 14px 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: #6b7280;
    user-select: none;
}

/* ── Dropdown Separator ─────────────────────────────────────── */
.tv-dropdown-sep {
    height: 1px;
    background: #2a2e39;
    margin: 4px 14px;
}

/* ── Tool Item ──────────────────────────────────────────────── */
.tv-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 14px;
    cursor: pointer;
    transition: background 0.1s;
    color: #d1d4dc;
    font-size: 13px;
    font-weight: 400;
    min-height: 34px;
    position: relative;
}

.tv-dropdown-item:hover {
    background: #2a2e39;
}

.tv-dropdown-item.selected {
    color: #fff;
    background: rgba(41, 98, 255, 0.15);
}

.tv-dropdown-item.selected:hover {
    background: rgba(41, 98, 255, 0.22);
}

/* Icon in dropdown */
.tv-ddi-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.tv-ddi-icon img {
    width: 28px;
    height: 28px;
    display: block;
    object-fit: contain;
    filter: brightness(0) invert(0.78);
    transition: filter 0.1s;
}

.tv-dropdown-item:hover .tv-ddi-icon img { filter: brightness(0) invert(0.95); }
.tv-dropdown-item.selected .tv-ddi-icon img {
    filter: brightness(0) invert(0.95);
}

/* Tool name */
.tv-ddi-name { flex: 1; }

/* Shortcut */
.tv-ddi-shortcut {
    font-size: 11px;
    color: #6b7280;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ── Backdrop ───────────────────────────────────────────────── */
.tv-toolbar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 199;
    background: transparent;
}

/* ══════════════════════════════════════════════════════════════
   Settings Popup Panel
   ══════════════════════════════════════════════════════════════ */
.tv-toolbar-settings-panel {
    position: fixed;
    background: #1e222d;
    border: 1px solid #363a45;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), 0 2px 8px rgba(0, 0, 0, 0.4);
    width: 280px;
    z-index: 210;
    padding: 0;
    overflow: hidden;

    /* Animation */
    opacity: 0;
    transform: translateX(-6px);
    transition: opacity 0.15s ease-out, transform 0.15s ease-out;
    pointer-events: none;
}

.tv-toolbar-settings-panel.visible {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

/* Panel header */
.tv-settings-header {
    display: flex;
    align-items: center;
    padding: 12px 14px 10px;
    border-bottom: 1px solid #2a2e39;
    font-size: 12px;
    font-weight: 600;
    color: #787b86;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    user-select: none;
}

/* Settings row */
.tv-settings-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid #1a1d2a;
}

.tv-settings-row:last-child {
    border-bottom: none;
}

.tv-settings-divider {
    height: 1px;
    background: #2a2e39;
    margin: 4px 0;
}

.tv-settings-row-text {
    flex: 1;
    min-width: 0;
}

.tv-settings-row-label {
    font-size: 13px;
    font-weight: 500;
    color: #d1d4dc;
    line-height: 1.3;
    margin-bottom: 3px;
}

.tv-settings-row-desc {
    font-size: 11px;
    color: #6b7280;
    line-height: 1.4;
}

/* Toggle switch */
.tv-toggle-switch {
    position: relative;
    width: 36px;
    height: 20px;
    flex-shrink: 0;
    margin-top: 1px;
    cursor: pointer;
}

.tv-toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.tv-toggle-track {
    position: absolute;
    inset: 0;
    background: #2a2e39;
    border-radius: 10px;
    border: 1px solid #363a45;
    transition: background 0.2s ease, border-color 0.2s ease;
    cursor: pointer;
}

.tv-toggle-switch input:checked + .tv-toggle-track {
    background: #2962ff;
    border-color: #2962ff;
}

.tv-toggle-knob {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.4);
    transition: transform 0.2s ease;
    pointer-events: none;
}

.tv-toggle-switch input:checked ~ .tv-toggle-track .tv-toggle-knob {
    transform: translateX(16px);
}

/* ══════════════════════════════════════════════════════════════
   Confirm Modal — "Clear All Drawings"
   ══════════════════════════════════════════════════════════════ */

/* Overlay */
.tv-confirm-overlay {
    position: fixed;
    inset: 0;
    z-index: 9000;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);

    opacity: 0;
    transition: opacity 0.2s ease;
}

.tv-confirm-overlay.visible {
    opacity: 1;
}

/* Dialog box */
.tv-confirm-dialog {
    background: #1e222d;
    border: 1px solid #363a45;
    border-radius: 12px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.7),
                0 4px 16px rgba(0, 0, 0, 0.5),
                inset 0 1px 0 rgba(255, 255, 255, 0.04);
    width: 360px;
    max-width: calc(100vw - 32px);
    padding: 0;
    overflow: hidden;
    position: relative;

    transform: translateY(16px) scale(0.97);
    transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tv-confirm-overlay.visible .tv-confirm-dialog {
    transform: translateY(0) scale(1);
}

/* Top danger accent bar */
.tv-confirm-dialog::before {
    content: '';
    display: block;
    height: 3px;
    background: linear-gradient(90deg, #ef4444 0%, #dc2626 100%);
}

/* Icon area */
.tv-confirm-icon-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 24px 0;
}

.tv-confirm-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ef4444;
    flex-shrink: 0;
}

.tv-confirm-icon svg {
    width: 24px;
    height: 24px;
}

/* Body text */
.tv-confirm-body {
    padding: 16px 24px 0;
    text-align: center;
}

.tv-confirm-title {
    font-size: 16px;
    font-weight: 700;
    color: #e2e8f0;
    margin-bottom: 8px;
    line-height: 1.3;
    letter-spacing: -0.01em;
}

.tv-confirm-msg {
    font-size: 13px;
    color: #8892a4;
    line-height: 1.6;
}

/* Actions */
.tv-confirm-actions {
    display: flex;
    gap: 10px;
    padding: 20px 24px 24px;
    margin-top: 4px;
}

.tv-confirm-btn {
    flex: 1;
    height: 38px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
    letter-spacing: 0.01em;
    outline: none;
    user-select: none;
}

.tv-confirm-btn:active {
    transform: scale(0.97);
}

/* Cancel button */
.tv-confirm-btn-cancel {
    background: #2a2e39;
    color: #9ca3af;
    border: 1px solid #363a45;
}

.tv-confirm-btn-cancel:hover {
    background: #343a4a;
    color: #d1d5db;
    border-color: #4b5563;
}

/* Confirm / danger button */
.tv-confirm-btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.35);
}

.tv-confirm-btn-danger:hover {
    background: linear-gradient(135deg, #f87171 0%, #ef4444 100%);
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.45);
}

/* Focus ring */
.tv-confirm-btn:focus-visible {
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.4);
}

/* ── Chart Context Menu (Right Click) ───────────────────────── */
.tv-chart-context-menu {
    position: fixed;
    background: #1e222d;
    border: 1px solid #363a45;
    border-radius: 6px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.65);
    color: #d1d4dc;
    font-size: 13px;
    padding: 4px 0;
    z-index: 10000;
    min-width: 240px;
    user-select: none;
}

.tv-chart-context-menu .tv-ctx-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    cursor: pointer;
    color: #d1d4dc;
    transition: background 0.12s, color 0.12s;
}

.tv-chart-context-menu .tv-ctx-item:hover {
    background: #2a2e39;
    color: #ffffff;
}

.tv-chart-context-menu .tv-ctx-item.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.tv-chart-context-menu .tv-ctx-item.disabled:hover {
    background: transparent;
    color: #d1d4dc;
}

.tv-chart-context-menu .tv-ctx-divider {
    height: 1px;
    background: #2a2e39;
    margin: 4px 0;
}

.tv-chart-context-menu .tv-ctx-item-has-sub {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.tv-chart-context-menu .tv-ctx-submenu {
    display: none;
    position: absolute;
    left: 100%;
    top: -4px;
    background: #1e222d;
    border: 1px solid #363a45;
    border-radius: 6px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.65);
    min-width: 160px;
    padding: 4px 0;
    z-index: 10001;
}

.tv-chart-context-menu .tv-ctx-item-has-sub:hover > .tv-ctx-submenu {
    display: block;
}

@media (pointer: coarse) {
    .tv-chart-context-menu .tv-ctx-item-has-sub.touch-open {
        flex-wrap: wrap;
    }

    .tv-chart-context-menu .tv-ctx-item-has-sub.touch-open > .tv-ctx-submenu {
        position: static;
        display: block;
        flex-basis: 100%;
        width: 100%;
        margin-top: 8px;
        box-shadow: none;
    }
}
.tv-toolbar-row[data-group="magnet"].active { background: #e0e3eb; } .tv-toolbar-row[data-group="magnet"].active .tv-tb-tool, .tv-toolbar-row[data-group="magnet"].active .tv-tb-chevron { color: #131722; } .tv-toolbar-row[data-group="magnet"].active:hover { background: #f0f3fa; } .tv-toolbar-row[data-group="magnet"].active .tv-tbico img, .tv-toolbar-row[data-group="magnet"].active .tv-tbico svg { filter: none !important; color: #131722 !important; }

/* ── Chart Style Dropdown (Pro Chart Toolbar) ───────────────── */
.chart-style-dropdown {
    background: #1e222d !important;
    border: 1px solid #363a45 !important;
    border-radius: 6px !important;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.7) !important;
    color: #d1d4dc;
    font-size: 13px;
    padding: 4px 0;
    user-select: none;
}

.chart-style-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 7px 14px;
    cursor: pointer;
    color: #d1d4dc;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.12s, color 0.12s;
}

.chart-style-item:hover {
    background: #2a2e39;
    color: #ffffff;
}

.chart-style-item.active {
    background: rgba(41, 98, 255, 0.18);
    color: #2962ff;
    font-weight: 600;
}

.chart-style-item.disabled {
    opacity: 0.42;
    cursor: not-allowed;
}

.chart-style-item.disabled:hover {
    background: transparent;
    color: #848e9c;
}

.chart-style-sep {
    height: 1px;
    background: #2a2e39;
    margin: 4px 0;
}

/* ── Light Theme Overrides ────────────────────────────────────── */
body[data-theme="light"] .tv-drawing-toolbar {
    background: #ffffff !important;
    border-right-color: #e0e3eb !important;
}
body[data-theme="light"] .tv-toolbar-row:hover,
body[data-theme="light"] .tv-tool-btn:hover,
body[data-theme="light"] .tv-toolbar-toggle:hover,
body[data-theme="light"] .tv-toolbar-cursor-btn:hover,
body[data-theme="light"] .tv-tb-tool:hover {
    background: #f0f3fa !important;
    color: #131722 !important;
}
body[data-theme="light"] .tv-toolbar-separator {
    background: #e0e3eb !important;
}

/* Unified Light Mode Active Highlight State for ALL Drawing Toolbar Items */
body[data-theme="light"] .tv-toolbar-row.active,
body[data-theme="light"] .tv-toolbar-toggle.active,
body[data-theme="light"] .tv-toolbar-cursor-btn.active,
body[data-theme="light"] .tv-tool-btn.active,
body[data-theme="light"] .tv-toolbar-row[data-group="magnet"].active,
body[data-theme="light"] .tv-toolbar-row[data-group="eye"].active {
    background: #eff6ff !important;
    outline: 1.5px solid #93c5fd !important;
    outline-offset: 0px !important;
    border-radius: 6px !important;
    box-shadow: none !important;
    border: none !important;
}

body[data-theme="light"] .tv-toolbar-row.active .tv-tb-tool,
body[data-theme="light"] .tv-toolbar-row.active .tv-tb-chevron,
body[data-theme="light"] .tv-toolbar-cursor-btn.active .tv-tb-tool,
body[data-theme="light"] .tv-toolbar-cursor-btn.active .tv-tb-chevron,
body[data-theme="light"] .tv-toolbar-row[data-group="magnet"].active .tv-tb-tool,
body[data-theme="light"] .tv-toolbar-row[data-group="magnet"].active .tv-tb-chevron,
body[data-theme="light"] .tv-toolbar-row[data-group="eye"].active .tv-tb-tool,
body[data-theme="light"] .tv-toolbar-row[data-group="eye"].active .tv-tb-chevron {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
    color: #2962ff !important;
}

body[data-theme="light"] .tv-toolbar-toggle.active {
    color: #2962ff !important;
}

/* Drawing Toolbar Icon Color Fix for Light Mode - 100% Solid Uniform Dark Black */
body[data-theme="light"] .tv-tb-tool,
body[data-theme="light"] .tv-tb-chevron,
body[data-theme="light"] .tv-tool-btn,
body[data-theme="light"] .tv-toolbar-toggle,
body[data-theme="light"] .tv-toolbar-row {
    color: #131722 !important;
}

body[data-theme="light"] .tv-tb-tool .tv-tbico img,
body[data-theme="light"] .tv-toolbar-cursor-btn .tv-tbico img,
body[data-theme="light"] .tv-toolbar-toggle .tv-tbico img,
body[data-theme="light"] .tv-drawing-toolbar img,
body[data-theme="light"] .tv-tbico img {
    filter: brightness(0) contrast(1000%) drop-shadow(0.2px 0 0 #131722) drop-shadow(-0.2px 0 0 #131722) !important;
    opacity: 1 !important;
}

body[data-theme="light"] .tv-toolbar-row:hover .tv-tb-tool .tv-tbico img,
body[data-theme="light"] .tv-toolbar-cursor-btn:hover .tv-tbico img,
body[data-theme="light"] .tv-toolbar-toggle:hover .tv-tbico img,
body[data-theme="light"] .tv-drawing-toolbar img:hover {
    filter: brightness(0) contrast(1000%) drop-shadow(0.3px 0 0 #131722) drop-shadow(-0.3px 0 0 #131722) !important;
    opacity: 1 !important;
}

body[data-theme="light"] .tv-drawing-toolbar svg,
body[data-theme="light"] .tv-tbico svg,
body[data-theme="light"] .tv-tb-chevron svg {
    stroke: #131722 !important;
    color: #131722 !important;
    stroke-width: 2px !important;
    opacity: 1 !important;
}

body[data-theme="light"] .tv-tb-chevron svg path,
body[data-theme="light"] .tv-tb-chevron svg polyline {
    fill: #131722 !important;
    stroke: #131722 !important;
    stroke-width: 2.2px !important;
}

body[data-theme="light"] .tv-toolbar-row.active .tv-tb-tool .tv-tbico img,
body[data-theme="light"] .tv-tool-btn.active img,
body[data-theme="light"] .tv-toolbar-toggle.active .tv-tbico img,
body[data-theme="light"] .tv-toolbar-row[data-group="magnet"].active .tv-tbico img,
body[data-theme="light"] .tv-toolbar-row[data-group="eye"].active .tv-tbico img {
    filter: brightness(0) saturate(100%) invert(35%) sepia(90%) saturate(1600%) hue-rotate(210deg) brightness(105%) contrast(102%) !important;
    opacity: 1 !important;
}

body[data-theme="light"] .tv-toolbar-row.active .tv-tbico svg,
body[data-theme="light"] .tv-toolbar-row.active .tv-tb-chevron svg,
body[data-theme="light"] .tv-tool-btn.active svg,
body[data-theme="light"] .tv-toolbar-toggle.active .tv-tbico svg,
body[data-theme="light"] .tv-toolbar-toggle.active svg,
body[data-theme="light"] .tv-toolbar-row[data-group="magnet"].active svg,
body[data-theme="light"] .tv-toolbar-row[data-group="eye"].active svg {
    stroke: #2962ff !important;
    color: #2962ff !important;
    fill: none !important;
    opacity: 1 !important;
}

body[data-theme="light"] .tv-toolbar-row.active .tv-tb-chevron svg path,
body[data-theme="light"] .tv-toolbar-row.active .tv-tb-chevron svg polyline,
body[data-theme="light"] .tv-toolbar-row.active .tv-tbico svg path,
body[data-theme="light"] .tv-toolbar-row.active .tv-tbico svg polyline {
    fill: none !important;
    stroke: #2962ff !important;
}

/* Drawing Flyout Dropdown Menu (Screenshot 4) */
body[data-theme="light"] .tv-drw-flyout,
body[data-theme="light"] #drwFlyout,
body[data-theme="light"] .drw-flyout-container,
body[data-theme="light"] div[class*="flyout"],
body[data-theme="light"] div[id*="flyout"] {
    background: #ffffff !important;
    border-color: #e0e3eb !important;
    color: #131722 !important;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15) !important;
}
body[data-theme="light"] .tv-drw-flyout-item,
body[data-theme="light"] div[class*="flyout"] div,
body[data-theme="light"] div[id*="flyout"] div {
    color: #131722 !important;
}
body[data-theme="light"] .tv-drw-flyout-header,
body[data-theme="light"] .tv-drw-section-title,
body[data-theme="light"] div[class*="flyout"] header {
    color: #787b86 !important;
}
body[data-theme="light"] .tv-drw-flyout-item:hover {
    background: #f0f3fa !important;
    color: #2962ff !important;
}
body[data-theme="light"] .tv-drw-flyout-item svg,
body[data-theme="light"] .tv-drw-flyout-item img {
    color: #131722 !important;
    stroke: #131722 !important;
    filter: brightness(0) opacity(0.95) !important;
}
body[data-theme="light"] .tv-alert-context-menu {
    background: #ffffff !important;
    border-color: #e0e3eb !important;
    color: #131722 !important;
    box-shadow: 0 6px 16px rgba(0,0,0,0.12) !important;
}
body[data-theme="light"] .tv-alert-context-item {
    color: #131722 !important;
}
body[data-theme="light"] .tv-alert-context-item:hover {
    background: #f0f3fa !important;
}
body[data-theme="light"] .chart-style-dropdown {
    background: #ffffff !important;
    border-color: #e0e3eb !important;
    box-shadow: 0 6px 16px rgba(0,0,0,0.12) !important;
}
body[data-theme="light"] .chart-style-item {
    color: #131722 !important;
}
body[data-theme="light"] .chart-style-item:hover {
    background: #f0f3fa !important;
    color: #2962ff !important;
}
body[data-theme="light"] .chart-style-sep {
    background: #e0e3eb !important;
}
body[data-theme="light"] .chart-toolbar {
    background: #ffffff !important;
    border-bottom-color: #e0e3eb !important;
}
body[data-theme="light"] .tv-drawer-menu {
    background: #ffffff !important;
    border-color: #e0e3eb !important;
    color: #131722 !important;
}
body[data-theme="light"] .tv-drawer-item {
    color: #131722 !important;
}
body[data-theme="light"] .tv-drawer-item:hover {
    background: #f0f3fa !important;
}

/* Drawing Toolbar Dropdown Submenu (Screenshot 5) */
body[data-theme="light"] .tv-toolbar-dropdown,
body[data-theme="light"] #tv-drawing-dropdown {
    background: #ffffff !important;
    border: 1px solid #e0e3eb !important;
    color: #131722 !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15) !important;
}

body[data-theme="light"] .tv-dropdown-section {
    color: #787b86 !important;
}

body[data-theme="light"] .tv-dropdown-sep {
    background: #e0e3eb !important;
}

body[data-theme="light"] .tv-dropdown-item {
    color: #131722 !important;
}

body[data-theme="light"] .tv-dropdown-item:hover {
    background: #f0f3fa !important;
    color: #2962ff !important;
}

body[data-theme="light"] .tv-dropdown-item.selected {
    background: rgba(41, 98, 255, 0.08) !important;
    color: #2962ff !important;
}

body[data-theme="light"] .tv-ddi-icon img,
body[data-theme="light"] .tv-ddi-icon svg {
    filter: brightness(0) opacity(0.85) !important;
    color: #131722 !important;
    stroke: #131722 !important;
}

body[data-theme="light"] .tv-dropdown-item:hover .tv-ddi-icon img,
body[data-theme="light"] .tv-dropdown-item.selected .tv-ddi-icon img {
    filter: brightness(0) opacity(1) !important;
}

body[data-theme="light"] .tv-ddi-shortcut {
    color: #787b86 !important;
    background: #f0f3fa !important;
}

/* Floating Edit Toolbar for Line Drawings (Screenshot 1) */
body[data-theme="light"] #drw-edit-toolbar {
    background: #ffffff !important;
    border: 1px solid #e0e3eb !important;
    color: #131722 !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12) !important;
}

body[data-theme="light"] #drw-edit-toolbar select,
body[data-theme="light"] #drw-btn-width,
body[data-theme="light"] #drw-btn-style,
body[data-theme="light"] #drw-btn-font-family,
body[data-theme="light"] #drw-btn-font-size {
    background: transparent !important;
    color: #131722 !important;
}

body[data-theme="light"] #drw-edit-toolbar select option {
    background: #ffffff !important;
    color: #131722 !important;
}

body[data-theme="light"] #drw-edit-toolbar div[style*="background: #2a2e39"],
body[data-theme="light"] #drw-btn-edit-text-sep {
    background: #e0e3eb !important;
}

body[data-theme="light"] #drw-edit-toolbar svg {
    stroke: #131722 !important;
}

body[data-theme="light"] #drw-edit-toolbar .drw-edit-btn:hover {
    background: #f0f3fa !important;
}

body[data-theme="light"] #drw-color-picker {
    background: #ffffff !important;
    border-color: #e0e3eb !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15) !important;
    color: #131722 !important;
}

/* Confirmation Alert Dialog Light Mode Overrides (Screenshot) */
body[data-theme="light"] .tv-confirm-overlay {
    background: rgba(0, 0, 0, 0.4) !important;
}

body[data-theme="light"] .tv-confirm-dialog {
    background: #ffffff !important;
    border: 1px solid #e0e3eb !important;
    color: #131722 !important;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.15), 0 4px 16px rgba(0, 0, 0, 0.08) !important;
}

body[data-theme="light"] .tv-confirm-title {
    color: #131722 !important;
}

body[data-theme="light"] .tv-confirm-msg {
    color: #434651 !important;
}

body[data-theme="light"] .tv-confirm-btn-cancel {
    background: #f0f3fa !important;
    border: 1px solid #e0e3eb !important;
    color: #131722 !important;
}

body[data-theme="light"] .tv-confirm-btn-cancel:hover {
    background: #e0e3eb !important;
    color: #131722 !important;
}

/* ── Icon / Sticker / Emoji Picker Popover Modal ─────────────────── */
.tv-icon-picker-modal {
    position: absolute;
    z-index: 1000;
    width: 340px;
    height: 420px;
    background: #1e222d;
    border: 1px solid #2a2e39;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color: #d1d4dc;
    font-family: -apple-system, BlinkMacSystemFont, "Trebuchet MS", Roboto, Ubuntu, sans-serif;
    font-size: 13px;
    user-select: none;
}

.tv-ip-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-bottom: 1px solid #2a2e39;
    background: #131722;
}

.tv-ip-cat-bar {
    display: flex;
    align-items: center;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
}
.tv-ip-cat-bar::-webkit-scrollbar { display: none; }

.tv-ip-cat-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 4px 6px;
    border-radius: 4px;
    transition: background 0.12s;
}
.tv-ip-cat-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.tv-ip-header-title {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #848e9c;
}

.tv-ip-close-btn {
    background: transparent;
    border: none;
    color: #848e9c;
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
}
.tv-ip-close-btn:hover {
    color: #f23645;
}

.tv-ip-body {
    flex: 1;
    overflow-y: auto;
    padding: 10px 12px;
    scrollbar-width: thin;
    scrollbar-color: #363a45 transparent;
}

.tv-ip-sec-title {
    font-size: 11px;
    font-weight: 700;
    color: #787b86;
    margin: 8px 0 6px 0;
    letter-spacing: 0.5px;
}
.tv-ip-sec-title:first-child {
    margin-top: 0;
}

.tv-ip-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
    margin-bottom: 10px;
}

.tv-ip-item {
    background: transparent;
    border: none;
    border-radius: 4px;
    font-size: 20px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.1s, background 0.12s;
    color: #d1d4dc;
}
.tv-ip-item:hover {
    background: rgba(255, 255, 255, 0.12);
    transform: scale(1.15);
}

.tv-ip-sticker-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 10px;
}

.tv-ip-sticker-item {
    background: #131722;
    border: 1px solid #2a2e39;
    border-radius: 6px;
    padding: 8px;
    height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.15s, border-color 0.15s, background 0.15s;
}
.tv-ip-sticker-item:hover {
    border-color: #2962ff;
    background: #1e222d;
    transform: translateY(-2px);
}
.tv-ip-sticker-item svg {
    width: 100%;
    height: 100%;
}

.tv-ip-footer {
    display: flex;
    border-top: 1px solid #2a2e39;
    background: #131722;
}

.tv-ip-tab-btn {
    flex: 1;
    padding: 10px 0;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: #787b86;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}
.tv-ip-tab-btn:hover {
    color: #d1d4dc;
}
.tv-ip-tab-btn.active {
    color: #2962ff;
    border-bottom-color: #2962ff;
}

/* Light Theme Overrides for Icon Picker Popover */
body[data-theme="light"] .tv-icon-picker-modal {
    background: #ffffff !important;
    border-color: #e0e3eb !important;
    color: #131722 !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15) !important;
}
body[data-theme="light"] .tv-ip-header,
body[data-theme="light"] .tv-ip-footer {
    background: #f8f9fd !important;
    border-color: #e0e3eb !important;
}
body[data-theme="light"] .tv-ip-sec-title,
body[data-theme="light"] .tv-ip-header-title {
    color: #787b86 !important;
}
body[data-theme="light"] .tv-ip-item {
    color: #131722 !important;
}
body[data-theme="light"] .tv-ip-item:hover {
    background: #f0f3fa !important;
}
body[data-theme="light"] .tv-ip-sticker-item {
    background: #f8f9fd !important;
    border-color: #e0e3eb !important;
}
body[data-theme="light"] .tv-ip-sticker-item:hover {
    background: #ffffff !important;
    border-color: #2962ff !important;
}
body[data-theme="light"] .tv-ip-tab-btn {
    color: #787b86 !important;
}
body[data-theme="light"] .tv-ip-tab-btn:hover {
    color: #131722 !important;
}
body[data-theme="light"] .tv-ip-tab-btn.active {
    color: #2962ff !important;
    border-bottom-color: #2962ff !important;
}
