/* YouTube Backgrounds Floating Button */
#open-youtube-bg-btn {
    display: none; /* Hidden - button moved to settings */
}

/* YouTube Background Video Container */
#yt-bg-container {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: -1 !important;
    overflow: hidden !important;
    display: none !important;
    pointer-events: none !important;
}

#yt-bg-container[style*="display: block"] {
    display: block !important;
}

#yt-bg-player {
    width: 100%;
    height: 100%;
    position: relative;
}

#yt-bg-player iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* COVER - Füllt Bildschirm, behält Seitenverhältnis */
#yt-bg-container.cover #yt-bg-player iframe {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100vw;
    height: 56.25vw;
    min-height: 100vh;
    min-width: 177.77vh;
    transform: translate(-50%, -50%);
}

/* CONTAIN - Zeigt komplettes Video */
#yt-bg-container.contain #yt-bg-player {
    display: flex;
    align-items: center;
    justify-content: center;
}

#yt-bg-container.contain #yt-bg-player iframe {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 177.77vh;
    max-height: 56.25vw;
    top: auto;
    left: auto;
    transform: none;
}

/* STRETCH - Streckt auf volle Größe */
#yt-bg-container.stretch #yt-bg-player iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    transform: none;
}

/* CENTER - Zentriert */
#yt-bg-container.center #yt-bg-player {
    display: flex;
    align-items: center;
    justify-content: center;
}

#yt-bg-container.center #yt-bg-player iframe {
    position: relative;
    width: 1280px;
    height: 720px;
    max-width: 90vw;
    max-height: 90vh;
    top: auto;
    left: auto;
    transform: none;
}

/* Overlay */
#yt-bg-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(5px);
}

/* Panel */
#yt-bg-panel {
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
    border-radius: 30px;
    padding: 40px;
    width: 1200px;
    max-width: 95vw;
    max-height: 95vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
    border: 3px solid var(--border);
    position: relative;
}

/* Header */
#yt-bg-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--border);
}

#yt-bg-header h2 {
    margin: 0;
    font-size: 32px;
    color: #ff0000;
    text-shadow: 0 0 10px rgba(255, 0, 0, 0.5);
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-buttons {
    display: flex;
    gap: 10px;
}

.header-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 20px;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-btn:hover {
    transform: scale(1.1);
    background: var(--accent);
}

.header-btn.close {
    background: var(--danger);
}

.header-btn.close:hover {
    background: #ef4444;
}

#yt-add-video-btn {
    background: var(--success);
}

#yt-add-video-btn:hover {
    background: #059669;
}

#yt-stop-video-btn {
    background: var(--danger);
}

#yt-stop-video-btn:hover {
    background: #dc2626;
}

/* Settings */
#yt-bg-settings {
    background: rgba(26, 26, 46, 0.3);
    padding: 20px;
    border-radius: 20px;
    border: 2px solid var(--border);
    margin-bottom: 30px;
}

.settings-row {
    display: flex;
    gap: 30px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

.settings-row:last-child {
    margin-bottom: 0;
}

.setting-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    min-width: 200px;
}

.setting-item label {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.setting-item select {
    background: var(--bg-tertiary);
    border: 2px solid var(--border);
    color: var(--text-primary);
    padding: 10px 15px;
    border-radius: 12px;
    font-size: 15px;
    cursor: pointer;
    transition: border-color 0.2s;
}

.setting-item select:hover,
.setting-item select:focus {
    border-color: var(--accent);
    outline: none;
}

.setting-item input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: 5px;
    background: var(--bg-tertiary);
    outline: none;
    -webkit-appearance: none;
}

.setting-item input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ff0000;
    cursor: pointer;
    transition: all 0.2s;
}

.setting-item input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 10px rgba(255, 0, 0, 0.5);
}

.setting-item input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ff0000;
    cursor: pointer;
    border: none;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 600;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: #ff0000;
    cursor: pointer;
}

.checkbox-label span {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Content */
#yt-bg-content {
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 10px;
}

#yt-videos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

/* Video Items */
.yt-video-item {
    background: linear-gradient(135deg, var(--bg-tertiary) 0%, var(--bg-secondary) 100%);
    border: 3px solid var(--border);
    border-radius: 20px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
}

.yt-video-item:hover {
    transform: translateY(-8px);
    box-shadow: 0 8px 30px rgba(255, 0, 0, 0.4);
    border-color: #ff0000;
}

.yt-video-item.active-video {
    border-color: var(--success);
    box-shadow: 0 0 25px rgba(16, 185, 129, 0.6);
}

.yt-thumbnail {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: #000;
}

.yt-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.yt-video-item:hover .yt-thumbnail img {
    transform: scale(1.1);
}

.yt-play-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    background: rgba(255, 0, 0, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    transition: all 0.3s;
    pointer-events: none;
}

.yt-video-item:hover .yt-play-overlay {
    transform: translate(-50%, -50%) scale(1.15);
    background: rgba(255, 0, 0, 1);
    box-shadow: 0 0 20px rgba(255, 0, 0, 0.6);
}

.yt-video-info {
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.yt-video-title {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 15px;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.yt-video-controls {
    display: flex;
    gap: 8px;
}

.yt-control-btn {
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid var(--border);
    color: var(--text-primary);
    width: 35px;
    height: 35px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.yt-control-btn:hover {
    transform: scale(1.1);
}

.yt-play-btn:hover {
    background: var(--success);
    border-color: var(--success);
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.5);
}

.yt-delete-btn:hover {
    background: var(--danger);
    border-color: var(--danger);
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.5);
}

.yt-active-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
    color: white;
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.5);
    z-index: 10;
}

/* Notifications */
.yt-notification {
    position: fixed;
    top: 80px;
    right: 20px;
    padding: 18px 28px;
    border-radius: 15px;
    color: white;
    font-weight: bold;
    z-index: 10001;
    opacity: 1;
    transition: opacity 0.3s;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
    max-width: 350px;
}

.yt-notification.success {
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
}

.yt-notification.error {
    background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
}

.yt-notification.info {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
}

/* Responsive */
@media (max-width: 768px) {
    #yt-bg-panel {
        width: 95vw;
        padding: 20px;
    }
    
    #yt-bg-header h2 {
        font-size: 24px;
    }
    
    #yt-videos-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 15px;
    }
    
    .settings-row {
        flex-direction: column;
        gap: 15px;
    }
    
    .setting-item {
        width: 100%;
        min-width: unset;
    }
}
