/**
 * Score History Graph Styles
 * Styling for interactive Chart.js score history visualizations
 */

/* Main wrapper */
.score-history-wrapper {
    width: 100%;
    min-height: 400px;
}

/* Controls section */
.score-history-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.control-group label {
    margin: 0;
    font-weight: 600;
    font-size: 0.9rem;
    color: #495057;
    white-space: nowrap;
}

.field-select,
.timeframe-select {
    padding: 0.5rem 0.75rem;
    border: 1px solid #ced4da;
    border-radius: 6px;
    background: white;
    font-size: 0.9rem;
    cursor: pointer;
    transition: border-color 0.15s ease-in-out;
}

.field-select:hover,
.timeframe-select:hover,
.field-select:focus,
.timeframe-select:focus {
    border-color: #86b7fe;
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.btn-refresh {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: #0d6efd;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.15s ease-in-out;
    margin-left: auto;
}

.btn-refresh:hover {
    background: #0b5ed7;
}

.btn-refresh:active {
    background: #0a58ca;
}

.btn-refresh svg {
    transition: transform 0.3s ease;
}

.btn-refresh:hover svg {
    transform: rotate(180deg);
}

/* Graph container */
.score-history-graph {
    position: relative;
    min-height: 300px;
    padding: 1rem;
    background: white;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.score-history-graph canvas {
    max-height: 400px;
}

/* Legend */
.score-history-legend {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.score-history-legend h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: #212529;
}

.legend-items {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.legend-marker {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
}

/* Change details panel */
.change-details {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 1rem;
    margin-top: 1.5rem;
}

.change-details h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #0d6efd;
}

.change-detail-item {
    padding: 0.5rem 0;
    border-bottom: 1px solid #f0f0f0;
}

.change-detail-item:last-child {
    border-bottom: none;
}

.change-detail-item strong {
    color: #212529;
    margin-right: 0.5rem;
}

.change-detail-item ul {
    margin: 0.5rem 0 0 0;
    padding-left: 1.5rem;
}

.change-detail-item li {
    padding: 0.25rem 0;
    color: #6c757d;
}

/* Change value indicators */
.positive {
    color: #198754;
    font-weight: 600;
}

.negative {
    color: #dc3545;
    font-weight: 600;
}

/* Loading state */
.loading-spinner {
    text-align: center;
    padding: 3rem 1rem;
    color: #6c757d;
    font-size: 1.1rem;
}

.loading-spinner::before {
    content: '';
    display: inline-block;
    width: 2rem;
    height: 2rem;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #0d6efd;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 0.75rem;
    vertical-align: middle;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error state */
.error-message {
    text-align: center;
    padding: 2rem 1rem;
    color: #dc3545;
    font-size: 1rem;
    background: #f8d7da;
    border: 1px solid #f5c2c7;
    border-radius: 8px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .score-history-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .control-group {
        width: 100%;
    }
    
    .field-select,
    .timeframe-select {
        flex: 1;
    }
    
    .btn-refresh {
        width: 100%;
        justify-content: center;
        margin-left: 0;
    }
    
    .legend-items {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .score-history-graph canvas {
        max-height: 250px;
    }
}

/* Print styles */
@media print {
    .score-history-controls,
    .btn-refresh {
        display: none;
    }
    
    .score-history-graph {
        page-break-inside: avoid;
    }
}

/* Accessibility */
.field-select:focus-visible,
.timeframe-select:focus-visible,
.btn-refresh:focus-visible {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
}

/* Score Change Explainer Styles */
.score-change-explainer {
    width: 100%;
}

.score-change-explainer.no-history {
    padding: 2rem;
    text-align: center;
    color: #6c757d;
}

.score-change-summary {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 2rem;
}

.score-change-summary h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #212529;
}

.summary-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.stat-item {
    background: white;
    padding: 1rem;
    border-radius: 6px;
    border: 1px solid #dee2e6;
}

.stat-label {
    display: block;
    font-weight: 600;
    color: #495057;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #0d6efd;
}

.reason-breakdown {
    margin-top: 0.5rem;
}

.reason-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f0f0f0;
}

.reason-item:last-child {
    border-bottom: none;
}

.reason-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 500;
}

.reason-count {
    font-weight: 600;
    color: #212529;
}

.biggest-changes ul {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0 0 0;
}

.biggest-changes li {
    padding: 0.5rem 0;
    border-bottom: 1px solid #f0f0f0;
}

.biggest-changes li:last-child {
    border-bottom: none;
}

.change-date {
    color: #6c757d;
    margin-right: 0.5rem;
}

.change-amount {
    font-weight: 600;
}

.change-amount.positive {
    color: #198754;
}

.change-amount.negative {
    color: #dc3545;
}

.change-reason {
    color: #6c757d;
    font-size: 0.875rem;
}

/* Change History Table */
.change-history-table-wrapper {
    margin-top: 1.5rem;
}

.change-history-table-wrapper h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #212529;
}

.change-history-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
}

.change-history-table thead {
    background: #f8f9fa;
}

.change-history-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: #495057;
    border-bottom: 2px solid #dee2e6;
}

.change-history-table td {
    padding: 1rem;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: top;
}

.change-history-table tbody tr:last-child td {
    border-bottom: none;
}

.change-history-table tbody tr:hover {
    background: #f8f9fa;
}

.change-row {
    transition: background-color 0.2s ease;
}

.change-date .date-text {
    display: block;
    font-weight: 500;
    color: #212529;
}

.change-date .date-relative {
    display: block;
    font-size: 0.875rem;
    color: #6c757d;
    margin-top: 0.25rem;
}

.change-values .change-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.change-values .change-list li {
    padding: 0.25rem 0;
}

.change-label {
    color: #6c757d;
    margin-right: 0.5rem;
}

.change-value {
    font-weight: 600;
}

.change-value.positive {
    color: #198754;
}

.change-value.negative {
    color: #dc3545;
}

.age-bracket-changes {
    margin-top: 0.5rem;
}

.bracket-list {
    list-style: none;
    padding-left: 1rem;
    margin: 0.5rem 0 0 0;
}

.bracket-name {
    color: #6c757d;
    font-size: 0.875rem;
}

.bracket-change {
    font-weight: 600;
    font-size: 0.875rem;
}

/* Metadata List */
.metadata-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.metadata-list li {
    padding: 0.25rem 0;
    color: #495057;
}

.metadata-list strong {
    color: #212529;
    margin-right: 0.5rem;
}

.badge-visual {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background: #0d6efd;
    color: white;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.no-metadata,
.no-changes {
    color: #adb5bd;
    font-style: italic;
}

/* Reason badges */
.reason-initial_assessment {
    background: #3498db;
    color: white;
}

.reason-assessor_upgrade {
    background: #9b59b6;
    color: white;
}

.reason-holistic_vote {
    background: #2ecc71;
    color: white;
}

.reason-field_consensus {
    background: #f39c12;
    color: white;
}

.reason-manual_override {
    background: #e74c3c;
    color: white;
}

.reason-metadata_update {
    background: #95a5a6;
    color: white;
}
