/* ============================================================================
   NEW INDICATOR PANEL STYLES - Single Panel, TradingView-inspired
   ============================================================================ */

.indicator-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
}

.subrbar::-webkit-scrollbar {
    width: 6px;
}
.indicator-panel::-webkit-scrollbar-thumb {
    background: #363a44;
    border-radius: 3px;
}
.indicator-panel::-webkit-scrollbar-track {
    background: transparent;
}

/* Search Bar */
.indicator-search {
    display: flex;
    align-items: center;
    background: var(--tv-bg);
    border: 1px solid var(--tv-border);
    border-radius: 6px;
    padding: 8px 12px;
    margin: 8px 12px;
    gap: 8px;
    transition: border-color 0.2s;
}
.indicator-search:focus-within {
    border-color: var(--tv-blue);
}
.search-icon {
    color: var(--tv-text-secondary);
    font-size: 14px;
}
.indicator-search input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--tv-text);
    font-size: 13px;
    outline: none;
}
.indicator-search input::placeholder {
    color: var(--tv-text-secondary);
}
.search-clear {
    background: transparent;
    border: none;
    color: var(--tv-text-secondary);
    cursor: pointer;
    padding: 2px 6px;
    font-size: 16px;
    line-height: 1;
}
.search-clear:hover {
    color: var(--tv-text);
}

/* Category Tabs */
.category-tabs {
    display: flex;
    gap: 4px;
    padding: 4px 12px;
    overflow-x: auto;
    scrollbar-width: none;
}
.category-tabs::-webkit-scrollbar {
    display: none;
}
.category-tab {
    background: transparent;
    border: none;
    color: var(--tv-text-secondary);
    font-size: 11px;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}
.category-tab:hover {
    background: var(--tv-hover);
    color: var(--tv-text);
}
.category-tab.active {
    background: rgba(41, 98, 255, 0.1);
    color: var(--tv-blue);
    font-weight: 600;
}

/* Indicator Sections */
.indicator-section {
    margin: 8px 12px 12px;
}
.indicator-section.favorites {
    background: rgba(41, 98, 255, 0.05);
    border-radius: 6px;
    padding: 8px;
    margin-top: 4px;
}
.section-title {
    font-size: 10px;
    color: var(--tv-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 8px 0;
    display: flex;
    align-items: center;
    gap: 5px;
}
.section-title button.clear-all,
.section-title button.visibility-toggle {
    display: none;
}
.section-title:hover button.clear-all,
.section-title:hover button.visibility-toggle {
    display: inline-block;
}
.visibility-toggle,
.clear-all {
    background: var(--tv-red);
    border: none;
    color: white;
    font-size: 9px;
    padding: 2px 8px;
    border-radius: 3px;
    cursor: pointer;
}
.visibility-toggle {
    background: var(--tv-blue);
}
.visibility-toggle:hover,
.clear-all:hover {
    opacity: 0.9;
}

/* Indicator Items */
.indicator-item {
    background: var(--tv-panel-bg);
    border: 1px solid var(--tv-border);
    border-radius: 6px;
    margin-bottom: 2px;
    transition: all 0.2s;
    overflow: hidden;
}
.indicator-item:hover {
    border-color: var(--tv-blue);
}
.indicator-item.favorite {
    border-color: rgba(41, 98, 255, 0.3);
}

.indicator-item-main {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    cursor: pointer;
}

.indicator-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0; /* Important for ellipsis */
    gap: 2px;
}

