:root {
    --bg-color: #0e0e10;
    --nav-bg: #18181b;
    --text-color: #efeff1;
    --accent-color: #9147ff;
    --accent-hover: #772ce8;
    --secondary-text: #adadb8;
    --chat-bg: #18181b;
    --border-color: #303032;
    --live-red: #e91916;
    --controls-bg: rgba(0, 0, 0, 0.85);
    --progress-bg: rgba(255, 255, 255, 0.2);
    --progress-buffered: rgba(255, 255, 255, 0.4);
    --progress-played: #9147ff;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* ============================================
   NAVIGATION
   ============================================ */
.top-nav {
    height: 50px;
    background-color: var(--nav-bg);
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid var(--border-color);
    justify-content: space-between;
    gap: 16px;
    flex-shrink: 0;
}

.logo {
    font-weight: 700;
    color: var(--accent-color);
    font-size: 1.3rem;
    letter-spacing: -0.5px;
}

.search-bar {
    flex: 1;
    max-width: 400px;
    display: flex;
}

.search-bar input {
    width: 100%;
    padding: 8px 12px;
    background-color: #2e2e30;
    border: 2px solid transparent;
    border-radius: 6px 0 0 6px;
    color: white;
    font-size: 14px;
    transition: all 0.2s ease;
}

.search-bar input:focus {
    outline: none;
    border-color: var(--accent-color);
    background-color: #1f1f23;
}

.search-bar button {
    padding: 0 16px;
    background: linear-gradient(135deg, var(--accent-color), var(--accent-hover));
    border: none;
    border-radius: 0 6px 6px 0;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.search-bar button:hover {
    opacity: 0.9;
}

.user-menu {
    display: flex;
    align-items: center;
}

.proxy-status {
    font-size: 13px;
    color: #00c853;
    background: rgba(0, 200, 83, 0.1);
    padding: 4px 10px;
    border-radius: 4px;
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.video-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    min-width: 0;
}

/* ============================================
   VIDEO PLAYER
   ============================================ */
.video-player-container {
    width: 100%;
    background: black;
    aspect-ratio: 16/9;
    position: relative;
    overflow: hidden;
}

video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Status Overlay */
#status-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 10;
}

#status-overlay.hidden {
    display: none;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(145, 71, 255, 0.3);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

#status-text {
    color: var(--secondary-text);
    font-size: 14px;
}

/* ============================================
   PLAYER CONTROLS
   ============================================ */
.player-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, var(--controls-bg));
    padding: 40px 16px 12px;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 5;
}

.video-player-container:hover .player-controls,
.video-player-container:focus-within .player-controls {
    opacity: 1;
}

/* Always show on mobile */
@media (hover: none) {
    .player-controls {
        opacity: 1;
        background: var(--controls-bg);
        padding: 12px;
    }
}

.controls-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.controls-top {
    margin-bottom: 10px;
}

.controls-bottom {
    justify-content: space-between;
}

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

/* Control Buttons */
.control-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    font-size: 16px;
    cursor: pointer;
    border-radius: 4px;
    min-width: 36px;
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    transition: background 0.2s ease;
    padding: 0 8px;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.control-btn .btn-icon {
    font-size: 14px;
}

.control-btn .btn-label {
    font-size: 11px;
    font-weight: 600;
}

/* Go Live Button */
.go-live-btn {
    background: var(--live-red);
    font-size: 12px;
    font-weight: 600;
    padding: 0 12px;
}

.go-live-btn:hover {
    background: #ff2d2a;
}

.go-live-btn.hidden {
    display: none;
}

/* ============================================
   PROGRESS BAR
   ============================================ */
.progress-container {
    flex: 1;
    padding: 8px 0;
}

.progress-bar {
    width: 100%;
    height: 5px;
    background: var(--progress-bg);
    border-radius: 3px;
    cursor: pointer;
    position: relative;
    transition: height 0.15s ease;
}

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

.progress-buffered,
.progress-played {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    border-radius: 3px;
    pointer-events: none;
}

.progress-buffered {
    background: var(--progress-buffered);
    width: 0%;
}

.progress-played {
    background: var(--progress-played);
    width: 0%;
}

