/* YouTube Overlay */
.youtube-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.youtube-overlay.show {
    opacity: 1;
    visibility: visible;
}

.youtube-container {
    width: 90%;
    max-width: 1200px;
    height: 90%;
    max-height: 800px;
    background: var(--surface);
    border-radius: 1rem;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.youtube-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--surface-light);
    border-bottom: 1px solid var(--border);
}

.youtube-info {
    flex: 1;
    min-width: 0;
}

.youtube-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 0.25rem 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.youtube-category {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin: 0;
}

.close-youtube-btn {
    background: var(--danger);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 1rem;
}

.close-youtube-btn:hover {
    background: #dc2626;
    transform: scale(1.05);
}

.close-youtube-btn svg {
    width: 20px;
    height: 20px;
}

.youtube-player-container {
    flex: 1;
    position: relative;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

#youtube-player {
    width: 100%;
    height: 100%;
    transition: opacity 0.3s ease;
}

.youtube-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    color: white;
    z-index: 10;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.youtube-loading p {
    margin: 0;
    font-size: 1rem;
    text-align: center;
}

/* Enhanced Controls */
.youtube-controls {
    background: var(--surface-light);
    border-top: 1px solid var(--border);
    padding: 1rem 1.5rem;
}

/* Progress Bar */
.youtube-progress-container {
    margin-bottom: 1rem;
}

.youtube-progress-bar {
    position: relative;
    height: 6px;
    background: #FFF;
    border-radius: 3px;
    cursor: pointer;
    margin-bottom: 0.5rem;
}

.youtube-progress-filled {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    width: 0%;
    transition: width 0.1s ease;
}

.youtube-progress-handle {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 12px;
    height: 12px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    left: 0%;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.youtube-progress-bar:hover .youtube-progress-handle {
    opacity: 1;
}

.youtube-time-display {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Control Buttons */
.youtube-control-buttons {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.youtube-control-btn {
    background: var(--primary);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.youtube-control-btn:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

.youtube-control-btn svg {
    width: 18px;
    height: 18px;
}

/* Volume Control */
.youtube-volume-control {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.youtube-volume-slider {
    width: 80px;
    height: 4px;
    background: #FFF;
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    appearance: none;
}

.youtube-volume-slider::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
}

.youtube-volume-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.youtube-volume-value {
    font-size: 0.875rem;
    color: var(--text-muted);
    min-width: 40px;
    text-align: right;
}

/* Quality Control */
.youtube-quality-control {
    position: relative;
}

.quality-btn {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    width: auto;
    padding: 0 0.75rem;
    border-radius: 1rem;
}

.quality-text {
    font-size: 0.75rem;
}

.quality-menu {
    position: absolute;
    bottom: 100%;
    left: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    padding: 0.5rem 0;
    min-width: 80px;
    box-shadow: var(--shadow-lg);
    display: none;
    z-index: 10;
}

.quality-menu.show {
    display: block;
}

.quality-option {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-muted);
    transition: all 0.2s;
}

.quality-option:hover {
    background: var(--surface-light);
    color: var(--text);
}

/* Erreur YouTube */
.youtube-error {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(239, 68, 68, 0.95);
    color: white;
    padding: 2rem;
    border-radius: 1rem;
    text-align: center;
    max-width: 400px;
    backdrop-filter: blur(10px);
    z-index: 20;
}

.youtube-error h4 {
    margin: 0 0 1rem 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.youtube-error p {
    margin: 0 0 1.5rem 0;
    opacity: 0.9;
    line-height: 1.5;
}

.retry-btn {
    background: white;
    color: var(--danger);
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.retry-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Plein écran */
.youtube-overlay:fullscreen {
    background: #000;
}

.youtube-overlay:fullscreen .youtube-container {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    border-radius: 0;
    border: none;
}

/* Responsive */
@media (max-width: 1024px) {
    .youtube-container {
        width: 95%;
        height: 95%;
    }

    .youtube-header {
        padding: 0.75rem 1rem;
    }

    .youtube-title {
        font-size: 1.125rem;
    }

    .youtube-controls {
        padding: 0.75rem 1rem;
        gap: 0.75rem;
    }

    .youtube-volume-control {
        max-width: 200px;
    }
}

@media (max-width: 768px) {
    .youtube-container {
        width: 100%;
        height: 100%;
        border-radius: 0;
    }

    .youtube-header {
        padding: 0.75rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .youtube-info {
        order: 1;
        flex-basis: 100%;
    }

    .close-youtube-btn {
        order: 2;
        margin-left: 0;
        width: 36px;
        height: 36px;
    }

    .youtube-title {
        font-size: 1rem;
        white-space: normal;
        overflow: visible;
        text-overflow: initial;
        line-height: 1.4;
    }

    .youtube-controls {
        padding: 0.75rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .youtube-control-btn {
        width: 36px;
        height: 36px;
    }

    .youtube-volume-control {
        flex-basis: 100%;
        max-width: none;
        order: 2;
    }

    .youtube-volume-slider {
        height: 6px;
    }

    .youtube-volume-slider::-webkit-slider-thumb {
        width: 18px;
        height: 18px;
    }

    .youtube-error {
        margin: 1rem;
        padding: 1.5rem;
        max-width: none;
    }

    .youtube-error h4 {
        font-size: 1.125rem;
    }
}

/* Animation d'entrée */
@keyframes youtubeSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.youtube-overlay.show .youtube-container {
    animation: youtubeSlideIn 0.3s ease-out;
}

/* Indicateur de lecture YouTube dans les contrôles principaux */
body.youtube-playing .player-controls {
    background: linear-gradient(135deg, var(--surface-light), rgba(239, 68, 68, 0.1));
    border-color: var(--danger);
}

body.youtube-playing .current-title {
    color: var(--danger);
}

body.youtube-playing .current-category::before {
    content: "📺 ";
}

/* Masquer le scroll quand YouTube est ouvert */
body.youtube-playing {
    overflow: hidden;
}