.seasons-section {
    width: 100%;
    margin-top: 24px;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    min-height: 32px;
    gap: 16px;

    &__left {
        display: flex;
        align-items: center;
        gap: 16px;
        flex: 1;
    }

    .section-title {
        font-size: 1.25rem;
        font-weight: 600;
        margin: 0;
        color: var(--text-primary);
        letter-spacing: -0.01em;
    }

    .back-btn {
        display: flex;
        align-items: center;
        gap: 6px;
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid rgba(255, 255, 255, 0.1);
        color: var(--text-secondary);
        font-size: 0.8125rem;
        font-weight: 500;
        cursor: pointer;
        transition: all 0.2s ease;
        padding: 6px 12px;
        border-radius: 4px;

        &:hover {
            color: var(--text-primary);
            background: rgba(255, 255, 255, 0.1);
            border-color: rgba(255, 255, 255, 0.2);
        }

        mat-icon {
            font-size: 18px;
            width: 18px;
            height: 18px;
        }
    }

    .view-toggle {
        mat-button-toggle-group {
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 6px;
            overflow: hidden;
            background: rgba(255, 255, 255, 0.03);

            ::ng-deep {
                .mat-button-toggle {
                    background: transparent;

                    .mat-button-toggle-button {
                        padding: 0 8px;
                        height: 32px;
                    }

                    mat-icon {
                        font-size: 18px;
                        width: 18px;
                        height: 18px;
                        color: var(--text-secondary);
                    }

                    &.mat-button-toggle-checked {
                        background: rgba(255, 255, 255, 0.1);

                        mat-icon {
                            color: var(--accent-color);
                        }
                    }

                    &:hover:not(.mat-button-toggle-checked) {
                        background: rgba(255, 255, 255, 0.05);
                    }
                }

                .mat-button-toggle-appearance-standard {
                    .mat-button-toggle-label-content {
                        line-height: 32px;
                        padding: 0;
                    }
                }

                .mat-button-toggle + .mat-button-toggle {
                    border-left: 1px solid rgba(255, 255, 255, 0.1);
                }
            }
        }
    }
}

.loading-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 30px 0;
    width: 100%;
}

.empty-state-panel {
    display: grid;
    justify-items: center;
    gap: 14px;
    width: min(100%, 520px);
    margin: 0 auto;
    padding: 32px 28px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.03)),
        radial-gradient(circle at top, rgba(255, 255, 255, 0.06), transparent 60%);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.04),
        0 18px 40px rgba(0, 0, 0, 0.22);
    text-align: center;

    &__icon {
        display: grid;
        place-items: center;
        width: 64px;
        height: 64px;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid rgba(255, 255, 255, 0.08);
        color: rgba(255, 255, 255, 0.52);

        mat-icon {
            font-size: 30px;
            width: 30px;
            height: 30px;
        }
    }

    &__title {
        margin: 0;
        color: var(--text-primary);
        font-size: 1.125rem;
        font-weight: 600;
        letter-spacing: -0.02em;
    }

    &__message {
        max-width: 40ch;
        margin: 0;
        color: var(--text-secondary);
        font-size: 0.9375rem;
        line-height: 1.6;
    }

    &--season {
        border-color: rgba(255, 255, 255, 0.1);
        background:
            linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.04)),
            radial-gradient(circle at top, rgba(255, 255, 255, 0.08), transparent 65%);
    }
}

// Grid Layouts
.seasons-grid,
.episodes-grid {
    display: grid;
    gap: 12px;
    width: 100%;
}

.seasons-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}

.episodes-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}

// Season Card
.season-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    position: relative;
    overflow: hidden;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;

    &:hover {
        background: rgba(255, 255, 255, 0.1);
        transform: translateY(-2px);
        border-color: rgba(255, 255, 255, 0.15);

        .season-card__arrow {
            opacity: 1;
            transform: translateX(0);
        }
    }

    &__progress-ring {
        position: relative;
        width: 42px;
        height: 42px;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;

        svg {
            width: 100%;
            height: 100%;
            transform: rotate(-90deg);
        }

        .progress-ring__bg {
            fill: none;
            stroke: rgba(255, 255, 255, 0.1);
            stroke-width: 3;
        }

        .progress-ring__fill {
            fill: none;
            stroke: var(--accent-color);
            stroke-width: 3;
            stroke-linecap: round;
            transition: stroke-dasharray 0.5s ease-out;
        }

        .season-card__number {
            position: absolute;
            font-size: 1rem !important;
            color: var(--text-primary);
            font-weight: 700;
            opacity: 1;
            margin: 0;
            padding: 0;
            background: transparent;
        }
    }

    &__info {
        flex: 1;
        display: flex;
        flex-direction: column;
        gap: 2px;
    }

    &__label {
        font-size: 0.9375rem !important;
        font-weight: 600;
        color: var(--text-primary);
    }

    &__progress-text {
        font-size: 0.75rem;
        color: var(--text-muted);
    }

    &__episodes {
        font-size: 0.75rem;
        color: var(--text-muted);
    }

    &__arrow {
        opacity: 0;
        transform: translateX(-5px);
        transition: all 0.2s ease;
        color: var(--text-muted);

        mat-icon {
            font-size: 18px;
            width: 18px;
            height: 18px;
        }
    }

    &--has-episodes {
        /* background: rgba(var(--accent-color-rgb), 0.1);
        border-color: rgba(var(--accent-color-rgb), 0.3); */

        .season-card__number {
            color: var(--text-primary);
        }

        /* .season-card__label {
            color: var(--accent-color);
        } */
    }
}

