/* Playlists page specific styles */
.playlists-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
    padding: 1rem 0;
}

.playlist-card {
    background: var(--bs-body-bg);
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid var(--bs-border-color);
    cursor: pointer;
}

.playlist-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
}

.playlist-card-dynamic {
    position: relative;
}

.playlist-grid-delete-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    z-index: 2;
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid var(--bs-danger);
    background: rgba(var(--bs-body-bg-rgb, 33, 37, 41), 0.92);
    color: var(--bs-danger);
    line-height: 1;
}

.playlist-grid-delete-btn:hover {
    background: var(--bs-danger);
    color: var(--bs-body-bg);
}

.playlist-grid-rename-btn {
    position: absolute;
    top: 6px;
    left: 6px;
    z-index: 2;
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid var(--bs-secondary);
    background: rgba(var(--bs-body-bg-rgb, 33, 37, 41), 0.92);
    color: var(--bs-secondary-color);
    line-height: 1;
}

.playlist-grid-rename-btn:hover {
    background: var(--bs-secondary);
    color: var(--bs-body-bg);
}

/* Remove control on cards for playlists shared *with* me (recipient side).
   Shared cards have no owner controls, so this is the only overlay button and
   sits top-right like the delete control on owned cards. */
.playlist-grid-remove-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    z-index: 2;
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid var(--bs-secondary);
    background: rgba(var(--bs-body-bg-rgb, 33, 37, 41), 0.92);
    color: var(--bs-secondary-color);
    line-height: 1;
}

.playlist-grid-remove-btn:hover {
    background: var(--bs-danger);
    color: var(--bs-body-bg);
    border-color: var(--bs-danger);
}

