/* Watchlist Add Modal - Sidebar Style (не блокирует контент) */
#watchlistAddModal {
    position: fixed;
    top: 0;
    right: 0;
    width: auto;
    height: 100vh;
    z-index: 11000;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    pointer-events: none; /* Пропускает клики к контенту */
}

#watchlistAddModal.hidden {
    display: none !important;
}

#watchlistAddModal .modal-overlay {
    display: none; /* Убираем overlay */
}

#watchlistAddModal .modal-content {
    pointer-events: auto; /* Модалка кликабельна */
    margin: 20px;
    max-width: 340px;
    width: 340px;
    max-height: calc(100vh - 40px);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.5);
    animation: slideInRight 0.25s ease;
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.watchlist-add-modal .modal-body {
    padding: 0 24px 20px;
}

.watchlist-add-modal .form-group {
    margin-bottom: 16px;
}

.watchlist-add-modal .form-label {
    display: block;
    color: #888;
    font-size: 12px;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.watchlist-add-modal .form-input {
    width: 100%;
    background: #252522;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 12px 16px;
    color: #e3e3e3;
    font-size: 14px;
    box-sizing: border-box;
}

.watchlist-add-modal .form-input:focus {
    outline: none;
    border-color: #7CC3E4;
}

.watchlist-notes-input {
    resize: vertical;
    min-height: 80px;
    max-height: 150px;
    font-family: inherit;
    line-height: 1.4;
}

.watchlist-notes-counter {
    text-align: right;
    color: #666;
    font-size: 11px;
    margin-top: 4px;
}

/* ==================== WATCHLIST SECTION ==================== */

.watchlist-section {
    display: none;
    flex-direction: column;
    height: 100%;
    padding: 20px 40px;
    overflow-y: auto;
    background: #1F1F1B;
}

.watchlist-section.active {
    display: flex;
}

/* Контейнер как в Stocks */
.watchlist-container {
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.watchlist-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.watchlist-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: #e3e3e3;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Кнопка Add Ticker */
.watchlist-add-btn {
    padding: 8px 14px;
    border: 1px solid #caa999;
    background: #1a1a1a;
    color: #caa999;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.watchlist-add-btn:hover {
    background: #252525;
    color: #e0c5b0;
    border-color: #e0c5b0;
}

.watchlist-sort-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

.watchlist-sort-label {
    color: #888;
    font-size: 13px;
}

.watchlist-sort-btn {
    padding: 8px 14px;
    border: 1px solid #444;
    background: #1a1a1a;
    color: #999;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 400;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.watchlist-sort-btn:hover {
    background: #252525;
    color: #ccc;
    border-color: #555;
}

.watchlist-sort-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 6px;
    overflow: hidden;
    z-index: 100;
    min-width: 120px;
}

.watchlist-sort-dropdown.open {
    display: block;
}

.watchlist-sort-option {
    padding: 8px 14px;
    color: #ccc;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s;
}

.watchlist-sort-option:hover {
    background: #252525;
    color: #fff;
}

.watchlist-sort-option.active {
    color: #caa999;
}

/* Таблица-обёртка как в Stocks */
.watchlist-table-wrapper {
    background: #252522;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #333;
}

.watchlist-table {
    width: 100%;
    border-collapse: collapse;
}

.watchlist-table th {
    padding: 14px 16px;
    text-align: left;
    color: #888;
    font-weight: 500;
    font-size: 12px;
    text-transform: uppercase;
    background: #252522;
    border-bottom: 1px solid #333;
    white-space: nowrap;
}

.watchlist-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #2a2a2a;
    font-size: 14px;
}

.watchlist-table tbody tr {
    cursor: pointer;
    transition: background 0.15s;
}

.watchlist-table tbody tr:hover {
    background: rgba(124, 195, 228, 0.05);
}

.watchlist-table tbody tr:last-child td {
    border-bottom: none;
}

