.chat-window-overlay {

    position: fixed;

    inset: 0;

    background:
        rgba(0,0,0,0.72);

    backdrop-filter: blur(6px);

    z-index: 100000;

    display: flex;
    align-items: center;
    justify-content: center;

    animation:
        chatFade .2s ease;
}

.chat-window {

    width: min(1600px, 94vw);

    height: min(88vh, 1200px);

    min-height: 720px;

    max-height: 88vh;

    border-radius: 34px;

    overflow: hidden;

    display: flex;

    background:
        linear-gradient(
            180deg,
            rgba(18,18,18,0.98),
            rgba(10,10,10,0.98)
        );

    border:
        1px solid rgba(255,255,255,0.06);

    box-shadow:
        0 0 80px rgba(0,0,0,0.55);

    backdrop-filter: blur(12px);
}

/*
|--------------------------------------------------------------------------
| Sidebar
|--------------------------------------------------------------------------
*/

.chat-window-sidebar {

    width: 300px;

    min-width: 300px;

    background:
        linear-gradient(
            180deg,
            rgba(255,255,255,0.03),
            rgba(255,255,255,0.01)
        );

    border-right:
        1px solid rgba(255,255,255,0.04);

    padding: 30px 22px;
}

.chat-window-logo {

    font-size: 24px;
    font-weight: 800;

    color: white;

    margin-bottom: 30px;
}

.chat-window-tab {

    height: 52px;

    padding: 0 18px;

    border-radius: 16px;

    display: flex;
    align-items: center;

    margin-bottom: 10px;

    color:
        rgba(255,255,255,0.55);

    cursor: pointer;

    transition: .2s;
}

.chat-window-tab:hover {

    background:
        rgba(255,255,255,0.04);
}

.chat-window-tab.active {

    background:
        linear-gradient(
            135deg,
            rgba(255,70,70,0.18),
            rgba(255,30,30,0.08)
        );

    color: white;
}

/*
|--------------------------------------------------------------------------
| Main
|--------------------------------------------------------------------------
*/

.chat-window-main {

    flex: 1;

    min-height: 0;

    display: flex;
    flex-direction: column;

    background:
        linear-gradient(
            180deg,
            rgba(255,255,255,0.01),
            transparent
        );
}

.chat-window-header {

    height: 86px;

    padding: 0 32px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    border-bottom:
        1px solid rgba(255,255,255,0.04);

    background:
        linear-gradient(
            180deg,
            rgba(255,255,255,0.02),
            transparent
        );

    backdrop-filter: blur(12px);
}

.chat-window-title {

    color: white;

    font-size: 22px;
    font-weight: 800;
}

.chat-window-close {

    width: 42px;
    height: 42px;

    border-radius: 12px;

    display: flex;
    align-items: center;
    justify-content: center;

    cursor: pointer;

    background:
        rgba(255,255,255,0.04);

    color: white;

    transition: .2s;
}

.chat-window-close:hover {

    background:
        rgba(255,255,255,0.08);
}

/*
|--------------------------------------------------------------------------
| Messages
|--------------------------------------------------------------------------
*/

.chat-window-messages {

    flex: 1;

    min-height: 0;

    overflow-y: auto;

    padding: 28px;

    background:
        radial-gradient(
            circle at top,
            rgba(255,70,70,0.04),
            transparent 45%
        );
}

.chat-window-message {

    margin-bottom: 16px;
}

.chat-window-message-name {

    color: #ff8e8e;

    font-size: 14px;
    font-weight: 700;

    margin-bottom: 4px;
}

.chat-window-message-text {

    color: white;

    line-height: 1.5;
}

/*
|--------------------------------------------------------------------------
| Bottom
|--------------------------------------------------------------------------
*/

.chat-window-bottom {

    min-height: 96px;

    position: relative;

    z-index: 5;

    flex-shrink: 0;

    padding: 18px 24px;

    display: flex;

    align-items: center;

    gap: 14px;

    border-top:
        1px solid rgba(255,255,255,0.04);

    background:
        linear-gradient(
            0deg,
            rgba(255,255,255,0.02),
            transparent
        );
}

