/*
 * Program browser (Livewire: meal-plans.filter-plans).
 * Shared by /meal-plans and the homepage meal plans section.
 * Hand-written CSS — not built by npm run build:styles.
 */

.dw-program-browser {
    --dw-green: #43c54c;
    --dw-green-dark: #31ad3b;
    --dw-green-soft: rgba(67, 197, 76, 0.12);
    --dw-blue: #32a3e8;
    --dw-blue-dark: #218fd2;
    --dw-page: #f4f5f9;
    --dw-card: #ffffff;
    --dw-text: #111827;
    --dw-muted: #8a94a6;
    --dw-border: #e7eaf0;
    --dw-pill: #f4f6f9;

    width: 100%;
}

/*
 * Category tabs
 */
.dw-category-tabs {
    display: flex;
    gap: 0.875rem;
    margin-top: 2.25rem;
    padding: 0 0 0.5rem;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scroll-snap-type: inline mandatory;
    scrollbar-width: none;
    padding-top: 0.3rem;
}

.dw-category-tabs::-webkit-scrollbar {
    display: none;
}

.dw-category-tab {
    position: relative;
    display: flex;
    flex: 0 0 17.5rem;
    min-width: 0;
    min-height: 4.5rem;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    overflow: hidden;
    text-align: start;
    color: var(--dw-muted);
    background: var(--dw-card);
    border: 1px solid var(--dw-border);
    border-radius: 1rem;
    cursor: pointer;
    scroll-snap-align: start;
    transition:
        color 180ms ease,
        background-color 180ms ease,
        border-color 180ms ease,
        box-shadow 220ms ease,
        transform 180ms ease;
}

.dw-category-tab:hover {
    color: var(--dw-text);
    border-color: rgba(67, 197, 76, 0.35);
    transform: translateY(-2px);
}

.dw-category-tab:focus-visible {
    outline: 3px solid rgba(50, 163, 232, 0.22);
    outline-offset: 3px;
}

.dw-category-tab:disabled {
    cursor: wait;
}

.dw-category-tab.is-active {
    color: #ffffff;
    background: var(--dw-green);
    border-color: var(--dw-green);
    box-shadow: 0 0.875rem 1.75rem rgba(67, 197, 76, 0.2);
}

.dw-category-tab__icon {
    display: inline-flex;
    flex: 0 0 2.75rem;
    width: 2.75rem;
    height: 2.75rem;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #f3f5f8;
    border-radius: 0.75rem;
}

.dw-category-tab.is-active .dw-category-tab__icon {
    background: rgba(255, 255, 255, 0.18);
}

.dw-category-tab__icon img {
    display: block;
    width: 2rem;
    height: 2rem;
    object-fit: contain;
}

.dw-category-tab__content {
    display: flex;
    min-width: 0;
    flex: 1;
    flex-direction: column;
    gap: 0.125rem;
}

.dw-category-tab__name {
    overflow: hidden;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.3;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dw-category-tab__description {
    display: -webkit-box;
    overflow: hidden;
    font-size: 0.7rem;
    font-weight: 500;
    line-height: 1.35;
    color: #a0a8b7;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.dw-category-tab.is-active .dw-category-tab__description {
    color: rgba(255, 255, 255, 0.84);
}

/*
 * Selected category heading
 */
.dw-selected-category {
    display: flex;
    width: 100%;
    align-items: center;
    gap: 0.75rem;
    margin: 2.25rem 0 1.25rem;
}

.dw-selected-category__line {
    height: 1px;
    flex: 1;
    background: linear-gradient(
        to var(--dw-line-direction, right),
        transparent,
        rgba(67, 197, 76, 0.72)
    );
}

.dw-selected-category__line:last-child {
    --dw-line-direction: left;
}

.dw-selected-category__content {
    display: inline-flex;
    flex: 0 1 auto;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-width: 0;
}

.dw-selected-category__icon {
    display: inline-flex;
    width: 1.65rem;
    height: 1.65rem;
    flex: 0 0 1.65rem;
    align-items: center;
    justify-content: center;
}

.dw-selected-category__icon img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.dw-selected-category__title {
    margin: 0;
    color: var(--dw-text);
    font-size: clamp(1rem, 2vw, 1.125rem);
    font-weight: 600;
    line-height: 1.35;
    text-align: center;
}

/*
 * Programs grid
 */
.dw-program-grid-wrapper {
    position: relative;
}

.dw-program-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem;
    opacity: 1;
    transition: opacity 160ms ease;
}

.dw-program-grid.is-loading {
    opacity: 0.45;
    pointer-events: none;
}

/*
 * Program card
 */
.dw-program-card {
    display: flex;
    min-width: 0;
    min-height: 13rem;
    flex-direction: column;
    padding: 1.25rem;
    overflow: hidden;
    background: var(--dw-card);
    border: 1px solid var(--dw-border);
    border-radius: 1.125rem;
    box-shadow: 0 0.25rem 0.75rem rgba(15, 23, 42, 0.045);
    opacity: 0;
    transform: translateY(0.75rem);
    animation: dwProgramCardEnter 420ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
    animation-delay: calc(var(--dw-card-index, 0) * 55ms);
    transition:
        border-color 220ms ease,
        box-shadow 220ms ease,
        transform 220ms ease;
}

.dw-program-card:hover {
    border-color: rgba(67, 197, 76, 0.3);
    box-shadow: 0 1rem 2.25rem rgba(15, 23, 42, 0.09);
    transform: translateY(-0.25rem);
}