.playlist-grid-share-btn {
    position: absolute;
    top: 6px;
    right: 44px;
    z-index: 2;
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid var(--bs-info, #0dcaf0);
    background: rgba(var(--bs-body-bg-rgb, 33, 37, 41), 0.92);
    color: var(--bs-info, #0dcaf0);
    line-height: 1;
}

.playlist-grid-share-btn:hover {
    background: var(--bs-info, #0dcaf0);
    color: var(--bs-body-bg);
}

.playlist-grid-share-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Greyed-out state for the share button on PRIVATE playlist cards.
   The button is still clickable so the user can be told why it's disabled,
   but the visual signals "not shareable". Mirrors `.viewer-button--disabled`
   on VideoPlaybackPage.html for consistency. */
.playlist-grid-share-btn--disabled,
.playlist-grid-share-btn--disabled:hover {
    opacity: 0.9;
    cursor: not-allowed;
    border-color: rgba(180, 180, 180, 0.55);
    background: rgba(var(--bs-body-bg-rgb, 33, 37, 41), 0.92);
    color: rgba(200, 200, 200, 0.7);
}

.playlist-card-toast {
    position: absolute;
    z-index: 1080;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.78rem;
    line-height: 1.2;
    color: #fff;
    background: rgba(20, 20, 20, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    max-width: 240px;
    text-align: center;
    white-space: normal;
}

.playlist-card-toast--visible {
    opacity: 1;
}

.playlist-card-toast[data-kind='success'] {
    border-color: rgba(40, 200, 130, 0.7);
}

.playlist-card-toast[data-kind='warning'] {
    border-color: rgba(255, 196, 0, 0.7);
}

.playlist-card-toast[data-kind='danger'] {
    border-color: rgba(220, 80, 80, 0.7);
}

/* Highlights grid: edit / delete on thumbnail corners (same look as playlist overlays) */
.highlight-card-dynamic .playlist-thumbnail .highlight-grid-edit-btn,
.highlight-card-dynamic .playlist-thumbnail .highlight-grid-delete-btn {
    position: absolute;
    z-index: 2;
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    line-height: 1;
}

.highlight-card-dynamic .playlist-thumbnail .highlight-grid-edit-btn {
    top: 6px;
    left: 6px;
    border: 1px solid var(--bs-secondary);
    background: rgba(var(--bs-body-bg-rgb, 33, 37, 41), 0.92);
    color: var(--bs-secondary-color);
}

.highlight-card-dynamic .playlist-thumbnail .highlight-grid-edit-btn:hover {
    background: var(--bs-secondary);
    color: var(--bs-body-bg);
}

.highlight-card-dynamic .playlist-thumbnail .highlight-grid-delete-btn {
    top: 6px;
    right: 6px;
    border: 1px solid var(--bs-danger);
    background: rgba(var(--bs-body-bg-rgb, 33, 37, 41), 0.92);
    color: var(--bs-danger);
}

.highlight-card-dynamic .playlist-thumbnail .highlight-grid-delete-btn:hover {
    background: var(--bs-danger);
    color: var(--bs-body-bg);
}

.playlist-card-link {
    cursor: pointer;
}

.playlist-thumbnail {
    position: relative;
    padding-bottom: 56.25%;
    background: var(--bs-secondary-bg);
    overflow: hidden;
}

.playlist-thumbnail img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.playlist-info {
    padding: 0.5rem;
}

.playlist-title {
    font-size: 0.875rem;
    font-weight: 600;
    margin: 0 0 0.25rem;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.playlist-meta-row {
    font-size: 0.75rem;
    color: var(--bs-secondary-color);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.2rem;
    line-height: 1.3;
    margin-bottom: 0.2rem;
}

.playlist-meta-sep {
    opacity: 0.6;
    user-select: none;
}

.playlist-privacy {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    font-size: inherit;
    color: var(--bs-secondary-color);
}

.playlist-updated {
    font-size: 0.7rem;
    color: var(--bs-secondary-color);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.new-playlist-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100px;
    border: 2px dashed var(--bs-border-color);
    border-radius: 12px;
    background: var(--bs-secondary-bg);
    cursor: pointer;
    transition: all 0.2s;
}

.new-playlist-btn:hover {
    border-color: var(--bs-primary);
    background: var(--bs-body-bg);
}

.new-playlist-btn > div:last-child {
    font-size: 0.75rem;
    line-height: 1.2;
    padding: 0 0.25rem;
    text-align: center;
    width: 100%;
}

.new-playlist-icon {
    font-size: 1.5rem;
    color: var(--bs-secondary-color);
    margin-bottom: 0.25rem;
}

.new-playlist-icon svg {
    width: 28px;
    height: 28px;
}

.filter-buttons {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 0.5rem 1.25rem;
    border-radius: 20px;
    border: 1px solid var(--bs-border-color);
    background: transparent;
    color: var(--bs-body-color);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.filter-btn:hover {
    background: var(--bs-secondary-bg);
}

.filter-btn.active {
    background: var(--bs-primary);
    border-color: var(--bs-primary);
    color: white;
}

.playlist-actions {
    display: flex;
    gap: 0.5rem;
    padding: 0 1rem 1rem;
}

.action-icon-btn {
    background: none;
    border: none;
    color: var(--bs-secondary-color);
    cursor: pointer;
    padding: 0.25rem;
    transition: color 0.2s;
}

.action-icon-btn:hover {
    color: var(--bs-body-color);
}

.playlist-badge {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.updated-indicator {
    width: 8px;
    height: 8px;
    background: var(--bs-danger);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

@media (max-width: 768px) {
    .playlists-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 0.5rem;
    }
}

/* playlistDetail.html — clickable rows */
#playlistDetailBody tr.playlist-detail-video-row {
    cursor: pointer;
    transition: background-color 0.15s ease;
}

#playlistDetailBody tr.playlist-detail-video-row:hover td {
    background-color: rgba(255, 255, 255, 0.08);
}

#playlistDetailBody tr.playlist-detail-video-row .playlist-row-action-btn {
    cursor: pointer;
}

.playlist-detail-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem 0.4rem;
    line-height: 1;
    transition:
        color 0.15s ease,
        background-color 0.15s ease,
        border-color 0.15s ease,
        box-shadow 0.15s ease,
        transform 0.15s ease;
}

.playlist-detail-icon-btn:hover {
    transform: translateY(-1px);
}

.playlist-detail-icon-btn:active {
    transform: translateY(0);
}

.playlist-detail-icon-btn svg {
    display: block;
    flex-shrink: 0;
}

@media (prefers-reduced-motion: reduce) {
    .playlist-detail-icon-btn {
        transition: none;
    }

    .playlist-detail-icon-btn:hover,
    .playlist-detail-icon-btn:active {
        transform: none;
    }
}

/* Highlight picker modal: scrollable video list with a visible scrollbar */
.pick-video-highlight-scroll-wrap {
    max-height: min(52vh, 440px);
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-gutter: stable;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.2);
}

.pick-video-highlight-scroll-wrap:focus-visible {
    outline: 2px solid rgba(55, 155, 254, 0.65);
    outline-offset: 2px;
}

.pick-video-highlight-scroll-wrap::-webkit-scrollbar {
    width: 12px;
}

.pick-video-highlight-scroll-wrap::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    margin: 4px 0;
}

.pick-video-highlight-scroll-wrap::-webkit-scrollbar-thumb {
    background: rgba(55, 155, 254, 0.45);
    border-radius: 8px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

.pick-video-highlight-scroll-wrap::-webkit-scrollbar-thumb:hover {
    background: rgba(55, 155, 254, 0.7);
    background-clip: padding-box;
}

@supports (scrollbar-width: thin) {
    .pick-video-highlight-scroll-wrap {
        scrollbar-width: auto;
        scrollbar-color: rgba(55, 155, 254, 0.55) rgba(255, 255, 255, 0.08);
    }
}

/* playlistDetail.html — row reorder + return highlight from detail save */
.playlist-detail-table .playlist-detail-video-row.playlist-detail-row--draggable {
    cursor: grab;
}

.playlist-detail-table .playlist-detail-video-row.playlist-detail-row--draggable:active {
    cursor: grabbing;
}

.playlist-detail-table .playlist-detail-play-target {
    cursor: pointer;
}

.playlist-detail-table .playlist-detail-video-row.playlist-detail-row--dragging {
    opacity: 0.75;
}

.playlist-card--focus-highlight {
    outline: 2px solid rgb(55, 155, 254);
    outline-offset: 4px;
    border-radius: 12px;
    transition: outline 0.15s ease;
}