/* Колонки: ★ | Asset | Target | Price | Gap to Goal | 24h% | Notes | Alert */
.watchlist-table th:nth-child(1),
.watchlist-table td:nth-child(1) { width: 5%; text-align: center; }  /* Star */

.watchlist-table th:nth-child(2),
.watchlist-table td:nth-child(2) { width: 28%; }  /* Asset */

.watchlist-table th:nth-child(3),
.watchlist-table td:nth-child(3) { width: 12%; }  /* Target */

.watchlist-table th:nth-child(4),
.watchlist-table td:nth-child(4) { width: 11%; text-align: right; }  /* Price */

.watchlist-table th:nth-child(5),
.watchlist-table td:nth-child(5) { width: 14%; text-align: right; }  /* Gap to Goal */

.watchlist-table th:nth-child(6),
.watchlist-table td:nth-child(6) { width: 10%; text-align: right; }  /* 24h % */

.watchlist-table th:nth-child(7),
.watchlist-table td:nth-child(7) { width: 7%; text-align: center; }  /* Notes */

.watchlist-table th:nth-child(8),
.watchlist-table td:nth-child(8) { width: 8%; text-align: center; }  /* Alert */

/* Asset cell с логотипом */
.watchlist-asset {
    display: flex;
    align-items: center;
    gap: 12px;
}

.watchlist-logo {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    background: #333;
}

.watchlist-ticker {
    font-weight: 600;
    color: #e3e3e3;
}

.watchlist-company {
    font-size: 12px;
    color: #888;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Звёздочка кликабельная */
.watchlist-table td.watchlist-star-cell {
    color: #caa999;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s;
    text-shadow: 0 0 2px #caa999;
}

.watchlist-star-cell:hover {
    transform: scale(1.1);
    text-shadow: 0 0 4px #caa999;
}

/* Note tooltip on hover */
.watchlist-note-cell {
    position: relative;
}

.watchlist-note-tooltip {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    background: #1a1a1a;
    border: 1px solid #3a3a3a;
    border-radius: 8px;
    padding: 10px 12px;
    color: #ddd;
    font-size: 12px;
    line-height: 1.5;
    max-width: 280px;
    min-width: 160px;
    width: max-content;
    z-index: 100;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    white-space: pre-wrap;
    word-wrap: break-word;
    pointer-events: none;
}

.watchlist-note-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    right: 12px;
    border: 6px solid transparent;
    border-top-color: #3a3a3a;
}

/* Tooltip below (for top rows) */
.watchlist-note-tooltip.tooltip-below {
    bottom: auto;
    top: calc(100% + 8px);
}

.watchlist-note-tooltip.tooltip-below::after {
    top: auto;
    bottom: 100%;
    border-top-color: transparent;
    border-bottom-color: #3a3a3a;
}

.watchlist-table tr:hover .watchlist-note-tooltip {
    display: block;
}

/* Price styling */
.watchlist-price {
    font-weight: 500;
    color: #e3e3e3;
}

/* Change percent */
.watchlist-change {
    font-weight: 500;
}

.watchlist-change.positive {
    color: #4CAF50;
}

.watchlist-change.negative {
    color: #f44336;
}

/* Target/Stop inputs */
.watchlist-target-input {
    background: #1a1a1a;
    border: 1px solid #333;
    color: #e3e3e3;
    padding: 6px 10px;
    border-radius: 6px;
    width: 90px;
    font-size: 13px;
    transition: all 0.2s;
}

.watchlist-target-input:hover {
    border-color: #444;
}

.watchlist-target-input:focus {
    outline: none;
    border-color: #7CC3E4;
    background: rgba(124, 195, 228, 0.1);
}

.watchlist-target-input::placeholder {
    color: #555;
    font-size: 12px;
}

.watchlist-target-input.reached {
    border-color: #555;
    color: #e3e3e3;
}

.watchlist-target-input.triggered {
    border-color: #f44336;
    color: #f44336;
}

/* Alert toggle */
.watchlist-alert-toggle {
    cursor: pointer;
    font-size: 18px;
    transition: transform 0.2s;
    user-select: none;
}