.dw-program-card__main {
    display: flex;
    min-width: 0;
    flex: 1;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.dw-program-card__content {
    display: flex;
    min-width: 0;
    flex: 1;
    flex-direction: column;
    gap: 0.65rem;
}

.dw-program-card__title-link {
    display: inline-flex;
    align-self: flex-start;
    color: inherit;
    text-decoration: none;
}

.dw-program-card__title {
    display: -webkit-box;
    min-height: 1.6rem;
    margin: 0;
    overflow: hidden;
    color: var(--dw-text);
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.35;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.dw-program-card__title-link:hover .dw-program-card__title {
    color: var(--dw-green-dark);
}

.dw-program-card__badges {
    display: flex;
    min-width: 0;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
}

.dw-program-card__badge {
    display: inline-flex;
    max-width: 100%;
    align-items: center;
    padding: 0.34rem 0.6rem;
    overflow: hidden;
    color: #4d5869;
    background: var(--dw-pill);
    border: 1px solid #edf0f4;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 550;
    line-height: 1.25;
    text-overflow: ellipsis;
}

.dw-program-card__image {
    display: inline-flex;
    width: 4.25rem;
    height: 4.25rem;
    flex: 0 0 4.25rem;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #f4f6fb;
    border-radius: 1rem;
    transition:
        transform 220ms ease,
        background-color 220ms ease;
}

.dw-program-card:hover .dw-program-card__image {
    background: #f0f8f1;
    transform: scale(1.025);
}

.dw-program-card__image img {
    display: block;
    width: 3.4rem;
    height: 3.4rem;
    object-fit: contain;
    transition: transform 260ms ease;
}

.dw-program-card:hover .dw-program-card__image img {
    transform: scale(1.04);
}

/*
 * Program footer and pricing
 */
.dw-program-card__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 1rem;
    padding-top: 0.9rem;
    border-top: 1px solid var(--dw-border);
}

.dw-program-card__price {
    min-width: 0;
    flex: 1;
}

.dw-program-card__price-main {
    display: flex;
    min-width: 0;
    align-items: baseline;
    gap: 0.24rem;
    white-space: nowrap;
}

.dw-program-card__currency {
    color: var(--dw-green);
    font-size: 1rem;
    font-weight: 600;
}

.dw-program-card__amount {
    color: var(--dw-green);
    font-size: clamp(1.25rem, 2vw, 1.45rem);
    font-weight: 600;
    letter-spacing: -0.03em;
    line-height: 1;
}

.dw-program-card__period {
    color: #97a0b1;
    font-size: 0.7rem;
    font-weight: 550;
}

.dw-program-card__unavailable {
    color: #8a94a6;
    font-size: 0.78rem;
    font-weight: 600;
}

.dw-program-card__select {
    display: inline-flex;
    min-width: 5.75rem;
    min-height: 2.4rem;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    padding: 0.55rem 1rem;
    color: #ffffff;
    background: var(--dw-blue);
    border-radius: 0.75rem;
    box-shadow: 0 0.45rem 1rem rgba(50, 163, 232, 0.2);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
    text-decoration: none;
    transition:
        background-color 180ms ease,
        box-shadow 180ms ease,
        transform 180ms ease;
}

.dw-program-card__select:hover {
    color: #ffffff;
    background: var(--dw-blue-dark);
    box-shadow: 0 0.65rem 1.25rem rgba(50, 163, 232, 0.28);
    transform: translateY(-0.1rem);
}

.dw-program-card__select:focus-visible {
    outline: 3px solid rgba(50, 163, 232, 0.24);
    outline-offset: 3px;
}

/*
 * Empty state
 */
.dw-program-empty {
    display: flex;
    grid-column: 1 / -1;
    min-height: 16rem;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
    background: var(--dw-card);
    border: 1px solid var(--dw-border);
    border-radius: 1.125rem;
}

.dw-program-empty__icon {
    width: 4rem;
    height: 4rem;
    margin-bottom: 1rem;
    color: #bdc4cf;
}

.dw-program-empty__icon svg {
    display: block;
    width: 100%;
    height: 100%;
}

.dw-program-empty__title {
    margin: 0;
    color: var(--dw-text);
    font-size: 1.05rem;
    font-weight: 600;
}

.dw-program-empty__description {
    max-width: 24rem;
    margin: 0.4rem 0 0;
    color: var(--dw-muted);
    font-size: 0.85rem;
    line-height: 1.6;
}

@keyframes dwProgramCardEnter {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/*
 * Tablet
 */
@media (min-width: 48rem) {
    .dw-program-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/*
 * Desktop
 */
@media (min-width: 64rem) {
    .dw-category-tabs {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        overflow: visible;
        padding-bottom: 0;
    }

    .dw-category-tab {
        width: 100%;
        min-width: 0;
        flex-basis: auto;
    }
}

@media (min-width: 68.75rem) {
    .dw-program-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/*
 * Small mobile
 */
@media (max-width: 30rem) {
    .dw-category-tabs {
        margin-inline: -0.25rem;
        padding-inline: 0.25rem;
    }

    .dw-category-tab {
        flex-basis: 15.75rem;
        padding: 0.7rem 0.8rem;
    }

    .dw-program-card {
        padding: 1rem;
    }

    .dw-program-card__main {
        gap: 0.75rem;
    }

    .dw-program-card__image {
        width: 3.8rem;
        height: 3.8rem;
        flex-basis: 3.8rem;
    }

    .dw-program-card__image img {
        width: 3rem;
        height: 3rem;
    }

    .dw-program-card__footer {
        gap: 0.5rem;
    }

    .dw-program-card__select {
        min-width: 5.25rem;
        padding-inline: 0.8rem;
    }

    .dw-selected-category {
        gap: 0.5rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .dw-category-tab,
    .dw-program-card,
    .dw-program-card__image,
    .dw-program-card__image img,
    .dw-program-card__select,
    .dw-program-grid {
        animation: none !important;
        transition: none !important;
    }

    .dw-program-card {
        opacity: 1;
        transform: none;
    }
}
