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

:root {
    --primary: #e50914;
    --primary-hover: #f40612;
    --bg-dark: #141414;
    --bg-darker: #0a0a0a;
    --bg-control: rgba(20, 20, 20, 0.9);
    --text-primary: #fff;
    --text-secondary: #b3b3b3;
    --border: rgba(255, 255, 255, 0.1);
    --transition: 0.2s ease;
}

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

/* App Container */
.app-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.hidden {
    display: none !important;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-darker);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loader-content {
    text-align: center;
    max-width: 400px;
    padding: 40px;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    margin: 0 auto 30px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loader-content h2 {
    font-size: 1.5rem;
    font-weight: 500;
    margin-bottom: 20px;
}

.progress-container {
    width: 100%;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #ff6b6b);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 2px;
}

.progress-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Player Container */
.player-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--bg-dark);
}

/* Video Wrapper */
.video-wrapper {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    overflow: hidden;
}

#video-player {
    width: 100%;
    height: 100%;
    object-fit: contain;
    cursor: pointer;
}

/* Video Controls */
.video-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.9));
    padding: 60px 20px 20px;
    opacity: 0;
    transition: opacity var(--transition);
}

.video-wrapper:hover .video-controls,
.video-controls.visible {
    opacity: 1;
}

/* Progress Bar */
.progress-wrapper {
    position: relative;
    padding: 10px 0;
    margin-bottom: 10px;
}

.seek-bar {
    position: relative;
    height: 5px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    cursor: pointer;
    transition: height 0.1s ease;
}

.seek-bar:hover {
    height: 8px;
}

.buffer-bar {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    width: 0%;
}

.playback-bar {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    width: 0%;
}

.seek-handle {
    position: absolute;
    top: 50%;
    left: 0%;
    width: 14px;
    height: 14px;
    background: var(--text-primary);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity var(--transition);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.seek-bar:hover .seek-handle {
    opacity: 1;
}

.seek-preview {
    position: absolute;
    bottom: 100%;
    left: 0;
    transform: translateX(-50%);
    background: var(--bg-control);
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.85rem;
    white-space: nowrap;
    pointer-events: none;
    margin-bottom: 10px;
}

/* Controls Row */
.controls-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.controls-left,
.controls-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Control Buttons */
.control-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.control-btn svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.control-btn:active {
    transform: scale(0.95);
}

/* Volume Control */
.volume-control {
    display: flex;
    align-items: center;
    gap: 4px;
}

.volume-slider-wrapper {
    width: 0;
    overflow: hidden;
    transition: width var(--transition);
}

.volume-control:hover .volume-slider-wrapper {
    width: 80px;
}

.volume-slider {
    width: 80px;
    height: 4px;
    appearance: none;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    cursor: pointer;
}

.volume-slider::-webkit-slider-thumb {
    appearance: none;
    width: 12px;
    height: 12px;
    background: var(--text-primary);
    border-radius: 50%;
    cursor: pointer;
}

.volume-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    background: var(--text-primary);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

/* Time Display */
.time-display {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-left: 10px;
    font-variant-numeric: tabular-nums;
}

/* Speed Label */
.speed-label {
    font-size: 0.9rem;
    font-weight: 500;
}

/* Dropdown */
.dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    bottom: 100%;
    right: 0;
    min-width: 180px;
    background: var(--bg-control);
    border-radius: 8px;
    padding: 8px 0;
    margin-bottom: 10px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all var(--transition);
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    z-index: 100;
}

.dropdown:hover .dropdown-menu,
.dropdown.active .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-header {
    padding: 8px 16px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}

.dropdown-item {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    cursor: pointer;
    transition: background var(--transition);
    font-size: 0.9rem;
}

.dropdown-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.dropdown-item.active {
    color: var(--primary);
}

.dropdown-item.active::before {
    content: '✓';
    margin-right: 10px;
    font-weight: bold;
}

/* Center Play Button */
.center-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80px;
    height: 80px;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
}

.center-play:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: translate(-50%, -50%) scale(1.1);
}

.center-play svg {
    width: 40px;
    height: 40px;
    fill: var(--text-primary);
    margin-left: 4px;
}

/* Video Info */
.video-info {
    padding: 20px;
    background: var(--bg-dark);
    border-top: 1px solid var(--border);
}

.video-info h1 {
    font-size: 1.3rem;
    font-weight: 500;
    margin-bottom: 8px;
}

.stream-info {
    display: flex;
    gap: 15px;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Error Screen */
.error-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-darker);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.error-content {
    text-align: center;
    padding: 40px;
}

.error-content svg {
    width: 80px;
    height: 80px;
    fill: var(--primary);
    margin-bottom: 20px;
}

.error-content h2 {
    font-size: 1.5rem;
    margin-bottom: 10px;
}

.error-content p {
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.retry-btn {
    background: var(--primary);
    color: var(--text-primary);
    border: none;
    padding: 12px 30px;
    font-size: 1rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background var(--transition);
}

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

/* Fullscreen */
.player-container:fullscreen,
.player-container:-webkit-full-screen {
    background: #000;
}

.player-container:fullscreen .video-info,
.player-container:-webkit-full-screen .video-info {
    display: none;
}

.player-container:fullscreen .video-wrapper,
.player-container:-webkit-full-screen .video-wrapper {
    height: 100%;
}

/* Responsive */
@media (max-width: 768px) {
    .controls-row {
        flex-wrap: wrap;
        gap: 10px;
    }

    .time-display {
        order: -1;
        width: 100%;
        text-align: center;
        margin-left: 0;
    }

    .volume-slider-wrapper {
        display: none;
    }

    .center-play {
        width: 60px;
        height: 60px;
    }

    .center-play svg {
        width: 30px;
        height: 30px;
    }
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Buffering Spinner */
.buffering-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
}

.spinner-small {
    width: 50px;
    height: 50px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Subtitle Container */
.subtitle-container {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    max-width: 80%;
    text-align: center;
    font-size: 1.4rem;
    color: var(--text-primary);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    background: rgba(0, 0, 0, 0.5);
    padding: 8px 16px;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.subtitle-container.visible {
    opacity: 1;
}

/* Double click for fullscreen */
.video-wrapper {
    user-select: none;
}

/* Touch device optimizations */
@media (hover: none) {
    .video-controls {
        opacity: 1;
    }

    .volume-slider-wrapper {
        display: none;
    }
}

/* Picture-in-Picture button style */
.pip-btn {
    position: relative;
}

/* Loading animation for segments */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.loading-pulse {
    animation: pulse 1.5s ease-in-out infinite;
}
