/* =================================================================
   responsive-cards.css — shared mobile "expand from a collapsed card"
   pattern for every data table in the app.

   Usage:
     • Wrap the desktop <table> (and its scroll wrapper) in an element
       with class "rt-desktop".
     • Render a <ResponsiveCardList> right after it (it emits .rt-mobile).
   Below 768px the table is hidden and each row becomes a collapsed
   summary card that expands on tap. Above 768px the table shows and
   the cards are hidden.

   These classes are global (not scoped) on purpose: ResponsiveCardList's
   Summary/Details/Badge templates are authored in the consuming page, so
   their markup carries the page's CSS scope — only global classes style
   reliably across that boundary.
   ================================================================= */

.rt-mobile {
    display: none;
}

@media (max-width: 768px) {
    .rt-desktop {
        display: none !important;
    }

    .rt-mobile {
        display: block;
        padding: 0.75rem;
    }

    .rcard {
        border: 1px solid var(--color-border);
        border-radius: 0.875rem;
        background: #fff;
        margin-bottom: 0.625rem;
        overflow: hidden;
    }

    .rcard:last-child {
        margin-bottom: 0;
    }

    /* Optional red accent for rows that need attention (errors, cancelled, etc.) */
    .rcard--alert {
        border-left: 3px solid var(--color-red);
    }

    /* Always-visible collapsed summary (the "drop-down box"). */
    .rcard-head {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.75rem;
        padding: 0.75rem 0.875rem;
        background: none;
        border: none;
        text-align: left;
        cursor: pointer;
    }

    .rcard-main {
        display: flex;
        flex-direction: column;
        gap: 0.15rem;
        min-width: 0;
    }

    .rcard-title {
        font-weight: 700;
        font-size: 0.9rem;
        color: var(--color-text);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .rcard-sub {
        font-size: 0.72rem;
        color: var(--color-muted);
    }

    .rcard-right {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        flex-shrink: 0;
    }

    .rcard-chev {
        color: var(--color-muted);
        transition: transform 0.18s ease;
        flex-shrink: 0;
    }

    .rcard-chev.is-open {
        transform: rotate(180deg);
    }

    /* Expanded detail panel. */
    .rcard-body {
        padding: 0.25rem 0.875rem 0.75rem;
        border-top: 1px solid var(--color-bg-light);
    }

    .rcard-kv {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        gap: 1rem;
        padding: 0.45rem 0;
        border-bottom: 1px solid var(--color-bg-light);
        font-size: 0.82rem;
    }

    .rcard-kv:last-child {
        border-bottom: none;
    }

    .rcard-k {
        flex: 0 0 auto;
        font-weight: 600;
        color: var(--color-muted);
    }

    .rcard-v {
        text-align: right;
        color: var(--color-text);
        word-break: break-word;
        min-width: 0;
    }

    /* Actions (buttons/links) inside an expanded card span the row. */
    .rcard-actions {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 0.5rem;
        padding-top: 0.6rem;
    }

    .rcard-actions > * {
        flex: 1 1 auto;
        justify-content: center;
    }
}
