/*
|--------------------------------------------------------------------------
| Chart Modal Shell
|--------------------------------------------------------------------------
| Shared modal surface, overlay, drag affordance, and compact list layout.
| Add new chart dialogs here instead of duplicating shell rules in theme.css.
|--------------------------------------------------------------------------
*/

.qt-modal-shell {
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    z-index: 50000 !important;
}

.qt-modal-card {
    border-radius: 8px !important;
    background: var(--symbol-modal-bg, var(--qt-surface, #ffffff)) !important;
    border: 1px solid var(--qt-border, var(--border-color, #d8dde6)) !important;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.32) !important;
}

.qt-modal-drag-handle {
    cursor: move;
    user-select: none;
}

.qt-modal-dragging {
    transition: none !important;
}

#symbol-search-modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: transparent;
    backdrop-filter: none;
    z-index: 5000;
}

#symbol-search-modal.open {
    display: flex;
}

body.qt-lang-rtl #symbol-search-modal {
    direction: ltr;
}

body[data-qt-language-direction="ltr"] #symbol-search-modal {
    direction: ltr !important;
    text-align: left;
}

body[data-qt-language-direction="rtl"] #symbol-search-modal {
    direction: rtl !important;
    text-align: right;
}

.symbol-search-box {
    width: min(840px, calc(100vw - 64px));
    max-width: calc(100vw - 64px);
    height: min(680px, calc(100vh - 96px));
    max-height: calc(100vh - 96px);
    border-radius: 8px;
    overflow: hidden;
    background: var(--symbol-modal-bg);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.22);
}

.symbol-search-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border-color);
}

.symbol-search-title {
    font-size: 16px;
    font-weight: 600;
}

.symbol-search-subtitle {
    margin-top: 4px;
    font-size: 12px;
    opacity: .7;
}

.symbol-search-close {
    width: 34px;
    height: 34px;
    border: 0;
    cursor: pointer;
    border-radius: 8px;
    background: transparent;
    color: inherit;
    font-size: 20px;
}

.symbol-search-close:hover {
    background: rgba(255,255,255,.08);
}

.symbol-search-input-wrap {
    padding: 16px;
}

#symbol-search-input {
    width: 100%;
    height: 44px;
    border-radius: 10px;
    border: 1px solid var(--qt-border);
    background: var(--qt-surface);
    color: var(--qt-text);
    padding: 0 14px;
    font-size: 14px;
    outline: none;
}

#symbol-search-input {
    border-color: var(--qt-border);
}

#symbol-search-input:focus {
    border-color: #111827;
    box-shadow: 0 0 0 1px #111827;
}

html.theme-dark #symbol-search-input:focus {
    border-color: #ffffff;
    box-shadow: 0 0 0 1px #ffffff;
}

.symbol-search-body {
    flex: 1;
    display: grid;
    grid-template-columns: 161px minmax(0, 1fr);
    min-height: 0;
    overflow: hidden;
    border-top: 1px solid var(--border-color);
}

