/* Base styles */
:root {
    --primary-color: #393B3D;
    --secondary-color: #232527;
    --accent-color: #00A2FF;
    --text-color: #FFFFFF;
    --border-radius: 8px;
    --header-height: 60px;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--secondary-color);
    color: var(--text-color);
    overflow-y: auto;
}

/* Header styles */
.homepage-header {
    background-color: var(--primary-color);
    height: var(--header-height);
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.header-button {
    background-color: var(--accent-color);
    color: var(--text-color);
    border: none;
    border-radius: var(--border-radius);
    padding: 8px 12px;
    font-size: 14px;
    margin-right: 10px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.header-button:hover {
    background-color: #0088ff;
}

.logo-container {
    display: flex;
    align-items: center;
}

.logo-container svg {
    width: 40px;
    height: 40px;
    margin-right: 10px;
}

.search-container {
    flex-grow: 1;
    max-width: 600px;
    margin: 0 20px;
    position: relative;
}

.search-bar {
    width: 100%;
    padding: 8px 15px;
    border-radius: var(--border-radius);
    border: none;
    background-color: var(--secondary-color);
    color: var(--text-color);
    font-size: 14px;
}

.auth-buttons {
    display: flex;
    gap: 10px;
}

.auth-button {
    padding: 8px 16px;
    border-radius: var(--border-radius);
    border: none;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.2s;
}

.login-button {
    background-color: transparent;
    color: var(--text-color);
    border: 1px solid var(--text-color);
}

.signup-button {
    background-color: var(--accent-color);
    color: var(--text-color);
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background-color: var(--primary-color);
    border-radius: var(--border-radius);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    z-index: 10;
    display: none;
    max-height: 300px;
    overflow-y: auto;
}

.search-result-item {
    padding: 10px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--secondary-color);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item img {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    margin-right: 10px;
}

.add-friend-btn {
    margin-left: auto;
    padding: 5px 10px;
    background-color: var(--accent-color);
    color: var(--text-color);
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.user-area {
    display: flex;
    align-items: center;
    gap: 15px;
}

.notification-icon {
    font-size: 20px;
    cursor: pointer;
    position: relative;
}

.notification-panel {
    position: absolute;
    top: var(--header-height);
    right: 10px;
    width: 300px;
    background-color: var(--primary-color);
    border-radius: var(--border-radius);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    display: none;
    max-height: 400px;
    overflow-y: auto;
}

.notification-panel.show {
    display: block;
}

.notification-panel h3 {
    padding: 10px;
    margin: 0;
    border-bottom: 1px solid var(--secondary-color);
}

.notification-list {
    padding: 10px;
}

.notification-item {
    padding: 10px;
    border-bottom: 1px solid var(--secondary-color);
}

.notification-item:last-child {
    border-bottom: none;
}

/* Sidebar Toggle Button */
.sidebar-toggle-btn {
    position: fixed;
    top: 20px;
    left: 20px;
    background-color: var(--accent-color);
    color: var(--text-color);
    border: none;
    border-radius: var(--border-radius);
    width: 40px;
    height: 40px;
    font-size: 20px;
    cursor: pointer;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Sidebar styles */
.sidebar {
    position: fixed;
    top: 0;
    left: -300px;
    width: 300px;
    height: 100vh;
    background-color: var(--primary-color);
    transition: left 0.3s ease;
    z-index: 1050;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
    overflow-y: auto;
    padding: 60px 20px 20px;
}

.sidebar.open {
    left: 0;
}

.sidebar-header {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--secondary-color);
}

.sidebar-section {
    margin-bottom: 25px;
}

.sidebar-section h3 {
    margin-bottom: 15px;
    font-size: 18px;
    color: var(--accent-color);
}

.sidebar-link {
    display: flex;
    align-items: center;
    padding: 10px;
    color: var(--text-color);
    text-decoration: none;
    border-radius: var(--border-radius);
    transition: background-color 0.2s;
    margin-bottom: 5px;
}

.sidebar-link:hover {
    background-color: var(--secondary-color);
}

.sidebar-link svg {
    margin-right: 10px;
    width: 20px;
    height: 20px;
}

.homepage-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.homepage-main {
    margin-top: var(--header-height);
    padding: 20px;
    transition: margin-left 0.3s ease, width 0.3s ease;
    flex: 1;
    overflow-y: auto;
}

/* Main content adjustment when sidebar is open */
.homepage-main.sidebar-open {
    margin-left: 300px;
    width: calc(100% - 300px);
    transition: margin-left 0.3s ease, width 0.3s ease;
}

/* Profile section */
.profile-section {
    background-color: var(--primary-color);
    border-radius: var(--border-radius);
    padding: 20px;
}

.profile-header {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
}

.profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    margin-right: 15px;
}

.profile-info h2 {
    margin: 0;
    font-size: 1.2em;
}

.profile-status {
    color: #7A8288;
    font-size: 0.9em;
}

/* Custom Avatar Button */
.custom-avatar-button {
    display: block;
    background-color: var(--accent-color);
    color: var(--text-color);
    border: none;
    border-radius: var(--border-radius);
    padding: 8px 12px;
    font-size: 14px;
    margin-top: 10px;
    width: 100%;
    cursor: pointer;
    transition: background-color 0.2s;
}

.custom-avatar-button:hover {
    background-color: #0088ff;
}

/* Friends list */
.friends-section {
    margin-top: 20px;
}

.friends-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
}

.friend-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.friend-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    margin-bottom: 5px;
}

