/**
 * Chart Options Panel Styles - Filigrane Design inspired by TimeRangeSlider
 */

/* Main Panel Container with increased bottom margin */
.chart-options-panel {
    margin: 10px 0 50px 0; /* Increased bottom margin from 30px to 50px */
    background: #f8f9fa;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Streamlined version without header */
.chart-options-panel.streamlined {
    margin: 10px 0 50px 0;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 16px;
}

/* Panel Header */
.chart-options-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s ease;
}

.chart-options-header:hover {
    background: #f1f5f9;
}

.chart-options-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Toggle Button */
.btn-toggle {
    background: #e2e8f0;
    border: 1px solid #cbd5e1;
    color: #475569;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-toggle:hover {
    background: #cbd5e1;
    color: #334155;
}

/* Panel Content */
.chart-options-content {
    padding: 16px;
    background: #f8f9fa;
    transition: max-height 0.3s ease;
    overflow: visible; /* Changed from hidden to visible to show expanded options */
    min-height: 200px; /* Ensure enough space for expanded options */
}

.chart-options-content.collapsed {
    max-height: 0;
    padding: 0 16px;
}

/* Streamlined content without background and padding */
.streamlined .chart-options-content {
    padding: 0;
    background: transparent;
}

/* Option Sections - Horizontal layout with compact spacing */
.option-section {
    margin-bottom: 16px; /* Reduced margin for more compact layout */
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 14px; /* Slightly reduced padding */
}

.option-section:last-child {
    margin-bottom: 0;
}

.section-title {
    margin: 0 0 12px 0;
    font-size: 16px;
    font-weight: 600;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e2e8f0;
}

/* Option Grid - Horizontal layout with compact spacing */
.option-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px; /* Reduced gap for more compact layout */
    align-items: flex-start; /* Changed from center to flex-start */
    justify-content: flex-start;
}

/* Streamlined grid for always-visible options */
.streamlined-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    align-items: start;
    margin-bottom: 16px;
}

/* Option Items - Filigrane checkbox style with compact layout */
.option-item {
    display: flex;
    flex-direction: column;
    gap: 0px; /* Removed gap to prevent spacing issues */
    min-width: 200px;
    min-height: 40px; /* Reduced height for more compact layout */
    align-items: flex-start;
    justify-content: flex-start;
}

/* Option Labels - similar to reference design with stable height */
.option-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 500;
    color: #374151;
    margin-bottom: 0;
    user-select: none;
    font-size: 14px;
    min-height: 24px; /* Ensure consistent height */
    white-space: nowrap; /* Keep text on one line */
}

.option-text {
    flex: 1;
}

/* Modern Checkboxes - styled like in the reference */
.option-checkbox {
    width: 18px;
    height: 18px;
    border: 2px solid #cbd5e1;
    border-radius: 3px;
    background: #fff;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    appearance: none;
    -webkit-appearance: none;
    pointer-events: auto; /* Ensure checkboxes are clickable */
    z-index: 10; /* Ensure checkboxes are above other elements */
}

.option-checkbox:checked {
    background: #3b82f6 !important;
    border-color: #3b82f6 !important;
}

.option-checkbox:checked::after {
    content: '✓';
    position: absolute;
    top: -1px;
    left: 2px;
    color: white;
    font-size: 14px;
    font-weight: bold;
}

.option-checkbox:hover {
    border-color: #94a3b8;
}

