#wp-instant-messenger {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 99999;
    font-family: Arial, sans-serif;
}

#wp-instant-messenger * {
    box-sizing: border-box;
}

#wp-instant-messenger .wim-input {
    font-size: 16px !important;
    line-height: 1.25;
    -webkit-appearance: none;
    appearance: none;
}

#wp-instant-messenger .wim-input {
    font-size: 16px !important;
    line-height: 1.25;
    -webkit-appearance: none;
    appearance: none;
}

#wp-instant-messenger.open .wim-toggle {
    display: none;
}

.wim-online-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: #22c55e;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.7);
    display: none;
    z-index: 3;
}

.wim-badge {
    position: absolute;
    right: -4px;
    bottom: -4px;

    min-width: 24px;
    height: 24px;
    padding: 0 6px;

    border-radius: 999px;
    background: #ff2d55;
    color: #fff;

    font-size: 12px;
    font-weight: bold;

    border: 2px solid #fff;
    line-height: 1;

    display: none;
    align-items: center;
    justify-content: center;
}

.wim-toggle {
    width: 62px;
    height: 62px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0084ff, #00c6ff);
    box-shadow: 0 8px 25px rgba(0,0,0,0.20);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    position: relative;
    transition: transform .2s ease, box-shadow .2s ease;
}

.wim-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 28px rgba(0,0,0,0.28);
}

.wim-toggle svg {
    width: 30px;
    height: 30px;
    fill: #fff;
}

.wim-window {
    position: absolute;
    right: 0;
    bottom: 22px;
    width: 360px;
    height: 520px;
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.22);
    overflow: hidden;
    display: none;
    flex-direction: column;
}

.wim-new-messages {
    position: absolute;
    left: 50%;
    bottom: 78px;
    transform: translateX(-50%);
    z-index: 5;

    border: 0;
    border-radius: 999px;
    background: #0084ff;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 14px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.18);
    cursor: pointer;

    display: none;
}

.wim-online-dot {
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 12px;
    height: 12px;
    background: #22c55e;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.7);
    display: none;
}

.wim-window.open {
    display: flex;
}

.wim-header {
    background: linear-gradient(135deg, #0084ff, #00a2ff);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 60px;
}

.wim-header-title {
    font-size: 16px;
    font-weight: bold;
}

.wim-close {
    background: transparent;
    color: #fff;
    border: 0;
    font-size: 26px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 30px;
    height: 30px;
}

.wim-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    background: #f5f7fb;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.wim-row {
    display: flex;
    flex-direction: column;
    max-width: 82%;
}

.wim-row.me {
    align-self: flex-start;
    align-items: flex-start;
}

.wim-row.client {
    align-self: flex-end;
    align-items: flex-end;
}

.wim-bubble {
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
    word-break: break-word;
    white-space: pre-wrap;
}

.wim-row.me .wim-bubble {
    background: #e9eef5;
    color: #111;
    border-bottom-left-radius: 6px;
}

.wim-row.client .wim-bubble {
    background: #0084ff;
    color: #fff;
    border-bottom-right-radius: 6px;
}

.wim-dt {
    margin-top: 4px;
    font-size: 11px;
    color: #7b8694;
    padding: 0 4px;
}

.wim-input-wrap {
    border-top: 1px solid #e7ebf0;
    background: #fff;
    padding: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.wim-input {
    flex: 1;
    min-width: 0;
    border: 1px solid #d6dde7;
    border-radius: 18px;
    padding: 10px 14px;
    outline: none;
    font-size: 16px !important;
    line-height: 1.4;
    background: #f9fbfd;
    resize: none;
    overflow: hidden;
    max-height: 120px;
}

.wim-input:focus {
    border-color: #0084ff;
    background: #fff;
}

.wim-send {
    border: 0;
    background: #0084ff;
    color: #fff;
    border-radius: 999px;
    padding: 11px 16px;
    cursor: pointer;
    font-weight: bold;
    white-space: nowrap;
    font-size: 16px;
    -webkit-appearance: none;
    appearance: none;
}

.wim-send:hover {
    background: #0075e3;
}

.wim-empty {
    text-align: center;
    color: #7b8694;
    font-size: 14px;
    margin: auto 0;
    padding: 20px;
}

.wim-loading {
    text-align: center;
    color: #7b8694;
    font-size: 13px;
    padding: 8px;
}

@media (max-width: 640px) {
    #wp-instant-messenger {
        right: 12px;
        bottom: 12px;
    }

    .wim-toggle {
        width: 58px;
        height: 58px;
    }

    .wim-window {
        position: fixed;
        left: 12px;
        right: 12px;
        bottom: 82px;
        top: auto;
        width: auto;
        height: min(60dvh, 560px);
        max-height: min(60dvh, 560px);
        border-radius: 18px;
    }
    #wp-instant-messenger.open .wim-window {
        bottom: 12px;
    }

    #wp-instant-messenger.keyboard-open .wim-window {
        height: 50dvh;
        max-height: 50dvh;
    }

    .wim-header {
        min-height: 56px;
        padding: 12px 14px;
    }

    .wim-messages {
        -webkit-overflow-scrolling: touch;
        padding: 12px;
    }

    .wim-input-wrap {
        padding: 10px;
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }

    .wim-input {
        font-size: 16px !important;
        line-height: 1.25;
        min-height: 44px;
    }

    .wim-send {
        font-size: 16px !important;
        min-height: 44px;
        padding: 10px 14px;
    }

    .wim-close {
        font-size: 24px !important;
        width: 32px;
        height: 32px;
    }

    .wim-new-messages {
        bottom: 72px;
    }

    #wp-instant-messenger.open .wim-new-messages {
        bottom: 72px;
    }

    #wp-instant-messenger.keyboard-open .wim-new-messages {
        bottom: 86px;
    }
}