/* ============================================
   Custom Chart Legend for Line Isolation Feature
   Created: 2025-11-19
   Updated: 2025-11-20 (Added search feature)
   ============================================ */

.chart-legend-container {
    margin-top: 4px;
}

.chart-legend-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.2s ease;
    border-radius: 8px;
}

.chart-legend-header:hover {
    background: #e0f2fe;
}

.chart-legend-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    flex: 1;
}

.chart-legend-title .toggle-icon {
    transition: transform 0.2s ease;
    color: #3b82f6;
    font-size: 20px;
}

.chart-legend-title .toggle-icon.expanded {
    transform: rotate(180deg);
}

/* Search Box Styles - Gmail-style matching AI search bar */
.chart-legend-search {
    padding: 12px 16px;
    transition: opacity 0.3s ease, max-height 0.3s ease;
    max-height: 64px;
    opacity: 1;
}

.chart-legend-search.collapsed {
    max-height: 0;
    opacity: 0;
    padding: 0 16px;
    overflow: hidden;
}

/* Inner search box - matches .ai-search-bar styling */
.chart-legend-search-box {
    width: 100%;
    height: 40px;
    background: #f1f3f4;
    border-radius: 20px;
    display: flex;
    align-items: center;
    padding: 0 14px;
    gap: 8px;
    transition: all 0.2s ease;
    position: relative;
}

.chart-legend-search-box:hover {
    background: #e8eaed;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.chart-legend-search-box.focused {
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.chart-legend-search-icon {
    color: #5f6368;
    font-size: 20px;
    pointer-events: none;
    flex-shrink: 0;
}

.chart-legend-search-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    font-size: 13px;
    color: #1f2937;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.chart-legend-search-input::placeholder {
    color: #5f6368;
}

/* Clear button uses shared .search-clear-btn class from styles.css */

/* Highlight matched text */
.legend-domain-name mark {
    background-color: #fef08a;
    color: #374151;
    padding: 2px 0;
    border-radius: 2px;
    font-weight: 600;
}

/* No results message */
.chart-legend-no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 24px 16px;
    color: #6b7280;
    font-size: 13px;
    font-style: italic;
}

.chart-legend-items {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px;
    max-height: 500px;
    overflow-y: auto;
    margin-top: 0;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    /* Hide scrollbar for Chrome, Safari and Opera */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
}

.chart-legend-items::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

.chart-legend-items.collapsed {
    display: none;
}

.chart-legend-item {
    display: flex;
    align-items: center;
    padding: 6px 10px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.chart-legend-item:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.chart-legend-item.isolated {
    background: #dbeafe;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.chart-legend-item.hidden {
    opacity: 0.4;
    background: #f9fafb;
}

.chart-legend-item.hidden:hover {
    opacity: 0.6;
}

.legend-color-indicator {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    margin-right: 8px;
    flex-shrink: 0;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.legend-domain-name {
    font-size: 13px;
    color: #374151;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.chart-legend-item.hidden .legend-domain-name {
    color: #9ca3af;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .chart-legend-items {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
    
    .legend-domain-name {
        font-size: 12px;
    }
    
    .chart-legend-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .chart-legend-actions {
        width: 100%;
        justify-content: flex-end;
    }
}
