/* TikTok-style Video Player Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --vh: 1vh;
    --primary-color: #fe2c55;
    --secondary-color: #25f4ee;
    --text-color: #fff;
    --bg-color: #000;
    --overlay-bg: rgba(0, 0, 0, 0.3);
    --control-bg: rgba(0, 0, 0, 0.6);
}

html, body {
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.app-container {
    width: 100vw;
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
    position: relative;
    background-color: var(--bg-color);
    overflow: hidden;
}

/* Header */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0.4) 70%, rgba(0, 0, 0, 0) 100%);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: max(env(safe-area-inset-top), 12px) 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.header h1 {
    text-align: center;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-color);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

/* Loading */
.loading-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
    background-color: var(--bg-color);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-container p {
    font-size: 16px;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 500;
}

/* Video Container */
.video-container {
    width: 100vw;
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
    position: relative;
    background-color: var(--bg-color);
    cursor: pointer;
    overflow: hidden;
}

.video-container.transitioning {
    pointer-events: none;
}

.video-player {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background-color: var(--bg-color);
    outline: none;
    border: none;
}

/* Swipe Animations */
.video-container.swipe-up {
    animation: swipeUp 0.3s ease-out;
}

.video-container.swipe-down {
    animation: swipeDown 0.3s ease-out;
}

@keyframes swipeUp {
    0% { transform: translateY(0); }
    100% { transform: translateY(-100%); }
}

@keyframes swipeDown {
    0% { transform: translateY(0); }
    100% { transform: translateY(100%); }
}

/* Play/Pause Overlay */
.play-pause-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
    z-index: 50;
    transition: all 0.2s ease;
}

.play-pause-overlay.show {
    display: block;
    animation: fadeInScale 0.2s ease-out;
}

@keyframes fadeInScale {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.play-button {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.play-button span {
    font-size: 28px;
    color: var(--bg-color);
    margin-left: 4px;
    text-shadow: none;
}

/* Controls Overlay */
.controls-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 40;
}

.controls-overlay > * {
    pointer-events: auto;
}

/* Right Side Controls */
.right-controls {
    position: absolute;
    right: 12px;
    bottom: max(env(safe-area-inset-bottom), 120px);
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
}

.action-button {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.action-button:hover {
    transform: scale(1.1);
    background: rgba(0, 0, 0, 0.8);
}

.action-button:active {
    transform: scale(0.95);
}

.action-button.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    box-shadow: 0 4px 16px rgba(254, 44, 85, 0.4);
}

.action-button svg {
    width: 20px;
    height: 20px;
    stroke-width: 2.5;
    margin-bottom: 2px;
}

.action-button span {
    font-size: 10px;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.heart-icon {
    fill: none;
    stroke: currentColor;
}

.action-button.active .heart-icon {
    fill: white;
    stroke: white;
}

/* Bottom Info */
.bottom-info {
    position: absolute;
    left: 16px;
    right: 80px;
    bottom: max(env(safe-area-inset-bottom), 120px);
    z-index: 41;
}

.bottom-info p {
    margin-bottom: 8px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}

#videoTitle {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
    max-height: 3.9em;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

#videoCounter {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 500;
}

.progress-text {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.6);
    font-weight: 400;
    margin-top: 4px;
}

/* Progress Bar */
.progress-container {
    position: absolute;
    bottom: max(env(safe-area-inset-bottom), 80px);
    left: 16px;
    right: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 42;
}

.progress-time-left,
.progress-time-right {
    font-size: 11px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.8);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    min-width: 32px;
    text-align: center;
}

.progress-bar-container {
    flex: 1;
    height: 20px;
    position: relative;
    cursor: pointer;
    display: flex;
    align-items: center;
}

.progress-bar-bg {
    width: 100%;
    height: 2px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 1px;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.progress-bar-fill {
    position: absolute;
    top: 50%;
    left: 0;
    height: 2px;
    background: var(--primary-color);
    border-radius: 1px;
    transform: translateY(-50%);
    width: 0%;
    transition: width 0.1s ease;
    box-shadow: 0 0 8px rgba(254, 44, 85, 0.5);
}

.progress-handle {
    position: absolute;
    top: 50%;
    left: 0%;
    width: 12px;
    height: 12px;
    background: var(--primary-color);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    border: 2px solid white;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.progress-bar-container:hover .progress-handle,
.progress-bar-container:active .progress-handle {
    opacity: 1;
}

/* Swipe Instructions */
.swipe-instructions {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 12px 24px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
    text-align: center;
    opacity: 0;
    pointer-events: none;
    animation: fadeInOut 3s ease-in-out 2s;
    z-index: 45;
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0; }
    20%, 80% { opacity: 1; }
}

/* No Videos Message */
.no-videos {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
    background-color: var(--bg-color);
    text-align: center;
    padding: 20px;
}

.no-videos p {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-color);
}

.no-videos small {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.6);
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .header h1 {
        font-size: 16px;
    }
    
    .right-controls {
        right: 8px;
        gap: 16px;
    }
    
    .action-button {
        width: 44px;
        height: 44px;
    }
    
    .action-button svg {
        width: 18px;
        height: 18px;
    }
    
    .action-button span {
        font-size: 9px;
    }
    
    .bottom-info {
        left: 12px;
        right: 60px;
    }
    
    #videoTitle {
        font-size: 15px;
    }
    
    .progress-container {
        left: 12px;
        right: 12px;
    }
}

/* Landscape Mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .header {
        padding: 8px 16px 12px;
    }
    
    .header h1 {
        font-size: 14px;
    }
    
    .right-controls {
        bottom: 60px;
        gap: 12px;
    }
    
    .action-button {
        width: 40px;
        height: 40px;
    }
    
    .bottom-info {
        bottom: 60px;
    }
    
    .progress-container {
        bottom: 20px;
    }
    
    .swipe-instructions {
        display: none;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .action-button {
        border-width: 2px;
        border-color: white;
    }
    
    .progress-bar-bg {
        background: rgba(255, 255, 255, 0.5);
    }
}

/* Dark mode (already dark, but for consistency) */
@media (prefers-color-scheme: dark) {
    /* Already optimized for dark theme */
}

/* Focus styles for keyboard navigation */
.action-button:focus,
.progress-bar-container:focus {
    outline: 2px solid var(--secondary-color);
    outline-offset: 2px;
}

/* Loading states */
.video-container.transitioning .play-pause-overlay,
.video-container.transitioning .controls-overlay {
    opacity: 0.5;
    pointer-events: none;
}

/* Error states */
.video-container.error {
    background: linear-gradient(45deg, #1a1a1a 25%, #2a2a2a 25%, #2a2a2a 50%, #1a1a1a 50%, #1a1a1a 75%, #2a2a2a 75%);
    background-size: 20px 20px;
}

/* Smooth transitions */
.video-container,
.controls-overlay > *,
.action-button,
.progress-bar-fill {
    transition: all 0.2s ease;
}

/* Performance optimizations */
.video-player,
.controls-overlay,
.progress-container {
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
}
