/* Shared patient-portal presentation. Keep page-specific content styles scoped to their Razor components. */

.patient-guide-list-page,
.patient-product-list-page,
.patient-faq-list-page {
    gap: 1.5rem;
}

.patient-guide-list-page > .admin-hero,
.patient-product-list-page > .admin-hero,
.patient-faq-list-page > .admin-hero {
    grid-template-columns: auto minmax(0, 1fr) minmax(260px, 360px);
}

.patient-guide-list-page > .admin-hero > .patient-guide-hero-search,
.patient-product-list-page > .admin-hero > .patient-product-hero-search,
.patient-faq-list-page > .admin-hero > .patient-faq-hero-search {
    align-self: center;
    grid-column: 3;
    grid-row: 1 / span 2;
    transform: translateX(1.4rem);
    width: 100%;
}

.patient-support-page > .admin-hero {
    grid-template-columns: auto minmax(0, 1fr) max-content;
}

.patient-support-page > .admin-hero > .patient-support-hero-actions {
    max-width: 100%;
    width: max-content;
}

.patient-support-hero-search {
    flex: 0 1 360px;
    min-width: 260px;
    width: 360px;
}

.patient-guide-discovery,
.patient-product-discovery {
    display: grid;
    gap: 1rem;
}

.patient-guide-progress,
.patient-product-recommendation {
    align-items: center;
    background: linear-gradient(90deg, var(--theme-light) 0%, transparent 100%);
    border: 1px solid color-mix(in srgb, var(--theme-primary) 10%, var(--colour-border));
    border-radius: 10px;
    display: grid;
    gap: 1rem;
    grid-template-columns: auto minmax(0, 1fr) auto;
    padding: 0.85rem 1rem;
}

.patient-guide-progress-icon,
.patient-product-recommendation-icon {
    align-items: center;
    background: var(--colour-surface);
    border: 1px solid color-mix(in srgb, var(--theme-primary) 40%, var(--colour-border));
    border-radius: 50%;
    color: var(--theme-primary);
    display: inline-flex;
    height: 2.75rem;
    justify-content: center;
    width: 2.75rem;
}

.patient-guide-progress-content,
.patient-product-recommendation-content {
    display: grid;
    gap: 0.22rem;
    min-width: 0;
}

.patient-guide-progress-content strong,
.patient-product-recommendation-content strong {
    font-size: 0.86rem;
}

.patient-guide-progress-content > span,
.patient-product-recommendation-content span,
.patient-product-recommendation-stat span {
    color: var(--colour-text-secondary);
    font-size: 0.74rem;
}

.patient-guide-progress-stat,
.patient-product-recommendation-stat {
    align-items: center;
    border-left: 1px solid var(--colour-border);
    display: grid;
    justify-items: center;
    min-width: 7.5rem;
    padding-left: 1rem;
}

.patient-guide-progress-stat strong,
.patient-product-recommendation-stat strong {
    color: var(--theme-primary);
    font-size: 1.75rem;
    line-height: 1.05;
}

.patient-category-filter-row {
    align-items: center;
    border-bottom: 1px solid var(--colour-border);
    display: grid;
    gap: 0.5rem;
    grid-template-columns: minmax(0, 1fr) auto;
    min-width: 0;
}

.patient-category-filter-track {
    align-items: center;
    display: flex;
    gap: 0.35rem;
    min-width: 0;
    overflow-x: auto;
    padding: 0.1rem 0 0.4rem;
    scroll-behavior: smooth;
    scrollbar-width: none;
    touch-action: pan-x pan-y;
}

.patient-category-filter-track::-webkit-scrollbar {
    display: none;
}

.patient-category-filter-track:focus-visible {
    border-radius: 8px;
    outline: 2px solid var(--app-focus);
    outline-offset: 3px;
}

.patient-category-filter-option {
    align-items: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--colour-text-secondary);
    display: inline-flex;
    flex: 0 0 auto;
    font: inherit;
    font-size: 0.7rem;
    font-weight: 700;
    justify-content: center;
    min-height: 2rem;
    padding: 0.35rem 0.65rem;
    transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
    white-space: nowrap;
}

.patient-category-filter-option:hover:not(:disabled) {
    background: var(--theme-light);
    color: var(--theme-primary);
}

.patient-category-filter-option:focus-visible {
    outline: 2px solid var(--app-focus);
    outline-offset: 2px;
}

