/* ===== Variables CSS ===== */
:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: #6366f1;
    --accent-color: #8b5cf6;
    --text-primary: #ffffff;
    --text-secondary: #d1d5db;
    --text-muted: #9ca3af;
    --bg-primary: #111827;
    --bg-secondary: #1f2937;
    --bg-tertiary: #374151;
    --border-color: #374151;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --transition: all 0.2s ease;
}

.light-theme {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: #6366f1;
    --accent-color: #8b5cf6;
    --text-primary: #111827;
    --text-secondary: #4b5563;
    --text-muted: #6b7280;
    --bg-primary: #f9fafb;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e5e7eb;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 20px;
    width: 100%;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ===== Header ===== */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.logo-container {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 24px;
}

/* Sélecteur d'artiste dans l'en-tête, à droite du logo */
.artist-selector-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.artist-selector-header .section-title {
    margin-bottom: 0;
    font-size: 0.95rem;
}

.artist-selector-header .select-wrapper {
    max-width: 280px;
    min-width: 200px;
}

.logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--text-primary);
}

.logo-image {
    width: 40px;
    height: auto;
    margin-bottom: 6px;
}

.logo-text {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.logo-text-ru {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 20px;
}

/* Theme Toggle (icône soleil/lune) */
.theme-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    line-height: 1;
}

.theme-btn:hover {
    background: var(--bg-tertiary);
}

/* Language Selector */
.language-selector {
    display: flex;
    gap: 5px;
}

.lang-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.lang-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

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

.lang-btn .flag-icon {
    font-size: 1.1rem;
    line-height: 1;
}

/* ===== Statut Discord RPC ===== */
.rpc-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.rpc-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--text-muted);
    transition: var(--transition);
}

.rpc-dot.on {
    background-color: #3ba55d;
    box-shadow: 0 0 6px rgba(59, 165, 93, 0.6);
}

/* ===== Main Content ===== */
.main-content {
    flex: 1;
    padding-bottom: 40px;
}

.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

/* Artist Selector (dans l'en-tête) */

.select-wrapper {
    position: relative;
    max-width: 400px;
}

.styled-select {
    width: 100%;
    padding: 12px 16px;
    padding-right: 40px;
    font-size: 1rem;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    appearance: none;
    cursor: pointer;
    transition: var(--transition);
}

.styled-select:hover,
.styled-select:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

.styled-select option {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

.select-arrow {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    font-size: 0.8rem;
}

/* ===== Player Container ===== */
.player-container {
    display: flex;
    gap: 24px;
    flex: 1;
}

.video-wrapper {
    flex: 2;
    min-width: 0;
}

.video-container {
    position: relative;
    background-color: #000;
    border-radius: var(--radius-lg);
    overflow: visible; /* Corrigé pour éviter de masquer les contrôles */
    aspect-ratio: 16/9;
    box-shadow: var(--shadow-lg);
}

.video-container video {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
}

.video-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    padding: 20px;
    color: var(--text-primary);
    pointer-events: none; /* Permet de cliquer à travers l'overlay */
    opacity: 1;
    transition: opacity 0.5s ease;
}

.video-overlay.hidden {
    opacity: 0;
}

.video-container:hover .video-overlay {
    opacity: 1;
}

.video-title {
    font-size: 1.1rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== Barre de contrôles du lecteur ===== */
.player-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.control-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    padding: 0;
}

.control-btn:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--primary-color);
}

.control-btn .control-icon {
    font-size: 1.1rem;
    line-height: 1;
}

.control-btn.active {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: var(--text-primary);
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.3);
}

/* Mode "répéter le titre en cours" : contour pointillé pour le
   distinguer du mode "répéter la playlist" */
.control-btn.one {
    border-style: dotted;
    border-width: 2px;
    box-shadow: none;
}

/* ===== Playlist ===== */
.playlist-wrapper {
    flex: 1;
    min-width: 300px;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

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

/* ===== Recherche dans la playlist ===== */
.playlist-search {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
}

.playlist-search-input {
    flex: 1;
    min-width: 0;
    padding: 8px 12px;
    font-size: 0.9rem;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    transition: var(--transition);
}

.playlist-search-input:hover,
.playlist-search-input:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

.playlist-search-input::placeholder {
    color: var(--text-muted);
}

.clear-search-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    width: 38px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: var(--transition);
}

.clear-search-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.playlist-grid {
    display: grid;
    /* 2 vignettes de largeur, 3 rangées de hauteur visibles :
       3 * 180px + 2 * 12px de gouttière = 564px */
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    height: 564px;
    overflow-y: auto;
    padding-right: 8px;
    align-content: start;
}

.playlist-grid::-webkit-scrollbar {
    width: 6px;
}

.playlist-grid::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 3px;
}

.playlist-grid::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 3px;
}

.playlist-grid::-webkit-scrollbar-thumb:hover {
    background: var(--border-color);
}

.playlist-item {
    background-color: var(--bg-secondary);
    border-radius: var(--radius-md);
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    height: 180px;
}

.playlist-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.playlist-item.active {
    border: 2px solid var(--primary-color);
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.3);
}

.thumbnail-container {
    height: 135px;
    width: 100%;
    background-color: var(--bg-tertiary);
    overflow: hidden;
}

.playlist-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.playlist-item:hover img {
    transform: scale(1.05);
}

.playlist-item .video-name {
    height: 45px;
    padding: 8px;
    text-align: center;
    font-size: 0.85rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

.empty-message {
    text-align: center;
    color: var(--text-muted);
    padding: 20px;
    font-size: 0.9rem;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

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

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

.btn-icon {
    font-size: 1rem;
}

.btn-text {
    color: inherit;
}

/* ===== Footer ===== */
.app-footer {
    text-align: center;
    padding: 20px;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ===== Responsive ===== */
@media (max-width: 1200px) {
    .player-container {
        flex-direction: column;
    }

    .video-wrapper {
        max-width: 100%;
    }

    .playlist-wrapper {
        max-width: 100%;
        /* Playlist sous le lecteur : plus d'alignement vertical */
        height: auto;
    }

    .playlist-grid {
        height: 564px;
    }

    .playlist-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
}

@media (max-width: 768px) {
    .app-header {
        flex-direction: column;
        gap: 16px;
        align-items: flex-start;
    }

    .header-controls {
        width: 100%;
        justify-content: flex-end;
        gap: 12px;
    }

    .artist-selector-header {
        width: 100%;
    }

    .artist-selector-header .select-wrapper {
        max-width: none;
        flex: 1;
    }

    .theme-btn {
        order: 1;
    }

    .language-selector {
        order: 2;
    }

    .rpc-status {
        display: none;
    }

    .video-container {
        aspect-ratio: 16/9;
        min-height: 250px;
    }

    .playlist-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        max-height: 300px;
    }

    .playlist-item {
        height: 150px;
    }

    .thumbnail-container {
        height: 110px;
    }

    .playlist-item .video-name {
        height: 40px;
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .logo-image {
        width: 40px;
    }

    .logo-text {
        font-size: 1.1rem;
    }

    .logo-text-ru {
        font-size: 0.9rem;
    }

    .video-container {
        min-height: 200px;
    }

    .playlist-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    }

    .playlist-item {
        height: 130px;
    }

    .thumbnail-container {
        height: 95px;
    }

    .playlist-item .video-name {
        height: 35px;
        font-size: 0.75rem;
    }
}
