.list-view .movie-item {
    grid-template-columns: var(--col-thumb) var(--col-title) var(--col-director) var(--col-year) var(--col-duration) var(--col-actions);
    gap: var(--col-gap);
}

.list-view .results-list-header {
    grid-template-columns: var(--col-thumb) var(--col-title) var(--col-director) var(--col-year) var(--col-duration) var(--col-actions);
    gap: var(--col-gap);
}

.list-view .results-list-header .header-year { text-align: left; }
.list-view .results-list-header .header-runtime { text-align: left; }
/* TUNNEL FLIX - Styles CSS */

/* Variables CSS */
:root {
    --primary-color: #e50914;
    --secondary-color: #221f1f;
    --accent-color: #f5f5f1;
    --text-color: #ffffff;
    --text-secondary: #b3b3b3;
    --background-color: #141414;
    --card-background: #2f2f2f;
    --border-color: #333333;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --info-color: #17a2b8;
    
    --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --font-size-base: 16px;
    --font-size-sm: 14px;
    --font-size-lg: 18px;
    --font-size-xl: 24px;
    --font-size-xxl: 32px;
    
    --border-radius: 8px;
    --box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
    /* Grid columns for list */
    --col-thumb: 40px;
    --col-title: 1fr;
    --col-director: 260px;
    --col-year: 90px;
    --col-duration: 90px;
    --col-actions: 220px;
    --col-gap: 0.75rem;
}

/* Reset et base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--background-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    background-color: var(--secondary-color);
    padding: 1rem 0;
    box-shadow: var(--box-shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo h1 {
    color: var(--primary-color);
    font-size: var(--font-size-xxl);
    font-weight: bold;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.logo img.brand-mark {
    height: 64px !important;
    width: 64px !important;
    display: inline-block;
    vertical-align: middle;
}

.nav {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.nav-link {
    color: var(--text-color);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-link:hover {
    background-color: var(--card-background);
    color: var(--primary-color);
}

.nav-link.admin {
    background-color: var(--warning-color);
    color: var(--secondary-color);
}

.nav-link.logout {
    background-color: var(--danger-color);
    color: var(--text-color);
}

/* Main content */
.main {
    flex: 1;
    padding: 2rem 0;
}

/* Welcome section */
.welcome-section {
    text-align: center;
    padding: 4rem 0;
}

.welcome-content h2 {
    font-size: var(--font-size-xxl);
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.welcome-content p {
    font-size: var(--font-size-lg);
    color: var(--text-secondary);
    margin-bottom: 2rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.welcome-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Search section */
.search-section {
    margin-bottom: 3rem;
}

.search-section h2 {
    text-align: center;
    margin-bottom: 2rem;
    color: var(--primary-color);
}

.search-container {
    max-width: 600px;
    margin: 0 auto;
}

.search-form {
    display: flex;
    gap: 1rem;
}

.search-input-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    background-color: #1c1c1c; /* subtle contrast vs container */
    border-radius: calc(var(--border-radius) + 4px);
    padding: 0.5rem;
    position: relative;
    border: 1px solid #2e2e2e;
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
    transition: box-shadow .25s ease, border-color .25s ease, transform .2s ease;
}
.search-input-group:hover {
    box-shadow: 0 10px 28px rgba(0,0,0,0.4);
}
.search-input-group:focus-within {
    border-color: #3a3a3a; /* subtle, no red */
    box-shadow: 0 8px 24px rgba(0,0,0,0.35);
    transform: none;
}

.search-input-wrapper {
    position: relative;
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

/* Selected person avatar inside the desktop search input */
.search-selected-avatar {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid var(--border-color);
    background: #444444;
    box-shadow: 0 2px 8px rgba(0,0,0,0.35);
    display: none;
}
.search-selected-avatar img { width: 100%; height: 100%; object-fit: cover; }
.search-input-wrapper.has-avatar #searchQuery { padding-left: 68px; }
.search-input-wrapper.has-avatar .search-selected-avatar { display: inline-block; }

/* Chips (multi-sélection) */
.search-chips {
    display: none;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 6px 6px 6px 6px;
}

/* Ensure list page chips sit inline inside the input wrapper */
#listSearchChips {
    display: none;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 6px;
    align-items: center;
    flex: 0 1 auto;
}

#listMovieQuery {
    flex: 1 1 220px;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.5rem 0.25rem 0.25rem;
    background: #2a2a2a;
    border: 1px solid #3a3a3a;
    border-radius: 999px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.chip img {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
}

.chip-avatar-fallback {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #444;
    color: #bbb;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.chip-label {
    font-size: 14px;
}

.chip-remove {
    appearance: none;
    -webkit-appearance: none;
    border: 0;
    background: transparent;
    color: #bbb;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.chip-remove:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
}

#searchQuery {
    flex: 1 1 220px;
    min-width: 180px;
    padding: 0.75rem 1rem;
    border: 1px solid #2a2a2a;
    background: #121212;
    color: var(--text-color);
    font-size: var(--font-size-base);
    border-radius: var(--border-radius);
    transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}