.patient-category-filter-option.active {
    background: var(--theme-primary);
    border-color: var(--theme-primary);
    color: var(--colour-surface);
}

.patient-category-filter-option:disabled {
    cursor: not-allowed;
    opacity: 0.58;
}

.patient-category-filter-controls {
    align-self: start;
    padding-bottom: 0.4rem;
}

.patient-category-filter-controls[hidden] {
    display: none;
}

.patient-guide-no-results,
.patient-product-no-results,
.patient-faq-no-results {
    background: linear-gradient(90deg, var(--theme-light) 0%, transparent 100%);
    border-radius: 12px;
    display: grid;
    gap: 0.4rem;
    justify-items: start;
    padding: 1.5rem;
}

.patient-guide-no-results > i,
.patient-product-no-results > i,
.patient-faq-no-results > i {
    color: var(--theme-primary);
    font-size: 1.5rem;
}

.patient-guide-no-results h3,
.patient-guide-no-results p,
.patient-product-no-results h3,
.patient-product-no-results p,
.patient-faq-no-results h3,
.patient-faq-no-results p {
    margin: 0;
}

.patient-guide-no-results .btn-app,
.patient-product-no-results .btn-app,
.patient-faq-no-results .btn-app {
    margin-top: 0.65rem;
}

.patient-guide-carousel-controls,
.patient-product-carousel-controls {
    display: flex;
    gap: 0.5rem;
}

.patient-product-carousel,
.patient-support-workspace {
    display: grid;
    gap: 1rem;
    min-width: 0;
}

.patient-guide-popular,
.patient-product-popular {
    display: grid;
    gap: 0.65rem;
    margin-top: -0.45rem;
    min-width: 0;
}

.patient-guide-popular-header,
.patient-product-popular-header {
    align-items: center;
    display: flex;
    gap: 1rem;
    justify-content: space-between;
}

.patient-guide-popular-header h2,
.patient-product-popular-header h2 {
    font-size: 1rem;
    margin: 0;
}

:is(.patient-guide-popular-header, .patient-product-popular-header) > [data-carousel-managed]:is([hidden], :not([data-carousel-ready])) {
    /* Keep the header height when carousel arrows are unavailable. */
    display: flex !important;
    visibility: hidden;
}

.patient-guide-popular-track,
.patient-product-popular-track {
    display: grid;
    gap: 0.75rem;
    grid-auto-columns: min(100%, 285px);
    grid-auto-flow: column;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0.15rem 0 0.5rem;
    scroll-behavior: smooth;
    scroll-snap-type: inline mandatory;
    scrollbar-width: none;
    touch-action: pan-x pan-y;
}

.patient-guide-popular-track::-webkit-scrollbar,
.patient-product-popular-track::-webkit-scrollbar {
    display: none;
}

.patient-guide-popular-track:focus-visible,
.patient-product-popular-track:focus-visible {
    border-radius: 8px;
    outline: 2px solid var(--app-focus);
    outline-offset: 3px;
}

.patient-guide-popular-card,
.patient-product-popular-card {
    background: var(--colour-surface);
    border: 1px solid var(--colour-border);
    border-radius: 9px;
    color: var(--colour-text);
    display: grid;
    grid-template-columns: minmax(0, 9rem) minmax(0, 1fr);
    overflow: hidden;
    scroll-snap-align: start;
    text-decoration: none;
    transition: border-color 150ms ease, transform 150ms ease;
}

.patient-guide-popular-card:focus-visible,
.patient-product-popular-card:focus-visible {
    outline: 2px solid var(--app-focus);
    outline-offset: 3px;
}

.patient-guide-popular-media,
.patient-product-popular-media {
    aspect-ratio: 16 / 9;
    background: color-mix(in srgb, var(--theme-primary) 10%, var(--colour-surface));
    display: block;
    height: 100%;
    overflow: hidden;
    width: 100%;
}

.patient-guide-popular-media > span,
.patient-product-popular-media > span {
    align-items: center;
    color: var(--theme-primary);
    display: flex;
    font-size: 1.5rem;
    height: 100%;
    justify-content: center;
}

.patient-guide-popular-body,
.patient-product-popular-body {
    display: grid;
    gap: 0.25rem;
    min-width: 0;
    padding: 0.45rem 0.5rem;
}

.patient-guide-popular-body h3,
.patient-product-popular-body h3 {
    color: var(--colour-text);
    font-size: 0.7rem;
    line-height: 1.35;
    margin: 0;
}

