/* ============================================
   WATCHLIST SYSTEM STYLES
   Complete styling for side panel and dashboard
   ============================================ */

/* Watchlist Side Panel - 1/4 Screen Width */
.watchlist-panel {
    position: fixed;
    top: 0;
    right: -28%;
    width: 25%;
    min-width: 320px;
    max-width: 450px;
    height: 100vh;
    background: var(--bg-primary);
    border-left: 1px solid var(--border-primary);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.watchlist-panel.active {
    right: 0;
}

/* Watchlist Header */
.watchlist-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 1.25rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-primary);
    flex-shrink: 0;
}

.watchlist-header h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-white);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.watchlist-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s;
}

.watchlist-close:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-white);
}

/* Watchlist List Container */
.watchlist-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.5rem 0;
}

.watchlist-list::-webkit-scrollbar {
    width: 8px;
}

.watchlist-list::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

.watchlist-list::-webkit-scrollbar-thumb {
    background: var(--border-secondary);
    border-radius: 4px;
}

.watchlist-list::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* Watchlist Category */
.watchlist-category {
    margin-bottom: 1rem;
}

.watchlist-category-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-primary);
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    position: sticky;
    top: 0;
    z-index: 10;
}

.watchlist-category-header i {
    font-size: 12px;
}

.watchlist-category-count {
    margin-left: auto;
    background: rgba(41, 98, 255, 0.2);
    color: var(--accent-primary);
    padding: 0.125rem 0.5rem;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
}

.watchlist-category-items {
    background: var(--bg-primary);
}

/* Watchlist Item */
.watchlist-item {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-primary);
    cursor: pointer;
    transition: background 0.15s;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.watchlist-item:hover {
    background: var(--bg-tertiary);
}

.watchlist-item-main {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
}

.watchlist-item-info {
    flex: 1;
    min-width: 0;
}

.watchlist-item-symbol {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-white);
    font-family: 'Courier New', monospace;
    margin-bottom: 0.25rem;
}

.watchlist-item-name {
    font-size: 12px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.watchlist-item-remove {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: all 0.2s;
    font-size: 14px;
    flex-shrink: 0;
}

.watchlist-item-remove:hover {
    background: rgba(239, 68, 68, 0.2);
    color: var(--red);
}

.watchlist-item-price {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.watchlist-price-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-white);
    font-family: 'Courier New', monospace;
}

.watchlist-price-change {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 14px;
    font-weight: 600;
    padding: 0.25rem 0.625rem;
    border-radius: 6px;
}

.watchlist-price-change.positive {
    background: rgba(16, 185, 129, 0.15);
    color: var(--green);
}

.watchlist-price-change.negative {
    background: rgba(239, 68, 68, 0.15);
    color: var(--red);
}

.watchlist-price-loading {
    color: var(--text-tertiary);
    font-size: 14px;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 400px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-secondary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    color: var(--text-white);
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast i {
    font-size: 18px;
    flex-shrink: 0;
}

.toast-success {
    border-left: 3px solid var(--green);
}

.toast-success i {
    color: var(--green);
}

.toast-error {
    border-left: 3px solid var(--red);
}

.toast-error i {
    color: var(--red);
}

.toast-info {
    border-left: 3px solid var(--accent-primary);
}

.toast-info i {
    color: var(--accent-primary);
}

/* Dashboard Watchlist Section */
#dashboard-watchlist-toggle {
    cursor: pointer;
    user-select: none;
}

#dashboard-watchlist-toggle:hover {
    background: var(--bg-tertiary) !important;
}