#searchQuery::placeholder {
    color: var(--text-secondary);
}

#searchQuery:focus {
    outline: none;
    border-color: #3a3a3a; /* remove red glow */
    box-shadow: none;
    background: #131313;
}

/* Movie list search input: keep full black at all times */
#listMovieQuery {
    background: #000000 !important;
}
#listMovieQuery:focus {
    background: #000000 !important;
    border-color: #3a3a3a;
    box-shadow: none;
}

.search-btn {
    background-color: var(--primary-color);
    color: var(--text-color);
    border: none;
    padding: 0.9rem 1.25rem; /* match input height */
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: bold;
}

.search-btn:hover {
    background-color: #b8070f;
}

/* Dropdown d'auto-suggest pour les acteurs */
.actor-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 var(--border-radius) var(--border-radius);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: var(--box-shadow);
}

.actor-suggestion {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 1px solid var(--border-color);
}

.actor-suggestion:last-child {
    border-bottom: none;
}

.actor-suggestion:hover {
    background: var(--secondary-color);
}

.actor-suggestion-photo {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

.actor-suggestion-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.no-actor-photo {
    width: 100%;
    height: 100%;
    background: var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.actor-suggestion-info {
    flex: 1;
}

.actor-suggestion-name {
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.25rem;
}

.actor-suggestion-details {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

/* Results section */
.results-section {
    margin-top: 2rem;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding: 1rem;
    background-color: var(--card-background);
    border-radius: var(--border-radius);
}

.results-header h3 {
    color: var(--primary-color);
    font-size: var(--font-size-xl);
}

.results-stats {
    display: flex;
    gap: 2rem;
    color: var(--text-secondary);
}

.results-list {
    background: var(--card-background);
    border-radius: var(--border-radius);
    overflow: hidden;
    margin-top: 1rem;
}

/* Anciens styles de carte supprimés - maintenant on utilise .movie-item */

/* Anciens styles de checkbox et bouton supprimés - maintenant dans .movie-item */

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    text-decoration: none;
    font-weight: bold;
    cursor: pointer;
    transition: var(--transition);
    font-size: var(--font-size-base);
}

.btn-primary {
    background-color: var(--primary-color);
    color: var(--text-color);
}

.btn-primary:hover {
    background-color: #b8070f;
}

.btn-secondary {
    background-color: var(--card-background);
    color: var(--text-color);
    border: 2px solid var(--primary-color);
}

.btn-secondary:hover {
    background-color: var(--primary-color);
}

.btn-success {
    background-color: var(--success-color);
    color: var(--text-color);
}

.btn-warning {
    background-color: var(--warning-color);
    color: var(--secondary-color);
}

.btn-danger {
    background-color: var(--danger-color);
    color: var(--text-color);
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-color);
    font-weight: bold;
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    background-color: #1a1a1a; /* darker for better contrast */
    color: var(--text-color);
    font-size: var(--font-size-base);
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: #141414; /* even darker on focus */
    box-shadow: 0 0 0 3px rgba(229, 9, 20, 0.12);
}

.form-control::placeholder {
    color: var(--text-secondary);
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
    border-left: 4px solid;
}

.alert-success {
    background-color: rgba(40, 167, 69, 0.1);
    border-color: var(--success-color);
    color: var(--success-color);
}

.alert-warning {
    background-color: rgba(255, 193, 7, 0.1);
    border-color: var(--warning-color);
    color: var(--warning-color);
}

.alert-danger {
    background-color: rgba(220, 53, 69, 0.1);
    border-color: var(--danger-color);
    color: var(--danger-color);
}

.alert-info {
    background-color: rgba(23, 162, 184, 0.1);
    border-color: var(--info-color);
    color: var(--info-color);
}

/* Footer */
.footer {
    background-color: var(--secondary-color);
    padding: 2rem 0;
    text-align: center;
    color: var(--text-secondary);
    margin-top: auto;
}

/* Styles supplémentaires pour les nouvelles pages */

/* Auth pages */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
    padding: 2rem 0;
}