.patient-guide-popular-meta,
.patient-product-popular-meta {
    align-items: center;
    align-self: end;
    display: flex;
    gap: 0.25rem;
    min-width: 0;
}

.patient-guide-popular-meta .guide-meta-pill.filter,
.patient-product-popular-meta .patient-product-meta-pill.filter {
    background: var(--theme-light);
    color: var(--theme-primary);
}

.patient-guide-popular-read,
.patient-product-popular-open {
    --btn-app-text: var(--colour-text-secondary);
    color: var(--colour-text-secondary);
    font-size: 0.7rem;
    line-height: 1;
    margin-left: auto;
    min-height: 1.7rem;
    width: 1.7rem;
}

.patient-support-page .support-ticket-hero > .support-conversation-header-actions,
.support-thread-page .support-ticket-hero > .support-conversation-header-actions {
    margin-right: -1.4rem;
}

@media (max-width: 700px) {
    .patient-guide-list-page > .admin-hero,
    .patient-product-list-page > .admin-hero,
    .patient-faq-list-page > .admin-hero {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .patient-guide-list-page > .admin-hero > .patient-guide-hero-search,
    .patient-product-list-page > .admin-hero > .patient-product-hero-search,
    .patient-faq-list-page > .admin-hero > .patient-faq-hero-search {
        grid-column: 1 / -1;
        grid-row: auto;
        margin-top: 0.4rem;
        transform: none;
    }

    .patient-support-page > .admin-hero > .patient-support-hero-actions {
        grid-column: 1 / -1;
        grid-row: auto;
        margin-right: 0;
        margin-top: 0.4rem;
        width: 100%;
    }

    .patient-support-hero-search {
        flex: 1 1 260px;
        min-width: 0;
        width: auto;
    }

    .patient-guide-progress,
    .patient-product-recommendation {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .patient-guide-progress-stat,
    .patient-product-recommendation-stat {
        border-left: 0;
        border-top: 1px solid var(--colour-border);
        grid-column: 1 / -1;
        justify-content: end;
        min-width: 0;
        padding: 0.65rem 0 0;
    }

    .patient-guide-progress-stat strong,
    .patient-product-recommendation-stat strong {
        font-size: 1.2rem;
    }
}

/* Keep library copy and metadata aligned across cards with different content. */
:is(.guide-carousel.has-mobile-grid .guide-carousel-body, .patient-product-list-page .patient-product-carousel .patient-product-card-body) {
    align-content: start;
    min-width: 0;
}

:is(.guide-carousel.has-mobile-grid .guide-carousel-body, .patient-product-list-page .patient-product-carousel .patient-product-card-body) h3 {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    height: 2.6em;
    overflow: hidden;
    overflow-wrap: anywhere;
}

:is(.guide-carousel.has-mobile-grid .guide-carousel-body, .patient-product-list-page .patient-product-carousel .patient-product-card-body) p {
    height: 2.9em;
}

:is(.guide-carousel.has-mobile-grid .guide-carousel-meta, .patient-product-list-page .patient-product-carousel .patient-product-card-meta) {
    min-width: 0;
}

:is(.guide-carousel.has-mobile-grid .guide-carousel-meta, .patient-product-list-page .patient-product-carousel .patient-product-card-meta) .guide-meta-pill {
    overflow: hidden;
}

:is(.guide-carousel.has-mobile-grid .guide-carousel-meta, .patient-product-list-page .patient-product-carousel .patient-product-card-meta) .guide-meta-pill > span {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Shared mobile library grids: fill each column before the next. */
@media (max-width: 700px) {
    :is(.guide-carousel.has-mobile-grid .guide-carousel-track, .patient-product-list-page .patient-product-carousel .patient-product-carousel-track) {
        --carousel-rows: 2;
        gap: 0.75rem;
        grid-auto-columns: calc((100% - 0.75rem) / 2);
        grid-auto-flow: column;
        grid-template-rows: repeat(2, auto);
    }

    :is(.guide-carousel.has-mobile-grid .guide-carousel-track, .patient-product-list-page .patient-product-carousel .patient-product-carousel-track):has(> :nth-child(2):last-child) {
        /* Keep the four-item paging capacity when the final window contains two cards. */
        grid-template-rows: auto;
    }

    :is(.guide-carousel.has-mobile-grid .guide-carousel-body, .patient-product-list-page .patient-product-carousel .patient-product-card-body) {
        --library-title-height: calc(0.85rem * 1.3 * 2);
        --library-description-height: calc(0.75rem * 1.45 * 4);
        --library-tags-height: calc(2 * (0.65rem * 1.2 + 0.36rem) + 0.25rem);
        gap: 0.5rem;
        grid-template-columns: minmax(0, 1fr) 2rem;
        padding: 0.65rem;
    }

    .guide-carousel.has-mobile-grid .guide-carousel-body {
        grid-template-rows: var(--library-title-height) var(--library-description-height) var(--library-tags-height);
    }

    :is(.guide-carousel.has-mobile-grid .guide-carousel-body, .patient-product-list-page .patient-product-carousel .patient-product-card-body) > :is(h3, p) {
        grid-column: 1 / -1;
    }

    :is(.guide-carousel.has-mobile-grid .guide-carousel-body, .patient-product-list-page .patient-product-carousel .patient-product-card-body) h3 {
        font-size: 0.85rem;
        height: var(--library-title-height);
    }

    :is(.guide-carousel.has-mobile-grid .guide-carousel-body, .patient-product-list-page .patient-product-carousel .patient-product-card-body) p {
        font-size: 0.75rem;
        height: var(--library-description-height);
        max-height: var(--library-description-height);
        -webkit-line-clamp: 4;
    }

    :is(.guide-carousel.has-mobile-grid .guide-carousel-meta, .patient-product-list-page .patient-product-carousel .patient-product-card-meta) {
        position: static;
        align-items: flex-start;
        flex-direction: column;
        gap: 0.25rem;
        height: var(--library-tags-height);
        min-height: 0;
        max-width: 100%;
        width: 100%;
    }

    :is(.guide-carousel.has-mobile-grid .guide-carousel-meta, .patient-product-list-page .patient-product-carousel .patient-product-card-meta) .guide-meta-pill {
        flex: 0 0 auto;
        max-width: 100%;
    }

    .patient-product-list-page .patient-product-carousel .patient-product-card-body {
        grid-template-rows: var(--library-title-height) var(--library-description-height) var(--library-tags-height) calc(0.72rem * 1.45) 2rem;
    }

    .guide-carousel.has-mobile-grid .guide-carousel-meta {
        grid-column: 1;
        grid-row: 3;
    }

    .guide-carousel.has-mobile-grid .guide-carousel-read {
        grid-column: 2;
        grid-row: 3;
    }

    .patient-product-list-page .patient-product-carousel .patient-product-card-meta {
        grid-column: 1 / -1;
        grid-row: 3;
    }

    .patient-product-list-page .patient-product-carousel .patient-product-seller {
        grid-column: 1 / -1;
        grid-row: 4;
        height: 1.45em;
        line-height: 1.45;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .patient-product-list-page .patient-product-carousel .patient-product-price {
        align-self: center;
        grid-column: 1;
        grid-row: 5;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .patient-product-list-page .patient-product-carousel .patient-product-open {
        grid-column: 2;
        grid-row: 5;
    }

    :is(.guide-carousel.has-mobile-grid .guide-carousel-read, .patient-product-list-page .patient-product-carousel .patient-product-open) {
        position: static;
        justify-self: end;
        align-self: center;
    }

    :is(.patient-guide-list-page, .patient-product-list-page) {
        min-width: 0;
        max-width: 100%;
    }

    :is(.patient-guide-popular-track, .patient-product-popular-track) {
        --carousel-stacked: 1;
        grid-auto-columns: 100%;
        grid-auto-flow: row;
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: none;
        overflow: visible;
        scroll-snap-type: none;
        touch-action: pan-y;
    }

    :is(.patient-guide-popular-card, .patient-product-popular-card) {
        grid-template-columns: minmax(0, 30%) minmax(0, 1fr);
        min-width: 0;
    }

    :is(.patient-guide-popular-body, .patient-product-popular-body) h3 {
        font-size: 0.85rem;
        overflow-wrap: anywhere;
    }
}

/* Keep the content language control outside the scrolling category track. */
.admin-landing-page > .patient-content-language-control {
    /* Standalone rows need a small gap, while retaining the 44px touch target. */
    margin-block: calc(.25rem - var(--app-page-gap));
}

.patient-content-filter-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: .5rem 1.25rem;
    min-width: 0;
}
@media (max-width: 900px) {
    .patient-content-filter-layout { grid-template-columns: minmax(0, 1fr); gap: .125rem; }
}
