.tenant-chat {
    display: flex;
    flex-direction: column;
    flex: 1;
    height: 100%;
    min-width: 0;
    background: #f7f8fc;
    position: relative;
}

.tenant-chat-sidebar {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px;
    border-bottom: 1px solid #e5e7eb;
    background: #ffffff;
    overflow: hidden;
}

.tenant-chat-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    color: #0f172a;
}

.tenant-chat-room-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 220px;
    overflow: auto;
}

.tenant-chat-room-list::-webkit-scrollbar,
.tenant-chat-messages::-webkit-scrollbar,
.tenant-chat-contacts::-webkit-scrollbar {
    width: 0;
    height: 0;
}

.tenant-chat-room-list,
.tenant-chat-messages,
.tenant-chat-contacts {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.tenant-chat-room {
    display: flex;
    flex-direction: column;
    gap: 4px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 10px;
    background: #ffffff;
    text-align: left;
}

.tenant-chat-room.active {
    border-color: #22c55e;
    background: #dcfce7;
}

.tenant-chat-room-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    color: #0f172a;
}

.tenant-chat-room-global {
    font-size: 16px;
    color: #2563eb;
}

.tenant-chat-main {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding: 12px;
    gap: 12px;
    overflow: hidden;
    position: relative;
    min-width: 0;
}

.tenant-chat-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #475569;
}

.tenant-chat-create {
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 0;
    padding: 16px;
    box-shadow: none;
    width: 100%;
    height: 100%;
    overflow: auto;
}

.tenant-chat-create-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: stretch;
    justify-content: center;
    padding: 0;
    margin: 0;
    background: rgba(15, 23, 42, 0.08);
    z-index: 4;
}

.tenant-chat-create-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    color: #0f172a;
}

.tenant-chat-create-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    overflow: auto;
}

.tenant-chat-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: #0f172a;
}

.tenant-chat-input {
    width: 100%;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px 12px;
    background: #ffffff;
    color: #0f172a;
}

.tenant-chat-toggle-row {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #0f172a;
}

.tenant-chat-checkbox {
    width: 18px;
    height: 18px;
}

.tenant-chat-global-toggle {
    border: 1px solid #e2e8f0;
    background: #ffffff;
    border-radius: 999px;
    padding: 0;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #2563eb;
}

.tenant-chat-global-toggle.active {
    background: #dbeafe;
    border-color: #2563eb;
}

.tenant-chat-room-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.tenant-chat-icon-button {
    border: 1px solid #e2e8f0;
    background: #ffffff;
    border-radius: 999px;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #0f172a;
    cursor: pointer;
}

.tenant-chat-icon-button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.tenant-chat-contacts {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 260px;
    overflow: auto;
    border-top: 1px solid #e5e7eb;
    padding-top: 10px;
}

.tenant-chat-tenant-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tenant-chat-tenant-name {
    font-weight: 600;
    color: #475569;
}

.tenant-chat-contact {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 12px;
    background: #f8fafc;
    border: 1px solid transparent;
    text-align: left;
}

.tenant-chat-contact.selected {
    border-color: #22c55e;
    background: #dcfce7;
}

.tenant-chat-avatar {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    object-fit: cover;
    background: #e2e8f0;
}

.tenant-chat-avatar-fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    color: #0f172a;
}

.tenant-chat-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: auto;
}

.tenant-chat-room-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: stretch;
    justify-content: center;
    background: rgba(15, 23, 42, 0.08);
    z-index: 3;
}

.tenant-chat-room-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 0;
    padding: 16px;
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: relative;
}

.tenant-chat-modal-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: stretch;
    justify-content: center;
    background: rgba(15, 23, 42, 0.08);
    z-index: 6;
}

.tenant-chat-modal {
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 0;
    padding: 16px;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.tenant-chat-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    color: #0f172a;
}

.tenant-chat-modal-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    overflow: auto;
}

.tenant-chat-expand {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    color: #0f172a;
    font-weight: 700;
    cursor: pointer;
}

.tenant-chat.collapsed .tenant-chat-sidebar {
    width: 36px;
    padding: 6px;
    align-items: center;
    border-bottom: none;
    border-right: 1px solid #e5e7eb;
    height: 100%;
}

.tenant-chat.collapsed {
    flex-direction: row;
}

.tenant-chat.collapsed .tenant-chat-room-list,
.tenant-chat.collapsed .tenant-chat-sidebar-header span,
.tenant-chat.collapsed .tenant-chat-sidebar-header .rz-button {
    display: none;
}

.tenant-chat-room-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    background: #ffffff;
    box-shadow: 0 10px 35px rgba(15, 23, 42, 0.08);
}

.tenant-chat-room-name {
    font-weight: 600;
    color: #0f172a;
}

.tenant-chat-room-info small {
    color: #475569;
}

.tenant-chat-messages {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
    overflow: auto;
    padding: 6px 2px;
}

.tenant-chat-message {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 10px 12px;
    color: #0f172a;
}

.tenant-chat-message.own {
    border-color: #22c55e;
    background: #dcfce7;
}

.tenant-chat-message-header {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #475569;
}

.tenant-chat-message-body {
    font-size: 14px;
}

.tenant-chat-input-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.tenant-chat-muted {
    color: #475569;
}

@media (min-width: 900px) {
    .tenant-chat {
        flex-direction: row;
    }

    .tenant-chat-sidebar {
        width: 260px;
        border-bottom: none;
        border-right: 1px solid #e5e7eb;
        height: 100%;
    }

    .tenant-chat-room-list {
        max-height: none;
        flex: 1;
    }

    .tenant-chat.collapsed .tenant-chat-sidebar {
        width: 44px;
    }
}

.tenant-chat-global-toggle:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
