/**
 * Performance Insights Tool - Styling
 */

/* Container and Layout */
.performance-insights-tool {
    max-width: 1400px;
    margin: 0 auto;
    padding: 5px;
}

.tool-intro {
    margin-bottom: 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 8px;
    border: 1px solid #dee2e6;
    overflow: hidden;
}

.intro-content {
    padding: 16px 20px 12px;
}

.intro-content p {
    margin: 0;
    color: #495057;
    font-size: 14px;
    line-height: 1.6;
}

.beta-notice {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 20px;
    background: rgba(255, 193, 7, 0.1);
    border-top: 1px solid rgba(255, 193, 7, 0.3);
}

.beta-badge {
    flex-shrink: 0;
    display: inline-block;
    padding: 3px 10px;
    background: linear-gradient(135deg, #ffc107 0%, #e0a800 100%);
    color: #212529;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.beta-notice p {
    margin: 0;
    color: #6c757d;
    font-size: 12px;
    line-height: 1.5;
    font-style: italic;
}

/* Filter Form */
.insights-filters {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 15px;
    margin-bottom: 20px;
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.filter-group-wide {
    flex: 1 1 auto;
}

.filter-group select,
.filter-group .form-control {
    padding: 5px 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 0.85rem;
    background: #fff;
    min-width: 100px;
}

.filter-group select:focus,
.filter-group .form-control:focus {
    border-color: #80bdff;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0,123,255,.25);
}

/* Button Groups */
.button-group {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.button-group-wrap {
    max-width: 100%;
}

.button-group-wrap .filter-btn {
    font-size: 0.75rem;
    padding: 3px 8px;
}

.filter-btn {
    padding: 4px 12px;
    border: 1px solid #dee2e6;
    background: #fff;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
}

.filter-btn:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.filter-btn.active {
    background: #007bff;
    color: #fff;
    border-color: #007bff;
}

.filter-btn:focus {
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0,123,255,.25);
}

/* Segment Checkboxes */
.segment-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.segment-checkbox {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    color: #495057;
}

.segment-checkbox input[type="checkbox"] {
    cursor: pointer;
    width: 14px;
    height: 14px;
}

/* Filter Actions */
.filter-actions {
    display: flex;
    align-items: center;
    margin-left: auto;
}

.filter-actions .btn {
    padding: 5px 16px;
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
}

/* Best For Row */
.bestfor-row {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #dee2e6;
}

.bestfor-group {
    gap: 6px;
}

.bestfor-btn {
    padding: 6px 14px;
    font-weight: 600;
}

.bestfor-btn.active {
    background: #28a745;
    border-color: #28a745;
}

/* Methodology Section */
.methodology-section {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    margin-bottom: 20px;
}

.methodology-toggle {
    padding: 12px 15px;
    cursor: pointer;
    font-weight: 600;
    color: #495057;
    display: flex;
    align-items: center;
    gap: 8px;
    list-style: none;
}

.methodology-toggle::-webkit-details-marker {
    display: none;
}

.toggle-icon {
    transition: transform 0.2s;
    font-size: 10px;
}

details[open] .toggle-icon {
    transform: rotate(90deg);
}

.current-mode {
    color: #28a745;
    font-weight: 500;
    margin-left: auto;
}

.methodology-content {
    padding: 15px;
    border-top: 1px solid #dee2e6;
    background: #fff;
}

.methodology-intro {
    margin-bottom: 15px;
    color: #495057;
    font-size: 14px;
}

.weight-breakdown {
    margin-bottom: 15px;
}

.weight-breakdown h5 {
    font-size: 13px;
    margin-bottom: 8px;
    color: #212529;
}

.weight-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.weight-chip {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
}

.weight-chip.wet {
    background: #0099ff;
}

.weight-chip.dry {
    background: #ffcc00;
    color: #212529;
}

.weight-chip.snow {
    background: #00bcd4;
}

.weight-chip.comfort {
    background: #9c27b0;
}

.weight-chip.value {
    background: #4caf50;
}

.weight-chip.position {
    background: #607d8b;
}

.methodology-factors {
    font-size: 13px;
}

.methodology-factors h5 {
    font-size: 13px;
    margin-bottom: 8px;
    color: #212529;
}

.methodology-factors ul {
    margin: 0;
    padding-left: 20px;
}

.methodology-factors li {
    margin-bottom: 6px;
    color: #495057;
}

/* Summary Statistics */
.insights-summary {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.summary-stat {
    background: #fff;
    color: #495057;
    padding: 10px 15px;
    border-radius: 4px;
    text-align: center;
    border: 1px solid #dee2e6;
    flex: 1;
    min-width: 120px;
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 2px;
    color: #212529;
}

.stat-label {
    display: block;
    font-size: 0.75rem;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Results Section */
.insights-results h3 {
    margin-bottom: 20px;
    color: #212529;
}

/* Table Styling */
.table-responsive {
    overflow-x: auto;
    margin-bottom: 30px;
}

.insights-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.insights-table thead {
    background: #343a40;
    color: #fff;
}

.insights-table th {
    padding: 12px 10px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
}

.insights-table th.text-center {
    text-align: center;
}

.insights-table tbody tr {
    border-bottom: 1px solid #dee2e6;
    transition: background-color 0.2s;
}

.insights-table tbody tr:hover {
    background-color: #f8f9fa;
}

.insights-table td {
    padding: 12px 10px;
    font-size: 14px;
}

/* Table Cells */
.rank-cell {
    font-size: 18px;
    color: #495057;
    width: 60px;
}

.thumbnail-cell {
    width: 80px;
    padding: 8px !important;
}

.tyre-thumbnail {
    width: 60px;
    height: auto;
    display: block;
    border-radius: 4px;
}

.tyre-cell {
    min-width: 200px;
}

.tyre-cell a {
    color: #212529;
    text-decoration: none;
}

.tyre-cell a:hover,
.tyre-cell a:hover strong {
    color: #007bff;
}

.tyre-name {
    font-size: 14px;
    margin-bottom: 4px;
}

.tyre-name strong {
    color: inherit;
}

.tyre-meta {
    font-size: 12px;
    color: #6c757d;
}

.price-segment {
    display: inline-block;
    padding: 2px 8px;
    background: #e9ecef;
    border-radius: 3px;
    font-size: 11px;
}

/* Confidence Pills */
.confidence-pill {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    cursor: help;
    white-space: nowrap;
}

.confidence-high {
    background-color: #28a745;
}

.confidence-medium {
    background-color: #ffc107;
    color: #212529;
}

.confidence-low {
    background-color: #dc3545;
}

/* Score Cells */
.score-cell {
    min-width: 80px;
}

.score-bar-container {
    position: relative;
    width: 100%;
    height: 24px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
}

.score-bar {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    transition: width 0.3s ease;
}

.score-text {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-weight: 600;
    font-size: 12px;
    color: #212529;
    z-index: 1;
}

/* Performance Indicator Colors */
.score-excellent {
    background-color: #28a745;
    color: #fff;
}

.score-very-good {
    background-color: #7cb342;
    color: #fff;
}

.score-good {
    background-color: #ffc107;
    color: #212529;
}

.score-fair {
    background-color: #ff9800;
    color: #fff;
}

.score-poor {
    background-color: #dc3545;
    color: #fff;
}

.score-none {
    color: #6c757d;
}

/* Category Score Cells */
.cat-header {
    font-size: 12px;
}

.cat-score-cell {
    min-width: 55px;
    padding: 8px 4px !important;
}

.cat-score-bar-container {
    position: relative;
    width: 100%;
    height: 20px;
    background: #e9ecef;
    border-radius: 3px;
    overflow: hidden;
    cursor: help;
}

.cat-score-bar {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    transition: width 0.3s ease;
}

.cat-score-text {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-weight: 600;
    font-size: 11px;
    color: #212529;
    z-index: 1;
}

.cat-score-na {
    display: block;
    color: #adb5bd;
    font-size: 14px;
    text-align: center;
}

/* Category Score Colors */
.cat-excellent {
    background-color: #28a745;
}

.cat-good {
    background-color: #7cb342;
}

.cat-fair {
    background-color: #ffc107;
}

.cat-poor {
    background-color: #dc3545;
}

/* Position Cell */
.position-cell {
    font-size: 16px;
    color: #212529;
}

/* Action Cell */
.btn-expand {
    padding: 6px 12px;
    background: #007bff;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.2s;
}

.btn-expand:hover {
    background: #0056b3;
}

/* Detail Rows */
.detail-row {
    background: #f8f9fa;
}

.detail-content {
    padding: 20px;
}

.test-details h4 {
    margin-bottom: 15px;
    color: #212529;
}

.test-details-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 4px;
    overflow: hidden;
}

.test-details-table thead {
    background: #6c757d;
    color: #fff;
}

.test-details-table th,
.test-details-table td {
    padding: 10px;
    text-align: left;
    font-size: 13px;
}

.test-details-table tbody tr {
    border-bottom: 1px solid #dee2e6;
}

.test-details-table tbody tr:last-child {
    border-bottom: none;
}

.test-details-table a {
    color: #007bff;
    text-decoration: none;
}

.test-details-table a:hover {
    text-decoration: underline;
}

.table-footnote {
    margin-top: 10px;
    font-size: 12px;
    color: #6c757d;
    font-style: italic;
}

/* Detail Sections Container */
.detail-sections {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

/* Quick Action Links */
.detail-quick-links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 15px 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.quick-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    color: #495057;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.quick-link:hover {
    background: #007bff;
    border-color: #007bff;
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
}

.quick-link-primary {
    background: #007bff;
    border-color: #007bff;
    color: #fff;
}

.quick-link-primary:hover {
    background: #0056b3;
    border-color: #0056b3;
}

.quick-link-icon {
    font-size: 16px;
}

/* Score Breakdown Section */
.score-breakdown-section {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    border: 1px solid #dee2e6;
}

.score-breakdown-section h4 {
    margin: 0 0 15px 0;
    color: #212529;
    font-size: 16px;
}

.breakdown-grid {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 20px;
    align-items: start;
}

.breakdown-table-wrap {
    overflow-x: auto;
}

.breakdown-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.breakdown-table thead {
    background: #495057;
    color: #fff;
}

.breakdown-table th,
.breakdown-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #dee2e6;
}

.breakdown-table th:last-child,
.breakdown-table td:last-child {
    text-align: right;
}

.contribution-cell {
    font-weight: 600;
    color: #28a745;
}

.contribution-cell.bonus {
    color: #17a2b8;
}

.contribution-cell.total {
    color: #212529;
    font-size: 15px;
}

.bonus-row {
    background: #e3f2fd;
}

.bonus-row td {
    font-style: italic;
}

.bonus-info {
    display: inline-block;
    width: 16px;
    height: 16px;
    background: #6c757d;
    color: #fff;
    border-radius: 50%;
    text-align: center;
    line-height: 16px;
    font-size: 11px;
    font-style: normal;
    cursor: help;
    margin-left: 4px;
}

.total-row {
    background: #f8f9fa;
    border-top: 2px solid #dee2e6;
}

.position-summary {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    min-width: 120px;
}

.position-stat {
    text-align: center;
}

.position-stat .stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: #212529;
}

.position-stat .stat-label {
    display: block;
    font-size: 11px;
    color: #6c757d;
    text-transform: uppercase;
}

/* Category Breakdown Section */
.category-breakdown-section {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    border: 1px solid #dee2e6;
}

.category-breakdown-section h4 {
    margin: 0 0 10px 0;
    color: #212529;
    font-size: 16px;
}

.section-intro {
    margin: 0 0 15px 0;
    font-size: 13px;
    color: #6c757d;
}

.category-accordions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.category-accordion {
    border: 1px solid #dee2e6;
    border-radius: 6px;
    overflow: hidden;
}

.category-accordion[open] {
    border-color: #adb5bd;
}

.category-accordion-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 15px;
    background: #f8f9fa;
    cursor: pointer;
    list-style: none;
    transition: background 0.2s;
}

