/**
 * Race Results & Standings Display Styles
 * @since 1.2.15
 */

/* =========================================
   COMMON STYLES
   ========================================= */

.ast-race-results,
.ast-standings,
.ast-race-history {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
    max-width: 100%;
    margin: 0 auto 2.5rem;
}

/* Additional spacing when multiple standings sections */
.ast-standings + .ast-standings {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 3px solid #e9ecef;
}

/* Class-specific standings header colors */
.ast-standings-pro .ast-standings-table thead {
    background: linear-gradient(135deg, #dc3545, #c82333);
}

.ast-standings-proam .ast-standings-table thead {
    background: linear-gradient(135deg, #0d6efd, #0b5ed7);
}

.ast-error,
.ast-no-results {
    padding: 2rem;
    text-align: center;
    background: #f8f9fa;
    border-radius: 8px;
    color: #6c757d;
}

/* =========================================
   RACE RESULTS
   ========================================= */

.ast-results-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e9ecef;
}

.ast-results-round {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6c757d;
    background: #e9ecef;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
}

.ast-results-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    color: #212529;
}

.ast-results-track {
    font-size: 0.9rem;
    color: #6c757d;
    margin: 0.25rem 0 0;
}

.ast-results-meta {
    text-align: right;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.ast-results-tournament {
    font-weight: 600;
    color: #495057;
}

.ast-results-date {
    font-size: 0.875rem;
    color: #6c757d;
}

/* Race Stats Bar (v2.1.16) */
.ast-race-stats-bar {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-bottom: 1.25rem;
    background: rgba(0,0,0,0.15);
    border-radius: 6px;
    font-size: 0.8rem;
    color: #adb5bd;
    overflow: hidden;
}

.ast-race-stats-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1.25rem;
    padding: 0.6rem 1rem;
}

.ast-race-stats-row + .ast-race-stats-row {
    border-top: 1px solid rgba(255,255,255,0.08);
}

