/* ChatMember Widget CSS */
#cm-launcher {
    position: fixed;
    bottom: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 2147483647;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
    transition: transform .2s ease, box-shadow .2s ease;
    user-select: none;
}
#cm-launcher:hover { transform: scale(1.08); box-shadow: 0 6px 20px rgba(0,0,0,0.32); }
#cm-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    border-radius: 10px;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    padding: 0 4px;
}

#cm-widget {
    position: fixed;
    bottom: 92px;
    width: 340px;
    max-height: 520px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    display: none;
    flex-direction: column;
    z-index: 2147483646;
    font-family: inherit;
    font-size: 14px;
    overflow: hidden;
    direction: rtl;
}
#cm-widget.cm-open { display: flex; }

#cm-widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    color: #fff;
    font-weight: bold;
    border-radius: 16px 16px 0 0;
}
#cm-close-btn {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
}

#cm-reg-form {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
#cm-reg-form input {
    padding: 9px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 13px;
    direction: rtl;
    width: 100%;
    box-sizing: border-box;
}
#cm-start-btn {
    padding: 10px;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
}
.cm-form-hint { margin: 0; color: #6b7280; font-size: 12px; }
.cm-error { color: #ef4444; font-size: 12px; margin: 0; }

#cm-chat-area { display: flex; flex-direction: column; flex: 1; overflow: hidden; }
#cm-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 200px;
    max-height: 340px;
}
.cm-msg {
    max-width: 78%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.5;
    word-break: break-word;
    position: relative;
}
.cm-msg.cm-user {
    background: #eff6ff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    color: #1e40af;
}
.cm-msg.cm-operator {
    background: #f3f4f6;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    color: #111827;
}
.cm-msg-time { font-size: 10px; color: #9ca3af; margin-top: 3px; display: block; text-align: left; }

#cm-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #f3f4f6;
}
#cm-input {
    flex: 1;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 13px;
    resize: none;
    direction: rtl;
    font-family: inherit;
}
#cm-input:focus { outline: none; border-color: #93c5fd; }
#cm-send-btn {
    border: none;
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
/* Closed chat / Resume conversation card */
/* Closed chat / Resume conversation card */
#cm-session-closed {
    display: none;
    flex: 0 0 auto;
    padding: 10px 12px 12px;
    border-top: 1px solid #e7edf5;
    background: #f8fafc;
    box-sizing: border-box;
    font-family: inherit;
}

#cm-session-closed .cm-closed-card {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 76px;
    padding: 11px;
    box-sizing: border-box;
    border: 1px solid #cfe0ff;
    border-radius: 11px;
    background: linear-gradient(135deg, #eff6ff 0%, #f8fbff 100%);
}

#cm-session-closed .cm-closed-icon {
    display: flex;
    flex: 0 0 34px;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    color: #2563eb;
    background: #dbeafe;
}

#cm-session-closed .cm-closed-icon svg {
    display: block;
    width: 19px !important;
    height: 19px !important;
    max-width: none !important;
    margin: 0 !important;
}

#cm-session-closed .cm-closed-content {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-width: 0;
    gap: 2px;
    text-align: right;
    line-height: 1.55;
}

#cm-session-closed .cm-closed-content strong {
    display: block;
    color: #1e3a5f;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

#cm-session-closed .cm-closed-content span {
    display: block;
    color: #64748b;
    font-size: 11px;
    white-space: nowrap;
}

#cm-session-closed #cm-resume-btn {
    display: inline-flex !important;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-width: 93px;
    height: 38px;
    margin: 0 !important;
    padding: 0 10px !important;
    box-sizing: border-box;
    border: 0 !important;
    border-radius: 8px !important;
    outline: 0;
    color: #ffffff !important;
    background: #2563eb !important;
    box-shadow: 0 3px 8px rgba(37, 99, 235, 0.25);
    cursor: pointer;
    font-family: inherit !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    line-height: 1 !important;
    text-decoration: none !important;
    white-space: nowrap;
    transition: background 0.18s ease, transform 0.18s ease;
}

#cm-session-closed #cm-resume-btn:hover {
    background: #1d4ed8 !important;
    transform: translateY(-1px);
}

#cm-session-closed #cm-resume-btn:active {
    transform: translateY(0);
}

#cm-session-closed #cm-resume-btn svg {
    display: block;
    flex: 0 0 auto;
    width: 15px !important;
    height: 15px !important;
    max-width: none !important;
    margin: 0 !important;
}

#cm-session-closed #cm-resume-btn:disabled {
    opacity: 0.65;
    cursor: wait;
    transform: none;
}

/* برای موبایل‌های کوچک: متن بالا و دکمه تمام‌عرض پایین */
@media (max-width: 380px) {
    #cm-session-closed .cm-closed-card {
        flex-wrap: wrap;
    }

    #cm-session-closed .cm-closed-content {
        flex-basis: calc(100% - 48px);
    }

    #cm-session-closed #cm-resume-btn {
        width: 100%;
        margin-top: 2px !important;
    }
}