/* 1. Import Fonts: 'Orbitron' for headers, 'Rajdhani' for text */
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700&family=Rajdhani:wght@300;500;700&display=swap');

:root {
    --bg-color: #050510;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: 1px solid rgba(255, 255, 255, 0.1);
    --neon-blue: #00f3ff;
    --neon-purple: #bc13fe;
    --text-main: #e0e6ed;
    --shadow-glow: 0 0 15px rgba(0, 243, 255, 0.3);
}

body {
    margin: 0;
    font-family: 'Rajdhani', sans-serif;
    background-color: var(--bg-color);
    /* Subtle grid background */
    background-image: 
        linear-gradient(rgba(0, 243, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 243, 255, 0.03) 1px, transparent 1px);
    background-size: 30px 30px;
    color: var(--text-main);
    
    /* MOBILE HEIGHT FIX: Use dvh to account for browser address bars */
    height: 100vh;      /* Fallback for older browsers */
    height: 100dvh;     /* Dynamic Viewport Height */
    
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

/* Scrollbar Styling - Cross Browser Support */
/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: #333 #0a0a0a;
}
/* Chrome, Edge, Safari */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #0a0a0a; }
::-webkit-scrollbar-thumb { background: #333; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--neon-blue); }

/* ==============================
   LOGIN SCREEN (Center Hub)
   ============================== */
#login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    background: radial-gradient(circle at center, #1a1a2e 0%, #000 100%);
}

#login-container h1 {
    font-family: 'Orbitron', sans-serif;
    font-size: 3rem;
    margin-bottom: 2rem;
    background: linear-gradient(90deg, var(--neon-blue), var(--neon-purple));
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 20px rgba(0, 243, 255, 0.5);
    letter-spacing: 4px;
}

.login-box {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    padding: 40px;
    border-radius: 15px;
    border: var(--glass-border);
    box-shadow: 0 0 30px rgba(0,0,0,0.7);
    text-align: center;
    border-top: 1px solid var(--neon-blue); /* subtle top glow */
}

.login-box input {
    display: block;
    margin: 15px 0;
    padding: 15px;
    width: 280px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid #333;
    color: #fff;
    border-radius: 5px;
    font-family: 'Rajdhani', sans-serif;
    font-size: 1.1rem;
    transition: 0.3s;
}

.login-box input:focus {
    outline: none;
    border-color: var(--neon-blue);
    box-shadow: var(--shadow-glow);
}

.login-box button {
    margin-top: 10px;
    width: 100%;
    padding: 15px;
    background: linear-gradient(45deg, var(--neon-blue), #0066ff);
    color: #000;
    border: none;
    border-radius: 5px;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    text-transform: uppercase;
    font-family: 'Orbitron', sans-serif;
    transition: 0.3s;
}

.login-box button:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 20px var(--neon-blue);
}

/* ==============================
   ROOM LAYOUT
   ============================== */
#room-container {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.main-content {
    display: flex;
    flex: 1;
    height: 100%;
    border-top: 1px solid #333;
}

/* Video Section */
.video-section {
    flex: 3;
    background-color: #000;
    display: flex;
    flex-direction: column;
    position: relative;
    border-right: 1px solid #333;
}

.controls {
    display: flex;
    background: #0a0a0a;
    padding: 10px;
    border-bottom: 1px solid #222;
}

.controls input {
    flex: 1;
    padding: 10px;
    background: #1a1a1a;
    border: 1px solid #333;
    color: white;
    border-radius: 4px 0 0 4px;
    font-family: 'Rajdhani', sans-serif;
}
.controls input:focus { outline: none; border-color: var(--neon-blue); }

.controls button {
    padding: 10px 20px;
    background: #222;
    color: var(--neon-blue);
    border: 1px solid #333;
    border-left: none;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
    font-weight: bold;
    transition: 0.2s;
}
.controls button:hover { background: #333; text-shadow: 0 0 5px var(--neon-blue); }

#player {
    width: 100%;
    height: 100%;
    flex-grow: 1;
}

/* ==============================
   CHAT SECTION (Glass Panel)
   ============================== */
