/* YouTube Custom Player Styles */
.ycp-container {
    position: relative;
    width: 100%;
    max-width: 100%;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.ycp-player-wrapper {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    background: #000;
}

.ycp-video-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
}

.ycp-video-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.ycp-iframe {
    width: 100%;
    height: 100%;
    border: none;
    pointer-events: none; /* Prevent direct interaction with iframe */
    position: absolute;
    top: 0;
    left: 0;
}

.ycp-click-blocker {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: auto;
    background: transparent;
}

.ycp-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: opacity 0.3s ease;
    z-index: 20;
}

.ycp-overlay:hover {
    background: rgba(0, 0, 0, 0.5);
}

.ycp-overlay.playing {
    opacity: 0;
    pointer-events: none;
}

.ycp-play-button {
    transition: transform 0.2s ease;
}

.ycp-play-button:hover {
    transform: scale(1.1);
}

/* Custom Controls */
.ycp-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    padding: 10px 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 30;
}

.ycp-container:hover .ycp-controls,
.ycp-container.playing .ycp-controls {
    opacity: 1;
}

.ycp-controls-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ycp-controls-right {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

.ycp-progress-container {
    flex: 1;
    margin: 0 15px;
}

.ycp-progress-bar {
    position: relative;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    cursor: pointer;
    transition: height 0.2s ease;
}

.ycp-progress-bar:hover {
    height: 6px;
}

.ycp-progress {
    height: 100%;
    background: #ff0000;
    border-radius: 2px;
    width: 0%;
    transition: width 0.1s ease;
}

.ycp-progress-handle {
    position: absolute;
    top: 50%;
    left: 0%;
    width: 12px;
    height: 12px;
    background: #ff0000;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.ycp-progress-bar:hover .ycp-progress-handle {
    opacity: 1;
}

.ycp-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ycp-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.ycp-btn:active {
    background: rgba(255, 255, 255, 0.3);
}

.ycp-time {
    color: white;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
}

.ycp-time-separator {
    margin: 0 2px;
    opacity: 0.7;
}

/* Volume Controls */
.ycp-volume-container {
    display: flex;
    align-items: center;
    gap: 5px;
}

.ycp-volume-slider {
    width: 60px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.ycp-volume-container:hover .ycp-volume-slider {
    opacity: 1;
}

.ycp-volume-range {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    -webkit-appearance: none;
}

.ycp-volume-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    background: #ff0000;
    border-radius: 50%;
    cursor: pointer;
}

.ycp-volume-range::-moz-range-thumb {
    width: 12px;
    height: 12px;
    background: #ff0000;
    border-radius: 50%;
    border: none;
    cursor: pointer;
}

/* Loading State */
.ycp-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 16px;
    z-index: 4;
}

.ycp-loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error State */
.ycp-error {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    text-align: center;
    z-index: 4;
}

.ycp-error-icon {
    font-size: 48px;
    margin-bottom: 10px;
    opacity: 0.7;
}

.ycp-error-message {
    font-size: 16px;
    margin-bottom: 15px;
}

.ycp-error-retry {
    background: #ff0000;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s ease;
}

.ycp-error-retry:hover {
    background: #cc0000;
}

/* Fullscreen Styles */
.ycp-container:-webkit-full-screen {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
}

.ycp-container:-moz-full-screen {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
}

.ycp-container:fullscreen {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
}

/* Mobile and iOS specific styles */
@media (max-width: 768px) {
    .ycp-container {
        border-radius: 0;
        box-shadow: none;
    }
    
    .ycp-controls {
        padding: 8px 10px;
        gap: 8px;
        opacity: 1; /* Always show controls on mobile */
    }
    
    .ycp-time {
        font-size: 12px;
    }
    
    .ycp-volume-slider {
        width: 40px;
    }
    
    .ycp-progress-container {
        margin: 0 10px;
    }
    
    /* Make controls more touch-friendly */
    .ycp-btn {
        padding: 8px;
        min-width: 44px;
        min-height: 44px;
    }
    
    .ycp-progress-bar {
        height: 6px;
    }
    
    .ycp-progress-handle {
        width: 16px;
        height: 16px;
    }
}