.progress-handle {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 14px;
    height: 14px;
    background: var(--accent-color);
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.15s ease;
    pointer-events: none;
}

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

/* ============================================
   LIVE INDICATOR
   ============================================ */
.live-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 700;
    transition: all 0.3s ease;
}

.live-indicator.live {
    background: var(--live-red);
    color: white;
}

.live-indicator.behind {
    background: rgba(255, 255, 255, 0.15);
    color: var(--secondary-text);
}

.live-dot {
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
}

.live-indicator.live .live-dot {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.7;
        transform: scale(0.85);
    }
}

/* ============================================
   LATENCY DISPLAY
   ============================================ */
.latency-display {
    font-size: 12px;
    font-weight: 500;
    color: var(--secondary-text);
    background: rgba(255, 255, 255, 0.1);
    padding: 4px 8px;
    border-radius: 4px;
    font-variant-numeric: tabular-nums;
    min-width: 48px;
    text-align: center;
}

/* ============================================
   QUALITY SELECTOR
   ============================================ */
.quality-selector {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    font-size: 12px;
    font-weight: 500;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23fff' d='M6 8L2 4h8z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 26px;
    min-width: 80px;
}

.quality-selector:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.quality-selector option {
    background: var(--nav-bg);
    color: white;
}

/* ============================================
   STREAM INFO
   ============================================ */
.stream-info {
    padding: 16px 20px;
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.streamer-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #5c16c5, #9147ff);
    flex-shrink: 0;
}

.info-text {
    min-width: 0;
}

.info-text h1 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.info-text p {
    color: var(--accent-color);
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 6px;
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 13px;
    color: var(--secondary-text);
    align-items: center;
}

.tag {
    color: var(--accent-color);
}

.live-tag {
    background-color: var(--live-red);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 700;
    font-size: 11px;
}

.viewer-count {
    color: var(--secondary-text);
}

/* ============================================
   CHAT SECTION
   ============================================ */
.chat-section {
    width: 340px;
    background-color: var(--chat-bg);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width 0.3s ease;
}

.chat-section.collapsed {
    width: 0;
    border-left: none;
}

.chat-header {
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    font-size: 14px;
    color: var(--secondary-text);
}

.toggle-chat-btn {
    background: none;
    border: none;
    color: var(--secondary-text);
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.toggle-chat-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

#chat-embed-container {
    flex: 1;
    overflow: hidden;
}

iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */
@media (max-width: 900px) {
    .chat-section {
        display: none;
    }

    .video-player-container {
        aspect-ratio: auto;
        height: 56.25vw;
        /* 16:9 based on viewport width */
        max-height: 50vh;
    }

    .stream-info {
        padding: 12px 16px;
    }

    .streamer-avatar {
        width: 48px;
        height: 48px;
    }
}

@media (max-width: 600px) {
    .top-nav {
        padding: 0 12px;
        gap: 8px;
    }

    .logo {
        font-size: 1.1rem;
    }

    .search-bar {
        max-width: none;
    }

    .user-menu {
        display: none;
    }

    .control-btn {
        min-width: 44px;
        min-height: 44px;
    }

    .latency-display,
    .quality-selector {
        font-size: 11px;
        padding: 6px;
    }

    .quality-selector {
        min-width: 70px;
    }

    .controls-bottom {
        flex-wrap: wrap;
        gap: 8px;
    }

    .controls-left,
    .controls-center,
    .controls-right {
        gap: 4px;
    }

    .info-text h1 {
        font-size: 1rem;
    }

    .tags {
        font-size: 12px;
    }
}

/* Touch devices - larger tap targets */
@media (hover: none) and (pointer: coarse) {
    .control-btn {
        min-width: 48px;
        min-height: 48px;
    }

    .progress-bar {
        height: 8px;
    }

    .quality-selector {
        padding: 10px 12px;
        padding-right: 28px;
    }
}

/* Fullscreen mode adjustments */
:fullscreen .video-player-container,
:-webkit-full-screen .video-player-container {
    aspect-ratio: auto;
    width: 100vw;
    height: 100vh;
}

:fullscreen video,
:-webkit-full-screen video {
    object-fit: contain;
}

/* Hidden utility class */
.hidden {
    display: none !important;
}