.watchlist-alert-toggle:hover {
    transform: scale(1.15);
}

/* Empty state */
.watchlist-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    color: #666;
}

.watchlist-empty svg {
    width: 48px;
    height: 48px;
    margin-bottom: 16px;
    opacity: 0.4;
}

.watchlist-empty p {
    font-size: 14px;
    margin: 4px 0;
}

/* Toast notifications */
.watchlist-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #252522;
    border: 1px solid #7CC3E4;
    border-radius: 8px;
    padding: 14px 18px;
    color: #e3e3e3;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    z-index: 10000;
    animation: toastSlide 0.3s ease;
    max-width: 320px;
}

.watchlist-toast.target {
    border-color: #4CAF50;
}

.watchlist-toast.stop {
    border-color: #f44336;
}

@keyframes toastSlide {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.toast-close {
    position: absolute;
    top: 6px;
    right: 8px;
    background: transparent;
    border: none;
    color: #666;
    cursor: pointer;
    font-size: 16px;
}

.toast-close:hover {
    color: #999;
}

th.asset-col,
td.asset-col {
    width: 280px;
    overflow: hidden;
}

th.price-col,
td.price-col {
    width: 110px;
    text-align: right;
}

th.change-24h-col,
td.change-24h-col {
    width: 80px;
    text-align: right;
}

th.change-7d-col,
td.change-7d-col {
    width: 80px;
    text-align: right;
}

th.market-cap-col,
td.market-cap-col {
    width: 100px;
    text-align: right;
}

th.volume-col,
td.volume-col {
    width: 90px;
    text-align: right;
}

th.chart-col,
td.chart-col {
    width: 130px;
    text-align: center;
    padding: 4px 8px;
}

.sparkline-loading {
    color: #666;
    font-size: 10px;
}

td.chart-col svg {
    display: block;
    margin: 0 auto;
}

/* Stock row asset cell */
.stock-asset {
    display: flex;
    align-items: center;
    gap: 12px;
}

.stock-logo {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #2a2a2a;
    flex-shrink: 0;
}

.stock-details {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.stock-ticker {
    color: #e3e3e3;
    font-weight: 500;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.exchange-badge {
    background: rgba(124, 195, 228, 0.15);
    color: #7CC3E4;
    font-size: 10px;
    font-weight: 500;
    padding: 2px 5px;
    border-radius: 3px;
    text-transform: uppercase;
}

.stock-company {
    color: #999;
    font-size: 12px;
    margin-top: 0px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 200px;
}

.table-price {
    color: #e3e3e3;
    font-weight: 500;
    font-size: 15px;
    white-space: nowrap;
}

.stock-change {
    font-size: 14px;
    font-weight: 500;
}

.stock-change.positive {
    color: #7CC3E4;
}

.stock-change.negative {
    color: #FF6B6B;
}

.market-cap-col, .volume-col {
    font-size: 14px;
    color: #e3e3e3;
}

.stocks-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: #121212;
    border-top: 1px solid #2a2a2a;
}

/* Stocks/ETFs Scroll Buttons */
.table-scroll-buttons {
    position: fixed;
    right: 30px;
    bottom: 100px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 1000;
}

.table-scroll-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #1a1a1a;
    border: 1px solid #444;
    color: #caa999;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.2s, color 0.2s;
}

.table-scroll-btn:hover {
    border-color: #caa999;
    color: #fff;
}

.pagination-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.page-btn {
    padding: 8px 14px;
    border: 1px solid #333;
    background: #111;
    color: #888;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
}

.page-btn:hover {
    border-color: #444;
    color: #aaa;
}

.page-btn.active {
    border-color: #caa999;
    background: #1a1a1a;
    color: #caa999;
}

.page-btn:disabled {
    background: #0a0a0a;
    border-color: #222;
    color: #555;
    cursor: not-allowed;
}

.page-dots {
    color: #666;
    padding: 0 8px;
}

.pagination-info {
    color: #999;
    font-size: 14px;
}