#dashboard-watchlist-content {
    margin-top: 1rem;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .watchlist-panel {
        position: fixed !important;
        top: 0 !important;
        right: -100% !important;
        width: 90% !important;
        max-width: none !important;
        height: 100vh !important;
        z-index: 2000 !important;
        background: var(--bg-primary) !important;
        border-left: 1px solid var(--border-primary) !important;
        transition: right 0.3s ease !important;
        display: none !important;
        flex-direction: column !important;
        pointer-events: none !important;
    }
    
    .watchlist-panel.active {
        right: 0 !important;
        display: flex !important;
        pointer-events: auto !important;
    }
    
    /* Watchlist header on mobile */
    .watchlist-header {
        position: relative;
        z-index: 10;
        flex-shrink: 0;
    }
    
    /* Prominent close button */
    .watchlist-close {
        position: relative;
        z-index: 2010;
        font-size: 20px;
        width: 36px;
        height: 36px;
        background: rgba(255, 255, 255, 0.1);
        color: var(--text-white);
        border: none;
        cursor: pointer;
        touch-action: manipulation;
        pointer-events: auto;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 6px;
        transition: all 0.2s ease;
    }
    
    .watchlist-close:hover {
        background: rgba(255, 255, 255, 0.15);
    }
    
    .watchlist-close:active {
        background: rgba(255, 255, 255, 0.2);
        transform: scale(0.95);
    }
    
    /* Watchlist list on mobile */
    .watchlist-list {
        flex: 1;
        overflow-y: auto;
        position: relative;
        z-index: 5;
    }
    
    /* Bottom close button - ALWAYS visible on mobile */
    .watchlist-mobile-close {
        display: block !important;
        position: sticky !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        padding: 1rem !important;
        border-top: 1px solid var(--border-primary) !important;
        background: var(--bg-secondary) !important;
        z-index: 2010 !important;
        flex-shrink: 0 !important;
        pointer-events: auto !important;
    }
    
    .watchlist-mobile-close button {
        width: 100% !important;
        padding: 14px !important;
        background: var(--accent-primary) !important;
        color: white !important;
        border: none !important;
        border-radius: 8px !important;
        font-size: 16px !important;
        font-weight: 600 !important;
        cursor: pointer !important;
        touch-action: manipulation !important;
        pointer-events: auto !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 0.5rem !important;
        transition: all 0.2s ease !important;
    }
    
    .watchlist-mobile-close button:hover {
        background: var(--accent-secondary) !important;
    }
    
    .watchlist-mobile-close button:active {
        background: #1565C0 !important;
        transform: scale(0.98) !important;
    }
    
    .watchlist-item-symbol {
        font-size: 14px;
    }
    
    .watchlist-price-value {
        font-size: 16px;
    }
    
    .toast-container {
        bottom: 1rem;
        right: 1rem;
        left: 1rem;
        max-width: none;
    }
}

@media (max-width: 480px) {
    .watchlist-panel {
        width: 100% !important;
        right: -100% !important;
    }
    
    .watchlist-header {
        padding: 1.25rem 1rem !important;
    }
    
    .watchlist-item {
        padding: 1rem !important;
        min-height: 75px;
    }
    
    .watchlist-item-info h4 {
        font-size: 14px !important;
        margin-bottom: 0.375rem !important;
    }
    
    .watchlist-item-info p {
        font-size: 11px !important;
        line-height: 1.3;
    }
    
    .watchlist-item-price {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .watchlist-item-current {
        font-size: 15px !important;
    }
    
    .watchlist-item-change {
        font-size: 12px !important;
    }
}

/* Add to existing search results */
.search-result-item .watchlist-star-btn {
    background: none;
    border: none;
    color: var(--text-tertiary);
    font-size: 18px;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 6px;
    transition: all 0.2s;
    margin-left: 0.5rem;
}

.search-result-item .watchlist-star-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--accent-primary);
}

.search-result-item .watchlist-star-btn.active {
    color: #fbbf24;
}

.search-result-item .watchlist-star-btn.active:hover {
    color: #f59e0b;
}

/* Watchlist badge */
#watchlist-count {
    display: none;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: var(--accent-primary);
    color: white;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    border: 2px solid var(--bg-primary);
}

/* Backdrop fade animation */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}