/* Tooltip Icon - subtle */
.tooltip-icon {
    font-size: 12px;
    color: #64748b;
    cursor: help;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.tooltip-icon:hover {
    opacity: 1;
}

/* Tooltips are handled by the original JavaScript system */

/* Sub-options - shown when checkbox is checked with stable layout */
.sub-options {
    margin: 16px 0px 16px 0px; /* Increased margin for better spacing */
    padding: 16px;
    background: #f8f9fa;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    animation: slideDown 0.2s ease;
    font-size: 13px;
    width: 100%; /* Full width in grid */
    box-sizing: border-box;
    position: relative;
    clear: both; /* Ensure it's on its own line */
    min-height: 120px; /* Ensure adequate height for content */
}

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

.sub-option {
    margin-bottom: 8px;
}

.sub-option:last-child {
    margin-bottom: 0;
}

/* Color Picker Groups - stable layout */
.color-picker-group {
    display: flex;
    gap: 8px;
    align-items: center; /* Center align for better appearance */
    margin-bottom: 8px;
    min-height: 32px; /* Prevent layout jumps */
    flex-wrap: nowrap; /* Keep items on same line */
}

.color-picker {
    width: 32px;
    height: 28px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    cursor: pointer;
    background: none;
    padding: 0;
    transition: all 0.2s ease;
    flex-shrink: 0; /* Prevent shrinking */
}

.color-picker:hover {
    border-color: #94a3b8;
}

.hex-input {
    width: 70px;
    height: 28px; /* Match color picker height exactly */
    padding: 4px 6px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 12px;
    text-transform: uppercase;
    background: white;
    transition: all 0.2s ease;
    box-sizing: border-box;
    flex-shrink: 0; /* Prevent shrinking */
    line-height: 1; /* Ensure consistent line height */
}

.hex-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

/* Highlight Controls - stable layout */
.highlight-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    min-height: 32px; /* Prevent layout jumps */
}

.inline-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    color: #4b5563;
}

.count-input,
.limit-input {
    width: 50px;
    padding: 4px 6px;
    border: 1px solid #cbd5e1;
    border-radius: 3px;
    font-size: 12px;
    text-align: center;
    background: white;
}

.style-select,
.limit-select,
.format-select {
    padding: 4px 6px;
    border: 1px solid #cbd5e1;
    border-radius: 3px;
    font-size: 12px;
    background: white;
    cursor: pointer;
}

/* Time Format Options */
.time-format-options {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* Responsive Design */
@media (max-width: 768px) {
    .option-grid {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .option-item {
        min-width: unset;
        width: 100%;
    }
    
    .option-label {
        white-space: normal; /* Allow wrapping on mobile */
    }
    
    .highlight-controls {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .color-picker-group {
        justify-content: flex-start;
    }
}

/* Focus States */
.option-checkbox:focus,
.count-input:focus,
.limit-input:focus,
.style-select:focus,
.limit-select:focus,
.format-select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

/* Disabled States */
.option-item.disabled {
    opacity: 0.6;
    pointer-events: none;
}

/* Active States */
.option-item.active {
    background: #f0f9ff;
    border-color: #0ea5e9;
}

.option-item.active .option-text {
    color: #0369a1;
    font-weight: 600;
}

/* Chart Header Options Styling */
.chart-header-option {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #374151;
    font-weight: 500;
    user-select: none;
    cursor: pointer;
}

.chart-header-option input[type="checkbox"] {
    border: 2px solid #cbd5e1;
    border-radius: 3px;
    background: #fff;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    appearance: none;
    -webkit-appearance: none;
}

.chart-header-option input[type="checkbox"]:checked {
    background: #3b82f6;
    border-color: #3b82f6;
}

.chart-header-option input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    top: -2px;
    left: 1px;
    color: white;
    font-size: 12px;
    font-weight: bold;
}

.chart-header-option input[type="checkbox"]:hover {
    border-color: #94a3b8;
}

/* Specific fix for unified colors alignment */
#unified-colors + .option-text {
    display: flex;
    align-items: center;
    min-height: 24px;
}

/* Sub-options containers should align with checkbox text - handled by main .sub-options rule above */

/* Legacy specific rules - updated to remove left margin */
#unified-color-options {
    margin-left: 0px; /* No left indent - align with other sub-options */
    padding: 12px; /* Keep normal padding inside */
}

#highlight-options {
    margin-left: 0px; /* No left indent - align with other sub-options */
    padding: 12px; /* Keep normal padding inside */
}