.ast-race-stat {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.ast-race-stat-label {
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-size: 0.7rem;
    opacity: 0.7;
}

.ast-race-stat-value {
    font-weight: 600;
    color: #dee2e6;
}

.ast-race-stat-divider {
    width: 1px;
    height: 1rem;
    background: rgba(255,255,255,0.15);
    align-self: center;
}

.ast-condition-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.ast-condition-dry {
    background: #198754;
    color: #fff;
}

.ast-condition-damp {
    background: #fd7e14;
    color: #fff;
}

.ast-condition-wet {
    background: #0d6efd;
    color: #fff;
}

/* Results Table */
.ast-results-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.ast-results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.ast-results-table thead {
    background: #1a1a2e;
    color: #fff;
}

.ast-results-table th {
    padding: 0.75rem 0.5rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
    color: #fff;
}

.ast-results-table td {
    padding: 0.6rem 0.5rem;
    border-bottom: 1px solid #e9ecef;
    vertical-align: middle;
}

.ast-results-table tbody tr:hover {
    background: #f8f9fa;
}

/* Position column */
.ast-col-pos {
    width: 50px;
    text-align: center !important;
}

.ast-position {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    font-weight: 700;
    font-size: 0.875rem;
    border-radius: 4px;
    background: #e9ecef;
    color: #495057;
}

.ast-pos-1 { background: linear-gradient(135deg, #ffd700, #ffec8b); color: #000; }
.ast-pos-2 { background: linear-gradient(135deg, #c0c0c0, #e8e8e8); color: #000; }
.ast-pos-3 { background: linear-gradient(135deg, #cd7f32, #daa06d); color: #fff; }

/* Class position column */
.ast-col-class-pos {
    width: 60px;
    text-align: center !important;
}

.ast-class-position {
    font-weight: 600;
    color: #495057;
}

.ast-class-position-pro {
    color: #dc3545;
    font-weight: 700;
}

.ast-class-position-proam {
    color: #0d6efd;
    font-weight: 700;
}

/* Podium colors for class positions */
.ast-class-pos-1 {
    background: linear-gradient(135deg, #ffd700, #ffec8b);
    color: #000 !important;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
}

.ast-class-pos-2 {
    background: linear-gradient(135deg, #c0c0c0, #e8e8e8);
    color: #000 !important;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
}

.ast-class-pos-3 {
    background: linear-gradient(135deg, #cd7f32, #daa06d);
    color: #fff !important;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
}

/* Driver column */
.ast-col-driver {
    min-width: 180px;
}

.ast-driver-cell {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ast-driver-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

/* v2.1.41: Champion coin overlay on standings rows.
   The avatar img is wrapped in .ast-standing-avatar-wrap so the coin can be absolutely
   positioned over the bottom-left corner of the avatar (mirrors the directory card pattern).
   Sized smaller than the directory's 23px coin since standings avatars are 32px (vs directory's 64px).
   The coin uses cursor:help so users get a hint that the title tooltip is interactive. */
.ast-standing-avatar-wrap {
    position: relative;
    flex-shrink: 0;
    line-height: 0; /* prevents inline-image baseline gap */
}

.ast-standing-champ {
    position: absolute;
    bottom: -2px;
    left: -2px;
    line-height: 0;
    cursor: help;
}

.ast-standing-champ img {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1.5px solid #fff;
    box-shadow: 0 1px 2px rgba(0,0,0,0.3);
    object-fit: cover;
    display: block;
}

/* v2.1.41b: Inline champion coin variant — renders after the country flag inside the driver-name link.
   This is a side-by-side alternative to the avatar-overlaid coin (.ast-standing-champ above).
   Only one of the two should appear in the rendered HTML; the other CSS rule is dormant.
   Inline gives the coin more breathing room and ties it visually to the driver name rather than the avatar. */
.ast-standing-champ-inline {
    display: inline-block;
    vertical-align: middle;
    margin-left: 0.4rem;
    line-height: 0;
    cursor: help;
}

.ast-standing-champ-inline img {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.1);
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
    object-fit: cover;
    display: inline-block;
    vertical-align: middle;
}

.ast-driver-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.ast-driver-name {
    font-weight: 600;
    color: #212529;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ast-driver-number {
    font-weight: 700;
    color: #6c757d;
    margin-right: 0.25rem;
}

.ast-driver-team-compact {
    font-size: 0.75rem;
    color: #6c757d;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ast-fastest-lap-badge,
.ast-pole-badge {
    display: inline-block !important;
    font-size: 0.65rem !important;
    font-weight: 700 !important;
    padding: 0.15rem 0.35rem !important;
    border-radius: 3px !important;
    margin-left: 0.35rem !important;
    text-transform: uppercase !important;
    line-height: 1.2 !important;
}

.ast-fastest-lap-badge {
    background: #6f42c1 !important;
    color: #fff !important;
}

.ast-pole-badge {
    background: #20c997 !important;
    color: #fff !important;
}

/* Team & Car columns */
.ast-col-team,
.ast-col-car {
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #495057;
}

/* Class column */
.ast-col-driver-class {
    width: 60px;
}

.ast-class-badge {
    display: inline-block;
    font-size: 0.55rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 0.1rem 0.25rem;
    border-radius: 2px;
    letter-spacing: 0.02em;
    line-height: 1.2;
}

.ast-class-pro {
    background: #dc3545;
    color: #fff;
}

.ast-class-proam {
    background: #0d6efd;
    color: #fff;
}

.ast-class-am {
    background: #28a745;
    color: #fff;
}

/* Points column */
.ast-col-points {
    width: 60px;
    text-align: center !important;
    font-size: 1rem;
}

/* Bonus column */
.ast-col-bonus {
    width: 80px;
    font-size: 0.75rem;
    color: #6c757d;
}

/* Incidents column */
.ast-col-incidents {
    width: 50px;
    text-align: center !important;
}

.ast-inc-med { color: #fd7e14; font-weight: 600; }
.ast-inc-high { color: #dc3545; font-weight: 700; }

/* Fastest lap column */
.ast-col-fastest {
    width: 90px;
    font-family: 'SF Mono', 'Consolas', monospace;
    font-size: 0.8rem;
    color: #495057;
}

/* Status badges */
.ast-status-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
}

.ast-dns {
    background: #6c757d;
    color: #fff;
}

.ast-dnf {
    background: #dc3545;
    color: #fff;
}

/* Row states */
.ast-result-podium {
    background: rgba(255, 215, 0, 0.05);
}

.ast-result-dns td,
.ast-result-dnf td {
    opacity: 0.6;
}

/* Legend */
.ast-results-legend {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e9ecef;
    font-size: 0.75rem;
    color: #6c757d;
}

/* Compact mode */
.ast-compact .ast-results-table {
    font-size: 0.8rem;
}

.ast-compact .ast-driver-avatar {
    width: 24px;
    height: 24px;
}

.ast-compact .ast-results-table td {
    padding: 0.4rem 0.35rem;
}

/* =========================================
   TOURNAMENT STANDINGS
   ========================================= */

.ast-standings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e9ecef;
}

.ast-standings-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    color: #212529;
}

.ast-standings-season {
    font-weight: 400;
    color: #6c757d;
}

.ast-standings-class-filter {
    font-size: 0.875rem;
    font-weight: 600;
    padding: 0.35rem 0.75rem;
    border-radius: 4px;
}

/* Standings Table */
.ast-standings-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.ast-standings-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.ast-standings-table thead {
    background: #1a1a2e;
    color: #fff;
}

.ast-standings-table th {
    padding: 0.75rem 0.5rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
    color: #fff;
}

.ast-standings-table td {
    padding: 0.6rem 0.5rem;
    border-bottom: 1px solid #e9ecef;
    vertical-align: middle;
}

.ast-standings-table tbody tr:hover {
    background: #f8f9fa;
}

.ast-standing-top {
    background: rgba(255, 215, 0, 0.05);
}

.ast-standing-top:nth-child(1) { background: rgba(255, 215, 0, 0.1); }
.ast-standing-top:nth-child(2) { background: rgba(192, 192, 192, 0.1); }
.ast-standing-top:nth-child(3) { background: rgba(205, 127, 50, 0.1); }

/* Standings columns */
.ast-col-races,
.ast-col-wins,
.ast-col-podiums,
.ast-col-top5,
.ast-col-top10 {
    width: 60px;
    text-align: center !important;
}

.ast-col-wins { color: #28a745; }
.ast-col-podiums { color: #fd7e14; }

/* =========================================
   DRIVER RACE HISTORY
   ========================================= */

.ast-history-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 1.5rem;
    color: #212529;
}

.ast-history-tournament {
    margin-bottom: 2rem;
}

.ast-history-tournament-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0 0 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e9ecef;
    color: #212529;
}

.ast-history-year {
    font-weight: 400;
    color: #6c757d;
}

.ast-history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.ast-history-table thead {
    background: #1a1a2e;
}

.ast-history-table th {
    padding: 0.5rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: #fff;
    border-bottom: 2px solid #e9ecef;
}

.ast-history-table td {
    padding: 0.5rem;
    border-bottom: 1px solid #e9ecef;
}

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

.ast-history-race-link {
    color: #0d6efd;
    text-decoration: none;
    font-weight: 500;
}

.ast-history-race-link:hover {
    color: #0a58ca;
    text-decoration: underline;
}

/* =========================================
   RESPONSIVE DESIGN
   ========================================= */

@media (max-width: 768px) {
    .ast-results-header,
    .ast-standings-header {
        flex-direction: column;
        text-align: center;
    }
    
    .ast-results-meta {
        text-align: center;
    }
    
    .ast-race-stats-row {
        justify-content: center;
        font-size: 0.75rem;
        gap: 0.4rem 0.75rem;
    }
    
    .ast-race-stat-divider {
        display: none;
    }
    
    .ast-results-table,
    .ast-standings-table,
    .ast-history-table {
        font-size: 0.8rem;
    }
    
    .ast-results-table th,
    .ast-results-table td,
    .ast-standings-table th,
    .ast-standings-table td {
        padding: 0.5rem 0.35rem;
    }
    
    .ast-driver-avatar {
        width: 28px;
        height: 28px;
    }
    
    /* v2.1.41: scale champion coin proportionally with smaller avatar */
    .ast-standing-champ img {
        width: 14px;
        height: 14px;
        border-width: 1.5px;
    }
    
    /* v2.1.41b: scale inline champion coin proportionally on tablets */
    .ast-standing-champ-inline img {
        width: 16px;
        height: 16px;
    }
    
    .ast-col-team,
    .ast-col-car,
    .ast-col-bonus,
    .ast-col-fastest {
        display: none;
    }
    
    .ast-col-driver {
        min-width: 140px;
    }
    
    .ast-results-legend {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .ast-results-title,
    .ast-standings-title,
    .ast-history-title {
        font-size: 1.25rem;
    }
    
    .ast-position {
        width: 24px;
        height: 24px;
        font-size: 0.75rem;
    }
    
    .ast-driver-avatar {
        width: 24px;
        height: 24px;
    }
    
    /* v2.1.41: scale champion coin proportionally with smallest avatar */
    .ast-standing-champ img {
        width: 12px;
        height: 12px;
        border-width: 1px;
    }
    
    .ast-standing-champ {
        bottom: -1px;
        left: -1px;
    }
    
    /* v2.1.41b: scale inline champion coin proportionally on phones */
    .ast-standing-champ-inline img {
        width: 14px;
        height: 14px;
    }
    
    .ast-standing-champ-inline {
        margin-left: 0.3rem;
    }
    
    .ast-driver-number {
        display: none;
    }
    
    .ast-col-class {
        display: none;
    }
}