.chat-window-input {

    flex: 1;

    height: 58px;

    border: none;
    outline: none;

    border-radius: 18px;

    padding: 0 22px;

    background:
        rgba(255,255,255,0.035);

    border:
        1px solid rgba(255,255,255,0.03);

    color: white;

    font-size: 15px;

    transition: .2s;
}

.chat-window-input:focus {

    border:
        1px solid rgba(255,70,70,0.18);

    background:
        rgba(255,255,255,0.05);
}

.chat-window-send {

    width: 150px;
    height: 58px;

    border: none;

    border-radius: 18px;

    background:
        linear-gradient(
            135deg,
            #ff4747,
            #ff2525
        );

    color: white;

    font-weight: 800;

    letter-spacing: .4px;

    cursor: pointer;

    transition: .2s;

    box-shadow:
        0 10px 30px rgba(255,70,70,0.16);
}

.chat-window-send:hover {

    transform:
        translateY(-2px);

    box-shadow:
        0 16px 40px rgba(255,70,70,0.24);
}

.chat-window-send:hover {

    transform:
        translateY(-2px);
}

.chat-window-messages .chat-message {

    margin-bottom: 18px;
}

.chat-window-messages .chat-message:last-child {

    margin-bottom: 0;
}

.chat-window-dialogs {

    margin-top: 24px;

    display: flex;
    flex-direction: column;

    gap: 10px;

    overflow-y: auto;

    max-height: calc(88vh - 170px);

    padding-right: 4px;
}

.chat-dialog-item {

    height: 62px;

    padding: 0 14px;

    border-radius: 16px;

    display: flex;
    align-items: center;

    gap: 12px;

    margin-bottom: 10px;

    cursor: pointer;

    transition: .2s;
}

.chat-dialog-item:hover {

    background:
        rgba(255,255,255,0.04);
}

.chat-dialog-avatar {

    width: 42px;
    height: 42px;

    border-radius: 14px;

    overflow: hidden;

    display: flex;
    align-items: center;
    justify-content: center;

    background:
        rgba(255,255,255,0.04);

    color: white;

    font-weight: 700;
}

.chat-dialog-avatar-image {

    width: 100%;
    height: 100%;

    object-fit: cover;
}

.chat-dialog-name {

    color: white;

    font-size: 14px;
    font-weight: 700;
}

.chat-dialog-item.active {

    background:
        rgba(255,255,255,0.06);

    border:
        1px solid rgba(255,255,255,0.06);
}

.chat-dialog-empty {

    padding: 20px;

    color:
        rgba(255,255,255,0.35);

    font-size: 13px;
}

.chat-window-private {

    flex: 1;

    min-height: 0;

    overflow: hidden;

    display: flex;
    flex-direction: column;
}

.chat-dialog-info {

    display: flex;
    align-items: center;
    justify-content: space-between;

    width: 100%;
}

.chat-dialog-badge {

    min-width: 22px;
    height: 22px;

    padding: 0 7px;

    border-radius: 999px;

    display: flex;
    align-items: center;
    justify-content: center;

    background:
        linear-gradient(
            135deg,
            #ff4747,
            #ff2525
        );

    color: white;

    font-size: 11px;
    font-weight: 800;

    box-shadow:
        0 0 16px rgba(255,70,70,0.35);
}

.chat-window-tab {

    position: relative;
}

.chat-global-badge {

    margin-left: auto;

    min-width: 22px;
    height: 22px;

    padding: 0 7px;

    border-radius: 999px;

    display: flex;
    align-items: center;
    justify-content: center;

    background:
        linear-gradient(
            135deg,
            #ff4747,
            #ff2525
        );

    color: white;

    font-size: 11px;
    font-weight: 800;

    box-shadow:
        0 0 14px rgba(255,70,70,0.35);
}

/*
|--------------------------------------------------------------------------
| Ultimate Mobile
|--------------------------------------------------------------------------
*/

