/* WASM Video Player — Dark theme */
:root {
    --bg: #1a1a2e;
    --surface: #16213e;
    --surface-alt: #0f3460;
    --accent: #e94560;
    --accent-hover: #ff6b81;
    --text: #eee;
    --text-muted: #aaa;
    --border: #333;
    --radius: 8px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 2rem 1rem;
}

#app {
    width: 100%;
    max-width: 900px;
}

h1 {
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: 1.6rem;
    color: var(--accent);
}

/* URL bar */
.url-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.url-bar input {
    flex: 1;
    padding: 0.6rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}

.url-bar input:focus {
    border-color: var(--accent);
}

.url-bar button,
.controls button {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: var(--radius);
    background: var(--accent);
    color: #fff;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s;
}

.url-bar button:hover,
.controls button:hover:not(:disabled),
.file-btn:hover {
    background: var(--accent-hover);
}

.file-btn {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: var(--radius);
    background: var(--surface-alt, #2a2a3e);
    color: #fff;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.2s;
    user-select: none;
}

.controls button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Drag & drop highlight */
.player-container.drag-over {
    outline: 3px dashed var(--accent, #e94560);
    outline-offset: -3px;
}

/* Player container */
.player-container {
    position: relative;
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 0.75rem;
    aspect-ratio: 16 / 9;
    display: flex;
    align-items: center;
    justify-content: center;
}

.player-container canvas {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* (Old external controls removed — now using PlayerControls overlay) */

/* Status bar */
#status-bar {
    padding: 0.5rem 1rem;
    background: var(--surface);
    border-radius: var(--radius);
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

/* Error display */
#error-display {
    padding: 0.75rem 1rem;
    background: #4a0e1c;
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    color: #ff8a9e;
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}

/* Media info panel */
#media-info {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
}

#media-info h3,
#playlist-panel h3 {
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
    color: var(--accent);
}

#media-info-list {
    list-style: none;
    font-size: 0.85rem;
    color: var(--text-muted);
}

#media-info-list li {
    padding: 0.2rem 0;
}

/* Playlist panel */
#playlist-panel {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
}

#playlist-list {
    list-style: none;
}

#playlist-list li {
    padding: 0.4rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.15s;
}

#playlist-list li:hover {
    background: var(--surface-alt);
}

#playlist-list li.active {
    background: var(--surface-alt);
    border-left: 3px solid var(--accent);
    padding-left: calc(0.5rem - 3px);
}

/* Utility */
.hidden {
    display: none !important;
}

/* =============================================
   PlayerControls — Canvas overlay controls
   ============================================= */

/* Overlay wrapper — covers the entire player container */
.pc-overlay {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    pointer-events: auto; /* capture clicks for play/pause toggle */
    transition: opacity 0.3s ease;
}

/* When controls are hidden (auto-hide) */
.pc-hide-controls .pc-bottom-bar,
.pc-hide-controls .pc-gradient {
    opacity: 0;
    pointer-events: none;
}

/* Center message overlay (Loading, Buffering, Seeking...) */
.pc-center-msg {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 1.2rem;
    letter-spacing: 0.02em;
    pointer-events: none;
    z-index: 20;
    transition: opacity 0.25s ease;
}

.pc-hidden {
    display: none !important;
}

/* Bottom gradient — fade from transparent to dark */
.pc-gradient {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 120px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.75));
    pointer-events: auto;
    transition: opacity 0.3s ease;
}

/* Bottom bar — contains seek + controls */
.pc-bottom-bar {
    position: relative;
    z-index: 15;
    padding: 0 12px 8px;
    pointer-events: auto;
    transition: opacity 0.3s ease;
}

/* Seek row — full width multi-layer progress bar */
.pc-seek-row {
    padding: 8px 0 4px;
}

.pc-seek-track {
    position: relative;
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.2);
    cursor: pointer;
    transition: height 0.15s ease;
}

.pc-seek-track:hover {
    height: 6px;
}

/* Buffered portion — light grey */
.pc-seek-buffered {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: rgba(255, 255, 255, 0.35);
    border-radius: 2px;
    pointer-events: none;
    transition: width 0.1s linear;
}

/* Played/watched portion — accent color */
.pc-seek-played {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: var(--accent, #e94560);
    border-radius: 2px;
    pointer-events: none;
    transition: width 0.1s linear;
}

/* Thumb — draggable circle */
.pc-seek-thumb {
    position: absolute;
    top: 50%;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent, #e94560);
    transform: translate(-50%, -50%);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s, transform 0.1s;
}

.pc-seek-track:hover .pc-seek-thumb {
    opacity: 1;
}

.pc-seek-track:hover .pc-seek-thumb:hover {
    transform: translate(-50%, -50%) scale(1.3);
}

/* Hidden range input — overlays the track for click/drag handling */
.pc-seek-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    cursor: pointer;
    opacity: 0;
}

.pc-seek-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
}

.pc-seek-input::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: transparent;
    border: none;
    cursor: pointer;
}

.pc-seek-input::-moz-range-track {
    background: transparent;
}

/* Controls row — play, time, spacer, volume, fullscreen */
.pc-controls-row {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 36px;
}

.pc-spacer {
    flex: 1;
}

/* Generic control button */
.pc-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    opacity: 0.85;
    transition: opacity 0.15s, background 0.15s;
    line-height: 1;
}

.pc-btn:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
}

/* Time display */
.pc-time {
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.82rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    user-select: none;
}

/* Volume slider */
.pc-volume-slider {
    width: 70px;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.25);
    outline: none;
    cursor: pointer;
}

.pc-volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    border: none;
}

.pc-volume-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    border: none;
}

.pc-volume-slider::-moz-range-track {
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.25);
}

/* Overlay click area — captures play/pause clicks */
.pc-overlay {
    cursor: pointer;
}

.pc-hide-controls {
    cursor: none;
}

/* Responsive */
@media (max-width: 600px) {
    body {
        padding: 1rem 0.5rem;
    }

    h1 {
        font-size: 1.2rem;
    }

    .url-bar {
        flex-direction: column;
    }

    .url-bar button {
        width: 100%;
    }

    .pc-volume-slider {
        width: 50px;
    }

    .pc-controls-row {
        gap: 6px;
    }

    .pc-btn {
        font-size: 0.95rem;
        padding: 4px 6px;
    }
}