.auth-card {
    background-color: var(--card-background);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    width: 100%;
    max-width: 400px;
}

.auth-card h2 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    text-align: center;
}

.auth-card p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    text-align: center;
}

.auth-links {
    text-align: center;
    margin-top: 1.5rem;
}

.auth-link {
    color: var(--primary-color);
    text-decoration: none;
    display: block;
    margin: 0.5rem 0;
    transition: var(--transition);
}

.auth-link:hover {
    color: var(--text-color);
}

/* Dashboard */
.dashboard-header {
    text-align: center;
    margin-bottom: 3rem;
}

.dashboard-header h2 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.stat-card {
    background-color: var(--card-background);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-icon {
    font-size: 2rem;
    color: var(--primary-color);
}

.stat-content h3 {
    font-size: var(--font-size-xxl);
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.stat-content p {
    color: var(--text-secondary);
    margin: 0;
}

.dashboard-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 3rem;
    flex-wrap: wrap;
}

.recent-lists h3 {
    color: var(--primary-color);
    margin-bottom: 2rem;
}

.lists-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.list-card {
    background-color: var(--card-background);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}

.list-card:hover {
    transform: translateY(-5px);
}

/* Page header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

/* Align the list title with the first text column of the grid (after thumbnail) */
/* Title alignment: use same left offset as grid first text column */
.list-view { --grid-left-pad: 1rem; }
.list-view #listTitleDisplay,
.list-view #listTitleInput {
    margin-left: calc(var(--grid-left-pad) + var(--col-thumb) + var(--col-gap));
}

/* Forms */
.create-form {
    margin-bottom: 2rem;
}

.form-card {
    background-color: var(--card-background);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.btn-full {
    width: 100%;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: var(--font-size-sm);
}

/* Lists */
.list-header {
    display: flex;
    flex-direction: column; /* Ensure title and actions stack vertically */
    align-items: stretch;
    margin-bottom: 1rem;
    gap: 0.75rem;
}

.list-header h3 {
    color: var(--primary-color);
    margin: 0;
}

.list-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-start; /* Align buttons left under the title */
}

.list-content p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

