:root {
    --chat-sidebar-width: 320px;
    --chat-gap: clamp(16px, 2vw, 28px);
    --chat-radius: 20px;
    --chat-bg: rgba(18, 24, 26, 0.88);
    --chat-panel: rgba(12, 16, 18, 0.92);
    --chat-border: rgba(255, 255, 255, 0.05);
    --chat-scrollbar: rgba(0, 237, 59, 0.4);
}

.chat-page {
    min-height: calc(100vh - 120px);
    padding: clamp(24px, 5vw, 48px) clamp(16px, 5vw, 56px);
    color: var(--ink);
    background: radial-gradient(circle at top right, rgba(0, 237, 59, 0.07), transparent 45%),
        radial-gradient(circle at 20% 20%, rgba(0, 237, 59, 0.04), transparent 55%);
}

.chat-layout {
    display: grid;
    grid-template-columns: minmax(240px, var(--chat-sidebar-width)) 1fr;
    gap: var(--chat-gap);
    max-width: 1200px;
    margin: 0 auto;
}

.chat-sidebar {
    background: var(--chat-panel);
    border: 1px solid var(--chat-border);
    border-radius: var(--chat-radius);
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.35);
}

.chat-sidebar__header {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-sidebar__title {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.chat-sidebar__subtitle {
    margin: 0;
    font-size: 0.95rem;
    color: rgba(198, 213, 204, 0.78);
}

.chat-sidebar__counter {
    align-self: flex-start;
    background: rgba(0, 237, 59, 0.12);
    border: 1px solid rgba(0, 237, 59, 0.35);
    color: var(--brand);
    font-weight: 600;
    padding: 6px 16px;
    border-radius: 999px;
    font-size: 0.85rem;
    letter-spacing: 0.02em;
}

.chat-users {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-users__toggle {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--ink);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 12px 16px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.25s ease;
}

.chat-users__toggle svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
    transition: transform 0.2s ease;
}

.chat-page--collapsed .chat-users__toggle svg {
    transform: rotate(-90deg);
}

.chat-users__toggle:hover {
    background: rgba(0, 237, 59, 0.18);
    color: var(--brand);
    border-color: rgba(0, 237, 59, 0.35);
}

.chat-users__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: calc(100vh - 260px);
    overflow-y: auto;
}

.chat-users__list::-webkit-scrollbar {
    width: 6px;
}

.chat-users__list::-webkit-scrollbar-thumb {
    background: var(--chat-scrollbar);
    border-radius: 999px;
}

.chat-user {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.chat-user:hover {
    /*transform: translateX(6px);*/
    border-color: rgba(0, 237, 59, 0.25);
    background: rgba(0, 237, 59, 0.06);
}

.chat-user--me {
    border-color: rgba(0, 237, 59, 0.35);
    background: rgba(0, 237, 59, 0.12);
}

.chat-user__info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-user__name {
    font-size: 0.98rem;
    letter-spacing: 0.01em;
}

.chat-user__meta {
    font-size: 0.82rem;
    color: rgba(198, 213, 204, 0.65);
    letter-spacing: 0.02em;
}

.chat-avatar {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    /*background: linear-gradient(135deg, rgba(0, 237, 59, 0.25), rgba(255, 255, 255, 0.05));*/
    display: grid;
    place-items: center;
    /*overflow: hidden;*/
    flex-shrink: 0;
    font-weight: 600;
    color: var(--brand);
    letter-spacing: 0.02em;
}

    .chat-avatar img {
        /*width: 100%;
    height: 100%;*/
        width: 42px;
        height: 42px;
        object-fit: cover;
        border-radius: 50%;
    }

.chat-main {
    background: var(--chat-bg);
    border: 1px solid var(--chat-border);
    border-radius: var(--chat-radius);
    padding: clamp(24px, 4vw, 40px);
    display: flex;
    flex-direction: column;
    gap: 24px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
}

.chat-main__header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
}

.chat-main__title {
    font-size: clamp(1.6rem, 2.6vw, 2.1rem);
    margin: 0 0 4px;
}

.chat-main__subtitle {
    margin: 0;
    font-size: 0.98rem;
    color: rgba(198, 213, 204, 0.72);
    max-width: 520px;
}

.chat-status {
    align-self: center;
    padding: 6px 18px;
    border-radius: 999px;
    font-size: 0.82rem;
    letter-spacing: 0.02em;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
}