@media (max-width: 900px) {

    .chat-window-overlay {

        padding:
            env(safe-area-inset-top)
            0
            env(safe-area-inset-bottom)
            0;
    }

    .chat-window {

        width: 100vw;
        height: 100dvh;

        min-height: 100dvh;
        max-height: 100dvh;

        border-radius: 0;

        flex-direction: column;

        overflow: hidden;
    }

    /*
    |--------------------------------------------------------------------------
    | Sidebar
    |--------------------------------------------------------------------------
    */

    .chat-window-sidebar {

        width: 100%;
        min-width: 100%;

        height: auto;

        padding: 14px;

        border-right: none;

        border-bottom:
            1px solid rgba(255,255,255,0.04);

        overflow: hidden;

        flex-shrink: 0;
    }

    .chat-window-logo {

        font-size: 18px;

        margin-bottom: 12px;
    }

    .chat-window-dialogs {

        display: flex;
        flex-direction: row;

        gap: 10px;

        overflow-x: auto;
        overflow-y: hidden;

        padding-bottom: 4px;

        margin-top: 12px;

        max-height: unset;
    }

    .chat-window-dialogs::-webkit-scrollbar {

        display: none;
    }

    .chat-dialog-item {

        min-width: 170px;

        height: 58px;

        margin-bottom: 0;

        flex-shrink: 0;
    }

    /*
    |--------------------------------------------------------------------------
    | Main
    |--------------------------------------------------------------------------
    */

    .chat-window-main {

        flex: 1;

        min-height: 0;

        overflow: hidden;
    }

    .chat-window-header {

        height: 68px;

        min-height: 68px;

        padding:
            0
            16px;

        flex-shrink: 0;
    }

    .chat-window-title {

        font-size: 17px;
    }

    /*
    |--------------------------------------------------------------------------
    | Messages
    |--------------------------------------------------------------------------
    */

    .chat-window-messages {

        flex: 1;

        min-height: 0;

        padding: 16px;

        overflow-y: auto;

        -webkit-overflow-scrolling: touch;
    }

    /*
    |--------------------------------------------------------------------------
    | Bottom
    |--------------------------------------------------------------------------
    */

    .chat-window-bottom {

        min-height: 82px;

        padding:
            12px
            12px
            calc(
                12px + env(safe-area-inset-bottom)
            )
            12px;

        gap: 10px;

        flex-shrink: 0;
    }

    .chat-window-input {

        height: 52px;

        min-width: 0;

        font-size: 16px;

        border-radius: 16px;

        padding: 0 16px;
    }

    .chat-window-send {

        width: 58px;
        min-width: 58px;

        height: 52px;

        border-radius: 16px;

        font-size: 0;

        padding: 0;
    }

    .chat-window-send::before {

        content: '➜';

        font-size: 18px;

        font-weight: 800;
    }

    /*
    |--------------------------------------------------------------------------
    | Popup
    |--------------------------------------------------------------------------
    */

    .chat-popup {

        right: 10px;
        bottom: calc(
            10px + env(safe-area-inset-bottom)
        );

        width: calc(100vw - 20px);

        max-width: 430px;

        height: 68dvh;

        border-radius: 24px;
    }

    .chat-popup.minimized {

        width: 72px;
        height: 72px;
    }

    /*
    |--------------------------------------------------------------------------
    | Private Chat
    |--------------------------------------------------------------------------
    */

    .private-chat-header {

        padding: 0 16px;

        height: 72px;
        min-height: 72px;
    }

    .private-chat-avatar {

        width: 46px;
        height: 46px;

        border-radius: 14px;
    }

    .private-chat-name {

        font-size: 16px;
    }

    .private-chat-messages {

        padding: 16px;
    }

    .private-message-content {

        max-width: 90%;

        padding: 12px 14px;

        border-radius: 18px;
    }

    /*
    |--------------------------------------------------------------------------
    | Player Card
    |--------------------------------------------------------------------------
    */

    .chat-player-card {

        width: calc(100vw - 24px);

        max-width: 420px;

        padding: 22px;

        border-radius: 26px;
    }

    .chat-player-actions {

        flex-direction: column;
    }

    .chat-player-button {

        height: 52px;
    }
}