// Episode Card
.episode-card {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid rgba(255, 255, 255, 0.05);
    position: relative;

    // In-progress state
    &--in-progress {
        border-color: color-mix(in srgb, var(--mat-sys-primary) 60%, transparent);
        background: color-mix(in srgb, var(--mat-sys-primary) 5%, transparent);

        &::before {
            content: '';
            position: absolute;
            inset: 0;
            background: linear-gradient(
                135deg,
                color-mix(in srgb, var(--mat-sys-primary) 10%, transparent) 0%,
                transparent 50%
            );
            pointer-events: none;
            z-index: 1;
        }
    }

    &--launching,
    &--active-external {
        border-color: color-mix(in srgb, var(--mat-sys-tertiary) 56%, transparent);
        box-shadow: 0 0 0 1px color-mix(in srgb, var(--mat-sys-tertiary) 28%, transparent);
    }

    &--launching {
        .episode-card__overlay {
            opacity: 1;
            background: rgba(0, 0, 0, 0.56);
        }
    }

    &--active-external {
        background: color-mix(in srgb, var(--mat-sys-tertiary-container) 18%, transparent);
    }

    // Watched state
    &--watched {
        opacity: 0.7;

        &:hover {
            opacity: 1;
        }

        .episode-card__title::after {
            content: ' ✓';
            color: var(--mat-sys-tertiary);
            font-weight: bold;
            margin-left: 4px;
        }
    }

    &:hover {
        transform: translateY(-2px);
        background: rgba(255, 255, 255, 0.07);
        border-color: rgba(255, 255, 255, 0.1);

        .episode-card__overlay {
            opacity: 1;
        }

        .episode-card__play {
            transform: scale(1);
        }
    }

    &__thumbnail {
        position: relative;
        aspect-ratio: 16 / 9;
        background: #000;
        overflow: hidden;

        img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }
    }

    &__position-text {
        position: absolute;
        bottom: 8px;
        left: 8px;
        background: rgba(0, 0, 0, 0.85);
        padding: 2px 6px;
        border-radius: 3px;
        font-size: 0.7rem;
        font-weight: 600;
        color: white;
        z-index: 2;
    }

    &__placeholder {
        width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        background: linear-gradient(135deg, #2a2a2a 0%, #1a1a1a 100%);
        color: var(--text-muted);

        mat-icon {
            font-size: 32px;
            width: 32px;
            height: 32px;
            opacity: 0.3;
        }
    }

    &__overlay {
        position: absolute;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        display: flex;
        align-items: center;
        justify-content: center;
        opacity: 0;
        transition: opacity 0.2s ease;
        z-index: 1;
    }

    &__actions {
        position: absolute;
        top: 4px;
        right: 4px;
        z-index: 2;
        opacity: 0;
        transition: opacity 0.2s ease;
        display: flex;
        gap: 4px;

        .download-btn,
        .toggle-watched-btn {
            color: rgba(255, 255, 255, 0.7);
            background: rgba(0, 0, 0, 0.5);
            width: 32px;
            height: 32px;
            padding: 4px;

            &:hover {
                color: white;
                background: rgba(0, 0, 0, 0.8);
            }

            mat-icon {
                font-size: 20px;
                width: 20px;
                height: 20px;
            }
        }

        .download-btn:hover {
            background: rgba(25, 118, 210, 0.8);
        }

        .download-btn--completed {
            color: var(--mat-sys-tertiary) !important;

            &:hover {
                background: color-mix(in srgb, var(--mat-sys-tertiary) 80%, transparent);
            }
        }

        .download-btn--downloading {
            color: rgba(255, 255, 255, 0.5) !important;
            cursor: not-allowed;
        }
    }

    &:hover {
        .episode-card__actions {
            opacity: 1;
        }
    }

    &__play {
        width: 40px;
        height: 40px;
        border-radius: 50%;
        background: var(--accent-color);
        display: flex;
        align-items: center;
        justify-content: center;
        color: white;
        transform: scale(0.8);
        transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);

        mat-icon {
            font-size: 24px;
            width: 24px;
            height: 24px;
        }
    }

    &__number {
        position: absolute;
        bottom: 6px;
        right: 6px;
        background: rgba(0, 0, 0, 0.85);
        padding: 2px 6px;
        border-radius: 3px;
        font-size: 0.7rem;
        font-weight: 600;
        color: white;
    }

    &__info {
        padding: 12px;
    }

    &__title {
        font-size: 0.875rem;
        font-weight: 600;
        margin: 0 0 4px 0;
        color: var(--text-primary);
        line-height: 1.4;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    &__plot {
        font-size: 0.75rem;
        color: var(--text-secondary);
        margin: 0 0 8px 0;
        line-height: 1.4;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    &__duration {
        font-size: 0.6875rem;
        color: var(--text-muted);
        display: inline-block;
        padding: 1px 6px;
        background: rgba(255, 255, 255, 0.08);
        border-radius: 10px;
    }
}

// Episodes List View
.episodes-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 100%;
}