/* Make the card body stretch so stats can stick to the bottom */
.list-content {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

.list-stats {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin-top: auto; /* stick to bottom of card regardless of description height */
}

.list-stats span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 4rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.empty-state h3 {
    color: var(--text-color);
    margin-bottom: 1rem;
}

/* Admin */
.admin-section {
    margin-bottom: 3rem;
}

.admin-section h3 {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
}

.table-container {
    overflow-x: auto;
    background-color: var(--card-background);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th,
.admin-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.admin-table th {
    background-color: var(--secondary-color);
    color: var(--text-color);
    font-weight: bold;
}

.admin-table tr:hover {
    background-color: rgba(229, 9, 20, 0.1);
}

.role-badge {
    padding: 0.25rem 0.5rem;
    border-radius: var(--border-radius);
    font-size: var(--font-size-sm);
    font-weight: bold;
}

.role-admin {
    background-color: var(--warning-color);
    color: var(--secondary-color);
}

.role-user {
    background-color: var(--info-color);
    color: var(--text-color);
}

/* Profile */
.profile-content {
    display: grid;
    gap: 2rem;
}

.profile-section {
    background-color: var(--card-background);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
}

.profile-section h3 {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
}

/* Nav active state */
.nav-link.active {
    background-color: var(--primary-color);
    color: var(--text-color);
}

/* Responsive */
@media (max-width: 768px) {
    /* Make brand more prominent on mobile */
    .logo h1 { font-size: 34px; }

    .header-content {
        flex-direction: column;
        gap: 1rem;
    }
    
    .nav {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .search-form { flex-direction: column; }
    
    .search-input-group { flex-direction: column; }

    /* Center subheading paragraph text under "Tu veux TOUT voir?" */
    .search-section p { text-align: center; }
    
    .search-btn {
        border-radius: 0 0 var(--border-radius) var(--border-radius);
    }
    
    .results-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .results-stats {
        justify-content: center;
    }
    
    .results-list {
        grid-template-columns: 1fr;
    }
    
    .welcome-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .page-header {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }

    /* On tablet, grid uses 28px thumb and 0.5rem gap with 0.5rem item padding */
    .list-view { --grid-left-pad: 0.5rem; }
    
    .dashboard-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .list-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .list-actions {
        justify-content: center;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .table-container {
        font-size: var(--font-size-sm);
    }
    
    .admin-table th,
    .admin-table td {
        padding: 0.5rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 10px;
    }
    
    .logo h1 {
        font-size: var(--font-size-xl);
    }
    
    .welcome-content h2 {
        font-size: var(--font-size-xl);
    }
    
    .welcome-content p {
        font-size: var(--font-size-base);
    }
}

/* Liste compacte de films */
.movie-item {
    display: grid;
    grid-template-columns: 32px 1fr 80px 80px 140px;
    gap: 1rem;
    align-items: center;
    padding: 0.75rem 1rem;
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0;
    transition: var(--transition);
    border-radius: 0;
}

.movie-thumbnail { position: relative; }
.movie-thumbnail img { transition: transform 0.2s ease; }

/* Floating poster preview */
.poster-preview {
    position: fixed;
    pointer-events: none;
    z-index: 9999;
    width: 300px; /* default, scaled by JS */
    aspect-ratio: 2/3; /* 9/16 ~ 2/3 for posters */
    border-radius: 8px;
    box-shadow: 0 12px 28px rgba(0,0,0,0.6);
    border: 1px solid rgba(255,255,255,0.08);
    background: #000;
    overflow: hidden;
    display: none;
}
.poster-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.movie-synopsis {
    background: #1b1b1b;
    border-top: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
}

.movie-item:last-child {
    border-bottom: none;
}

.movie-item:hover {
    background: #3a3a3a;
}

.movie-item.checked {
    background: #2a4a2a;
}

/* Conteneur de la liste */
.results-list {
    background: var(--card-background);
    border-radius: var(--border-radius);
    overflow: hidden;
    margin-top: 1rem;
}

.movie-thumbnail {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    overflow: hidden;
    flex-shrink: 0;
}

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

.movie-title {
    font-weight: 600;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.movie-year {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    text-align: left;
    font-weight: 500;
}

.movie-runtime {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    text-align: left;
    font-weight: 500;
}

.movie-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: flex-end;
}

/* Compact inline icon buttons for list actions */
.list-item-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 6px;
    background: #3a3a3a;
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-icon:hover { background: #4a4a4a; }
.btn-icon.btn-danger { background: var(--danger-color); }
.btn-icon.btn-danger:hover { background: #c82333; }

/* TV icon button */
.btn-icon.btn-tv { background: #2b2b2b; }
.btn-icon.btn-tv:hover { background: #3a3a3a; }

/* Tooltip synopsis */
.synopsis-icon {
    color: var(--text-secondary);
    position: relative;
}
.synopsis-icon:hover { color: var(--primary-color); }
.synopsis-tooltip {
    position: absolute;
    bottom: 130%;
    right: 0;
    width: 320px;
    max-width: 60vw;
    background: #111;
    border: 1px solid var(--border-color);
    padding: 0.75rem;
    border-radius: 6px;
    color: var(--text-color);
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    font-size: var(--font-size-sm);
    line-height: 1.4;
    z-index: 10;
    display: none;
}
.synopsis-icon:hover .synopsis-tooltip { display: block; }

.movie-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

/* Toggle switch for watched state */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 42px;
    height: 24px;
}

.toggle-switch .movie-checkbox {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #4a4a4a;
    transition: var(--transition);
    border-radius: 999px;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);
}

.toggle-slider::before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    top: 3px;
    background-color: #ffffff;
    border-radius: 50%;
    transition: var(--transition);
    box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--primary-color);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(18px);
}

/* Ensure immediate visual state when we toggle label class programmatically */
.toggle-switch.active .toggle-slider {
    background-color: var(--primary-color);
}
.toggle-switch.active .toggle-slider::before {
    transform: translateX(18px);
}

/* JS fallback class in case :checked styling is overridden */
.toggle-switch.active .toggle-slider {
    background-color: var(--primary-color);
}

.toggle-switch.active .toggle-slider::before {
    transform: translateX(18px);
}

.add-to-list-btn {
    background: var(--primary-color);
    color: var(--text-color);
    border: none;
    border-radius: 4px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    font-size: 12px;
}

.add-to-list-btn:hover {
    background: #d40813;
    transform: scale(1.05);
}

/* En-tête de la liste */
.results-list-header {
    display: grid;
    grid-template-columns: 32px 1fr 80px 80px 140px;
    gap: 1rem;
    align-items: center;
    padding: 0.5rem 1rem;
    background: var(--secondary-color);
    border-radius: var(--border-radius);
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.results-list-header .header-thumbnail {
    text-align: center;
}

.results-list-header .header-title {
    text-align: left;
}

.results-list-header .header-year { text-align: center; }
.results-list-header .header-runtime { text-align: center; }

.results-list-header .header-actions {
    text-align: center;
}

/* Animation de creusage de tunnel */
.tunnel-progress {
    text-align: center;
    padding: 2rem;
}

.tunnel-animation {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.tunnel-animation i {
    font-size: 2rem;
    color: var(--primary-color);
    animation: hammer 1s ease-in-out infinite;
}

.digging-dots {
    display: flex;
    gap: 0.5rem;
}

.digging-dots span {
    width: 8px;
    height: 8px;
    background: var(--primary-color);
    border-radius: 50%;
    animation: digging 1.5s ease-in-out infinite;
}

.digging-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.digging-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes hammer {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-15deg); }
    75% { transform: rotate(15deg); }
}

@keyframes digging {
    0%, 100% { transform: translateY(0); opacity: 1; }
    50% { transform: translateY(-10px); opacity: 0.5; }
}

.progress-text {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 1rem;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #000000; /* black track */
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-fill {
    height: 100%;
    background: var(--primary-color); /* solid app red */
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-percentage {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    font-weight: 600;
}

.progress-details {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin-top: 0.5rem;
    font-style: italic;
}

/* Pagination */
.pagination-controls {
    margin-top: 2rem;
    padding: 1.5rem;
    background: var(--card-background);
    border-radius: var(--border-radius);
    text-align: center;
}

.pagination-info {
    margin-bottom: 1rem;
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
}

.pagination-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    align-items: center;
}

.pagination-buttons .btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    font-size: var(--font-size-sm);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pagination-buttons .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.pagination-buttons .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.pagination-buttons .btn-primary {
    background: var(--primary-color);
    color: var(--text-color);
}

.pagination-buttons .btn-primary:hover:not(:disabled) {
    background: #d40813;
}

.pagination-buttons .btn-secondary {
    background: var(--secondary-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.pagination-buttons .btn-secondary:hover:not(:disabled) {
    background: #333333;
}

@media (max-width: 768px) {
    .pagination-buttons {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .pagination-buttons .btn {
        width: 100%;
        justify-content: center;
    }
    
    /* Tune list page columns via CSS variables for better mobile readability */
    .list-view {
        --col-thumb: 28px;
        --col-director: 180px;
        --col-year: 60px;
        --col-duration: 70px;
        --col-actions: 170px;
        --col-gap: 0.5rem;
    }

    /* Liste compacte responsive: match tunnel layout (hide director on mobile) */
    .list-view .movie-item {
        grid-template-columns: 28px 1fr 60px 70px 170px;
        gap: var(--col-gap);
        padding: 0.5rem;
    }
    .list-view .results-list-header {
        grid-template-columns: 28px 1fr 60px 70px 170px;
        gap: var(--col-gap);
        padding: 0.5rem;
        font-size: 11px;
    }
    /* Denser actions on list view for mobile */
    .list-view .list-item-actions { gap: 0.25rem; }
    .list-view .btn-icon { width: 28px; height: 28px; }
    /* Hide the 3rd column (director) on mobile in list view */
    .list-view .results-list-header > *:nth-child(3),
    .list-view .movie-item > *:nth-child(3) { display: none; }

    /* Tunnel pages (no director column): keep to 5 columns on mobile */
    .tunnel-container .movie-item {
        grid-template-columns: 28px 1fr 60px 70px 120px;
        gap: 0.5rem;
        padding: 0.5rem;
    }

    .tunnel-container .results-list-header {
        grid-template-columns: 28px 1fr 60px 70px 120px;
        gap: 0.5rem;
        padding: 0.5rem;
        font-size: 11px;
    }
    
    .movie-year,
    .movie-runtime {
        font-size: 11px;
    }
    
    .movie-title {
        font-size: 14px;
    }
}

/* Section de recherche */
.search-section {
    background: #1b1b1b;
    border-radius: var(--border-radius);
    padding: 2rem;
    margin-bottom: 2rem;
    border: 1px solid #444444;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(255, 255, 255, 0.02);
}

.search-section h2 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    font-size: var(--font-size-xl);
}

/* List page search title spacing */
.search-section h3 {
    margin-bottom: 0.75rem;
}

.search-section p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.search-input-group {
    display: flex;
    gap: 1rem;
    align-items: center;
    background: #252525;
    border: 1px solid #3a3a3a;
    border-radius: var(--border-radius);
    padding: 0.5rem;
}

.search-input-wrapper {
    position: relative;
    flex: 1;
}

.search-input-group input {
    width: 100%;
    padding: 1rem 1.25rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    background: #1e1e1e;
    color: var(--text-color);
    font-size: var(--font-size-base);
    caret-color: var(--primary-color);
}

.search-input-group input:focus {
    outline: none;
    border-color: #3a3a3a;
    background: #131313;
    box-shadow: none;
}

/* Grille des tunnels */
.tunnels-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

.tunnels-section {
    margin-top: 2rem;
}

.tunnels-section h2 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    font-size: var(--font-size-xl);
}

.tunnels-section p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.tunnel-column {
    display: flex;
    flex-direction: column;
}

/* Tunnels d'acteurs */
.tunnel-container {
    background: var(--card-background);
    border-radius: var(--border-radius);
    overflow: hidden;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Dedicated public read-only table: redistribute columns to fill width */
.tunnel-container.public-table .results-list-header {
    grid-template-columns: 48px 1.8fr 1.1fr 0.6fr 0.6fr;
}
.tunnel-container.public-table .movie-item {
    grid-template-columns: 48px 1.8fr 1.1fr 0.6fr 0.6fr;
}
.tunnel-container.public-table .movie-thumbnail {
    width: 48px;
    height: 48px;
}

@media (max-width: 768px) {
    .tunnel-container.public-table .results-list-header {
        grid-template-columns: 36px 1.6fr 0.8fr 0.5fr 0.5fr;
    }
    .tunnel-container.public-table .movie-item {
        grid-template-columns: 36px 1.6fr 0.8fr 0.5fr 0.5fr;
    }
    .tunnel-container.public-table .movie-thumbnail {
        width: 36px;
        height: 36px;
    }
}

@media (max-width: 480px) {
    .tunnel-container.public-table .results-list-header {
        grid-template-columns: 0px 1fr 0.7fr 0.5fr 0.5fr;
    }
    .tunnel-container.public-table .movie-item {
        grid-template-columns: 0px 1fr 0.7fr 0.5fr 0.5fr;
    }
    .tunnel-container.public-table .movie-thumbnail { display: none; }
}

/* List cover mosaic / custom cover */
.list-cover {
    width: 100%;
    aspect-ratio: 3 / 2; /* same visible ratio as 3-wide by 2-high posters */
    position: relative;
    overflow: hidden;
    background: #0f0f0f;
}
.list-cover.mosaic {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 2px;
}
.list-cover.mosaic .tile {
    position: relative;
    background: #1c1c1c;
}
.list-cover.mosaic .tile img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.list-cover.single img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.list-cover-actions {
    position: absolute;
    right: 8px;
    bottom: 8px;
    display: flex;
    gap: 0.5rem;
}
.btn-cover {
    padding: 0.4rem 0.6rem;
    font-size: 12px;
    border-radius: 6px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.2);
}
.btn-cover:hover { background: rgba(0,0,0,0.75); }

.tunnel-header {
    background: var(--secondary-color);
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    transition: var(--transition);
    position: relative;
    padding-right: 3.5rem; /* reserve space for absolute chevron so it doesn't overlap */
}

.tunnel-main-content {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    cursor: pointer;
}

.tunnel-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-delete-tunnel {
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    font-size: 14px;
}

.btn-delete-tunnel:hover {
    background: #c82333;
    transform: scale(1.1);
}

.tunnel-header:hover {
    background: #333333;
}

.actor-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.actor-thumbnail {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

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

.no-actor-image {
    width: 100%;
    height: 100%;
    background: var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--text-secondary);
}

.actor-details h3 {
    color: var(--text-color);
    font-size: var(--font-size-xl);
    margin-bottom: 0.5rem;
}

.tunnel-stats {
    display: flex;
    gap: 1rem;
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
}

.progress-container {
    min-width: 300px;
    flex: 1;
    max-width: 400px;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.progress-text {
    font-weight: 500;
}

.progress-percentage {
    font-weight: 600;
    color: var(--primary-color);
}

.tunnel-movies {
    padding: 0;
    flex: 1;
    overflow-y: auto;
    max-height: 600px;
}

.tunnel-toggle {
    position: absolute;
    top: 1rem;
    right: 1rem;
    color: var(--text-secondary);
    font-size: 1.2rem;
    transition: var(--transition);
}

.tunnel-toggle:hover {
    color: var(--primary-color);
}

/* Watch providers popup */
.watch-popup {
    position: absolute;
    z-index: 2000;
    display: none;
    left: 0; top: 0;
}
.watch-popup.open { display: block; }
.watch-popup-inner {
    min-width: 260px;
    max-width: 360px;
    background: #111111;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 10px;
    box-shadow: 0 14px 38px rgba(0,0,0,0.6);
    overflow: hidden;
}
.watch-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    padding: .6rem .8rem;
    background: #1a1a1a;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    font-weight: 600;
}
.watch-popup-close {
    background: transparent;
    color: #cccccc;
    border: 0;
    width: 28px; height: 28px;
    border-radius: 6px;
    cursor: pointer;
}
.watch-popup-close:hover { background: rgba(255,255,255,0.06); color: #fff; }
.watch-popup-body { padding: .5rem .5rem .75rem; }
.watch-popup-list { display: flex; flex-direction: column; gap: .25rem; max-height: 300px; overflow: auto; }
.watch-popup-loading { padding: .75rem; color: var(--text-secondary); }
.watch-popup-empty { padding: .75rem; color: var(--text-secondary); font-style: italic; }
.watch-provider { display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: .5rem; padding: .4rem .4rem; border-radius: 8px; text-decoration: none; color: var(--text-color); }
.watch-provider:hover { background: rgba(255,255,255,0.06); }
.watch-provider-logo { width: 28px; height: 28px; border-radius: 6px; object-fit: contain; background: #1f1f1f; border: 1px solid rgba(255,255,255,0.08); }
.watch-provider-fallback { width: 28px; height: 28px; border-radius: 6px; background: #1f1f1f; color: #aaa; display: inline-flex; align-items: center; justify-content: center; }
.watch-provider-name { font-weight: 600; }
.watch-provider-kind { color: var(--text-secondary); font-size: 12px; padding-left: .5rem; }
.watch-popup-footer { padding: .25rem .5rem 0; display: flex; justify-content: flex-end; }
.watch-popup-link { color: var(--primary-color); text-decoration: none; font-size: 13px; display: none; }
.watch-popup-link:hover { text-decoration: underline; }

.movie-item.watched {
    background: #2a4a2a;
    opacity: 0.8;
}

.movie-item.watched .movie-title {
    text-decoration: line-through;
    color: var(--text-secondary);
}

.no-poster {
    width: 100%;
    height: 100%;
    background: var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 4rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.empty-state h3 {
    color: var(--text-color);
    margin-bottom: 1rem;
}

.empty-state p {
    margin-bottom: 2rem;
    font-size: var(--font-size-lg);
}

@media (max-width: 768px) {
    .tunnels-grid {
        gap: 1rem;
    }
    
    .tunnel-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
        padding-right: 5rem; /* room for chevron + delete button */
    }
    /* Make the bin icon compact and overlay it in the header */
    .tunnel-actions {
        position: absolute;
        top: 0.75rem;
        right: 0.75rem;
        z-index: 2;
    }
    .btn-delete-tunnel {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }
    
    .progress-container {
        min-width: auto;
        max-width: none;
    }
    
    /* Keep chevron in the header's top-right, left of the bin */
    .tunnel-toggle {
        position: absolute;
        top: 0.8rem;
        right: 3.4rem; /* ~32px button + spacing */
    }
}

@media (max-width: 480px) {
    /* Further tighten list page columns to match tunnel at <=480px */
    .list-view .movie-item {
        grid-template-columns: 26px 1fr 54px 54px 170px;
        gap: 0.25rem;
        padding: 0.5rem 0.25rem;
    }
    .list-view .results-list-header {
        grid-template-columns: 26px 1fr 54px 54px 170px;
        gap: 0.25rem;
        padding: 0.5rem 0.25rem;
        font-size: 10px;
    }

    /* On mobile narrowest, 26px thumb, 0.25rem gap, 0.25rem left padding */
    .list-view #listTitleDisplay,
    .list-view #listTitleInput {
        padding-left: calc(0.25rem + 26px + 0.25rem);
    }
    /* Make list page action icons a touch smaller on the narrowest screens */
    .list-view .btn-icon { width: 26px; height: 26px; }
    .list-view .results-list-header > *:nth-child(3),
    .list-view .movie-item > *:nth-child(3) { display: none; }

    /* Tunnel pages: stick to 5 columns, prioritise title width */
    .tunnel-container .movie-item {
        grid-template-columns: 26px 1fr 54px 54px 110px;
        gap: 0.25rem;
        padding: 0.5rem 0.25rem;
    }

    .tunnel-container .results-list-header {
        grid-template-columns: 26px 1fr 54px 54px 110px;
        gap: 0.25rem;
        padding: 0.5rem 0.25rem;
        font-size: 10px;
    }
    
    .movie-thumbnail {
        width: 28px;
        height: 28px;
    }
    
    .movie-year,
    .movie-runtime {
        font-size: 10px;
    }
    
    .movie-title {
        font-size: 13px;
    }
    
    .add-to-list-btn {
        width: 28px;
        height: 28px;
        font-size: 10px;
    }
    
    .actor-thumbnail {
        width: 48px;
        height: 48px;
    }
    
    .tunnel-movies {
        max-height: 400px;
    }
}