.category-accordion-header::-webkit-details-marker {
    display: none;
}

.category-accordion-header:hover {
    background: #e9ecef;
}

.cat-icon {
    font-size: 18px;
}

.cat-name {
    font-weight: 600;
    color: #212529;
}

.cat-score-pill {
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
}

.cat-metric-count {
    color: #6c757d;
    font-size: 12px;
    margin-left: auto;
}

.accordion-arrow {
    font-size: 10px;
    color: #6c757d;
    transition: transform 0.2s;
}

.category-accordion[open] .accordion-arrow {
    transform: rotate(90deg);
}

.category-accordion-content {
    padding: 15px;
    background: #fff;
    border-top: 1px solid #dee2e6;
}

.metric-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.metric-table thead {
    background: #e9ecef;
}

.metric-table th,
.metric-table td {
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid #dee2e6;
}

.metric-table .test-cell {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.metric-table .range-cell {
    color: #6c757d;
    font-size: 11px;
}

.direction-hint {
    display: inline-block;
    color: #6c757d;
    font-size: 10px;
    cursor: help;
}

/* Percentile Classes */
.percentile-excellent {
    color: #28a745;
    font-weight: 600;
}

.percentile-good {
    color: #7cb342;
    font-weight: 600;
}

.percentile-fair {
    color: #ffc107;
    font-weight: 600;
}

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

/* Award Badges */
.award-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.award-winner {
    background: #ffd700;
    color: #212529;
}

.award-highly-recommended {
    background: #c0c0c0;
    color: #212529;
}

.award-recommended {
    background: #cd7f32;
    color: #fff;
}

/* Legend */
.insights-legend {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
    margin-top: 30px;
}

.insights-legend h4 {
    margin-bottom: 15px;
    color: #212529;
}

.insights-legend ul {
    list-style: none;
    padding: 0;
    margin-bottom: 15px;
}

.insights-legend li {
    margin-bottom: 8px;
    font-size: 14px;
    color: #495057;
}

.score-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    padding-top: 15px;
    border-top: 1px solid #dee2e6;
}

