/* =========================================
   PROJECTIONS
   ========================================= */

.forecast-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.meta-headers th { text-align: center !important; font-size: 11px; color: #333; padding-bottom: 5px; border-bottom: none !important; }
.meta-group-border { border-bottom: 1px solid #ccc !important; }

.forecast-table th {
    text-align: center;
    padding: 12px 18px 8px 8px;
    border-bottom: 2px solid #333;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
    user-select: none;
    vertical-align: bottom;
    position: relative;
}

.forecast-table th.sortable { cursor: pointer; transition: background 0.1s; }
.forecast-table th.sortable:hover { background-color: #f4f4f4; color: #111; }

.forecast-table th.sortable::after {
    content: ' \25B4';
    opacity: 0.3;
    position: absolute;
    right: 4px;
    bottom: 8px;
}
.forecast-table th.sortable.desc::after { content: ' \25BE'; opacity: 0.3; }
.forecast-table th.sortable.active-sort::after { opacity: 1; color: #ff5e2f; }

.forecast-table th.team-col,
.forecast-table td.team-col {
    position: sticky;
    left: 0;
    z-index: 10;
    background-color: #fff;
    box-shadow: 2px 0 5px rgba(0,0,0,0.05);
    text-align: left;
}

.forecast-table th.team-col {
    padding-right: 8px;
    z-index: 11;
}

.forecast-table td.team-col {
    font-weight: bold;
    font-size: 15px;
    color: #111;
    white-space: nowrap;
}

.team-name-wrapper { display: flex; align-items: baseline; gap: 6px; }

.forecast-table td { padding: 8px; border-bottom: 1px solid #eee; text-align: center; vertical-align: middle; }
.dimmed-points { color: #999; font-size: 12px; font-weight: normal; }

.forecast-table tbody tr:nth-child(even) { background-color: #fcfcfc; }
.forecast-table tbody tr:nth-child(even) td.team-col { background-color: #fcfcfc; }

.team-eliminated { opacity: 0.4; filter: grayscale(100%); transition: opacity 0.2s; }
.dash-eliminated { color: #ccc; font-weight: normal; }
.check-mark { color: #111; font-weight: bold; }

.bg-90 { background-color: rgba(255, 94, 47, 0.85); color: white; }
.bg-75 { background-color: rgba(255, 133, 46, 0.65); color: #111; }
.bg-50 { background-color: rgba(255, 171, 52, 0.45); color: #111; }
.bg-25 { background-color: rgba(255, 205, 82, 0.30); color: #111; }
.bg-10 { background-color: rgba(255, 228, 133, 0.20); color: #111; }
.bg-1  { background-color: rgba(255, 243, 191, 0.10); color: #333; }
.bg-0  { background-color: transparent; color: #999; }

.pct-cell { width: 70px; min-width: 70px; text-align: center !important; font-weight: 600; font-size: 13px; }
.pct-cell-narrow { width: 45px; min-width: 45px; text-align: center !important; font-weight: 600; font-size: 13px; }

.forecast-table th.pts-col,
.forecast-table td.pts-col { width: 60px; min-width: 60px; max-width: 60px; text-align: center; }

.forecast-table th.gd-col,
.forecast-table td.gd-col { width: 75px; min-width: 75px; max-width: 75px; text-align: center; }

.position-dist-header { text-align: center; vertical-align: bottom; padding-bottom: 8px; width: 160px; min-width: 160px; cursor: default; }
.position-dist-cell { width: 160px; min-width: 160px; padding-right: 20px !important; padding-left: 20px !important; vertical-align: bottom; }

/* 🟢 UPDATED SPARKLINE ENGINE: Uses gap instead of margins for easy squishing */
.sparkline-container { width: 100%; height: 26px; position: relative; cursor: crosshair; }
.spark-bars {
    position: absolute; bottom: 0; left: 0; width: 100%; height: 15px;
    display: flex; gap: 1px; align-items: flex-end; border-bottom: 1px solid #ddd;
}
.sparkbar {
    flex: 1; min-width: 0; /* min-width 0 allows infinite squish */
    min-height: 1px; pointer-events: none; transition: background 0.1s, opacity 0.1s;
}
.sparkline-container:hover .sparkbar { background: #fcd5c5 !important; opacity: 1 !important; }
.sparkline-container .sparkbar.active { background: #ff5e2f !important; opacity: 1 !important; }
.spark-label { position: absolute; top: -2px; font-size: 10px; line-height: 1.1; color: #111; display: none; pointer-events: none; z-index: 5; width: 130px; }
.pos-header-labels { display: flex; justify-content: space-between; font-size: 9px; color: #999; margin-top: 5px; font-weight: normal; text-transform: none; padding: 0 10px; }

.divider-left { border-left: 2px solid #ddd !important; }
.divider-right { border-right: 2px solid #ddd !important; }
.thin-right { border-right: 1px solid #eee !important; }

/* 🟢 Desktop Group Column */
.forecast-table th.group-col,
.forecast-table td.group-col {
    width: 50px;
    min-width: 50px;
    max-width: 50px;
    text-align: center;
    padding-right: 12px; /* Adds breathing room on the right */
    color: #888;
    font-weight: 600;
    font-size: 13px;
}

@media screen and (max-width: 768px) {

    /* 2. Global table strictness */
    .forecast-table { font-size: 10px; table-layout: fixed; width: 100%; border-collapse: collapse; }

    /* Give all headers room at the bottom for the sort arrows */
    .forecast-table th { box-sizing: border-box; padding: 2px 0 10px 0 !important; overflow: hidden; }
    .forecast-table td { box-sizing: border-box; padding: 2px 0; overflow: hidden; }

    /* 3. Meta Headers (Shrunk to fit strict layout, no arrows needed so less padding) */
    .meta-headers { display: table-row; }
    .meta-headers th {
        font-size: 7.5px !important;
        line-height: 1.1;
        padding: 2px 1px !important;
        white-space: normal;
    }

    /* 4. Team Column - Stacked and Truncated */
    .forecast-table th.team-col,
    .forecast-table td.team-col,
    .forecast-table .meta-headers th:first-child {
        width: 70px; min-width: 70px; max-width: 70px;
        padding-left: 2px !important;
        white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
        box-shadow: none;
    }

    .forecast-table td.team-col { font-size: 11px; }
    .team-name-wrapper { display: flex; flex-direction: column; align-items: flex-start; gap: 0; }
    .dimmed-points { font-size: 7.5px; margin-left: 0; }

    /* 5. Points Column Squeezed */
    .forecast-table th.pts-col,
    .forecast-table td.pts-col {
        width: 18px; min-width: 18px; max-width: 18px;
        font-size: 8px;
    }
    .forecast-table td.pts-col { padding: 2px 0 !important; }

    /* 6. Goal Diff Column (CSS Text Replacement -> "GD") */
    .forecast-table th.gd-col {
        width: 18px; min-width: 18px; max-width: 18px;
        font-size: 0 !important; /* Hides original text */
    }
    .forecast-table th.gd-col::before {
        content: "GD";
        font-size: 8px;
        display: block;
    }
    .forecast-table td.gd-col {
        width: 18px; min-width: 18px; max-width: 18px;
        font-size: 8px; padding: 2px 0 !important;
    }

    /* 7. Sparkline Squeeze (CSS Text Replacement -> "POS") */
    .position-dist-header {
        width: 32px; min-width: 32px; max-width: 32px;
        font-size: 0 !important; height: auto; padding-bottom: 2px !important;
    }
    .position-dist-header::before {
        content: "POS";
        font-size: 8px;
        display: block;
    }
    .pos-header-labels { display: none; }

    .position-dist-cell {
        width: 32px; min-width: 32px; max-width: 32px;
        padding-left: 1px !important; padding-right: 1px !important;
    }

    /* 🟢 The Sparkline Auto-Squish Magic */
    .spark-bars:has(.sparkbar:nth-child(25)) { gap: 0; }

    /* 🟢 TOOLTIP FIX */
    .spark-label {
        width: 32px !important;
        font-size: 4.5px !important;
        line-height: 1.1 !important;
        top: 0 !important; left: 0 !important;
        transform: none !important;
        background: rgba(255, 255, 255, 0.9) !important;
        color: #000 !important; box-shadow: none !important;
        border-radius: 0 !important; padding: 1px 0 !important;
        text-align: center; white-space: normal !important;
        word-break: break-word !important; height: auto !important;
        display: none;
    }
    .spark-label::after { display: none !important; }

    /* 8. THE VERTICAL CLASS FIX */
    .forecast-table th.vert-mobile {
        writing-mode: vertical-rl;
        white-space: normal !important;
        line-height: 1.1 !important;
        height: 90px !important;
        width: 25px !important;
        min-width: 25px !important;
        max-width: 25px !important;
        padding: 2px 0 12px 0 !important;
        font-size: 7px !important;
        letter-spacing: -0.2px;
        text-align: right !important;
        vertical-align: middle !important;
        overflow: hidden;
    }

    /* 9. Probability Cell Widths */
    .pct-cell, .pct-cell-narrow {
        width: 25px; min-width: 25px; max-width: 25px;
        font-size: 8.5px;
        letter-spacing: -0.5px;
        padding: 4px 0 !important;
    }

    /* 10. The "Leftover" Horizontal Small Headers (e.g. Group Stages 1st, 2nd) */
    .forecast-table th.sortable:not(.vert-mobile):not(.team-col):not(.pts-col):not(.gd-col) {
        writing-mode: horizontal-tb !important;
        white-space: normal !important;
        font-size: 7.5px !important;
        line-height: 1.1 !important;
        padding: 2px 1px 12px 1px !important;
        width: 25px !important;
        min-width: 25px !important;
        max-width: 25px !important;
        text-align: center !important;
        vertical-align: bottom !important;
    }

    /* ==========================================================
       🟢 11. THE MASTER SORT ARROW STANDARDIZATION (MOBILE)
       ========================================================== */
    .forecast-table th.sortable::after {
        display: block !important;
        writing-mode: horizontal-tb !important;
        content: '\25B4';
        position: absolute;
        bottom: 1px;         /* Pins arrow to the very bottom */
        left: 0; right: 0;   /* Allows exact horizontal centering */
        margin: 0 auto;
        text-align: center;
        transform: none !important; /* Strips desktop float offsets */
        font-size: 8px !important;  /* Overrides GD font-size: 0 bug */
        opacity: 0.4;
    }

    /* Custom placement just for the Team column so it aligns right */
    .forecast-table th.team-col.sortable::after {
        left: auto;
        right: 2px;
    }

    .forecast-table th.sortable.desc::after { content: '\25BE'; }
    .forecast-table th.sortable.active-sort::after { opacity: 1; color: #ff5e2f; }

    /* 🟢 Mobile Group Column Logic */

    /* completely hide the dedicated group column on mobile */
    .forecast-table th.group-col,
    .forecast-table td.group-col {
        display: none !important;
    }

    /* Show the inline badge so the user still sees the group letter */
    .mobile-group-badge {
        display: inline !important;
    }

}

.projection-team-link {
    text-decoration: none;
    color: inherit;
    font-weight: 600;
}