@media (max-width: 480px) {
    .ycp-controls {
        padding: 6px 8px;
        gap: 6px;
    }
    
    .ycp-time {
        display: none;
    }
    
    .ycp-volume-container {
        display: none;
    }
    
    .ycp-progress-container {
        margin: 0 5px;
    }
    
    .ycp-play-button {
        transform: scale(1.2);
    }
}

/* iOS specific fixes */
@supports (-webkit-touch-callout: none) {
    .ycp-container {
        -webkit-overflow-scrolling: touch;
    }
    
    .ycp-iframe {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }
    
    .ycp-controls {
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
    }
    
    /* Prevent iOS from zooming on double tap */
    .ycp-container {
        touch-action: manipulation;
    }
}

/* Mobile-specific styles */
.ycp-container.mobile .ycp-controls {
    opacity: 1 !important;
    transition: opacity 0.3s ease;
}

.ycp-container.mobile .ycp-overlay {
    opacity: 0.8;
}

.ycp-container.mobile .ycp-play-button {
    transform: scale(1.1);
}

/* iOS-specific mode - let YouTube handle everything */
.ycp-container.ios-mode .ycp-iframe {
    pointer-events: none !important;
    transform: none !important;
}

.ycp-container.ios-mode .ycp-click-blocker {
    display: none !important;
}

.ycp-container.ios-mode .ycp-controls {
    display: none !important;
}

.ycp-container.ios-mode .ycp-overlay {
    display: none !important;
}

/* Hide play button when video is playing on iOS */
.ycp-container.ios-mode.playing .ycp-overlay {
    display: none !important;
}

.ycp-container.ios-mode.playing .ycp-play-button {
    display: none !important;
}

/* iOS click protector */
.ycp-ios-click-protector {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 25;
    background: transparent;
    pointer-events: auto;
    cursor: pointer;
}

/* iOS video wrapper adjustments */
.ycp-container.ios-mode .ycp-video-wrapper::before,
.ycp-container.ios-mode .ycp-video-wrapper::after {
    display: none !important;
}

/* Unmute message for iOS */
.ycp-unmute-message {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    cursor: pointer;
    animation: fadeIn 0.5s ease-in;
}

.ycp-unmute-content {
    text-align: center;
    color: white;
    padding: 20px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 12px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    max-width: 280px;
    margin: 0 20px;
}

.ycp-unmute-icon {
    font-size: 48px;
    margin-bottom: 15px;
    animation: pulse 2s infinite;
}

.ycp-unmute-text {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 8px;
}

.ycp-unmute-subtext {
    font-size: 14px;
    opacity: 0.8;
    line-height: 1.4;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* iOS exit fullscreen button */
.ycp-ios-exit-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 60;
    transition: background-color 0.2s ease;
}

.ycp-ios-exit-btn:hover {
    background: rgba(0, 0, 0, 0.9);
}

.ycp-ios-exit-btn svg {
    width: 24px;
    height: 24px;
}

/* Touch-friendly button sizes */
@media (max-width: 768px) {
    .ycp-btn {
        min-width: 44px;
        min-height: 44px;
        padding: 12px;
    }
    
    .ycp-play-button {
        width: 80px;
        height: 80px;
    }
    
    .ycp-play-button svg {
        width: 80px;
        height: 80px;
    }
}

/* Landscape mobile orientation */
@media (max-width: 768px) and (orientation: landscape) {
    .ycp-controls {
        padding: 4px 8px;
    }
    
    .ycp-time {
        font-size: 11px;
    }
    
    .ycp-btn {
        min-width: 36px;
        min-height: 36px;
        padding: 8px;
    }
}

