:root {
    --bg-primary: #0f1419;
    --bg-secondary: #1a1f26;
    --accent-primary: #2196f3;
    --accent-secondary: #1976d2;
    --text-primary: #ffffff;
    --text-secondary: #adb5bd;
    --border: #2d3748;
    --glass-bg: rgba(255, 255, 255, 0.03);
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
}

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

body {
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-body);
    height: 100vh;
    overflow: hidden;
}

/* Views */
.view {
    position: absolute;
    width: 100%;
    height: 100%;
    transition: opacity 0.3s ease;
}

.view.hidden {
    opacity: 0;
    pointer-events: none;
}

.view.active {
    opacity: 1;
    pointer-events: all;
}

/* Glass Panel */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: 12px;
}

/* Landing Page */
#landing-view {
    display: flex;
    justify-content: center;
    align-items: center;
}

.hero-container {
    text-align: center;
    max-width: 500px;
}

.logo-text {
    font-family: var(--font-heading);
    font-size: 3.5rem;
    font-weight: 700;
    color: white;
    margin-bottom: 1rem;
}

.subtitle {
    color: var(--text-secondary);
    margin-bottom: 2.5rem;
    font-size: 1.1rem;
}

.action-card {
    padding: 2.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Buttons */
.btn-premium {
    background: var(--accent-primary);
    border: none;
    color: white;
    padding: 1rem 2rem;
    border-radius: 8px;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-premium:hover {
    background: var(--accent-secondary);
    transform: translateY(-2px);
}

.btn-premium.secondary {
    background: transparent;
    border: 1px solid var(--border);
}

.btn-premium.secondary:hover {
    background: var(--glass-bg);
}

.btn-premium.danger {
    background: #b42318;
}

.btn-premium.danger:hover {
    background: #912018;
}

.btn-premium.small {
    padding: 0.75rem 1.5rem;
    font-size: 0.9rem;
}

.divider {
    display: flex;
    align-items: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.divider::before,
.divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}

.divider span {
    margin: 0 1rem;
}

.join-form {
    display: flex;
    gap: 0.75rem;
}

input[type="text"] {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: white;
    padding: 1rem;
    border-radius: 8px;
    flex: 1;
    font-family: var(--font-body);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

input[type="text"]:focus {
    border-color: var(--accent-primary);
}

input[type="text"]::placeholder {
    color: var(--text-secondary);
}

/* Room View */
#room-view {
    display: flex;
    flex-direction: column;
}

.room-header {
    min-height: 70px;
    height: auto;
    margin: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
    gap: 1rem;
}

.header-actions {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-left: auto;
    flex-wrap: nowrap;
}

.room-action-btn {
    white-space: nowrap;
    line-height: 1;
}

.header-actions > * {
    flex-shrink: 0;
}

.room-info {
    flex: 1;
}

.logo-small {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.5rem;
    color: var(--accent-primary);
}

.room-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.room-info .label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    letter-spacing: 1px;
}

.room-info .code-display {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.icon-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0.5rem;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    color: white;
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
}

.room-content {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 1rem;
    padding: 0 1rem 1rem 1rem;
    height: calc(100vh - 90px);
}

.video-section {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
}

.video-container {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

video {
    width: 100%;
    max-height: 100%;
    background: #000;
    display: block;
    object-fit: contain;
}

#main-video {
    position: relative;
    z-index: 1;
}

.no-source-state {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    z-index: 5;
    gap: 1rem;
}

.no-source-state.hidden {
    display: none !important;
}

.no-source-state i {
    width: 64px;
    height: 64px;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

.no-source-state h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.no-source-state p {
    font-size: 1rem;
    opacity: 0.7;
    margin-bottom: 1rem;
}

/* Video Loading */
.video-loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.8);
    z-index: 10;
}

.video-loading.hidden {
    display: none;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top: 4px solid var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

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

.video-loading p {
    color: var(--text-primary);
    font-size: 1rem;
}

.host-controls {
    margin-top: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    max-width: 820px;
    flex-wrap: nowrap;
}

.host-controls.hidden {
    display: none;
}

#video-url-input {
    flex: 1;
    min-width: 0;
}

.divider-vertical {
    width: 1px;
    height: 30px;
    background: var(--border);
    margin: 0 0.5rem;
    flex-shrink: 0;
}

.host-controls .btn-premium {
    white-space: nowrap;
    flex-shrink: 0;
}

/* Video Controls Overlay */
.video-controls-overlay {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: flex;
    gap: 0.5rem;
    z-index: 60; /* High z-index */
}

.video-ctrl-btn {
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    color: white;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.video-ctrl-btn:hover {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

/* Sidebar */
.room-sidebar {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    padding: 1rem;
    color: var(--text-secondary);
    cursor: pointer;
    position: relative;
    transition: color 0.2s;
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.tab-btn:hover {
    color: white;
}

.tab-btn.active {
    color: white;
}

.tab-btn.active::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--accent-primary);
}

.badge {
    background: var(--accent-primary);
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 700;
}

.tab-content {
    display: none;
    flex: 1;
    overflow: hidden;
    flex-direction: column;
}

.tab-content.active {
    display: flex;
}

#chat-tab {
    padding-bottom: 1rem;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

.message {
    font-size: 0.9rem;
    line-height: 1.4;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.message .user {
    font-weight: 700;
    color: var(--accent-primary);
    margin-right: 0.5rem;
}

.message .text {
    color: var(--text-primary);
}

.system-message {
    color: var(--text-secondary);
    font-style: italic;
    text-align: center;
    font-size: 0.8rem;
    margin: 0.5rem 0;
}

.chat-input-area {
    padding: 0 1rem;
    display: flex;
    gap: 0.5rem;
}

.chat-input-area input {
    font-size: 0.9rem;
    padding: 0.75rem;
}

#send-chat-btn {
    background: var(--accent-primary);
    border: none;
    width: 45px;
    height: 45px;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

#send-chat-btn:hover {
    background: var(--accent-secondary);
}

#users-tab {
    padding: 1rem;
}

.user-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.user-list li {
    list-style: none;
    padding: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.user-avatar {
    width: 35px;
    height: 35px;
    background: var(--accent-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 0.9rem;
}

.user-name {
    font-weight: 500;
    color: var(--text-primary);
}

.host-badge {
    background: var(--accent-primary);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 700;
    margin-left: auto;
}

/* Toast */
#toast-container {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 0.9rem;
    border: 1px solid var(--border);
    animation: toastIn 0.3s ease;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Video Controls */
.video-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    z-index: 50; /* Increased z-index */
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
}

.ctrl-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

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

.progress-bar-container {
    flex: 1;
    height: 5px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    cursor: pointer;
}

.progress-bar {
    height: 100%;
    background: var(--accent-primary);
    border-radius: 3px;
    transition: width 0.1s;
}

.time-display {
    font-size: 0.85rem;
    font-weight: 600;
    color: white;
    min-width: 100px;
    text-align: right;
}

.hidden {
    display: none !important;
}

@media (max-width: 1200px) {
    .room-content {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr 300px;
    }
}

@media (max-width: 768px) {
    .logo-text {
        font-size: 2.5rem;
    }

    .room-header {
        padding: 0 1rem;
    }

    .header-actions {
        gap: 0.5rem;
    }

    .room-action-btn {
        padding: 0.6rem 0.9rem;
        font-size: 0.8rem;
    }

    .host-controls {
        max-width: 100%;
        flex-wrap: wrap;
    }

    #video-url-input {
        min-width: 220px;
    }

    .divider-vertical {
        display: none;
    }
}