.chat-status[data-status="online"] {
    color: var(--brand);
    border-color: rgba(0, 237, 59, 0.35);
    background: rgba(0, 237, 59, 0.12);
}

.chat-status[data-status="offline"] {
    color: #f87171;
    border-color: rgba(248, 113, 113, 0.35);
    background: rgba(248, 113, 113, 0.12);
}

.chat-status[data-status="warning"] {
    color: #f6c23e;
    border-color: rgba(246, 194, 62, 0.35);
    background: rgba(246, 194, 62, 0.12);
}

.chat-history {
    background: rgba(8, 12, 14, 0.8);
    border-radius: calc(var(--chat-radius) - 6px);
    border: 1px solid rgba(255, 255, 255, 0.04);
    padding: clamp(18px, 3vw, 28px);
    height: clamp(360px, 60vh, 540px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
    scroll-behavior: smooth;
}

.chat-history:focus {
    outline: 2px solid rgba(0, 237, 59, 0.4);
    outline-offset: 4px;
}

.chat-history::-webkit-scrollbar {
    width: 8px;
}

.chat-history::-webkit-scrollbar-thumb {
    background: var(--chat-scrollbar);
    border-radius: 999px;
}

.chat-message {
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 12px;
    animation: slide-in 0.3s ease;
}

.chat-message--mine {
    align-self: flex-end;
    justify-content: flex-end;
}

.chat-message--mine .chat-message__bubble {
    background: linear-gradient(135deg, rgba(0, 237, 59, 0.85), rgba(0, 182, 85, 0.85));
    color: #04100a;
    box-shadow: 0 12px 32px rgba(0, 237, 59, 0.2);
}

.chat-message--mine .chat-message__header {
    color: rgba(4, 16, 10, 0.8);
}

.chat-message--mine .chat-message__time {
    color: rgba(4, 16, 10, 0.65);
}

.chat-message--mine .chat-avatar {
    /*background: rgba(255, 255, 255, 0.6);*/
    color: rgba(4, 16, 10, 0.75);
}

.chat-message__bubble {
    background: rgba(255, 255, 255, 0.04);
    border-radius: 18px;
    padding: 14px 18px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: min(520px, 100%);
    min-width: 200px;
}

.chat-message__header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 0.85rem;
    color: rgba(198, 213, 204, 0.75);
}

.chat-message__author {
    font-weight: 600;
    letter-spacing: 0.02em;
}

.chat-message__time {
    font-size: 0.75rem;
    color: rgba(198, 213, 204, 0.55);
}

.chat-message__text {
    margin: 0;
    line-height: 1.55;
    font-size: 0.98rem;
}

.chat-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-form__label {
    font-size: 0.9rem;
    color: rgba(198, 213, 204, 0.65);
    letter-spacing: 0.02em;
}

.chat-form__composer {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: flex-end;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 18px;
    padding: 12px 16px;
}

.chat-form__input {
    background: transparent;
    border: 0;
    color: var(--ink);
    font-size: 1rem;
    resize: none;
    outline: none;
    max-height: 200px;
    padding: 0;
}

.chat-form__input::placeholder {
    color: rgba(198, 213, 204, 0.45);
}

.chat-form__send {
    border: 0;
    background: linear-gradient(135deg, rgba(0, 237, 59, 0.9), rgba(0, 182, 85, 0.9));
    color: #04100a;
    font-weight: 700;
    padding: 12px 22px;
    border-radius: 14px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chat-form__send:hover {
    transform: translateY(-1px);
    box-shadow: 0 16px 32px rgba(0, 237, 59, 0.25);
}

.chat-form__send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

.chat-form__hint {
    margin: 0;
    font-size: 0.82rem;
    color: rgba(198, 213, 204, 0.5);
    letter-spacing: 0.02em;
}

@keyframes slide-in {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 1024px) {
    .chat-layout {
        grid-template-columns: 1fr;
    }

    .chat-sidebar {
        flex-direction: column;
        gap: 12px;
    }

    .chat-users__toggle {
        display: flex;
    }

    .chat-page--collapsed .chat-users__list {
        display: none;
    }
}

@media (max-width: 768px) {
    .chat-page {
        padding: clamp(18px, 4vw, 28px) clamp(12px, 4vw, 28px);
    }

    .chat-main {
        padding: clamp(18px, 5vw, 32px);
    }

    .chat-history {
        height: clamp(300px, 50vh, 420px);
    }

    .chat-form__composer {
        grid-template-columns: 1fr;
    }

    .chat-form__send {
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
