/* Library Overlay Styles */
#library-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #141414;
    z-index: 2000;
    /* Above everything */
    overflow-y: auto;
    display: none;
    /* Hidden by default */
    padding-bottom: 50px;
}

#library-overlay.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.library-container {
    max-width: 1600px;
    /* Wider for 16:9 grid */
    margin: 0 auto;
    padding: 2rem;
}

.library-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.library-header h1 {
    font-size: 2.2rem;
    font-weight: 700;
    color: white;
    letter-spacing: -1px;
    display: flex;
    align-items: center;
    gap: 0;
    /* Continuous text */
}

.library-header h1 span {
    color: #94a3b8;
    /* The "KK" or second part color */
}

.close-library-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.close-library-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Netflix-style Movie Grid (Landscape) */
.movies-grid {
    display: grid;
    /* Cards roughly 280px wide minimum */
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px 16px;
}

.movie-card {
    position: relative;
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.2s ease;
    overflow: visible;
    /* Allow deletion button or badges to pop out if needed */
    /* REMOVED: aspect-ratio 2/3, box-shadow */
}

.movie-card:hover {
    transform: scale(1.02);
    /* Subtle pop */
    z-index: 10;
    /* REMOVED: heavy shadow */
}


/* Poster Container (16:9) - Cross-Browser Compatible (LG TV Fix) */
.movie-poster-placeholder {
    width: 100%;
    /* aspect-ratio: 16 / 9; <-- Not supported on old WebOS */
    padding-top: 56.25%;
    /* 16:9 Aspect Ratio Hack */
    height: 0;
    position: relative;
    background-color: #202020;
    border-radius: 4px;
    overflow: hidden;
}

/* Fix children to fill the padded container */
.movie-poster-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Center the SVG placeholder absolutely */
.movie-poster-placeholder svg {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    fill: rgb(255 255 255 / 20%);
    display: block;
    /* Ensure it's block so transform works */
}

/* Info Below (Subtitle/Duration) */
.movie-info-below {
    margin-top: 8px;
    padding: 0 2px;
}

.movie-title-text {
    font-size: 0.95rem;
    font-weight: 500;
    color: #e5e5e5;
    margin-bottom: 4px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.movie-meta-text {
    font-size: 0.8rem;
    color: #808080;
    font-weight: 400;
}

/* Clean Delete Button (Top Right of Poster) */
.delete-action-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s, background 0.2s;
    z-index: 5;
    padding: 5px;
}

.movie-card:hover .delete-action-btn {
    opacity: 1;
}

.delete-action-btn:hover {
    background: #E50914;
}

.delete-action-btn svg {
    width: 16px;
    height: 16px;
    fill: white;
}

/* Play Icon Overlay (Center) - Optional/Subtle */
.play-overlay-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
    /* Let clicks pass to card */
}

.play-overlay-icon svg {
    width: 24px;
    height: 24px;
    fill: white;
    margin-left: 2px;
}

.movie-card:hover .play-overlay-icon {
    opacity: 1;
}

/* Empty State */
.lib-empty-state {
    text-align: center;
    padding: 6rem 2rem;
    color: #b3b3b3;
}

.lib-empty-state svg {
    width: 80px;
    height: 80px;
    fill: rgba(255, 255, 255, 0.1);
    margin-bottom: 1.5rem;
}

.lib-empty-state h2 {
    font-size: 1.5rem;
    color: #fff;
    margin-bottom: 0.5rem;
}

.lib-empty-state p {
    margin-bottom: 1.5rem;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

/* Loading */
.lib-loading {
    display: flex;
    justify-content: center;
    padding: 6rem;
}

.lib-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: #E50914;
    border-radius: 50%;
    animation: lib-spin 1s linear infinite;
}

@keyframes lib-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Status Banner */
.lib-status-banner {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(229, 9, 20, 0.15);
    border: 1px solid rgba(229, 9, 20, 0.3);
    color: #ff6b6b;
}

.lib-status-banner svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
    flex-shrink: 0;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .library-container {
        padding: 0;
        /* Antigravity Fix: Edge-to-edge */
        max-width: 100%;
    }

    .movies-grid {
        /* Mobile: 1 column (YouTube Style) - Strict 1fr */
        grid-template-columns: minmax(0, 1fr);
        gap: 16px;
    }

    .library-header {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        /* Ensure space between title and btn */
        padding: 10px 16px;
        /* Padding for the header */
    }

    .library-header h1 {
        font-size: 1.5rem;
    }

    /* Simple Mobile Close Button */
    .close-library-btn {
        background: transparent !important;
        box-shadow: none !important;
        border: none !important;
        padding: 4px 8px !important;
        width: auto !important;
        font-size: 0.9rem !important;
        transform: none !important;
        /* Remove scale effect */
        transition: none !important;
        color: rgba(255, 255, 255, 0.8) !important;
    }

    .close-library-btn:active {
        transform: scale(0.95) !important;
        /* Subtle touch feedback only */
    }



    .movie-title-text {
        font-size: 0.85rem;
    }
}