/* FINTEL™ Custom Weights Panel - Phase 2 CSS */

/* Main Panel Container */
.fintel-weights-panel {
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Panel Header */
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
    gap: 8px;
}

.panel-header h3 {
    margin: 0;
    color: #333;
    font-size: 18px;
}

/* Position help icon in top right */
.weights-help-icon {
    color: #8B5CF6;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    animation: pulse-glow-purple 2s ease-in-out infinite;
    margin-left: auto;
    margin-right: 12px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    z-index: 100;
    pointer-events: auto;
}

.weights-help-icon svg {
    width: 18px;
    height: 18px;
}

.weights-help-icon:hover {
    color: #7C3AED;
    animation: none;
}

@keyframes pulse-glow-purple {
    0%, 100% {
        opacity: 1;
        filter: drop-shadow(0 0 3px rgba(139, 92, 246, 0.5));
    }
    50% {
        opacity: 0.7;
        filter: drop-shadow(0 0 6px rgba(139, 92, 246, 0.8));
    }
}

/* Popup styling */
.weights-help-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 24px;
    max-width: 400px;
    width: 90%;
    z-index: 10000;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.weights-help-popup h4 {
    color: #8B5CF6;
    margin-top: 0;
    margin-bottom: 16px;
    font-size: 16px;
}

.weights-help-popup p {
    color: #ccc;
    font-size: 14px;
    line-height: 1.6;
    margin: 10px 0;
}

.weights-help-popup strong {
    color: #fff;
}

.weights-help-popup-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    color: #888;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
}

.weights-help-popup-close:hover {
    color: #fff;
}

.close-panel {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #999;
    padding: 0;
    width: 30px;
    height: 30px;
}

.close-panel:hover {
    color: #333;
}

/* Weights Grid */
.weights-grid {
    margin: 20px 0;
}

.weight-control {
    display: grid;
    grid-template-columns: 150px 30px 1fr 60px 20px;
    gap: 10px;
    align-items: center;
    margin: 10px 0;
}

.weight-control label {
    font-weight: 500;
    color: #555;
}

.weight-lock {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 0;
    line-height: 1;
    transition: transform 0.2s ease;
}

.weight-lock:hover {
    transform: scale(1.1);
}

.weight-lock:active {
    transform: scale(0.95);
}

/* PHASE 4: Visible focus styles for keyboard navigation */
.weight-lock:focus {
    outline: 2px solid #8B5CF6;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.2);
}

/* Remove outline on mouse click (but keep for keyboard) */
.weight-lock:focus:not(:focus-visible) {
    outline: none;
    box-shadow: none;
}

/* Focus-visible for keyboard users only */
.weight-lock:focus-visible {
    outline: 2px solid #8B5CF6;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.2);
}

/* Focus styles for sliders and inputs */
.weight-control input[type="range"]:focus {
    outline: 2px solid #8B5CF6;
    outline-offset: 2px;
}

.weight-control input[type="number"]:focus {
    border-color: #8B5CF6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
    outline: none;
}

.weight-control input[type="range"] {
    width: 100%;
}

.weight-number {
    width: 60px;
    padding: 5px;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-align: center;
}

.weight-percent {
    color: #999;
    font-weight: 500;
}

/* Weights Footer */
.weights-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    border-top: 1px solid #eee;
    border-bottom: 1px solid #eee;
    margin: 20px 0;
}

.weights-total {
    font-size: 16px;
    font-weight: 600;
}

.total-value {
    font-weight: bold;
    transition: color 0.3s;
}

.total-value.valid { 
    color: #00a86b; 
}

.total-value.invalid { 
    color: #f44336; 
}

/* Normalize Button */
.btn-normalize {
    background: #f0f0f0;
    border: 1px solid #ddd;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-normalize:not(:disabled):hover {
    background: #e0e0e0;
}

.btn-normalize:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Panel Actions */
.panel-actions {
    display: flex;
    gap: 10px;
}

.btn-primary, .btn-secondary {
    flex: 1;
    padding: 10px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s;
}

.btn-primary {
    background: #00a86b;
    color: white;
}

.btn-primary:hover {
    background: #008856;
}

.btn-secondary {
    background: #f0f0f0;
    border: 1px solid #ddd;
    color: #333;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

/* Customize Button - FIXED HEIGHT */
.customize-btn {
    background: white;
    border: 1px solid #e0e0e0;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    font-size: 13px;
    font-family: 'Inter', sans-serif;
    transition: all 0.3s;
    height: 32px !important; /* Same height as dropdowns */
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
}

.customize-btn:hover {
    background: #f8f8f8;
    border-color: #00a86b;
}

/* Override any filter-group styles that cause vertical expansion */
.filters-section .filter-group {
    margin: 0 !important;
    padding: 0 !important;
}

/* Ensure all buttons in filter bar have same height */
.filters-section button {
    height: 32px !important;
    padding: 6px 12px !important;
    font-size: 13px !important;
    line-height: 1 !important;
    display: inline-flex !important;
    align-items: center !important;
}

/* Fix reset button height */
.filters-section .reset-filters-btn {
    height: 32px !important;
    padding: 6px 12px !important;
    min-width: auto !important;
}

/* Fix snapshot button height */
.filters-section .snapshot-button {
    height: 32px !important;
    padding: 6px 12px !important;
}

/* Custom Badge */
.custom-badge {
    background: #00a86b;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    margin-left: 10px;
}

/* Score Updated Animation */
.score-updated {
    animation: highlightChange 0.5s ease-out;
}

@keyframes highlightChange {
    0% { background-color: #ffeb3b; }
    100% { background-color: transparent; }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    /* Keep title on one line on mobile */
    #fintelWeightsPanel h3,
    .panel-header h3 {
        font-size: 14px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    /* Slightly smaller icon on mobile to save space */
    .weights-help-icon svg {
        width: 16px;
        height: 16px;
    }
    
    /* Reduce spacing if needed */
    .weights-help-icon {
        margin-right: 8px;
    }
    
    /* 2-row layout on mobile:
       Row 1: Label + Lock button
       Row 2: Slider
       Row 3: Number box (full width with % inside) */
    .weight-control {
        grid-template-columns: 1fr auto;
        grid-template-rows: auto auto auto;
        gap: 8px;
        position: relative;
    }
    
    /* Label spans row 1, column 1 */
    .weight-control label {
        grid-column: 1;
        grid-row: 1;
    }
    
    /* Lock button in row 1, column 2 */
    .weight-control .weight-lock {
        grid-column: 2;
        grid-row: 1;
    }
    
    /* Slider spans row 2, columns 1-2 */
    .weight-control input[type="range"] {
        grid-column: 1 / 3;
        grid-row: 2;
        height: 44px;
    }
    
    /* Number input spans full width in row 3 */
    .weight-control .weight-number {
        grid-column: 1 / 3;
        grid-row: 3;
        width: 100%;
        height: 44px;
        font-size: 16px;
        padding-right: 30px;
        text-align: center;
    }
    
    /* % symbol positioned inside the number box */
    .weight-control .weight-percent {
        grid-column: 1 / 3;
        grid-row: 3;
        position: absolute;
        right: 10px;
        pointer-events: none;
        align-self: center;
        z-index: 1;
    }
    
    .panel-actions {
        flex-direction: column;
    }
    
    .btn-primary, .btn-secondary {
        width: 100%;
    }
}