.indicator-name {
    font-size: 13px;
    color: var(--tv-text);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.indicator-desc {
    font-size: 11px;
    color: var(--tv-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.indicator-actions {
    display: flex;
    gap: 4px;
    margin-left: 8px;
    flex-shrink: 0;
}

.indicator-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--tv-text-secondary);
    cursor: pointer;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
}
.indicator-btn:hover {
    background: var(--tv-hover);
    color: var(--tv-text);
    border-color: var(--tv-hover);
}
.indicator-btn.add:hover {
    background: var(--tv-blue);
    color: white;
    border-color: var(--tv-blue);
}

.indicator-presets {
    display: none;
}
@media (min-width: 768px) {
    .indicator-presets {
        display: block;
    }
    .indicator-desc {
        display: inline;
        font-size: 11px;
        color: var(--tv-text-secondary);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 120px;
    }
}

/* Active Indicator Item */
.indicator-item.active {
    border-color: var(--tv-blue);
}

.indicator-item.active .indicator-name {
    color: var(--tv-blue);
    font-weight: 600;
}

.indicator-item.active.expanded {
    border-color: var(--tv-blue);
    background: rgba(41, 98, 255, 0.05);
}

.drag-handle {
    cursor: grab;
    color: var(--tv-text-secondary);
    font-size: 12px;
    user-select: none;
    padding: 0 2px;
}
.drag-handle:hover {
    color: var(--tv-text);
}

.indicator-btn.visible,
.indicator-btn.expand,
.indicator-btn.favorite {
    width: 20px;
    height: 20px;
    font-size: 11px;
}
.indicator-btn.expand.rotated {
    transform: rotate(180deg);
}

/* Indicator Config (Expanded) */
.indicator-config {
    border-top: 1px solid var(--tv-border);
    background: rgba(0, 0, 0, 0.2);
    animation: slideDown 0.2s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
    }
    to {
        opacity: 1;
        max-height: 1000px;
    }
}

.config-sections {
    padding: 12px;
}

.config-section {
    margin-bottom: 16px;
}
.config-section:last-child {
    margin-bottom: 0;
}

.section-subtitle {
    font-size: 10px;
    color: var(--tv-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.preset-action-btn {
    background: var(--tv-blue);
    border: none;
    color: white;
    font-size: 9px;
    padding: 2px 8px;
    border-radius: 3px;
    cursor: pointer;
    margin-left: auto;
}
.preset-action-btn:hover {
    opacity: 0.9;
}

/* Config Row */
.config-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.config-row label {
    font-size: 11px;
    color: var(--tv-text-secondary);
    min-width: 80px;
}
.config-row select,
.config-row input[type="text"],
.config-row input[type="number"] {
    flex: 1;
    background: var(--tv-bg);
    border: 1px solid var(--tv-border);
    border-radius: 4px;
    color: var(--tv-text);
    font-size: 12px;
    padding: 4px 8px;
    min-width: 0;
}
.config-row select:focus,
.config-row input:focus {
    outline: none;
    border-color: var(--tv-blue);
}

.input-with-preset {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
}
.input-with-preset input {
    flex: 1;
}
.presets-btn {
    background: transparent;
    border: 1px solid var(--tv-border);
    color: var(--tv-text-secondary);
    cursor: pointer;
    padding: 4px 8px;
    font-size: 10px;
    border-radius: 3px;
}
.presets-btn:hover {
    background: var(--tv-hover);
}

/* Color Picker */
.color-picker {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}
.color-picker input[type="color"] {
    width: 32px;
    height: 28px;
    border: 1px solid var(--tv-border);
    border-radius: 4px;
    cursor: pointer;
    padding: 0;
    background: transparent;
}
.color-preview {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    border: 1px solid var(--tv-border);
}

/* Range Slider */
.config-row input[type="range"] {
    flex: 1;
    accent-color: var(--tv-blue);
}

/* Actions */
.config-actions {
    display: flex;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--tv-border);
}
.btn-secondary {
    flex: 1;
    background: var(--tv-bg);
    border: 1px solid var(--tv-border);
    color: var(--tv-text);
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}
.btn-secondary:hover {
    background: var(--tv-hover);
}
.btn-danger {
    flex: 1;
    background: var(--tv-red);
    border: none;
    color: white;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}
.btn-danger:hover {
    opacity: 0.9;
}

/* No Results */
.no-results {
    text-align: center;
    color: var(--tv-text-secondary);
    padding: 40px 20px;
    font-size: 12px;
}

/* Presets List */
.presets-list {
    max-height: 200px;
    overflow-y: auto;
}
.preset-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s;
}
.preset-item:hover {
    background: var(--tv-hover);
}
.preset-item.applied {
    background: rgba(38, 166, 154, 0.1);
    border-radius: 4px;
}
.preset-label {
    font-size: 11px;
    color: var(--tv-text);
}
.preset-delete {
    background: transparent;
    border: none;
    color: var(--tv-text-secondary);
    cursor: pointer;
    padding: 2px 6px;
    font-size: 14px;
    line-height: 1;
}
.preset-delete:hover {
    color: var(--tv-red);
}