.score-legend span {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

/* No Results */
.no-results {
    padding: 40px;
    text-align: center;
    color: #6c757d;
    font-size: 16px;
    background: #f8f9fa;
    border-radius: 8px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .beta-notice {
        flex-direction: column;
        gap: 8px;
    }

    .beta-badge {
        align-self: flex-start;
    }

    .filter-row {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-group {
        width: 100%;
    }

    .filter-group-wide {
        width: 100%;
    }

    .filter-actions {
        margin-left: 0;
        width: 100%;
    }

    .filter-actions .btn {
        width: 100%;
    }

    .insights-summary {
        flex-direction: column;
    }

    .summary-stat {
        min-width: 100%;
    }

    .insights-table {
        font-size: 12px;
    }

    .insights-table th,
    .insights-table td {
        padding: 8px 6px;
    }

    .tyre-cell {
        min-width: 150px;
    }

    .score-bar-container {
        height: 20px;
    }

    .score-text {
        font-size: 11px;
    }

    /* Detail sections responsive */
    .detail-quick-links {
        flex-direction: column;
        padding: 12px;
    }

    .quick-link {
        justify-content: center;
        padding: 12px 16px;
    }

    .breakdown-grid {
        grid-template-columns: 1fr;
    }

    .position-summary {
        flex-direction: row;
        justify-content: space-around;
    }

    .breakdown-table th,
    .breakdown-table td {
        padding: 8px;
        font-size: 12px;
    }

    .category-accordion-header {
        flex-wrap: wrap;
        gap: 8px;
    }

    .cat-metric-count {
        width: 100%;
        margin-left: 28px;
    }

    .metric-table {
        font-size: 11px;
    }

    .metric-table th,
    .metric-table td {
        padding: 6px 8px;
    }

    .metric-table .test-cell {
        max-width: 120px;
    }
}

/* Print Styles */
@media print {
    .insights-filters,
    .btn-expand,
    .filter-actions {
        display: none;
    }

    .insights-table {
        box-shadow: none;
    }

    .detail-row {
        display: none;
    }
}