/* Completely hide YouTube branding and controls */
.ycp-iframe {
    pointer-events: none; /* Prevent direct interaction with iframe */
    transform: scale(1.05); /* Hide YouTube's watermark by scaling */
    transform-origin: center center;
    filter: contrast(1.1) brightness(1.05) saturate(1.1);
}

/* Hide YouTube watermark and branding */
.ycp-video-wrapper::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        to bottom,
        transparent 0%,
        transparent 85%,
        rgba(0,0,0,0.1) 100%
    );
    z-index: 5;
    pointer-events: none;
}

/* Hide overlay when playing but keep click blocker */
.ycp-container.playing .ycp-overlay {
    display: none;
}

/* Fullscreen fixes */
.ycp-container:-webkit-full-screen,
.ycp-container:-moz-full-screen,
.ycp-container:fullscreen {
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    background: #000 !important;
    position: relative !important;
    top: 0 !important;
    left: 0 !important;
    z-index: 9999 !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Fallback fullscreen class */
.ycp-container.fullscreen {
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    background: #000 !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    z-index: 9999 !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Ensure video fills fullscreen */
.ycp-container:fullscreen .ycp-player-wrapper,
.ycp-container:-webkit-full-screen .ycp-player-wrapper,
.ycp-container:-moz-full-screen .ycp-player-wrapper,
.ycp-container.fullscreen .ycp-player-wrapper {
    width: 100% !important;
    height: 100% !important;
    padding-bottom: 0 !important;
    position: relative !important;
    margin: 0 !important;
}

.ycp-container:fullscreen .ycp-video-container,
.ycp-container:-webkit-full-screen .ycp-video-container,
.ycp-container:-moz-full-screen .ycp-video-container,
.ycp-container.fullscreen .ycp-video-container {
    width: 100% !important;
    height: 100% !important;
    position: relative !important;
    margin: 0 !important;
}

.ycp-container:fullscreen .ycp-video-wrapper,
.ycp-container:-webkit-full-screen .ycp-video-wrapper,
.ycp-container:-moz-full-screen .ycp-video-wrapper,
.ycp-container.fullscreen .ycp-video-wrapper {
    width: 100% !important;
    height: 100% !important;
    position: relative !important;
    margin: 0 !important;
}

.ycp-container:fullscreen .ycp-iframe,
.ycp-container:-webkit-full-screen .ycp-iframe,
.ycp-container:-moz-full-screen .ycp-iframe,
.ycp-container.fullscreen .ycp-iframe {
    width: 100% !important;
    height: 100% !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    margin: 0 !important;
    object-fit: cover !important;
}

/* Hide YouTube's built-in fullscreen button */
.ycp-iframe::-webkit-media-controls-fullscreen-button {
    display: none !important;
}

/* Additional YouTube branding removal */
.ycp-video-wrapper {
    overflow: hidden;
    position: relative;
}

/* Hide any YouTube UI elements that might appear */
.ycp-iframe[src*="youtube.com"] {
    filter: contrast(1.1) brightness(1.05);
}

/* Additional YouTube branding removal techniques */
.ycp-video-wrapper {
    position: relative;
    overflow: hidden;
    background: #000;
}

/* Hide YouTube's watermark with overlay */
.ycp-video-wrapper::before {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 120px;
    height: 40px;
    background: linear-gradient(45deg, transparent 0%, rgba(0,0,0,0.8) 50%);
    z-index: 15;
    pointer-events: none;
}

/* Hide YouTube's title and info overlay */
.ycp-video-wrapper::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.7) 0%, transparent 100%);
    z-index: 15;
    pointer-events: none;
}

/* Ensure click blocker covers everything */
.ycp-click-blocker {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 20;
    pointer-events: auto;
    background: transparent;
    cursor: pointer;
}

/* When playing, still block clicks to prevent YouTube navigation */
.ycp-container.playing .ycp-click-blocker {
    display: block !important;
    z-index: 20;
}
