/* Explain: Mobile CSS: live status badges and legend are now consistent and readable on narrow screens. */
/* זרימת ההדרכה בטלפון: טבלת המעקב החי מוצגת ככרטיסים במסך צר, תגיות הסטטוס והמקרא, וסינון „טרם חתמו” */

/* תגית הסטטוס במעקב החי: אותו צבע, אייקון ונוסח בשורות הטבלה, בכרטיסים במסך צר ובמקרא שמעל הרשימה.
   המצב נקבע ב-js/live-status.js: exam – במבחן, sign – ממתין לחתימה, signed – חתם, failed – נכשל */
.live-status {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    min-height: 1.75rem;
    padding: 0.25rem 0.7rem;
    border: 1px solid var(--border-color);
    border-radius: 9999px;
    background: var(--surface-color);
    color: var(--secondary-color);
    font-family: var(--font-body);
    font-size: 0.8125rem;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
}

.live-status i {
    font-size: 0.75rem;
    flex-shrink: 0;
}

.live-status[data-state="exam"] {
    background: var(--warning-bg);
    border-color: var(--warning-border);
    color: var(--warning-text);
}

.live-status[data-state="sign"] {
    background: var(--badge-bg);
    border-color: var(--border-color);
    border-color: color-mix(in srgb, var(--accent-color) 45%, transparent);
    color: var(--secondary-color);
}

.live-status[data-state="signed"] {
    background: var(--success-bg);
    border-color: var(--success-border);
    color: var(--success-text);
}

.live-status[data-state="failed"] {
    background: var(--error-bg);
    border-color: var(--error-border);
    color: var(--error-text);
}

/* הציון בשורה: ירוק למי שחתם, אדום למי שנכשל – באותם צבעים של התגית */
.live-score {
    font-family: var(--font-heading);
    font-size: 1.125rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--secondary-color);
}

.live-score-empty {
    font-size: 1rem;
    font-weight: 600;
    color: #66768b;
}

table.live-table tr[data-state="signed"] .live-score:not(.live-score-empty) {
    color: var(--success-text);
}

table.live-table tr[data-state="failed"] .live-score:not(.live-score-empty) {
    color: var(--error-text);
}

/* המקרא במסך צר: תגית ארוכה יורדת שורה בתוך הכרטיס הקטן במקום לחרוג ממנו */
@media (max-width: 639.98px) {
    .live-legend .live-status {
        white-space: normal;
        text-align: start;
    }
}

/* מסך המעקב החי: במסך צר כל שורה בטבלה מוצגת ככרטיס קומפקטי.
   שורה ראשונה: שם וסטטוס. מתחת: ת"ז ומחלקה, והציון בצד */
@media (max-width: 767.98px) {
    table.live-table thead {
        display: none;
    }

    table.live-table,
    table.live-table tbody {
        display: block;
        width: 100%;
    }

    table.live-table tbody tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        column-gap: 0.75rem;
        row-gap: 0.2rem;
        align-items: center;
        padding: 0.75rem 0.875rem;
    }

    table.live-table tbody td {
        display: block;
        min-width: 0;
        padding: 0;
        border: 0;
    }

    table.live-table tbody td[colspan] {
        grid-column: 1 / -1;
    }

    table.live-table tbody tr > td:nth-child(1):not([colspan]) {
        grid-column: 1;
        grid-row: 1;
        min-width: 0;
        font-size: 1rem;
        line-height: 1.35;
    }

    table.live-table tbody tr > td:nth-child(4) {
        grid-column: 2;
        grid-row: 1;
        justify-self: end;
    }

    table.live-table tbody tr > td:nth-child(2) {
        grid-column: 1;
        grid-row: 2;
        font-size: 0.8125rem;
    }

    table.live-table tbody tr > td:nth-child(3) {
        grid-column: 1;
        grid-row: 3;
        font-size: 0.8125rem;
        color: var(--text-muted);
        overflow-wrap: anywhere;
    }

    table.live-table tbody tr > td:nth-child(5) {
        grid-column: 2;
        grid-row: 2 / span 2;
        justify-self: end;
        min-width: 3.25rem;
        text-align: center;
    }

    table.live-table tbody tr > td:nth-child(2)::before {
        content: 'ת"ז ';
        color: var(--text-muted);
        font-weight: 600;
    }

    table.live-table tbody tr > td:nth-child(3)::before {
        content: 'מחלקה: ';
        font-weight: 600;
    }

    table.live-table tbody tr > td:nth-child(5)::before {
        content: 'ציון';
        display: block;
        font-family: var(--font-body);
        font-size: 0.6875rem;
        font-weight: 600;
        line-height: 1.2;
        color: var(--text-muted);
    }

    /* אותה תגית כמו בטבלה, מעט קומפקטית יותר כדי להשאיר מקום לשם */
    table.live-table .live-status {
        min-height: 1.6rem;
        padding: 0.2rem 0.55rem;
        font-size: 0.75rem;
    }
}

/* סינון „טרם חתמו”: מסתירים את מי שכבר חתם (המצב נקבע באותו כלל של תגית הסטטוס) */
.live-only-pending table.live-table tbody tr[data-state="signed"] {
    display: none !important;
}