/* TradingView Watchlist - Custom Implementation
 * Extracted from TradingView.com using MCP on Sep 20, 2026
 * Font: -apple-system, BlinkMacSystemFont, "Trebuchet MS", Roboto, Ubuntu, sans-serif
 */

/* Container - Lives inside right toolbar panel */
.custom-watchlist {
    width: 100%;
    height: 100%;
    background: #ffffff;
    border-left: 1px solid #e0e3eb;
    font-family: -apple-system, BlinkMacSystemFont, "Trebuchet MS", Roboto, Ubuntu, sans-serif;
    color: #0f0f0f;
    display: flex;
    flex-direction: column;
    box-shadow: -2px 0 8px rgba(0,0,0,0.05);
    min-width: 415px; /* TradingView exact width */
}

/* Dark mode support */
.custom-watchlist.dark-mode {
    background: #1e222d;
    color: #d1d4dc;
    border-left-color: #2a2e39;
}

/* Header */
.custom-watchlist-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #e0e3eb;
    min-height: 48px;
}

.dark-mode .custom-watchlist-header {
    border-bottom-color: #2a2e39;
}

.custom-watchlist-title {
    font-size: 16px;
    font-weight: 600;
    color: #131722;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dark-mode .custom-watchlist-title {
    color: #d1d4dc;
}

.custom-watchlist-actions {
    display: flex;
    gap: 0;
}

.custom-watchlist-btn {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.15s;
}

.custom-watchlist-btn:hover {
    background: #f0f3fa;
}

.dark-mode .custom-watchlist-btn:hover {
    background: #2a2e39;
}

.custom-watchlist-btn svg {
    width: 28px;
    height: 28px;
    fill: #131722;
}

.dark-mode .custom-watchlist-btn svg {
    fill: #d1d4dc;
}

/* Table Header */
.custom-watchlist-table-header {
    display: grid;
    grid-template-columns: 16px minmax(120px, 3fr) 70px 60px 65px 24px;
    align-items: center;
    padding: 8px 16px;
    background: #f7f8fa;
    border-bottom: 1px solid #e0e3eb;
    font-size: 12px;
    font-weight: 600;
    color: #787b86;
    user-select: none;
    column-gap: 12px;
}

.dark-mode .custom-watchlist-table-header {
    background: #1e222d;
    border-bottom-color: #2a2e39;
    color: #787b86;
}

.custom-watchlist-col-symbol {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    min-width: 0;
    overflow: hidden;
}

.custom-watchlist-col-last {
    text-align: right;
    cursor: pointer;
    justify-self: end;
    white-space: nowrap;
}

.custom-watchlist-col-change {
    text-align: right;
    cursor: pointer;
    justify-self: end;
    white-space: nowrap;
}

.custom-watchlist-col-percent {
    text-align: right;
    cursor: pointer;
    justify-self: end;
    white-space: nowrap;
}

.sort-arrow {
    width: 18px;
    height: 18px;
    opacity: 0.5;
    transition: opacity 0.15s, transform 0.15s;
}

.sort-arrow.active {
    opacity: 1;
}

.sort-arrow.desc {
    transform: rotate(180deg);
}

/* Scrollable Content */
.custom-watchlist-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.custom-watchlist-content::-webkit-scrollbar {
    width: 6px;
}

.custom-watchlist-content::-webkit-scrollbar-track {
    background: transparent;
}

.custom-watchlist-content::-webkit-scrollbar-thumb {
    background: #c1c4cd;
    border-radius: 3px;
}

.dark-mode .custom-watchlist-content::-webkit-scrollbar-thumb {
    background: #434651;
}

/* Section Headers */
.custom-watchlist-section {
    padding: 12px 16px 6px;
    font-size: 12px;
    font-weight: 600;
    color: #787b86;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.custom-watchlist-section:hover {
    background: #f7f8fa;
}

.dark-mode .custom-watchlist-section:hover {
    background: #2a2e39;
}

.section-expand-icon {
    width: 18px;
    height: 18px;
    transition: transform 0.15s;
}

.section-expand-icon.collapsed {
    transform: rotate(-90deg);
}