.no-presets {
    text-align: center;
    color: var(--tv-text-secondary);
    font-size: 10px;
    padding: 8px;
}

/* Range Value Display */
.range-value {
    font-size: 11px;
    color: var(--tv-text);
    min-width: 20px;
}

/* Preset Indicator Button */
.preset-indicator {
    background: transparent;
    border: 1px solid var(--tv-border);
    color: var(--tv-text-secondary);
    cursor: pointer;
    padding: 2px 6px;
    font-size: 10px;
    border-radius: 3px;
}
.preset-indicator:hover {
    background: var(--tv-hover);
    border-color: var(--tv-blue);
    color: var(--tv-blue);
}

/* Mobile Responsive */
@media (max-width: 767px) {
    .category-tabs {
        font-size: 10px;
        padding: 4px 8px;
    }
    .category-tab {
        padding: 4px 8px;
    }
    
    .indicator-item-main {
        padding: 6px 8px;
    }
    
    .indicator-btn {
        width: 20px;
        height: 20px;
    }
    
    .config-actions {
        flex-direction: column;
    }
    
    .config-row label {
        min-width: 60px;
        font-size: 10px;
    }
}

/* Touch-friendly styles for mobile */
@media (hover: none) {
    .indicator-btn {
        min-width: 40px;
        min-height: 40px;
    }
    
    .category-tab {
        padding: 10px 14px;
    }
    
    .indicator-item-main {
        padding: 12px;
    }
}

/* Dark theme improvements */
@media (prefers-color-scheme: dark) {
    .indicator-search {
        background: #1e222d;
    }
    .indicator-item {
        background: #1e222d;
    }
    .indicator-config {
        background: rgba(0, 0, 0, 0.3);
    }
}

/* Animations */
.indicator-item {
    transition: all 0.2s ease;
}

.indicator-config > * {
    animation: fadeIn 0.2s ease;
}

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

/* Scrollbar styling for presets list */
.presets-list::-webkit-scrollbar {
    width: 4px;
}
.presets-list::-webkit-scrollbar-thumb {
    background: var(--tv-border);
    border-radius: 2px;
}

/* Sidebar Tabs */
.sidebar-tabs {
    display: flex;
    gap: 4px;
    flex: 1;
    margin-right: 8px;
}

.sidebar-tab {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--tv-text-secondary);
    font-size: 11px;
    padding: 6px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.sidebar-tab:hover {
    background: var(--tv-hover);
    color: var(--tv-text);
}

.sidebar-tab.active {
    background: rgba(41, 98, 255, 0.15);
    color: var(--tv-blue);
    font-weight: 600;
}

/* Sidebar Tab Panels */
.sidebar-tab-panel {
    display: none;
    animation: fadeIn 0.2s ease;
}

.sidebar-tab-panel.active {
    display: block;
}

/* Collapsed sidebar adjustments */
.right-sidebar.collapsed .sidebar-tabs {
    display: none;
}

/* Strategy Panel Styles */
.indicator-checklist {
    max-height: 120px;
    overflow-y: auto;
    background: var(--tv-bg);
    border: 1px solid var(--tv-border);
    border-radius: 4px;
    padding: 4px;
    margin-top: 4px;
}
.indicator-checklist::-webkit-scrollbar {
    width: 4px;
}
.indicator-checklist::-webkit-scrollbar-thumb {
    background: var(--tv-border);
    border-radius: 2px;
}

.checklist-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
    border-radius: 3px;
}
.checklist-item:hover {
    background: var(--tv-hover);
}
.checklist-item input {
    cursor: pointer;
}

.equity-chart-container {
    width: 100%;
    height: 150px;
    margin-top: 12px;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid var(--tv-border);
    background: var(--tv-bg);
}

.results-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.chart-toggle-group {
    display: flex;
    background: var(--tv-hover);
    border-radius: 4px;
    padding: 2px;
}

.chart-toggle-group .toggle-btn {
    padding: 2px 8px;
    font-size: 10px;
    border: none;
    background: transparent;
    color: var(--tv-text-secondary);
    cursor: pointer;
    border-radius: 3px;
    transition: all 0.2s ease;
}

.chart-toggle-group .toggle-btn.active {
    background: var(--tv-border);
    color: var(--tv-text);
}

.chart-toggle-group .toggle-btn:hover:not(.active) {
    color: var(--tv-text);
}