/* recentActivity module styles */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

#ra-table td {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* Active transmission row — subtle pulsing background */
#ra-table tr.ra-active {
    background: var(--ps-active-bg, rgba(40, 167, 69, 0.1));
    animation: ra-pulse 1.5s ease-in-out infinite;
}

@keyframes ra-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Lost transmission row — subtle italic to distinguish from clean end */
#ra-table tr.ra-lost {
    font-style: italic;
}

/* Callsigns and targets in monospace, so a D-Star command target such
   as "       E" lines up at full width */
#ra-table .ra-callsign,
#ra-table .ra-target {
    font-family: var(--ps-font-mono);
}

/* POCSAG page text, talkgroup names and who a caller is keep the
   normal font */
#ra-table .ra-target.ra-page,
#ra-table .ra-target .ra-tgname,
#ra-table .ra-callsign .ra-who,
#ra-table .ra-callsign .call-links {
    font-family: inherit;
    font-weight: normal;
}

/* NXDN / P25 talkgroup name under the TG number */
.ra-tgname {
    font-size: 0.8em;
    color: var(--ps-text-secondary);
    white-space: normal;
    overflow-wrap: anywhere;
    max-width: 20em;
}

/* Duration column — monospace for ticking counter */
#ra-table .ra-duration {
    font-family: var(--ps-font-mono, monospace);
    min-width: 4em;
}

/* Mode colour classes — applied to the mode cell only */
#ra-table td[class^="ra-mode-"] { font-weight: 600; }
#ra-table .ra-mode-dmr    { color: var(--ps-accent-text, var(--ps-accent)); }
#ra-table .ra-mode-dstar  { color: var(--ps-info-text, var(--ps-info)); }
#ra-table .ra-mode-ysf    { color: var(--ps-success-text, var(--ps-success)); }
#ra-table .ra-mode-p25    { color: var(--ps-warning-text, var(--ps-warning)); }
#ra-table .ra-mode-nxdn   { color: var(--ps-danger-text, var(--ps-danger)); }
#ra-table .ra-mode-m17    { color: var(--ps-accent-text, var(--ps-accent)); }
#ra-table .ra-mode-fm     { color: var(--ps-text-secondary); }
#ra-table .ra-mode-pocsag { color: var(--ps-info-text, var(--ps-info)); }
#ra-table .ra-mode-cw     { color: var(--ps-text-secondary); }

/* POCSAG page text, where a talkgroup would be: shown in full, wrapping */
#ra-table .ra-target.ra-page {
    max-width: 32em;
    white-space: normal;
    overflow-wrap: anywhere;
}

/* RSSI: shown only once a call has one (the modem sends it) */
#ra-table-full .ra-rssi {
    display: none;
}
#ra-table-full.ra-has-rssi .ra-rssi {
    display: table-cell;
}

/* RSSI: the S reading (VHF/UHF scale) with a small meter, the dBm under
   it in the muted style of a talkgroup's name */
#ra-table .ra-rssi .ra-s {
    display: flex;
    align-items: center;
    gap: 0.4em;
    font-weight: 600;
}

#ra-table .ra-rssi .ra-s-val {
    min-width: 4.1em;
}

/* The meter: segments rising in height, the unlit ones faint so the
   scale shows; green to S9, then the warning colour, then danger from +30 */
#ra-table .ra-rssi .ra-s-meter {
    display: inline-flex;
    align-items: flex-end;
    gap: 1px;
    height: 1.05em;
}

#ra-table .ra-rssi .ra-seg {
    display: block;
    width: 4px;
    border-radius: 1px;
    background: var(--ps-text-secondary, #6c757d);
    opacity: 0.22;
}

#ra-table .ra-rssi .ra-seg-on {
    opacity: 1;
}

#ra-table .ra-rssi .ra-seg-s.ra-seg-on {
    background: var(--ps-success, #28a745);
}

#ra-table .ra-rssi .ra-seg-over.ra-seg-on {
    background: var(--ps-warning, #ffc107);
}

#ra-table .ra-rssi .ra-seg-hot.ra-seg-on {
    background: var(--ps-danger, #dc3545);
}

/* A little gap where S9 ends and the over-S9 steps begin, as on a meter's
   scale */
#ra-table .ra-rssi .ra-seg-s + .ra-seg-over {
    margin-left: 2px;
}

#ra-table .ra-rssi .ra-dbm {
    font-size: 0.8em;
    font-weight: normal;
    color: var(--ps-text-secondary);
}