/* Games sections */
.games-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}

.game-card {
    background-color: var(--primary-color);
    border-radius: var(--border-radius);
    overflow: hidden;
    transition: transform 0.2s;
    cursor: pointer;
    position: relative;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.game-card:hover {
    transform: translateY(-5px);
}

.game-thumbnail {
    width: 100%;
    aspect-ratio: 16/9;
    object-fit: cover;
}

.game-info {
    padding: 10px;
}

.game-title {
    margin: 0;
    font-size: 1em;
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.game-stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.8em;
    color: #7A8288;
    margin-top: 5px;
}

.play-button {
    position: absolute;
    right: 10px;
    bottom: 10px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background-color: var(--accent-color);
    color: var(--text-color);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    transition: transform 0.2s, background-color 0.2s;
    z-index: 5;
}

.play-button:hover {
    transform: scale(1.1);
    background-color: #0088ff;
}

/* Import RBXL button */
.import-button {
    background-color: #E31B23;
    color: white;
    border: none;
    border-radius: var(--border-radius);
    padding: 8px 12px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.import-button:hover {
    background-color: #FF424A;
}

/* Imported by text */
.game-importer {
    font-size: 0.8em;
    color: #aaa;
    margin-top: 3px;
}

/* Loading and no maps messages */
.loading-maps, .no-maps {
    grid-column: 1 / -1;
    padding: 20px;
    text-align: center;
    color: #888;
    background-color: var(--primary-color);
    border-radius: var(--border-radius);
}

/* Mobile friends button */
.mobile-friends-button {
    display: none;
    background-color: var(--accent-color);
    color: var(--text-color);
    border: none;
    border-radius: var(--border-radius);
    padding: 8px 12px;
    font-size: 14px;
    margin-top: 10px;
    width: 100%;
    cursor: pointer;
}

.mobile-friends-button:hover {
    background-color: #0088ff;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .homepage-main.sidebar-open {
        margin-left: 0;
        width: 100%;
    }
    
    .sidebar {
        width: 80%;
        max-width: 300px;
    }
    
    /* NEW: Mobile bottom navigation */
    .mobile-nav {
        display: none;
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 60px;
        background-color: var(--primary-color);
        z-index: 1000;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2);
    }
    
    .mobile-nav-tabs {
        display: flex;
        justify-content: space-around;
        height: 100%;
    }
    
    .mobile-nav-tab {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        flex: 1;
        color: #aaa;
        text-decoration: none;
        padding: 8px;
    }
    
    .mobile-nav-tab.active {
        color: var(--accent-color);
    }
    
    .mobile-nav-tab svg {
        width: 24px;
        height: 24px;
        margin-bottom: 4px;
    }
    
    .mobile-nav-tab span {
        font-size: 12px;
    }
    
    /* Avatar popup styles */
    .avatar-popup {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        background-color: var(--primary-color);
        border-radius: var(--border-radius);
        padding: 20px;
        width: 90%;
        max-width: 320px;
        z-index: 2000;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
        display: none;
    }
    
    .avatar-popup-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 15px;
        padding-bottom: 10px;
        border-bottom: 1px solid var(--secondary-color);
    }
    
    .avatar-popup-close {
        background: none;
        border: none;
        color: var(--text-color);
        font-size: 20px;
        cursor: pointer;
    }
    
    .avatar-popup-content {
        text-align: center;
    }
    
    .avatar-popup-button {
        background-color: var(--accent-color);
        color: var(--text-color);
        border: none;
        border-radius: var(--border-radius);
        padding: 10px 15px;
        margin-top: 15px;
        cursor: pointer;
        width: 100%;
    }
    
    .avatar-popup-button:hover {
        background-color: #0088ff;
    }
    
    /* Theme toggle styles */
    .theme-toggle {
        display: flex;
        align-items: center;
        margin: 15px 0;
    }
    
    .theme-toggle-label {
        margin-right: 10px;
        color: var(--text-color);
    }
    
    .theme-toggle-switch {
        position: relative;
        display: inline-block;
        width: 50px;
        height: 24px;
    }
    
    .theme-toggle-switch input {
        opacity: 0;
        width: 0;
        height: 0;
    }
    
    .theme-toggle-slider {
        position: absolute;
        cursor: pointer;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: #888;
        border-radius: 24px;
        transition: .4s;
    }
    
    .theme-toggle-slider:before {
        position: absolute;
        content: "";
        height: 16px;
        width: 16px;
        left: 4px;
        bottom: 4px;
        background-color: white;
        border-radius: 50%;
        transition: .4s;
    }
    
    input:checked + .theme-toggle-slider {
        background-color: var(--accent-color);
    }
    
    input:checked + .theme-toggle-slider:before {
        transform: translateX(26px);
    }
}

