
:root {
    --primary: #315efb;
    --primary-dark: #2448d8;
    --primary-light: #edf1ff;

    --background: #f5f7fb;
    --sidebar: #ffffff;
    --surface: #ffffff;

    --text: #182230;
    --muted: #788395;
    --border: #e8ecf2;

    --success: #16a36a;
    --danger: #e34d59;

    --radius: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Inter, -apple-system, BlinkMacSystemFont,
        "Segoe UI", Roboto, Arial, sans-serif;

    background: var(--background);
    color: var(--text);
    min-height: 100vh;
}

button,
input,
textarea,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

.app {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */

.sidebar {
    width: 270px;
    min-width: 270px;
    background: var(--sidebar);
    border-right: 1px solid var(--border);

    display: flex;
    flex-direction: column;
    padding: 25px 18px 18px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 5px 30px;
}

.brand-logo {
    width: 42px;
    height: 42px;
    border-radius: 12px;

    background: var(--primary);
    color: white;

    display: flex;
    align-items: center;
    justify-content: center;

    font-size: 22px;
    font-weight: 800;
}

.brand h2 {
    font-size: 15px;
    font-weight: 750;
    letter-spacing: -0.3px;
}

.brand span {
    display: block;
    font-size: 11px;
    color: var(--muted);
    margin-top: 4px;
}

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

.section-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;

    padding: 0 9px;
    margin-bottom: 12px;

    color: #929baa;
    font-size: 10px;
    font-weight: 750;
    letter-spacing: 1px;
}

.workspace-item {
    display: flex;
    align-items: center;
    gap: 11px;

    padding: 12px;
    border-radius: 8px;

    font-size: 13px;
    font-weight: 600;
    color: #566173;
}

.workspace-item.active {
    background: var(--primary-light);
    color: var(--primary);
}

.workspace-icon {
    font-size: 21px;
    font-weight: 700;
}

.count-badge {
    background: #edf0f5;
    color: #637083;

    padding: 3px 8px;
    border-radius: 20px;

    font-size: 11px;
}

.users-section {
    flex: 1;
    min-height: 100px;
    overflow-y: auto;
}

.users-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.user-item {
    display: flex;
    align-items: center;
    gap: 10px;

    padding: 10px;
    border-radius: 8px;

    cursor: pointer;
    transition: background 0.2s;
}

.user-item:hover {
    background: #f4f6fa;
}

.user-item.selected {
    background: var(--primary-light);
}

.user-avatar {
    position: relative;

    width: 34px;
    height: 34px;
    min-width: 34px;

    border-radius: 50%;

    display: flex;
    align-items: center;
    justify-content: center;

    background: #e9edff;
    color: var(--primary);

    font-weight: 700;
    font-size: 13px;
}

.user-avatar::after {
    content: "";

    position: absolute;
    right: -1px;
    bottom: -1px;

    width: 9px;
    height: 9px;

    background: var(--success);
    border: 2px solid white;
    border-radius: 50%;
}

.user-details {
    min-width: 0;
    flex: 1;
}

.user-name {
    display: block;
    font-size: 12px;
    font-weight: 650;

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-id {
    display: block;
    color: var(--muted);
    font-size: 10px;
    margin-top: 3px;
}

.empty-users {
    padding: 15px 10px;
    color: var(--muted);
    font-size: 12px;
}

.sidebar-bottom {
    border-top: 1px solid var(--border);
    padding-top: 18px;
}

.connection-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.connection-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #e5a12a;
}

.connection-dot.connected {
    background: var(--success);
}

.connection-dot.disconnected {
    background: var(--danger);
}

.connection-indicator strong {
    display: block;
    font-size: 12px;
}

.connection-indicator small {
    display: block;
    margin-top: 3px;
    font-size: 10px;
    color: var(--muted);
}

.reconnect-btn {
    width: 100%;
    padding: 9px;

    border: 1px solid var(--border);
    background: white;
    border-radius: 7px;

    font-size: 12px;
    font-weight: 650;
    color: #536174;
}