.episode-list-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1px solid transparent;

    &:hover {
        background: rgba(255, 255, 255, 0.06);
        border-color: rgba(255, 255, 255, 0.08);

        .episode-list-item__actions {
            opacity: 1;
        }
    }

    &--watched {
        opacity: 0.6;

        &:hover {
            opacity: 1;
        }
    }

    &--in-progress {
        border-color: color-mix(in srgb, var(--mat-sys-primary) 40%, transparent);
        background: color-mix(in srgb, var(--mat-sys-primary) 5%, transparent);

        &:hover {
            border-color: color-mix(in srgb, var(--mat-sys-primary) 60%, transparent);
            background: color-mix(in srgb, var(--mat-sys-primary) 8%, transparent);
        }
    }

    &__number {
        display: flex;
        align-items: center;
        justify-content: center;
        min-width: 36px;
        height: 36px;
        background: rgba(255, 255, 255, 0.06);
        border-radius: 6px;
        font-size: 0.875rem;
        font-weight: 600;
        color: var(--text-secondary);
        flex-shrink: 0;
    }

    &__content {
        flex: 1;
        min-width: 0;
        display: flex;
        flex-direction: column;
        gap: 4px;
    }

    &__header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
    }

    &__title {
        margin: 0;
        font-size: 0.9375rem;
        font-weight: 500;
        color: var(--text-primary);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        display: flex;
        align-items: center;
        gap: 6px;

        .watched-icon {
            font-size: 16px;
            width: 16px;
            height: 16px;
            color: var(--mat-sys-tertiary);
        }
    }

    &__meta {
        display: flex;
        align-items: center;
        gap: 12px;
        flex-shrink: 0;
    }

    &__duration {
        font-size: 0.75rem;
        color: var(--text-muted);
        padding: 2px 8px;
        background: rgba(255, 255, 255, 0.06);
        border-radius: 10px;
    }

    &__progress-text {
        font-size: 0.75rem;
        font-weight: 500;
        color: var(--mat-sys-primary);
        padding: 2px 8px;
        background: color-mix(in srgb, var(--mat-sys-primary) 15%, transparent);
        border-radius: 10px;
    }

    &__description {
        margin: 0;
        font-size: 0.8125rem;
        color: var(--text-secondary);
        line-height: 1.4;
        display: -webkit-box;
        -webkit-line-clamp: 1;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    &__progress-bar {
        height: 3px;
        background: rgba(255, 255, 255, 0.1);
        border-radius: 2px;
        overflow: hidden;
        margin-top: 4px;
    }

    &__progress-fill {
        height: 100%;
        background: var(--mat-sys-primary);
        border-radius: 2px;
        transition: width 0.3s ease;
    }

    &__actions {
        display: flex;
        align-items: center;
        gap: 4px;
        opacity: 0;
        transition: opacity 0.15s ease;

        .action-btn {
            width: 36px;
            height: 36px;
            color: var(--text-secondary);
            transition: all 0.15s ease;

            mat-icon {
                font-size: 20px;
                width: 20px;
                height: 20px;
            }

            &:hover {
                color: var(--text-primary);
                background: rgba(255, 255, 255, 0.1);
            }

            &.play-btn {
                color: var(--accent-color);

                &:hover {
                    background: rgba(var(--accent-color-rgb), 0.15);
                }
            }

            &--success {
                color: var(--mat-sys-tertiary);

                &:hover {
                    background: color-mix(in srgb, var(--mat-sys-tertiary) 15%, transparent);
                }
            }

            &:disabled {
                color: var(--text-muted);
                cursor: not-allowed;
                opacity: 0.5;
            }
        }
    }

    &--launching,
    &--active-external {
        border-color: color-mix(in srgb, var(--mat-sys-tertiary) 46%, transparent);
        background: color-mix(in srgb, var(--mat-sys-tertiary-container) 12%, transparent);
    }

    // Always show actions on touch devices
    @media (hover: none) {
        .episode-list-item__actions {
            opacity: 1;
        }
    }
}
