/**
 * Tyre Test Prediction Tool - Compact Bootstrap-first Styling
 * Matches site's clean, modern aesthetic
 */

/* ============================================
   CONTAINER AND LAYOUT
   ============================================ */

.tyre-prediction-tool {
    max-width: 1400px;
    margin: 0 auto;
    padding: 5px;
}

.tool-header {
    margin-bottom: 15px;
}

.tool-header h1 {
    font-size: 1.6em;
    margin-bottom: 8px;
    color: #212529;
}

/* ============================================
   HOW IT WORKS SECTION
   ============================================ */

.how-it-works-section {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 12px;
    margin-bottom: 15px;
}

.how-it-works-section h2 {
    font-size: 1.1em;
    margin: 0 0 10px 0;
    color: #495057;
    font-weight: 600;
}

.how-it-works-steps {
    list-style-position: outside;
    padding-left: 20px;
    margin: 10px 0;
}

.how-it-works-steps li {
    margin-bottom: 8px;
    color: #495057;
    font-size: 0.9rem;
}

.disclaimer-box {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 4px;
    padding: 10px 12px;
    margin-top: 12px;
    color: #856404;
    font-size: 0.9rem;
}

/* ============================================
   COLLAPSIBLE SECTIONS
   ============================================ */

.collapsible {
    border: 1px solid #dee2e6;
    border-radius: 4px;
    margin-bottom: 15px;
    overflow: hidden;
}

.collapsible-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: #f8f9fa;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s ease;
    margin: 0;
    font-weight: 600;
}

.collapsible-header:hover {
    background: #e9ecef;
}

.collapse-icon {
    width: 18px;
    height: 18px;
    transition: transform 0.3s ease;
}

.collapsible.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

.collapsible-content {
    padding: 12px;
    background: #fff;
}

.collapsible.collapsed .collapsible-content {
    display: none;
}

/* ============================================
   MAIN INTERFACE LAYOUT
   ============================================ */