/* Symbol Rows */
.custom-watchlist-row {
    display: grid;
    grid-template-columns: 16px minmax(120px, 3fr) 70px 60px 65px 24px;
    align-items: center;
    padding: 5px 16px;
    min-height: 31px;
    cursor: default;
    transition: background 0.15s;
    border-bottom: 1px solid transparent;
    position: relative;
    column-gap: 12px;
    will-change: auto;
}

.custom-watchlist-row:hover {
    background: #f0f3fa;
    cursor: pointer;
}

.dark-mode .custom-watchlist-row:hover {
    background: #2a2e39;
}

.custom-watchlist-row.active {
    background: #e3f2fd;
}

.dark-mode .custom-watchlist-row.active {
    background: #1e2a3a;
}

/* Prevent layout shift during drag */
.custom-watchlist-row.dragging {
    opacity: 0.5;
    background: #f0f3fa;
    will-change: transform;
}

.dark-mode .custom-watchlist-row.dragging {
    background: #2a2e39;
}

/* Drag Handle */
.custom-watchlist-drag-handle {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    opacity: 0;
    transition: opacity 0.15s;
}

.custom-watchlist-row:hover .custom-watchlist-drag-handle {
    opacity: 0.5;
}

.custom-watchlist-drag-handle:hover {
    opacity: 1 !important;
}

.custom-watchlist-drag-handle svg {
    width: 16px;
    height: 16px;
    fill: #787b86;
}

/* Symbol Column */
.custom-watchlist-symbol {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    overflow: hidden;
}

.dark-mode .custom-watchlist-symbol {
    /* No specific dark mode styles needed */
}

.symbol-icon {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Trebuchet MS', Roboto, Ubuntu, sans-serif;
    overflow: hidden;
}

/* Letter-based icons */
.symbol-icon-letter {
    background-color: #EBEBEB;
    color: #131722;
}

/* Image-based icons (single logo) */
.symbol-icon-image {
    background-color: transparent;
    padding: 0;
}

.symbol-icon-image img {
    width: 18px;
    height: 18px;
    object-fit: contain;
    display: block;
}

/* Forex pair icons (two flags) */
.symbol-icon-pair {
    position: relative;
    background-color: transparent;
    padding: 0;
}

.pair-flag {
    width: 12px;
    height: 12px;
    object-fit: contain;
    display: block;
    position: absolute;
}

.pair-flag-left {
    left: 6px;
    top: 0px;
    z-index: 1;
}

.pair-flag-right {
    left: 0px;
    top: 6px;
    z-index: 2;
}

.symbol-name {
    font-size: 13px;
    font-weight: 500;
    color: #131722;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dark-mode .symbol-name {
    color: #d1d4dc;
}

.symbol-status {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin-left: 4px;
    flex-shrink: 0;
}

.symbol-status.open {
    background: #26a69a;
}

.symbol-status.closed {
    background: #787b86;
}

/* Price Columns */
.custom-watchlist-price,
.custom-watchlist-change,
.custom-watchlist-percent {
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
    text-align: right;
    justify-self: end;
    white-space: nowrap;
    overflow: hidden;
}

.custom-watchlist-price {
    font-weight: 600;
    color: #131722;
}

.dark-mode .custom-watchlist-price {
    color: #d1d4dc;
}

.custom-watchlist-change {
    font-weight: 500;
}

.custom-watchlist-percent {
    font-weight: 500;
}

/* Remove Button */
.custom-watchlist-remove-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    cursor: pointer;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s;
    justify-self: center;
}

.custom-watchlist-row:hover .custom-watchlist-remove-btn {
    opacity: 1;
}

.custom-watchlist-remove-btn:hover {
    background: #f0f3fa;
}

.dark-mode .custom-watchlist-remove-btn:hover {
    background: #434651;
}

.custom-watchlist-remove-btn svg {
    width: 18px;
    height: 18px;
    fill: #787b86;
}

.custom-watchlist-remove-btn:hover svg {
    fill: #ef5350;
}

.dark-mode .custom-watchlist-remove-btn:hover svg {
    fill: #f23645;
}

