:host {
    display: block;
    width: 100%;
    container-type: inline-size;
}

.channel-list-item {
    width: 100%;
    min-height: 68px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px 8px 12px;
    border: 1px solid transparent;
    border-radius: 12px;
    background: transparent;
    color: inherit;
    cursor: pointer;
    box-sizing: border-box;
    overflow: hidden;
    transition:
        background 0.15s ease,
        border-color 0.15s ease,
        box-shadow 0.18s ease,
        transform 0.18s ease,
        color 0.15s ease;

    &:hover {
        background: color-mix(in srgb, currentColor 8%, transparent);
    }

    &.active {
        background: linear-gradient(
            135deg,
            var(--app-selection-surface-strong),
            var(--app-selection-surface)
        );
        border-color: var(--app-selection-border);
        color: var(--app-selection-color);
        box-shadow:
            inset 0 0 0 1px var(--app-selection-border),
            0 12px 20px -18px var(--app-selection-glow);
        transform: translateY(-1px);
    }

    &.compact {
        min-height: 52px;
        padding-block: 7px;
    }
}

.drag-icon {
    flex-shrink: 0;
    cursor: move;
    opacity: 0.46;
}

.channel-content {
    min-width: 0;
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
}

.channel-logo-shell {
    position: relative;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border-radius: 10px;
    display: grid;
    place-items: center;
    overflow: hidden;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0)),
        rgba(127, 127, 127, 0.12);
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.08),
        inset 0 1px 1px rgba(0, 0, 0, 0.15);

    .compact & {
        width: 38px;
        height: 38px;
    }
}

.channel-logo-fallback {
    position: absolute;
    inset: 0;
    margin: auto;
    width: 18px;
    height: 18px;
    font-size: 18px;
    opacity: 0.5;
}

.channel-logo {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 6px;
    box-sizing: border-box;
}

.channel-details {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
}

.channel-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.96rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.2;
}

.epg-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.82rem;
    line-height: 1.2;
    opacity: 0.84;
}

.epg-timeline {
    min-width: 0;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
}

.epg-time {
    font-size: 0.75rem;
    line-height: 1;
    opacity: 0.72;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.epg-progress-track {
    position: relative;
    width: 100%;
    height: 6px;
    overflow: hidden;
    border-radius: 999px;
    background-color: rgba(127, 127, 127, 0.28);
    background-image: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.12),
        rgba(255, 255, 255, 0)
    );
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.12),
        inset 0 1px 1px rgba(0, 0, 0, 0.18);
}

.epg-progress-fill {
    position: absolute;
    inset-block: 0;
    inset-inline-start: 0;
    border-radius: inherit;
    background-color: var(--app-selection-color);
    background-image: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.18),
        rgba(255, 255, 255, 0)
    );
    box-shadow:
        0 0 0 1px color-mix(in srgb, var(--app-selection-border) 82%, transparent),
        0 0 10px -2px var(--app-selection-glow);
    transition: width 0.35s ease;
}

.epg-placeholder {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.78rem;
    line-height: 1.2;
    opacity: 0.52;
}

.action-buttons {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 2px;
    margin-inline-start: auto;

    button {
        width: 32px;
        height: 32px;
        /* border-radius: 10px; */
        color: inherit;
        opacity: 0.76;
        transition:
            opacity 0.15s ease,
            background-color 0.15s ease,
            transform 0.15s ease;

        &:hover {
            opacity: 1;
            background: color-mix(in srgb, currentColor 10%, transparent);
            /* transform: translateY(-1px); */
        }
    }

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

.channel-list-item.active {
    .epg-title,
    .epg-time,
    .epg-placeholder,
    .drag-icon,
    .action-buttons button,
    .action-buttons mat-icon {
        color: inherit;
    }
}

@container (max-width: 360px) {
    .channel-list-item {
        gap: 10px;
        padding-inline: 10px 8px;
    }

    .channel-logo-shell {
        width: 40px;
        height: 40px;
    }

    .epg-timeline {
        gap: 8px;
    }

    .action-buttons {
        gap: 0;
    }
}

@container (max-width: 310px) {
    .epg-timeline {
        grid-template-columns: 1fr;
        gap: 5px;
    }

    .epg-time:last-child {
        display: none;
    }
}

@container (max-width: 270px) {
    .channel-list-item {
        min-height: 52px;
        gap: 8px;
        padding-inline: 8px 6px;
    }

    .channel-logo-shell {
        width: 34px;
        height: 34px;
    }

    .epg-title,
    .epg-timeline,
    .epg-placeholder,
    .program-info-button {
        display: none;
    }
}

@container (max-width: 220px) {
    .channel-logo-shell,
    .action-buttons {
        display: none;
    }

    .channel-content {
        gap: 0;
    }
}

.favorite-button, .program-info-button {
    padding: 0;
}