/* Mobile refinements for the app shell and the pages added for menu fatigue. */

/*
 * Tabler lays alerts out as a flex row, so a text alert with an inline link
 * (or a list of error lines) is split into side-by-side columns on narrow
 * screens. Alerts that need an icon beside the text opt in with `d-flex`.
 */
.alert {
    display: block;
}

/*
 * `row-deck` columns are flex containers, but only Tabler's `.card` stretches
 * to fill them; the member pages use `.premium-glass-card`, which stayed at
 * its content width (about 70% of the column on a phone).
 */
.row-deck > [class*="col"] > .premium-glass-card {
    flex: 1 1 auto;
    min-width: 0;
}

/*
 * Sidebar opener: icon plus a visible "Menu" label (NN/g: a labelled opener is
 * found more often). Limited to the widths where the sidebar collapses
 * (navbar-expand-lg), otherwise it would reappear on desktop.
 */
@media (max-width: 991.98px) {
    .navbar-vertical .navbar-toggler {
        display: inline-flex;
        align-items: center;
        gap: 0.75rem;
        width: auto;
        color: rgba(255, 255, 255, 0.85);
    }

    /* The icon is drawn with ::before/::after and has no content, so a flex row would shrink it to nothing. */
    .navbar-vertical .navbar-toggler-icon {
        flex: 0 0 1.5rem;
        width: 1.5rem;
    }

    .navbar-vertical .navbar-toggler-label {
        font-size: .875rem;
        font-weight: 500;
    }

    /* Air between the opener row and the first section label of the opened menu. */
    .navbar-vertical .navbar-collapse .navbar-nav {
        padding-top: 0.75rem;
        padding-bottom: 0.5rem;
    }
}

@media (min-width: 992px) {
    .navbar-toggler-label {
        display: none;
    }
}

@media (max-width: 575.98px) {
    /* Hero: let the action button drop under the title instead of squeezing the text. */
    .premium-hero-banner > .d-flex,
    .page-hero.d-flex {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    /* Comfortable touch targets for the "Hari Ini" actions and the Hub's next step. */
    #today-tasks .btn,
    #hub-next-step .btn {
        min-height: 2.75rem;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 0.35rem;
    }

    #hub-next-step .btn {
        width: 100%;
    }

    /* Command palette: near full width, 16px input (iOS zooms smaller ones), 44px rows. */
    .command-palette {
        width: calc(100vw - 1rem);
        margin-top: 4vh;
    }

    .command-palette-card {
        max-height: 80vh;
    }

    .command-palette-input {
        font-size: 1rem;
    }

    .command-palette-option {
        min-height: 2.75rem;
        align-items: center;
    }
}

/* Keyboard hints make no sense without a hover-capable pointer (phones, tablets). */
@media (hover: none) {
    .command-palette-hint {
        display: none;
    }
}

/*
 * Wide data tables (Members, Cockpit) turn into one card per row on phones, so
 * the actions at the end of a row are no longer hidden behind a sideways
 * scroll. Cells carry a data-label that is shown in front of their value; the
 * header row stays available to assistive technology but is hidden visually.
 */
@media (max-width: 767.98px) {
    .table-stack thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
    }

    .table-stack,
    .table-stack tbody,
    .table-stack tr,
    .table-stack td {
        display: block;
        width: 100%;
    }

    .table-stack tr {
        padding: 0.75rem 1rem;
        border-bottom: 1px solid var(--ex-line, #e2e8f0);
    }

    /* Label above the value: cells with several children (name + email) keep reading top to bottom. */
    .table-stack td,
    .table-stack td:first-child,
    .table-stack td:last-child {
        padding: 0.35rem 0 !important;
        border: 0;
        max-width: none !important;
        text-align: left;
    }

    .table-stack td::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 0.125rem;
        font-size: .75rem;
        font-weight: 500;
        letter-spacing: 0;
        color: var(--ex-caption, #64748b);
    }

    .table-stack td[data-label=""]::before,
    .table-stack td[colspan]::before {
        display: none;
    }

    .table-stack td[data-label=""] {
        padding-top: 0.5rem;
    }
}

/*
 * Goal Hub stepper: six phases with arrows wrap into a zigzag on a phone, so
 * it becomes a plain vertical list (number, phase name, count) without arrows.
 */
@media (max-width: 575.98px) {
    .premium-dashboard-scope .goal-stepper {
        flex-direction: column;
        gap: 0.5rem;
    }

    /* The arrows carry the `d-flex` utility, which is !important. */
    .premium-dashboard-scope .goal-stepper-arrow {
        display: none !important;
    }

    .premium-dashboard-scope .goal-stepper-item {
        flex: 0 0 auto;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 0.5rem;
        padding: 0;
    }

    .premium-dashboard-scope .goal-stepper-step {
        flex: 1 1 auto;
        flex-direction: row;
        justify-content: flex-start;
        gap: 0.75rem;
        width: auto;
        min-height: 2.75rem;
        padding: 0.5rem 0.75rem;
    }

    .premium-dashboard-scope .goal-stepper-step .step-label {
        margin-top: 0;
        text-align: left;
        font-size: .875rem !important;
    }

    .premium-dashboard-scope .stepper-badge {
        margin-top: 0 !important;
        white-space: nowrap;
    }
}
