/* === Main Window Layout === */

.main-window {
    width: 100%;
    height: 100%;
    max-width: 1200px;
    max-height: 100vh;
}

@media (min-width: 769px) {
    .main-window {
        width: 95vw;
        height: 92vh;
        max-width: 1200px;
    }
}

.main-body {
    display: flex;
    flex: 1;
    overflow: hidden;
    padding: 0;
}

/* === Sidebar === */

.sidebar {
    width: 200px;
    min-width: 200px;
    background: var(--bg-window);
    box-shadow: var(--bevel-in);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
}

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

.sidebar-header {
    background: var(--bg-window);
    padding: 3px 6px;
    font-weight: bold;
    font-size: 11px;
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid var(--border-dark);
}

.sidebar-header:hover {
    background: var(--border-light);
}

.sidebar-list {
    list-style: none;
    background: var(--bg-field);
}

.sidebar-item {
    padding: 2px 6px 2px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-item:hover {
    background: #000080;
    color: #fff;
}

.sidebar-item.active {
    background: #000080;
    color: #fff;
}

.room-hash {
    color: var(--text-secondary);
    font-weight: bold;
}

.sidebar-item.active .room-hash,
.sidebar-item:hover .room-hash {
    color: #fff;
}

.buddy-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.buddy-away {
    font-style: italic;
    color: var(--text-secondary);
    font-size: 10px;
    margin-left: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-item:hover .buddy-away,
.sidebar-item.active .buddy-away {
    color: #ccc;
}

.sidebar-item.buddy-offline {
    opacity: 0.5;
}

.sidebar-item.buddy-offline:hover {
    opacity: 1;
}

.unread-badge {
    background: #cc0000;
    color: #fff;
    font-size: 9px;
    padding: 0 4px;
    border-radius: 2px;
    font-weight: bold;
    margin-left: auto;
}

/* === Chat Area === */

.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-window);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    background: var(--bg-field);
    box-shadow: var(--bevel-in);
    margin: 2px;
    padding: 4px;
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.4;
}

.chat-input-area {
    padding: 2px 4px 4px;
}

.input-toolbar {
    display: flex;
    gap: 2px;
    margin-bottom: 2px;
}

.toolbar-btn {
    background: var(--bg-window);
    box-shadow: var(--bevel-out);
    border: none;
    width: 24px;
    height: 22px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.toolbar-btn:active {
    box-shadow: var(--bevel-in);
}

.input-row {
    display: flex;
    gap: 4px;
}

.message-input {
    flex: 1;
    min-height: 24px;
    max-height: 80px;
    font-family: var(--font-main);
    font-size: var(--font-size);
}

.send-btn {
    min-width: 60px;
    align-self: flex-end;
}

/* === Status Bar === */

.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2px 4px;
    box-shadow: var(--bevel-in);
    font-size: 10px;
    min-height: 20px;
}

.status-bar-left {
    display: flex;
    align-items: center;
    gap: 4px;
}

.status-bar-right {
    color: var(--text-secondary);
}

.status-bar-right a {
    font-size: 10px;
}

.away-input {
    width: 150px;
    font-size: 10px;
    padding: 1px 3px;
}

/* === Typing Indicator === */

.typing-indicator {
    padding: 2px 8px;
    font-size: 10px;
    color: var(--text-secondary);
    font-style: italic;
}

.typing-dots {
    animation: blink 1s steps(3) infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* === Reply Preview === */

.reply-preview {
    display: flex;
    align-items: center;
    padding: 2px 8px;
    background: #e8e8e8;
    border-left: 3px solid #000080;
    margin: 0 4px;
    font-size: 10px;
    gap: 8px;
}

.reply-preview-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.reply-cancel {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
}

/* === Mobile === */

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -220px;
        top: 0;
        bottom: 0;
        width: 220px;
        z-index: 100;
        transition: left 0.2s;
        box-shadow: 2px 0 8px rgba(0,0,0,0.3);
    }

    .sidebar.open {
        left: 0;
    }

    .main-window {
        width: 100%;
        height: 100%;
        max-width: none;
    }
}

/* === Dialog Layout (login/register) === */

.dialog-overlay {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dialog-window {
    width: 360px;
    max-width: 95vw;
}

.admin-window {
    width: 700px;
    max-height: 90vh;
    overflow-y: auto;
}

.dialog-body {
    padding: 12px;
}

.dialog-icon-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.app-logo {
    font-size: 32px;
}

.auth-form .form-group {
    margin-bottom: 8px;
}

.auth-form label {
    display: block;
    margin-bottom: 2px;
    font-size: 11px;
}

.dialog-buttons {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.avatar-preview {
    display: block;
    width: 48px;
    height: 48px;
    object-fit: cover;
    margin-bottom: 4px;
    box-shadow: var(--bevel-in);
}

.inline-form {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-wrap: wrap;
}

/* === Pop-out DM Windows === */

.dm-window {
    position: absolute;
    width: 350px;
    height: 300px;
    min-width: 250px;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    resize: both;
    overflow: hidden;
}

.dm-title-bar {
    cursor: default;
}

.dm-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 2px;
    overflow: hidden;
}

.dm-messages {
    flex: 1;
    overflow-y: auto;
    background: var(--bg-field);
    box-shadow: var(--bevel-in);
    padding: 4px;
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.4;
    margin-bottom: 2px;
}

.dm-typing {
    padding: 1px 6px;
    font-size: 10px;
    color: var(--text-secondary);
    font-style: italic;
}

.dm-input-row {
    display: flex;
    gap: 4px;
    padding: 2px;
}

.dm-input {
    flex: 1;
    min-height: 22px;
    max-height: 60px;
    resize: none;
    font-family: var(--font-main);
    font-size: var(--font-size);
}

.dm-send-btn {
    min-width: 50px;
    padding: 2px 8px;
    font-size: 10px;
    align-self: flex-end;
}
