/* Sidebar styles */

.app-layout {
    display: flex;
    min-height: calc(100vh - 160px);
}

.sidebar {
    width: 260px;
    background: var(--secondary-color, #2c3e50);
    color: #fff;
    flex-shrink: 0;
    overflow-y: auto;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-nav {
    padding: 1rem 0;
}

.sidebar-header {
    padding: 0.5rem 1rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
}

.chat-list {
    list-style: none;
    padding: 0.5rem 0;
    margin: 0;
}

.chat-item a {
    display: flex;
    align-items: center;
    padding: 0.65rem 1rem;
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    transition: background 0.2s ease;
    gap: 0.75rem;
}

.chat-item a:hover {
    background: rgba(255, 255, 255, 0.1);
}

.chat-item.active a {
    background: rgba(255, 255, 255, 0.15);
    border-left: 3px solid var(--primary-color, #3498db);
}

.chat-icon {
    font-size: 1.25rem;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-avatar {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    object-fit: cover;
    background: rgba(255, 255, 255, 0.1);
}

.chat-name {
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 0.75rem 1rem;
}

.sidebar-section-header {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(255, 255, 255, 0.5);
    padding: 0.5rem 1rem;
    font-weight: 600;
}

.sidebar-login-prompt {
    padding: 1rem;
    text-align: center;
}

.sidebar-login-prompt a {
    color: var(--primary-color, #3498db);
    text-decoration: none;
}

.sidebar-login-prompt a:hover {
    text-decoration: underline;
}

/* Sidebar footer - hidden on desktop, shown on mobile */
.sidebar-footer {
    display: none;
}

/* Sidebar mobile logout - hidden on desktop */
.sidebar-logout-mobile {
    display: none;
}

/* Sidebar toggle button */
.sidebar-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 28px;
    height: 20px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

.sidebar-toggle span {
    display: block;
    width: 100%;
    height: 2px;
    background: #fff;
    border-radius: 1px;
    transition: transform 0.3s ease;
}

/* Adjust main content when sidebar is present */
.app-layout .main-content {
    flex: 1;
    min-width: 0;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .sidebar-toggle {
        display: flex;
    }

    .sidebar {
        position: fixed;
        left: -260px;
        top: 0;
        bottom: 0;
        z-index: 1000;
        transition: left 0.3s ease;
        padding-top: 60px;
    }

    .sidebar.open {
        left: 0;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }

    .sidebar.open + .sidebar-overlay {
        display: block;
    }

    .app-layout {
        flex-direction: column;
        flex: 1;
        min-height: 0; /* Allow shrinking for flex children */
    }

    .app-layout .main-content {
        width: 100%;
        flex: 1;
        display: flex;
        flex-direction: column;
    }

    /* Show logout/login in sidebar on mobile */
    .sidebar-logout-mobile {
        display: block;
        padding: 1rem;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .sidebar-logout-btn,
    .sidebar-login-btn {
        display: block;
        width: 100%;
        padding: 0.75rem 1rem;
        background: rgba(255, 255, 255, 0.1);
        color: #fff;
        border: none;
        border-radius: 6px;
        font-size: 1rem;
        cursor: pointer;
        text-align: center;
        text-decoration: none;
        transition: background 0.2s ease;
    }

    .sidebar-logout-btn:hover,
    .sidebar-login-btn:hover {
        background: rgba(255, 255, 255, 0.2);
    }

    /* Sidebar footer for mobile */
    .sidebar-footer {
        display: block;
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 1rem;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        text-align: center;
    }

    .sidebar-footer p {
        margin: 0;
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.6);
    }

    /* Make sidebar nav scrollable but keep footer at bottom */
    .sidebar-nav {
        height: 100%;
        display: flex;
        flex-direction: column;
    }

    .sidebar .chat-list {
        flex: 1;
        overflow-y: auto;
    }

    /* Hide main footer on mobile */
    footer {
        display: none;
    }
}
