/* Main widget container */
#chat-widget {
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    font-family: 'Vazirmatn', sans-serif;
    direction: rtl;
    z-index: 2147483647 !important;
    /* top of everything */
}

/* Toggle button */
#chat-toggle {
    position: fixed !important;
    /* must have position for z-index to work */
    bottom: 40px !important;
    /* above call button */
    right: 10px !important;
    background: #0078ff;
    color: #fff;
    padding: 10px 16px;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: all .2s ease;
    z-index: 2147483647 !important;
    /* above everything */
}

#chat-toggle:hover {
    background: #005ed6;
}

/* Chat box */
#chat-box {
    position: fixed !important;
    /* crucial */
    bottom: 100px !important;
    /* above toggle and call button */
    right: 20px !important;
    width: 320px;
    height: 420px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: fadeIn .3s ease;
    z-index: 2147483647 !important;
    /* top-most layer */
}

/* Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(15px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header */
#chat-header {
    background: #0078ff;
    color: white;
    padding: 10px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    /* keep inside box */
    z-index: 2147483647 !important;
    /* ensures header stays above box content */
}

/* Avatar */
#chat-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    margin-left: 8px;
    border: 2px solid #fff;
    position: relative;
    z-index: 2147483647 !important;
}

/* Close button */
#chat-close {
    background: none;
    border: none;
    color: white;
    font-size: 22px;
    line-height: 22px;
    cursor: pointer;
    width: auto !important;
    position: relative;
    z-index: 2147483647 !important;
}

/* Messages */
#chat-messages {
    flex: 1;
    padding: 10px;
    overflow-y: auto;
    font-size: 14px;
    background: #f9f9f9;
    position: relative;
    z-index: 2147483647 !important;
}

.message {
    margin-bottom: 10px;
    line-height: 1.4;
    position: relative;
    z-index: 2147483647 !important;
}

.message.admin {
    text-align: left;
}

.message.user {
    text-align: right;
}

.message .text {
    display: inline-block;
    padding: 6px 10px;
    border-radius: 10px;
    background: #e6e6e6;
    max-width: 80%;
    word-wrap: break-word;
    position: relative;
    z-index: 2147483647 !important;
}

.message.user .text {
    background: #0078ff;
    color: white;
}

/* Timestamp */
.timestamp {
    font-size: 11px;
    color: gray;
    margin-top: 2px;
    position: relative;
    z-index: 2147483647 !important;
}

/* Form */
#chat-form {
    display: flex;
    border-top: 1px solid #ddd;
    position: relative;
    z-index: 2147483647 !important;
}

#chat-input {
    flex: 1;
    border: none;
    padding: 10px;
    font-family: inherit;
}

#chat-input:focus {
    outline: none;
}

#chat-form button {
    background: #0078ff;
    color: #fff;
    border: none;
    padding: 0 15px;
    cursor: pointer;
    font-family: inherit;
    position: relative;
    z-index: 2147483647 !important;
}

#chat-form button:hover {
    background: #005ed6;
}