/* App container — fixed to viewport */
#app {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#main-screen {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* Sidebar */
#sidebar {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--color-sidebar-bg);
    border-right: 1px solid var(--color-border);
    position: relative;
    flex-shrink: 0;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    height: var(--header-height);
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}

.sidebar-header .avatar {
    cursor: pointer;
}

.sidebar-header-title {
    flex: 1;
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--color-text);
}

.sidebar-search {
    padding: 8px 12px;
    background: var(--color-bg);
    position: relative;
    flex-shrink: 0;
}

.sidebar-search svg {
    position: absolute;
    left: 22px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--color-text-light);
}

.room-list {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.room-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background var(--transition-fast);
    border-bottom: 1px solid var(--color-border);
}

.room-item:hover {
    background: var(--color-hover);
}

.room-item.active {
    background: var(--color-hover);
}

.room-item-avatar {
    position: relative;
    flex-shrink: 0;
}

.room-item-info {
    flex: 1;
    min-width: 0;
}

.room-item-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.room-item-name {
    font-weight: 500;
    font-size: var(--font-size-base);
    color: var(--color-text);
}

.room-item-time {
    font-size: var(--font-size-xs);
    color: var(--color-text-light);
    flex-shrink: 0;
}

.room-item-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 2px;
}

.room-item-preview {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

/* Chat area */
#chat-area {
    display: none;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    min-height: 0;
    height: 100%;
    background: var(--color-chat-bg);
    overflow: hidden;
}

#chat-area .empty-state {
    background: var(--color-bg);
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Chat view — flex column: header (fixed) + messages (scrollable) + compose (fixed) */
#chat-view {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

#chat-view.hidden {
    display: none !important;
}

#no-chat-selected {
    flex: 1;
}

#no-chat-selected.hidden {
    display: none !important;
}

/* Mobile: sidebar shown, chat hidden by default */
#sidebar.mobile-hidden { display: none; }
#chat-area.mobile-visible { display: flex; }

/* Desktop */
@media (min-width: 768px) {
    #sidebar {
        width: var(--sidebar-width);
        min-width: var(--sidebar-width);
        display: flex !important;
    }

    #sidebar.mobile-hidden {
        display: flex !important;
    }

    #chat-area {
        display: flex !important;
    }

    .back-btn {
        display: none !important;
    }
}