@media (max-width: 400px) {
    .homepage-header {
        padding: 0 10px;
    }

    .search-container {
        display: none;
    }

    .homepage-main {
        grid-template-columns: 1fr;
        padding: 10px;
        padding-bottom: 70px; /* Add padding at bottom for mobile nav */
    }

    .auth-buttons {
        gap: 5px;
    }

    .auth-button {
        padding: 6px 12px;
        font-size: 0.9em;
    }

    .games-grid {
        grid-template-columns: 1fr;
    }

    .friends-section {
        display: none;
    }
    
    .sidebar {
        display: none; /* Hide sidebar on mobile */
    }
    
    .sidebar-toggle-btn {
        display: none; /* Hide sidebar toggle on mobile */
    }
    
    .mobile-nav {
        display: block; /* Show mobile navigation on mobile */
    }
    
    /* Custom styles for the games tab content */
    .mobile-tab-content {
        display: none;
        padding: 10px;
        margin-bottom: 60px; /* Space for mobile nav */
    }
    
    .mobile-tab-content.active {
        display: block;
    }
    
    #mobile-settings-tab .settings-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 10px;
        background-color: var(--primary-color);
        border-radius: var(--border-radius);
        margin-bottom: 10px;
    }
    
    #mobile-online-tab .online-user-item {
        display: flex;
        align-items: center;
        padding: 10px;
        background-color: var(--primary-color);
        border-radius: var(--border-radius);
        margin-bottom: 8px;
    }
    
    #mobile-online-tab .online-user-avatar {
        width: 40px;
        height: 40px;
        border-radius: 50%;
        margin-right: 10px;
    }
    
    #mobile-online-tab .online-user-info {
        flex: 1;
    }
    
    #mobile-online-tab .online-user-name {
        font-weight: bold;
        color: var(--text-color);
    }
    
    #mobile-online-tab .online-user-status {
        font-size: 12px;
        color: #888;
    }
}

/* Light theme variables */
:root.light-theme {
    --primary-color: #f0f0f0;
    --secondary-color: #e0e0e0;
    --accent-color: #0088ff;
    --text-color: #333333;
}

/* Footer */
.homepage-footer {
    background-color: var(--primary-color);
    padding: 20px;
    text-align: center;
    margin-top: 40px;
}

.footer-content {
    color: #7A8288;
    font-size: 0.9em;
}