.symbol-search-footer {
    flex: 0 0 40px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
    border-top: 1px solid var(--border-color);
    color: var(--qt-muted-text, #6b7280);
    background: var(--symbol-modal-bg);
    font-size: 12px;
    line-height: 1.2;
    text-align: center;
}

.symbol-search-categories {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 8px;
    border-right: 1px solid var(--border-color);
    background: rgba(100, 116, 139, 0.06);
}

.symbol-search-categories button {
    width: 100%;
    min-height: 34px;
    padding: 0 10px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: inherit;
    cursor: pointer;
    font: inherit;
    font-size: 13px;
    text-align: left;
}

.symbol-search-categories button:hover,
.symbol-search-categories button.active {
    background: rgba(100, 100, 100, .10);
}

.symbol-search-categories button.active {
    font-weight: 600;
}

.symbol-search-results {
    height: 100%;
    max-height: none;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.symbol-search-empty {
    padding: 40px;
    text-align: center;
    opacity: .6;
}

.symbol-search-row {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border: 0;
    background: transparent;
    cursor: pointer;
    color: inherit;
    text-align: left;
    border-top: 1px solid var(--border-color);
}

.symbol-search-row[hidden], .symbol-search-call-sign[hidden] { display: none; }

.symbol-search-row:focus-visible { outline: 2px solid currentColor; outline-offset: -2px; }

.symbol-search-row:hover {
    background: rgba(100,100,100,.08);
}

.symbol-search-row.disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.symbol-search-icons {
    width: 52px;
    display: flex;
    justify-content: center;
    gap: 2px;
    flex-shrink: 0;
}

.symbol-search-flag {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    overflow: hidden;
}

.symbol-search-flag img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.symbol-search-flag.is-missing {
    display: none;
}

.symbol-search-info {
    flex: 1;
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(90px, 140px) minmax(0, 1fr);
    align-items: center;
    gap: 12px;
}

.symbol-search-main {
    font-size: 14px;
    font-weight: 500;
    color: #2962ff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

html.theme-dark .symbol-search-main { color: #7199ff; }

.symbol-search-name {
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.symbol-search-call-sign {
    margin-top: 2px;
    color: var(--qt-muted-text, #64748b);
    font-size: 10px;
    line-height: 1.2;
}

.symbol-search-type {
    flex: 0 0 auto;
    max-width: 90px;
    text-align: right;
    color: var(--qt-muted-text, #64748b);
    font-size: 11px;
    text-transform: lowercase;
}

.symbol-search-provider {
    min-width: 104px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    font-size: 11px;
    text-transform: uppercase;
}

.symbol-search-provider-mark {
    order: 2;
    width: 20px;
    height: 20px;
    display: inline-grid;
    place-items: center;
    flex: 0 0 20px;
    border-radius: 50%;
    background: #172554;
    color: #fff;
    font-size: 10px;
    font-weight: 800;
}

.symbol-search-provider-mark[data-provider-logo="oanda"] { background: #e02424; }
.symbol-search-provider-mark[data-provider-logo="binance"] { background: #f0b90b; color: #171717; }

.symbol-search-contract-toggle {
    display: inline-grid;
    place-items: center;
    width: 20px;
    height: 20px;
    margin-left: 5px;
    border-radius: 4px;
    color: var(--qt-muted-text, #64748b);
    vertical-align: middle;
}

.symbol-search-contract-toggle:hover { background: rgba(100, 116, 139, .14); }
.symbol-search-contract-child { padding-left: 38px; }

@media (max-width: 640px) {
    .symbol-search-info { grid-template-columns: minmax(64px, 90px) minmax(0, 1fr); gap: 8px; }
    .symbol-search-type { max-width: 55px; font-size: 10px; }
    .symbol-search-provider { min-width: 0; max-width: 90px; font-size: 10px; }
    .symbol-search-provider-mark { display: none; }
    .symbol-search-icons { width: 24px; }
    .symbol-search-row { gap: 6px; padding: 8px; }
}

@media (max-width: 640px) {
    .symbol-search-box {
        width: calc(100vw - 24px);
        max-width: calc(100vw - 24px);
        height: calc(100vh - 24px);
        max-height: calc(100vh - 24px);
    }

    .symbol-search-body {
        grid-template-columns: 1fr;
        min-height: 0;
    }

    .symbol-search-categories {
        flex-direction: row;
        overflow-x: auto;
        border-right: 0;
        border-bottom: 1px solid var(--border-color);
    }

    .symbol-search-categories button {
        width: auto;
        flex: 0 0 auto;
        white-space: nowrap;
    }
}

#symbol-search-modal {
    align-items: center !important;
    justify-content: center !important;
}

.symbol-search-box {
    width: min(840px, calc(100vw - 48px)) !important;
    max-width: calc(100vw - 48px) !important;
    max-height: calc(100vh - 48px);
    display: flex;
    flex-direction: column;
}

.symbol-search-header {
    min-height: 58px;
    padding: 0 18px !important;
    flex-shrink: 0;
}

.symbol-search-subtitle {
    display: none;
}

.symbol-search-input-wrap {
    padding: 12px 16px !important;
    flex-shrink: 0;
}

#symbol-search-input {
    height: 38px !important;
    border-radius: 8px !important;
}

.symbol-search-body {
    min-height: 0;
    display: grid;
    grid-template-columns: 132px minmax(0, 1fr);
    border-top: 1px solid var(--qt-border, var(--border-color, #e5e7eb));
    overflow: hidden;
}

.symbol-search-categories {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px;
    border-right: 1px solid var(--qt-border, var(--border-color, #e5e7eb));
    overflow-y: auto;
}

.symbol-search-categories button {
    width: 100%;
    min-height: 32px;
    border: 0;
    border-radius: 7px;
    padding: 0 10px;
    background: transparent;
    color: var(--qt-text, inherit);
    cursor: pointer;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
}

.symbol-search-categories button:hover {
    background: rgba(100, 116, 139, 0.10);
}

.symbol-search-categories button.active {
    background: var(--qt-text, #111827);
    color: var(--qt-surface, #ffffff);
}

.symbol-search-results {
    max-height: min(520px, calc(100vh - 190px)) !important;
    scrollbar-width: thin !important;
    scrollbar-color: rgba(100, 116, 139, 0.36) transparent !important;
}

.symbol-search-results::-webkit-scrollbar {
    width: 4px !important;
    height: 4px !important;
}

.symbol-search-results::-webkit-scrollbar-track {
    background: transparent !important;
}

.symbol-search-results::-webkit-scrollbar-thumb {
    border: 0 !important;
    border-radius: 999px !important;
    background: rgba(100, 116, 139, 0.36) !important;
}

body.theme-dark .symbol-search-results,
html.theme-dark .symbol-search-results {
    scrollbar-color: rgba(148, 163, 184, 0.48) transparent !important;
}

body.theme-dark .symbol-search-results::-webkit-scrollbar-thumb,
html.theme-dark .symbol-search-results::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.48) !important;
}

.symbol-search-row {
    min-height: 40px;
    padding: 8px 12px !important;
}

/* Watchlist add mode reuses the same symbol picker. The plus action is
   intentionally scoped to symbol-search-modal so the normal header symbol
   switcher keeps its original row-click behavior. */
.symbol-search-modal[data-symbol-search-mode="watchlist-add"] .symbol-search-row {
    padding-right: 8px !important;
}

.symbol-search-watchlist-add {
    flex: 0 0 auto;
    display: inline-grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 999px;
    margin-left: 4px;
    border: 1px solid transparent;
    color: var(--qt-text, #111827);
    font-size: 22px;
    font-weight: 300;
    line-height: 1;
}

.symbol-search-watchlist-add:hover {
    border-color: var(--qt-border, #d1d5db);
    background: rgba(41, 98, 255, 0.10);
}

.symbol-search-row.is-added-to-watchlist .symbol-search-watchlist-add {
    color: #00a98f;
}

#chart-viewport-wrapper.chart-soft-loading canvas {
    filter: none !important;
    opacity: .72 !important;
    transition: opacity .12s ease !important;
}

@media (max-width: 720px) {
    .symbol-search-box {
        width: calc(100vw - 24px) !important;
        max-width: calc(100vw - 24px) !important;
    }

    .symbol-search-body {
        grid-template-columns: 1fr;
    }

    .symbol-search-categories {
        flex-direction: row;
        border-right: 0;
        border-bottom: 1px solid var(--qt-border, var(--border-color, #e5e7eb));
        overflow-x: auto;
    }

    .symbol-search-categories button {
        width: auto;
        white-space: nowrap;
    }
}

/* Watchlist symbol-add mode: keep the shared Symbol Search modal intact, but
   expose a clear SVG plus action at the end of every enabled symbol row. */
.symbol-search-watchlist-add svg {
    width: 18px;
    height: 18px;
    display: block;
    pointer-events: none;
}

.symbol-search-modal[data-symbol-search-mode="watchlist-add"] .symbol-search-row:not(.disabled) {
    cursor: default;
}

.symbol-search-modal[data-symbol-search-mode="watchlist-add"] .symbol-search-watchlist-add {
    cursor: pointer;
}


/* Watchlist UI final: delayed/provider-delayed symbols remain visible in the shared
   symbol picker, but the Watchlist add action is blocked so delayed feeds do not
   enter saved watchlists. */
.symbol-search-modal[data-symbol-search-mode="watchlist-add"] .symbol-search-row.is-watchlist-delayed-blocked .symbol-search-watchlist-add,
.symbol-search-modal[data-symbol-search-mode="watchlist-add"] .symbol-search-watchlist-add.is-blocked {
    opacity: 0.38;
    cursor: not-allowed;
}

.symbol-search-modal[data-symbol-search-mode="watchlist-add"] .symbol-search-row.is-watchlist-delayed-blocked .symbol-search-watchlist-add:hover,
.symbol-search-modal[data-symbol-search-mode="watchlist-add"] .symbol-search-watchlist-add.is-blocked:hover {
    border-color: transparent;
    background: transparent;
}

/* TradingView-faithful Watchlist Add Symbol layout. This is deliberately
   mode-scoped so the canonical chart symbol switcher keeps its own layout. */
.symbol-search-modal[data-symbol-search-mode="watchlist-add"] .symbol-search-header {
    min-height: 63px;
}

.symbol-search-modal[data-symbol-search-mode="watchlist-add"] .symbol-search-close {
    display: inline-grid;
    place-items: center;
    padding: 0;
}

.symbol-search-modal[data-symbol-search-mode="watchlist-add"] .symbol-search-close svg {
    display: block;
    width: 28px;
    height: 28px;
}

.symbol-search-modal[data-symbol-search-mode="watchlist-add"] .symbol-search-input-wrap {
    padding: 12px 28px 12px 56px !important;
}

.symbol-search-modal[data-symbol-search-mode="watchlist-add"] #symbol-search-input {
    height: 24px !important;
    border: 0;
    border-radius: 0 !important;
    padding: 0;
    font-size: 18px;
}

.symbol-search-modal[data-symbol-search-mode="watchlist-add"] #symbol-search-input:focus {
    border: 0;
    box-shadow: none;
}

.symbol-search-modal[data-symbol-search-mode="watchlist-add"] .symbol-search-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 48px minmax(0, 1fr);
}

.symbol-search-modal[data-symbol-search-mode="watchlist-add"] .symbol-search-categories {
    min-width: 0;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    padding: 12px 18px 8px;
    border-right: 0;
    border-bottom: 1px solid var(--qt-border, var(--border-color, #e5e7eb));
    background: transparent;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
}

.symbol-search-modal[data-symbol-search-mode="watchlist-add"] .symbol-search-categories::-webkit-scrollbar {
    display: none;
}

.symbol-search-modal[data-symbol-search-mode="watchlist-add"] .symbol-search-categories button {
    width: auto;
    min-width: auto;
    min-height: 28px;
    height: 28px;
    flex: 0 0 auto;
    padding: 0 10px;
    border-radius: 14px;
    font-size: 13px;
    font-weight: 400;
    white-space: nowrap;
    text-align: center;
}

.symbol-search-modal[data-symbol-search-mode="watchlist-add"] .symbol-search-categories button.active {
    background: rgba(41, 98, 255, .12);
    color: #2962ff;
    font-weight: 500;
}

.symbol-search-modal[data-symbol-search-mode="watchlist-add"] .symbol-search-results {
    max-height: none !important;
}

.symbol-search-modal[data-symbol-search-mode="watchlist-add"] .symbol-search-row {
    min-height: 40px;
    height: 40px;
    gap: 8px;
    padding: 5px 18px !important;
}

.symbol-search-modal[data-symbol-search-mode="watchlist-add"] .symbol-search-icons {
    width: 34px;
}

.symbol-search-modal[data-symbol-search-mode="watchlist-add"] .symbol-search-main {
    font-size: 14px;
}

.symbol-search-modal[data-symbol-search-mode="watchlist-add"] .symbol-search-name {
    font-size: 11px;
}