/* Positive/Negative Colors */
.positive {
    color: #26a69a !important;
}

.negative {
    color: #ef5350 !important;
}

.dark-mode .positive {
    color: #26a69a !important;
}

.dark-mode .negative {
    color: #f23645 !important;
}

/* Empty State */
.custom-watchlist-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
    color: #787b86;
}

.custom-watchlist-empty svg {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.custom-watchlist-empty-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
}

.custom-watchlist-empty-text {
    font-size: 13px;
    line-height: 1.5;
}

/* Add Symbol Modal */
.custom-watchlist-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(19, 23, 34, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.custom-watchlist-modal-content {
    background: white;
    border-radius: 8px;
    width: 400px;
    max-width: 90vw;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    overflow: hidden;
}

.dark-mode .custom-watchlist-modal-content {
    background: #1e222d;
}

.custom-watchlist-modal-header {
    padding: 16px 48px 8px 16px;
    border-bottom: 1px solid #e0e3eb;
    position: relative;
}

.dark-mode .custom-watchlist-modal-header {
    border-bottom-color: #2a2e39;
}

.custom-watchlist-modal-title {
    font-size: 16px;
    font-weight: 600;
    color: #131722;
}

.dark-mode .custom-watchlist-modal-title {
    color: #d1d4dc;
}

.custom-watchlist-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.15s;
}

.custom-watchlist-modal-close:hover {
    background: #f0f3fa;
}

.dark-mode .custom-watchlist-modal-close:hover {
    background: #2a2e39;
}

.custom-watchlist-modal-body {
    padding: 16px;
}

.custom-watchlist-search {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e0e3eb;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
}

.custom-watchlist-search:focus {
    border-color: #2962ff;
}

.dark-mode .custom-watchlist-search {
    background: #2a2e39;
    border-color: #434651;
    color: #d1d4dc;
}

.custom-watchlist-search-results {
    margin-top: 12px;
    max-height: 300px;
    overflow-y: auto;
}

.custom-watchlist-search-result {
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.15s;
}

.custom-watchlist-search-result:hover {
    background: #f0f3fa;
}

.dark-mode .custom-watchlist-search-result:hover {
    background: #2a2e39;
}

.search-result-info {
    flex: 1;
    min-width: 0;
}

.search-result-symbol {
    font-size: 14px;
    font-weight: 600;
    color: #131722;
}

.dark-mode .search-result-symbol {
    color: #d1d4dc;
}

.search-result-name {
    font-size: 12px;
    color: #787b86;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Loading State */
.custom-watchlist-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
}

.custom-watchlist-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e0e3eb;
    border-top-color: #2962ff;
    border-radius: 50%;
    animation: watchlist-spin 0.8s linear infinite;
}

@keyframes watchlist-spin {
    to { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 768px) {
    .custom-watchlist {
        width: 100%;
        max-width: 320px;
    }
}


/* Drag Handle */
.custom-watchlist-drag-handle {
    width: 24px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    opacity: 0;
    transition: opacity 0.15s;
    flex-shrink: 0;
    user-select: none;
}

.custom-watchlist-drag-handle:active {
    cursor: grabbing;
}

.custom-watchlist-row:hover .custom-watchlist-drag-handle {
    opacity: 0.5;
}

.custom-watchlist-drag-handle:hover {
    opacity: 1 !important;
}

.custom-watchlist-drag-handle svg {
    fill: #131722;
    pointer-events: none;
    width: 16px;
    height: 16px;
}

.custom-watchlist-drag-handle * {
    pointer-events: none;
}

.dark-mode .custom-watchlist-drag-handle svg {
    fill: #787b86;
}

/* Symbol Info (ticker + description) */
.symbol-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.symbol-name {
    font-size: 13px;
    font-weight: 500;
    color: #131722;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.symbol-description {
    font-size: 11px;
    color: #787b86;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dark-mode .symbol-name {
    color: #d1d4dc;
}

/* Row already defined above with grid layout - removed duplicate conflicting flex layout */

/* Row already defined above with grid layout - removed duplicate conflicting flex layout */