.reconnect-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}


/* Main Content */

.main-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: 86px;
    min-height: 86px;

    background: white;
    border-bottom: 1px solid var(--border);

    display: flex;
    justify-content: space-between;
    align-items: center;

    padding: 0 35px;
}

.topbar-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar h1 {
    font-size: 19px;
    font-weight: 750;
    letter-spacing: -0.5px;
}

.topbar p {
    margin-top: 5px;
    font-size: 12px;
    color: var(--muted);
}

.online-status {
    display: flex;
    align-items: center;
    gap: 8px;

    padding: 9px 13px;

    border-radius: 20px;
    background: #edfaf4;

    color: #168354;
    font-size: 11px;
    font-weight: 650;
}

.live-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--success);
}

.mobile-brand {
    display: none;
}


/* Chat */

.chat-section {
    width: 100%;
    max-width: 1250px;

    margin: 0 auto;
    padding: 25px 35px;

    flex: 1;

    display: flex;
    flex-direction: column;
    min-height: 0;
}

.chat-info {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);

    padding: 18px 20px;

    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;

    margin-bottom: 18px;
}

.chat-info-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.chat-avatar {
    width: 42px;
    height: 42px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 11px;
    background: var(--primary-light);

    color: var(--primary);
    font-size: 22px;
    font-weight: 700;
}

.chat-info h3 {
    font-size: 14px;
    font-weight: 700;
}

.chat-info p {
    margin-top: 5px;
    color: var(--muted);
    font-size: 11px;
}

.recipient-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

.recipient-control label {
    color: var(--muted);
    font-size: 11px;
    white-space: nowrap;
}

.recipient-control select {
    min-width: 180px;

    padding: 9px 30px 9px 11px;

    border: 1px solid var(--border);
    border-radius: 7px;

    background: white;
    color: var(--text);

    font-size: 11px;
    outline: none;
}

.recipient-control select:focus {
    border-color: var(--primary);
}


/* Message area */

.message-area {
    flex: 1;
    min-height: 280px;

    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);

    padding: 25px;

    overflow-y: auto;

    display: flex;
    flex-direction: column;
    gap: 17px;
}

.welcome-message {
    margin: auto;
    max-width: 380px;
    text-align: center;
    padding: 35px 15px;
}

.welcome-icon {
    width: 55px;
    height: 55px;

    display: flex;
    justify-content: center;
    align-items: center;

    margin: 0 auto 18px;

    border-radius: 16px;
    background: var(--primary-light);

    color: var(--primary);
    font-size: 27px;
    font-weight: 800;
}

.welcome-message h2 {
    font-size: 17px;
    margin-bottom: 9px;
}

.welcome-message p {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.7;
}


/* Message bubbles */

.message-row {
    display: flex;
    flex-direction: column;
    max-width: 78%;
    gap: 5px;
}

.message-row.sent {
    align-self: flex-end;
    align-items: flex-end;
}

.message-row.received {
    align-self: flex-start;
    align-items: flex-start;
}

.message-meta {
    display: flex;
    align-items: center;
    gap: 8px;

    color: var(--muted);
    font-size: 10px;
}

.message-bubble {
    padding: 12px 15px;

    border-radius: 12px;

    font-size: 13px;
    line-height: 1.65;

    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.sent .message-bubble {
    background: var(--primary);
    color: white;
    border-bottom-right-radius: 3px;
}

.received .message-bubble {
    background: #f0f3f8;
    color: #283548;
    border-bottom-left-radius: 3px;
}

.message-type {
    font-size: 9px;
    font-weight: 650;
    color: var(--muted);
    margin-top: 3px;
}

.server-message {
    align-self: center;

    max-width: 90%;

    padding: 8px 13px;
    border-radius: 20px;

    background: #f4f6f9;
    color: #7d8795;

    font-size: 10px;
    text-align: center;
}


/* Composer */

.typing-status {
    height: 20px;
    padding: 5px 5px 0;

    color: var(--muted);
    font-size: 10px;
}

.composer-wrapper {
    margin-top: 5px;
}

.composer {
    background: white;

    border: 1px solid #dfe4ed;
    border-radius: var(--radius);

    padding: 15px;

    transition: border-color 0.2s, box-shadow 0.2s;
}

.composer:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(49, 94, 251, 0.07);
}