.chat-section {
    flex: 1;
    background: rgba(10, 10, 16, 0.95);
    display: flex;
    flex-direction: column;
    max-width: 400px;
    min-width: 320px;
    border-left: 1px solid var(--neon-blue);
}

.chat-header {
    padding: 20px;
    background: rgba(0, 243, 255, 0.05);
    border-bottom: 1px solid #333;
    text-align: center;
}

.chat-header h3 {
    margin: 0;
    font-family: 'Orbitron', sans-serif;
    color: var(--neon-blue);
    font-size: 1.2rem;
    letter-spacing: 2px;
}

#chat-window {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px; /* Spacing between messages */
}

/* --- CHAT BUBBLES LOGIC --- */

.message {
    font-size: 0.95rem;
    word-wrap: break-word;
    padding: 10px 15px;
    border-radius: 12px;
    max-width: 80%;
    line-height: 1.4;
    position: relative;
    animation: fadeIn 0.3s ease;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

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

/* System Message (Joined/Left) */
.system-msg { 
    align-self: center;
    color: #888; 
    font-size: 0.8rem; 
    font-style: italic; 
    background: transparent;
    border: 1px solid #333;
    padding: 5px 15px;
    border-radius: 20px;
    box-shadow: none;
}

/* REMOTE USER (Left Side) */
.remote {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.08);
    border-left: 3px solid var(--neon-blue);
    color: #ddd;
    border-top-left-radius: 0;
}

/* ME (Right Side) */
.self {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--neon-purple), #8000ff);
    color: white;
    border-right: 3px solid #fff;
    border-top-right-radius: 0;
    text-align: right;
}

/* Username Label inside bubble */
.username-label {
    display: block;
    font-size: 0.75rem;
    margin-bottom: 4px;
    font-family: 'Orbitron', sans-serif;
    opacity: 0.8;
}

.self .username-label { display: none; /* Hide my name */ }
.remote .username-label { color: var(--neon-blue); }

/* --- INPUT AREA --- */

.chat-input {
    display: flex;
    padding: 15px;
    background: #050505;
    border-top: 1px solid #333;
}

.chat-input input {
    flex: 1;
    padding: 12px;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 20px;
    color: white;
    margin-right: 10px;
    font-family: 'Rajdhani', sans-serif;
    transition: 0.3s;
}
.chat-input input:focus {
    border-color: var(--neon-purple);
    outline: none;
}

.chat-input button {
    padding: 10px 20px;
    background: linear-gradient(135deg, var(--neon-purple), #8000ff);
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-weight: bold;
    font-family: 'Orbitron', sans-serif;
    transition: 0.3s;
}

.chat-input button:hover {
    box-shadow: 0 0 15px var(--neon-purple);
    transform: scale(1.05);
}

/* --- MOBILE RESPONSIVENESS (Fixes Address Bar & Input) --- */
@media (max-width: 768px) {
    /* 1. Stack Vertical */
    .main-content {
        flex-direction: column;
        height: 100%; /* Ensure it fills parent */
    }

    /* 2. Resize Video (Make it smaller on phone to leave room for chat) */
    .video-section {
        flex: none;
        height: 35%; /* Video takes top 35% */
        border-right: none;
        border-bottom: 1px solid var(--neon-blue);
    }

    /* 3. Resize Chat (Takes remaining space) */
    .chat-section {
        flex: 1;
        max-width: 100%;
        border-left: none;
        display: flex;
        flex-direction: column;
        overflow: hidden; /* Crucial: Prevents page scroll */
    }

    /* 4. Chat Window (Scrollable area) */
    #chat-window {
        flex: 1;
        overflow-y: auto;
    }

    /* 5. Input Area (Fixed at bottom) */
    .chat-input {
        flex-shrink: 0; /* Never shrink this area */
        padding: 10px;
        /* Extra padding at bottom for iPhone Home Indicator / Android Nav Bar */
        padding-bottom: max(10px, env(safe-area-inset-bottom)); 
        background: #000; /* Ensure solid background so it's readable */
    }
    
    /* Login Screen Adjustments */
    #login-container h1 { font-size: 2rem; }
    .login-box { width: 85%; padding: 20px; }
    .login-box input { width: 90%; }
}


.controls {
    transition: all 0.3s ease;
}
