/* ArcadeVerse Professional Midnight Lobby Styles */

:root {
    --bg-deep: #050507;
    --bg-surface: #0f0f13;
    --bg-card: #16161d;
    --accent: #bc13fe;
    --accent-glow: rgba(188, 19, 254, 0.4);
    --neon-blue: #00f2ff;
    --text-main: #ffffff;
    --text-muted: #888888;
}

body {
    background-color: var(--bg-deep);
    color: var(--text-main);
    font-family: 'Outfit', sans-serif;
    margin: 0;
}

/* Header */
.glass-header {
    background: rgba(5, 5, 7, 0.85);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 2000;
    /* Highest priority */
    width: 100%;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--bg-surface);
    border-right: 1px solid rgba(255, 255, 255, 0.03);
    height: calc(100vh - 70px);
    position: fixed;
    top: 70px;
    transition: all 0.4s ease;
    z-index: 40;
    padding: 16px;
    overflow-y: auto;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 12px;
    font-weight: 700;
    color: var(--text-muted);
    text-decoration: none;
    transition: 0.2s;
}

.sidebar-item:hover {
    color: var(--accent);
    background: rgba(188, 19, 254, 0.05);
}

/* Active Sidebar Item */
.sidebar-item.active {
    background: linear-gradient(90deg, #9333ea, #6366f1);
    border: none;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4);
    color: white;
}

/* Main Container */
.main-container {
    margin-left: 260px;
    padding: calc(70px + 30px) 30px 30px;
    transition: 0.3s ease;
}

@media (max-width: 1100px) {
    .sidebar {
        top: calc(60px + env(safe-area-inset-top));
        height: calc(100dvh - (60px + env(safe-area-inset-top)));
        z-index: 1900;
        transform: translateX(-100%);
    }

    .main-container {
        margin-left: 0;
        padding: calc(60px + env(safe-area-inset-top) + 20px) 20px 20px;
    }
}

@media (max-width: 768px) {
    .glass-header {
        height: calc(60px + env(safe-area-inset-top));
        padding: env(safe-area-inset-top) 14px 0;
    }
}

@media (max-width: 1100px) {
    body.mobile-view-headerless .sidebar {
        top: 0;
        height: 100dvh;
        padding-top: calc(env(safe-area-inset-top) + 14px);
    }
}

/* Games Grid */
.games-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    /* Mobile: 2 columns */
    gap: 16px;
}

@media (min-width: 640px) {
    .games-grid {
        grid-template-columns: repeat(3, 1fr);
        /* Tablet: 3 columns */
        gap: 20px;
    }
}

@media (min-width: 1024px) {
    .games-grid {
        grid-template-columns: repeat(4, 1fr);
        /* Desktop: 4 columns */
        gap: 24px;
    }
}

@media (min-width: 1440px) {
    .games-grid {
        grid-template-columns: repeat(5, 1fr);
        /* Large Desktop: 5 columns */
    }
}

.game-card {
    background: var(--bg-card);
    border-radius: 20px;
    position: relative;
    aspect-ratio: 1/1;
    overflow: hidden;
    transition: all 0.4s;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.03);
}

.game-card:hover {
    transform: scale(1.05);
    border-color: var(--accent);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 15px var(--accent-glow);
}

.card-image-box {
    position: absolute;
    inset: 0;
}

.card-image-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s;
}

.game-card:hover .card-image-box img {
    transform: scale(1.1);
}

.card-gradient {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, transparent 60%);
}

.card-info {
    position: absolute;
    bottom: 15px;
    left: 15px;
    right: 15px;
}

.game-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 4px;
}

.badge-dot {
    width: 6px;
    height: 6px;
    background: var(--accent);
    border-radius: 50%;
}

.badge-text {
    font-size: 9px;
    font-weight: 900;
    text-transform: uppercase;
    color: #888;
}

.card-title {
    font-weight: 900;
    font-size: 1.1rem;
    color: #fff;
}

/* Theater Mode */
.player-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: #020204;
    z-index: 1001;
    /* Lower than header but higher than content */
    overflow-y: auto;
    padding: 20px;
}

@media (min-width: 1100px) {
    .player-overlay {
        top: 70px;
        /* Offset for header */
        z-index: 100;
        /* Ensure header at z-index 1000 stays above */
    }
}

.theater-grid {
    display: grid;
    grid-template-columns: 300px 1fr 300px;
    gap: 24px;
    max-width: 1920px;
    margin: 0 auto;
}