/* The day and date under the time: on one line */
#ra-table .ra-time .ra-day {
    white-space: nowrap;
}

/* The caller's ID after the callsign, in brackets: quieter than it */
#ra-table .ra-callsign .ra-id {
    font-size: 0.85em;
    color: var(--ps-text-secondary);
}

/* "No EoT": a network call whose end never came */
#ra-table .ra-loss .ra-eot {
    color: var(--ps-warning-text, var(--ps-warning));
    font-weight: 600;
    white-space: nowrap;
    cursor: help;
}

/* Phones and narrow windows (under 920px, where the nine columns no
   longer fit): each call a compact entry instead of a row of nine columns,
   which ran off the screen. Three lines: the caller (with their name
   and country) and the time; the mode and where it went; the figures,
   smaller. Cells: callsign, mode, target, source, duration, loss, BER,
   RSSI, time. */
@media (max-width: 920px) {
    #ra-table-full thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }
    #ra-table-full,
    #ra-table-full tbody {
        display: block;
        width: 100%;
    }
    #ra-table tr {
        display: flex;
        flex-wrap: wrap;
        align-items: baseline;
        column-gap: 0.6rem;
        row-gap: 0.15rem;
        padding: 0.55rem 0.25rem;
        border-bottom: 1px solid var(--ps-border);
    }
    #ra-table td {
        display: block;
        padding: 0;
        border: 0;
        white-space: normal;
        min-width: 0;
    }
    #ra-table td:empty { display: none; }
    /* Line breaks between the three lines */
    #ra-table tr::before,
    #ra-table tr::after {
        content: "";
        flex-basis: 100%;
        height: 0;
    }
    #ra-table tr::before { order: 2; }
    #ra-table tr::after { order: 5; }

    /* 1: the caller, the time on the right */
    #ra-table td:nth-child(1) { order: 0; flex: 1 1 0; font-weight: 600; }
    #ra-table td:nth-child(9) { order: 1; flex: 0 0 auto; text-align: right; font-size: 0.875em; }
    #ra-table .ra-callsign .ra-who { font-weight: normal; }
    /* 2: the mode, and the target with its network beside it */
    #ra-table td:nth-child(2) { order: 3; flex: 0 0 auto; }
    #ra-table td:nth-child(3) { order: 4; flex: 1 1 0; }
    #ra-table .ra-target .ra-via { display: inline; margin-left: 0.35em; }
    .ra-tgname { max-width: none; }
    /* 3: the figures */
    #ra-table td:nth-child(n+4):nth-child(-n+8) {
        order: 6;
        font-size: 0.8em;
        color: var(--ps-text-secondary);
        min-width: 0;
    }
    #ra-table td[data-label]:not(:empty)::before {
        content: attr(data-label) " ";
    }
    #ra-table .ra-loss .ra-eot { display: inline; margin-left: 0.35em; }
    #ra-table-full.ra-has-rssi .ra-rssi { display: block; }
    #ra-table .ra-rssi .ra-s,
    #ra-table .ra-rssi .ra-dbm { display: inline-flex; }
    #ra-table .ra-rssi .ra-dbm { margin-left: 0.4em; font-size: 1em; }
    #ra-table .ra-rssi .ra-s-val { min-width: 0; }
}

/* The heading and the Compact switch on one line */
.ra-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
.ra-head h2 { margin-bottom: 0.75rem; }
.ra-compact {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
    color: var(--ps-text-secondary);
}

/* "×N": a caller's calls, compacted; opens them */
.ra-more {
    display: inline-block;
    min-height: 0;
    margin-left: 0.35rem;
    padding: 0.05rem 0.45rem;
    border: 1px solid var(--ps-border);
    border-radius: 1rem;
    background: var(--ps-bg-tertiary);
    color: var(--ps-text-primary);
    font: inherit;
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
    line-height: 1.4;
    cursor: pointer;
    vertical-align: 0.1em;
}
.ra-more:hover,
.ra-more[aria-expanded="true"] {
    border-color: var(--ps-accent);
    color: var(--ps-accent-text, var(--ps-accent));
}
.ra-more:focus-visible {
    outline: 2px solid var(--ps-accent);
    outline-offset: 1px;
}

/* A caller's earlier calls, opened under their line */
#ra-table tr.ra-sub {
    background: color-mix(in srgb, var(--ps-bg-tertiary) 55%, transparent);
}
#ra-table tr.ra-sub td:first-child {
    padding-left: 1.5rem;
    border-left: 3px solid var(--ps-accent);
}
