.movies-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

.movie-card {
    background: var(--bg-card);
    border-radius: 16px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    border: 1px solid rgba(12, 27, 48, 0.7);
}

.movie-card:hover {
    transform: translateY(-12px) scale(1.02);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.movie-poster {
    width: 100%;
    aspect-ratio: 2/3;
    background: linear-gradient(135deg, #1f2327 0%, #14181c 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    position: relative;
    overflow: hidden;
}

.movie-poster img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.movie-card:hover .movie-poster img {
    transform: scale(1.1);
}

.watchlist-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 700;
    z-index: 2;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.6);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.watched-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
    color: #fff;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 700;
    z-index: 2;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.search-input {
    width: 100%;
    border: none;
    background: transparent;
    color: white;
    padding-left: 15px;
    outline: none;
    font-size: 16px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Le bouton rond avec la loupe */
.search-btn {
    width: 40px;
    height: 40px;
    background: #667eea;
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: absolute;
    right: 5px;
}

/* ── Grilles de taille fixe (watchlist / watched) ── */
@media (min-width: 769px) {
    .movies-grid.cols-3  { grid-template-columns: repeat(3,  1fr); }
    .movies-grid.cols-4  { grid-template-columns: repeat(4,  1fr); }
    .movies-grid.cols-5  { grid-template-columns: repeat(5,  1fr); }
    .movies-grid.cols-6  { grid-template-columns: repeat(6,  1fr); }
    .movies-grid.cols-7  { grid-template-columns: repeat(7,  1fr); }
    .movies-grid.cols-8  { grid-template-columns: repeat(8,  1fr); }
    .movies-grid.cols-9  { grid-template-columns: repeat(9,  1fr); }
    .movies-grid.cols-10 { grid-template-columns: repeat(10, 1fr); }
    .movies-grid.cols-11 { grid-template-columns: repeat(11, 1fr); }
    .movies-grid.cols-12 { grid-template-columns: repeat(12, 1fr); }
}

@media (max-width: 963px) {
    #searchWidget {
        position: fixed !important;
        bottom: calc(72px + env(safe-area-inset-bottom) + 12px) !important;
        right: 16px !important;
        z-index: 1001 !important;
        top: auto !important;
        left: auto !important;
    }
}

/* ── Overlay masqué sur mobile/touch — sécurité pour WebView Android ── */
.movie-card-overlay {
    display: none;
}

/* ── Overlay hover (desktop uniquement) ── */
@media (hover: hover) and (min-width: 769px) {
    .movie-card {
        position: relative;
    }

    /* Blur en dégradé via ::after — apparaît au hover */
    .movie-card::after {
        content: '';
        position: absolute;
        inset: 0;
        backdrop-filter: blur(14px) saturate(0.75);
        -webkit-backdrop-filter: blur(14px) saturate(0.75);
        -webkit-mask-image: linear-gradient(to top, black 0%, black 40%, transparent 75%);
        mask-image: linear-gradient(to top, black 0%, black 40%, transparent 75%);
        z-index: 2;
        pointer-events: none;
        opacity: 0;
        transition: opacity 0.28s ease;
        transform: translateZ(0);
        will-change: opacity;
    }

    .movie-card:hover::after {
        opacity: 1;
    }

    /* Overlay texte + dégradé */
    .movie-card-overlay {
        display: flex;
        position: absolute;
        inset: 0;
        background: linear-gradient(
            to top,
            rgba(5, 8, 18, 0.90) 0%,
            rgba(5, 8, 18, 0.55) 45%,
            rgba(5, 8, 18, 0.10) 68%,
            rgba(5, 8, 18, 0.00) 82%
        );
        flex-direction: column;
        justify-content: flex-end;
        padding: 14px 12px 12px;
        opacity: 0;
        transform: translateY(6px);
        transition: opacity 0.28s ease, transform 0.28s ease;
        z-index: 3;
        pointer-events: none;
        overflow: hidden;
    }

    .movie-card:hover .movie-card-overlay {
        opacity: 1;
        transform: translateY(0);
    }

    .movie-card-overlay-title {
        font-size: 13px;
        font-weight: 700;
        color: #fff;
        line-height: 1.3;
        margin-bottom: 6px;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .movie-card-overlay-meta {
        display: flex;
        align-items: center;
        gap: 8px;
        flex-wrap: wrap;
        margin-bottom: 7px;
    }

    .overlay-year {
        font-size: 11px;
        color: rgba(255, 255, 255, 0.55);
        font-weight: 500;
    }

    .overlay-rating {
        font-size: 11px;
        color: #fbbf24;
        font-weight: 700;
        background: rgba(251, 191, 36, 0.12);
        padding: 2px 7px;
        border-radius: 6px;
    }

    .overlay-runtime {
        font-size: 11px;
        color: rgba(255, 255, 255, 0.5);
        font-weight: 500;
    }

    .overlay-genres {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
        margin-bottom: 7px;
    }

    .overlay-genres .genre-badge {
        font-size: 10px;
        padding: 2px 7px;
        border-radius: 6px;
        background: rgba(37, 99, 235, 0.25);
        color: rgba(255, 255, 255, 0.75);
        border: 1px solid rgba(37, 99, 235, 0.35);
    }

    .movie-card-overlay-overview {
        font-size: 10.5px;
        color: rgba(255, 255, 255, 0.62);
        line-height: 1.45;
        display: -webkit-box;
        -webkit-line-clamp: 3;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .overlay-user-rating {
        font-size: 11px;
        color: #fbbf24;
        margin-top: 5px;
        font-weight: 600;
    }
}