.prediction-interface {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

@media (max-width: 1024px) {
    .prediction-interface {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   CONTROLS PANEL
   ============================================ */

.prediction-controls {
    background: #fff;
    border: none;
    padding: 0;
}

.control-section {
    margin-bottom: 20px;
}

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

.control-section h3 {
    padding: 8px 10px;
    font-weight: 600;
    font-size: 1.1em;
    margin: 0 0 10px 0;
    background: #f8f9fa;
    border-left: 3px solid #6c757d;
    border-radius: 4px;
    color: #495057;
}

/* ============================================
   TEST AND TYRE SELECTORS
   ============================================ */

.test-selector-wrapper,
.tyre-selector-wrapper {
    position: relative;
}

.form-control {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 0.85rem;
    background: #fff;
}

/* Narrow inputs for numbers */
input[type="number"].form-control {
    width: 80px;
}

.form-control:focus {
    border-color: #80bdff;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(51, 122, 183, 0.25);
}

.selector-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    margin-top: 8px;
    background: #fff;
}

.selector-item {
    padding: 8px 10px;
    border-bottom: 1px solid #f1f1f1;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

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

.selector-item:hover {
    background: #f8f9fa;
}

.selector-item.selected {
    background: #e7f3ff;
    border-left: 3px solid #337ab7;
}

.item-title {
    font-weight: 500;
    color: #212529;
    margin-bottom: 4px;
    font-size: 0.9rem;
}

.item-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.badge {
    display: inline-block;
    padding: 2px 6px;
    font-size: 0.7rem;
    background: #e9ecef;
    color: #495057;
    border-radius: 3px;
    font-weight: 500;
}

/* ============================================
   OPTIONS FORM
   ============================================ */

.options-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-weight: 500;
    margin-bottom: 5px;
    color: #495057;
    font-size: 0.85rem;
}

.form-help {
    font-size: 0.75rem;
    color: #6c757d;
    margin-top: 3px;
    font-style: italic;
}

/* ============================================
   BUTTONS (uses Bootstrap base, overrides in style.css)
   ============================================ */

.btn:focus {
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(51, 122, 183, 0.25);
}

.btn-primary:disabled {
    background: #6c757d;
    border-color: #6c757d;
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-large {
    width: 100%;
    padding: 8px 20px;
    font-size: 0.9rem;
}

/* ============================================
   RESULTS PANEL
   ============================================ */

.prediction-results {
    background: #fff;
    border: none;
    padding: 0;
    min-height: 500px;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: #6c757d;
    text-align: center;
}

.empty-state-icon {
    width: 60px;
    height: 60px;
    margin-bottom: 15px;
    opacity: 0.5;
}

.empty-state p {
    font-size: 0.9rem;
}

/* ============================================
   PREDICTION RESULT DISPLAY
   ============================================ */

.prediction-result {
    animation: fadeIn 0.5s ease-in;
}

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

.prediction-header {
    margin-bottom: 15px;
}

.prediction-summary {
    margin-bottom: 15px;
}

.prediction-summary h2 {
    font-size: 1.4rem;
    margin: 0 0 5px 0;
    color: #212529;
}

.prediction-summary h3 {
    font-size: 1rem;
    margin: 0;
    color: #6c757d;
    font-weight: 400;
}

/* ============================================
   MAIN RESULT DISPLAY
   ============================================ */

.prediction-main-result {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

.predicted-rank-display,
.predicted-score-display {
    flex: 1;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 15px 20px;
    text-align: center;
}

.predicted-rank-display {
    border-left: 4px solid #337ab7;
}

.predicted-score-display {
    border-left: 4px solid #28a745;
}

.predicted-rank-display .rank-label,
.predicted-score-display .score-label {
    display: block;
    font-size: 0.75rem;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    margin-bottom: 5px;
}

.predicted-rank-display .rank-value {
    display: block;
    font-size: 2.5rem;
    font-weight: 700;
    color: #337ab7;
    line-height: 1.1;
}

.predicted-score-value {
    display: block;
    font-size: 2.5rem;
    font-weight: 700;
    color: #28a745;
    line-height: 1.1;
}

.predicted-rank-display .rank-total {
    display: block;
    font-size: 0.85rem;
    color: #6c757d;
    margin-top: 3px;
}

@media (max-width: 576px) {
    .prediction-main-result {
        flex-direction: column;
    }

    .predicted-rank-display .rank-value,
    .predicted-score-value {
        font-size: 2rem;
    }
}

/* ============================================
   STATS CARDS - FLAT DESIGN WITH ACCENTS
   ============================================ */

.prediction-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
    margin-bottom: 15px;
}

.stat-card {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 12px;
    text-align: center;
}

.stat-label {
    font-size: 0.75rem;
    color: #6c757d;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #212529;
    line-height: 1.2;
}

.stat-subtitle {
    font-size: 0.8rem;
    color: #6c757d;
    margin-left: 6px;
    font-weight: 400;
}

/* Flat color design with border accent */
.rank-card {
    background: #f8f9fa;
    border-left: 4px solid #337ab7;
}

.score-card {
    background: #f8f9fa;
    border-left: 4px solid #28a745;
}

/* Confidence cards with subtle backgrounds */
.confidence-card.confidence-high {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    border-left: 4px solid #28a745;
}

.confidence-card.confidence-medium {
    background: #fff3cd;
    border: 1px solid #ffeeba;
    border-left: 4px solid #ffc107;
}

.confidence-card.confidence-low {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-left: 4px solid #dc3545;
}

.confidence-card.confidence-high .stat-label,
.confidence-card.confidence-high .stat-value {
    color: #155724;
}

.confidence-card.confidence-medium .stat-label,
.confidence-card.confidence-medium .stat-value {
    color: #856404;
}

.confidence-card.confidence-low .stat-label,
.confidence-card.confidence-low .stat-value {
    color: #721c24;
}

.confidence-indicator {
    width: 100%;
    height: 6px;
    background: #dee2e6;
    border-radius: 3px;
    margin-top: 8px;
    overflow: hidden;
}

.confidence-bar {
    height: 100%;
    background: #337ab7;
    transition: width 0.5s ease;
}

.percentile-bar {
    width: 100%;
    height: 6px;
    background: #dee2e6;
    border-radius: 3px;
    margin-top: 8px;
    overflow: hidden;
}

.percentile-fill {
    height: 100%;
    background: #28a745;
    transition: width 0.5s ease;
}

/* ============================================
   CONFIDENCE SECTION
   ============================================ */

.confidence-section {
    background: #f8f9fa;
    border-radius: 4px;
    padding: 12px;
    margin-bottom: 15px;
}

.confidence-section h3 {
    font-size: 1.1rem;
    margin: 0 0 8px 0;
    color: #495057;
    font-weight: 600;
}

.confidence-factors {
    display: flex;
    gap: 15px;
    margin-top: 10px;
}

.factor-item {
    flex: 1;
    padding: 8px;
    background: #fff;
    border-radius: 4px;
    font-size: 0.85rem;
    border: 1px solid #dee2e6;
}

/* ============================================
   RANKINGS LADDER
   ============================================ */

.rankings-ladder {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ranking-item {
    display: grid;
    grid-template-columns: 50px 1fr 70px;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: #f8f9fa;
    border-radius: 4px;
    border: 1px solid #dee2e6;
    transition: all 0.2s ease;
}

.ranking-item.predicted-position {
    background: #e7f3ff;
    border: 2px solid #337ab7;
    font-weight: 600;
}

.rank-number {
    font-size: 1.1rem;
    font-weight: 700;
    color: #495057;
}

.predicted-position .rank-number {
    color: #337ab7;
}

.tyre-name {
    flex: 1;
    font-size: 0.9rem;
}

.predicted-label {
    display: inline-block;
    background: #337ab7;
    color: #fff;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.65rem;
    margin-left: 6px;
    font-weight: 600;
    text-transform: uppercase;
}

.score-value {
    font-weight: 600;
    color: #495057;
    text-align: right;
    font-size: 0.9rem;
}

/* ============================================
   METRICS GRID
   ============================================ */

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px;
}

.metric-card {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 10px;
}

.metric-name {
    font-weight: 600;
    color: #495057;
    margin-bottom: 3px;
    font-size: 0.85rem;
}

.metric-category {
    font-size: 0.7rem;
    color: #6c757d;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: #212529;
    margin-bottom: 5px;
}

.metric-rank {
    font-size: 0.8rem;
    color: #6c757d;
    margin-bottom: 6px;
}

.mini-bar {
    width: 100%;
    height: 5px;
    background: #dee2e6;
    border-radius: 3px;
    overflow: hidden;
}

.mini-bar-fill {
    height: 100%;
    background: #337ab7;
    transition: width 0.5s ease;
}

/* ============================================
   REFERENCE TESTS
   ============================================ */

.reference-tests-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.reference-test-card {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 10px;
}

.test-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.test-header h4 {
    margin: 0;
    font-size: 1rem;
    color: #212529;
}

.test-year {
    background: #337ab7;
    color: #fff;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 600;
}

.test-details {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 0.85rem;
}

.detail-label {
    color: #6c757d;
    font-weight: 500;
}

.detail-value {
    color: #212529;
    font-weight: 600;
}

/* ============================================
   METHODOLOGY SECTION
   ============================================ */

.methodology-section {
    background: #f8f9fa;
}

.methodology-content {
    font-size: 0.9rem;
    line-height: 1.6;
}

.methodology-content h4 {
    font-size: 1rem;
    margin: 0 0 10px 0;
    color: #495057;
    font-weight: 600;
}

.methodology-content ol {
    padding-left: 20px;
}

.methodology-content li {
    margin-bottom: 8px;
    color: #495057;
    font-size: 0.85rem;
}

/* ============================================
   MESSAGES
   ============================================ */

.info-message {
    padding: 10px 12px;
    background: #d1ecf1;
    border: 1px solid #bee5eb;
    border-radius: 4px;
    color: #0c5460;
    font-size: 0.85rem;
}

.loading-message {
    text-align: center;
    padding: 30px 20px;
    color: #6c757d;
}

.loading-spinner {
    display: inline-block;
    width: 35px;
    height: 35px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #337ab7;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 12px;
}

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

/* ============================================
   ERROR DISPLAY
   ============================================ */

.prediction-error {
    text-align: center;
    padding: 30px 20px;
}

.error-icon {
    width: 50px;
    height: 50px;
    margin: 0 auto 15px;
    color: #dc3545;
}

.prediction-error h3 {
    color: #dc3545;
    margin-bottom: 12px;
    font-size: 1.1rem;
}

.error-suggestions {
    background: #f8f9fa;
    border-radius: 4px;
    border: 1px solid #dee2e6;
    padding: 15px;
    margin-top: 15px;
    text-align: left;
}

.error-suggestions h4 {
    margin: 0 0 8px 0;
    color: #495057;
    font-size: 0.95rem;
}

.error-suggestions ul {
    margin: 0;
    padding-left: 20px;
}

.error-suggestions li {
    margin-bottom: 6px;
    color: #6c757d;
    font-size: 0.85rem;
}

.section-description {
    color: #6c757d;
    margin-bottom: 12px;
    font-size: 0.9rem;
}