.composer textarea {
    width: 100%;
    min-height: 55px;
    max-height: 220px;

    resize: none;
    border: none;
    outline: none;

    color: var(--text);
    background: transparent;

    font-size: 13px;
    line-height: 1.7;
}

.composer textarea::placeholder {
    color: #a0a8b5;
}

.composer-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;

    padding-top: 12px;
    border-top: 1px solid #f0f2f6;
}

.composer-hint {
    color: #9aa3b1;
    font-size: 10px;
}

.hint-separator {
    margin: 0 5px;
}

.composer-actions {
    display: flex;
    align-items: center;
    gap: 13px;
}

#characterCount {
    color: #9aa3b1;
    font-size: 10px;
}

.send-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;

    padding: 11px 17px;

    border: none;
    border-radius: 7px;

    background: var(--primary);
    color: white;

    font-size: 11px;
    font-weight: 700;

    transition: background 0.2s;
}

.send-button:hover:not(:disabled) {
    background: var(--primary-dark);
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.send-arrow {
    font-size: 13px;
}

.composer-note {
    text-align: center;
    margin-top: 11px;

    color: #9ba4b1;
    font-size: 10px;
}


/* Toast */

.toast-container {
    position: fixed;
    right: 20px;
    top: 20px;

    display: flex;
    flex-direction: column;
    gap: 8px;

    z-index: 1000;
}

.toast {
    padding: 12px 16px;

    background: #202b3b;
    color: white;

    border-radius: 8px;
    font-size: 12px;

    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.12);

    animation: toastIn 0.2s ease;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* Responsive */

@media (max-width: 900px) {

    .sidebar {
        width: 230px;
        min-width: 230px;
    }

    .topbar {
        padding: 0 22px;
    }

    .chat-section {
        padding: 20px 22px;
    }

    .chat-info {
        align-items: flex-start;
        flex-direction: column;
    }

    .recipient-control {
        width: 100%;
    }

    .recipient-control select {
        flex: 1;
    }
}

@media (max-width: 650px) {

    .app {
        display: block;
    }

    .sidebar {
        width: 100%;
        min-width: 0;
        padding: 12px 16px;

        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .brand,
    .sidebar-section,
    .users-section,
    .sidebar-bottom {
        display: none;
    }

    .topbar {
        height: 75px;
        min-height: 75px;
        padding: 0 15px;
    }

    .mobile-brand {
        display: block;
    }

    .mobile-brand .brand-logo {
        width: 35px;
        height: 35px;
        font-size: 18px;
    }

    .topbar h1 {
        font-size: 15px;
    }

    .topbar p {
        font-size: 10px;
    }

    .online-status {
        padding: 8px;
        font-size: 9px;
    }

    .chat-section {
        padding: 12px;
        height: calc(100vh - 75px);
        min-height: 500px;
    }

    .chat-info {
        padding: 13px;
        margin-bottom: 10px;
    }

    .chat-info-left {
        width: 100%;
    }

    .recipient-control {
        gap: 7px;
    }

    .recipient-control label {
        font-size: 10px;
    }

    .recipient-control select {
        min-width: 0;
        padding: 9px;
    }

    .message-area {
        padding: 15px 11px;
        gap: 14px;
    }

    .message-row {
        max-width: 92%;
    }

    .composer {
        padding: 11px;
    }

    .composer-hint {
        font-size: 9px;
    }

    .composer-actions {
        gap: 8px;
    }

    .send-button {
        padding: 10px 12px;
    }

    .send-button span:first-child {
        display: none;
    }
}