.game-stage-wrapper {
    background: #000;
    border-radius: 24px;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.game-iframe-container {
    width: 100%;
    aspect-ratio: 16/9;
    background: #000;
}

.game-iframe-container iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.canvas-header {
    height: 60px;
    background: #0a0a0f;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.game-controls {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 24px;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 1px solid rgba(255, 255, 255, 0.05);
    margin-top: 20px;
}

.neon-btn {
    background: var(--accent);
    color: white;
    padding: 10px 20px;
    border-radius: 10px;
    font-weight: 900;
    cursor: pointer;
    border: none;
}

@media (max-width: 1280px) {
    .theater-grid {
        grid-template-columns: 1fr 300px;
    }

    .left-ad {
        display: none;
    }
}

@media (max-width: 1100px) {
    .theater-grid {
        grid-template-columns: 1fr;
    }

    .side-content {
        display: none;
    }
}

@media (max-width: 768px) {
    .game-stage-wrapper {
        position: fixed;
        inset: 0;
        border-radius: 0;
    }

    .canvas-header,
    .game-controls {
        display: none;
    }

    .game-iframe-container {
        height: 100vh;
        aspect-ratio: auto;
    }
}

/* Chat Sidebar */
.chat-sidebar {
    position: fixed;
    right: 0;
    top: 70px;
    width: 300px;
    height: calc(100vh - 70px);
    background: var(--bg-surface);
    border-left: 1px solid rgba(255, 255, 255, 0.05);
    z-index: 50;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    transform: translateX(0);
}

.chat-sidebar.collapsed {
    transform: translateX(100%);
}

.chat-header {
    padding: 15px;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-input-area {
    padding: 15px;
    background: rgba(255, 255, 255, 0.03);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    gap: 10px;
}

.chat-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 8px 12px;
    color: white;
    font-size: 0.9rem;
}

.chat-send-btn {
    background: var(--accent);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Chat Message Styles */
.chat-message {
    padding: 8px 12px;
    border-radius: 12px;
    max-width: 85%;
    font-size: 0.9rem;
    line-height: 1.4;
    word-wrap: break-word;
}

.chat-message.me {
    background: var(--accent);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 2px;
}

.chat-message.other {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    align-self: flex-start;
    border-bottom-left-radius: 2px;
}

.chat-message .msg-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    margin-bottom: 2px;
    opacity: 0.7;
    gap: 8px;
}

.chat-message .msg-user {
    font-weight: bold;
}

/* Floating Toggle Button */
#chatFloatingBtn {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: 50px;
    height: 50px;
    background: var(--accent);
    color: white;
    border-radius: 50%;
    display: none;
    /* See JS for toggle logic */
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: 0 4px 15px var(--accent-glow);
    cursor: pointer;
    z-index: 200;
    transition: transform 0.2s;
    border: none;
}

#chatFloatingBtn:hover {
    transform: scale(1.1);
}

/* Login Overlay */
#chatLoginOverlay {
    position: fixed;
    inset: 0;
    background: rgba(5, 5, 7, 0.95);
    backdrop-filter: blur(5px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 7000;
}

#chatLoginOverlay.active {
    display: flex;
}

/* Chat Tabs */
.chat-tabs {
    display: flex;
    justify-content: space-around;
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.chat-tab {
    background: none;
    border: none;
    color: var(--text-muted);
    font-weight: bold;
    font-size: 0.8rem;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 8px;
    transition: all 0.2s;
}

.chat-tab.active {
    color: white;
    background: var(--accent);
    box-shadow: 0 0 10px var(--accent-glow);
}

/* Auth Modal Styles */
.auth-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 15px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.auth-input:focus {
    outline: none;
    border-color: var(--accent);
}

.auth-btn {
    width: 100%;
    padding: 12px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 900;
    cursor: pointer;
    margin-bottom: 10px;
    transition: transform 0.1s;
}

.auth-btn:active {
    transform: scale(0.98);
}

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

.auth-switch {
    font-size: 0.8rem;
    color: var(--text-muted);
    cursor: pointer;
    text-decoration: underline;
}

/* Friend List Styles */
.friend-list {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: none;
    /* Toggled via JS */
}

.friend-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.friend-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

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

.friend-info {
    flex: 1;
}

.friend-name {
    font-weight: bold;
    font-size: 0.9rem;
    display: block;
}

.friend-status {
    font-size: 0.7rem;
    color: #4ade80;
    /* Green for online */
}

.friend-status.offline {
    color: #9ca3af;
}

.add-friend-box {
    display: flex;
    gap: 5px;
    margin-bottom: 15px;
}

/* Private Message Header */
.private-chat-header {
    background: var(--accent);
    color: white;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    font-weight: bold;
}

/* PROFILE VIEW OVERRIDE FOR MOBILE */
/* Force full width on Profile Page by removing container padding */
@media (max-width: 1100px) {
    body.view-profile-active .main-container {
        padding-left: 0 !important;
        padding-right: 0 !important;
        width: 100vw;
        max-width: 100vw;
        overflow-x: hidden;
    }
}
