* {
    box-sizing: border-box;
    font-family: Tahoma, Arial, sans-serif;
}

body {
    margin: 0;
    background: #f3f5f8;
}

.chat-box {
    width: 380px;
    max-width: 95%;
    height: 600px;
    background: #fff;
    position: fixed;
    right: 25px;
    bottom: 25px;
    border-radius: 20px;
    box-shadow: 0 10px 35px rgba(0, 0, 0, .15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-header {
    background: #009688;
    color: #fff;
    padding: 12px 14px;
    font-size: 14px;
    font-weight: bold;
    line-height: 1.5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.transcript-toggle {
    border: 1px solid rgba(255, 255, 255, .8);
    background: #25d366;
    color: #fff;
    padding: 7px 11px;
    border-radius: 16px;
    cursor: pointer;
    font-size: 10.5px;
    font-weight: bold;
    white-space: nowrap;
    box-shadow: 0 0 0 rgba(37, 211, 102, .45);
    animation: sendConversationBlink 1.15s infinite;
}

.chat-messages {
    flex: 1;
    padding: 10px;
    overflow-y: auto;
    scroll-behavior: auto;
}

.message {
    display: block;
    width: fit-content;
    max-width: 82%;
    padding: 8px 11px;
    margin: 7px;
    border-radius: 12px;
    position: relative;
    font-size: 12px;
    line-height: 1.75;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.message.user {
    background: #d9ecff;
    margin-left: auto;
    margin-right: 0;
    text-align: right;
    border-bottom-right-radius: 3px;
}

.message.bot,
.message.admin {
    background: #e6ffe6;
    margin-right: auto;
    margin-left: 0;
    text-align: right;
    border-bottom-left-radius: 3px;
}

.message .text {
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.message .text a {
    color: #0069c2;
    text-decoration: underline;
    overflow-wrap: anywhere;
    word-break: break-all;
}

.message .time {
    font-size: 9px;
    color: #777;
    margin-top: 3px;
    opacity: .85;
}

.chat-input {
    display: flex;
    gap: 7px;
    padding: 9px;
    border-top: 1px solid #ddd;
    background: #fff;
}

.chat-input input {
    flex: 1;
    min-width: 0;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 10px 12px;
    outline: none;
    font-size: 12px;
}

.chat-input input:focus {
    border-color: #009688;
}

.chat-input button,
.transcript-email-row button {
    background: #009688;
    color: #fff;
    border: 0;
    padding: 0 16px;
    min-height: 39px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 11px;
}

.transcript-panel {
    border-top: 1px solid #e2e2e2;
    background: #fafafa;
    padding: 10px;
}

.transcript-title {
    font-size: 11px;
    font-weight: bold;
    margin-bottom: 8px;
    color: #444;
}

.transcript-email-row {
    display: flex;
    gap: 6px;
}

.transcript-email-row input {
    flex: 1;
    min-width: 0;
    border: 1px solid #ddd;
    border-radius: 18px;
    padding: 9px 11px;
    outline: none;
    font-size: 11px;
}

.whatsapp-button {
    width: 100%;
    margin-top: 7px;
    min-height: 37px;
    border: 0;
    border-radius: 18px;
    background: #25d366;
    color: #fff;
    cursor: pointer;
    font-size: 11px;
}

.transcript-status {
    min-height: 16px;
    margin-top: 5px;
    font-size: 10px;
    color: #666;
    text-align: center;
}

.waiting-status {
    display: flex;
    align-items: center;
    gap: 7px;
    width: fit-content;
    max-width: 82%;
    margin: 6px 8px 9px auto;
    padding: 4px 7px;
    color: rgba(70, 70, 70, .58);
    background: transparent;
    font-size: 10px;
    line-height: 1.6;
    direction: rtl;
}

.waiting-dots {
    display: inline-flex;
    gap: 3px;
    direction: ltr;
}

.waiting-dots i {
    width: 4px;
    height: 4px;
    display: block;
    border-radius: 50%;
    background: currentColor;
    opacity: .25;
    animation: chatWaitingDot 1.15s infinite ease-in-out;
}

.waiting-dots i:nth-child(2) { animation-delay: .16s; }
.waiting-dots i:nth-child(3) { animation-delay: .32s; }

@keyframes chatWaitingDot {
    0%, 60%, 100% { transform: translateY(0); opacity: .22; }
    30% { transform: translateY(-3px); opacity: .8; }
}

@media (max-width: 600px) {
    .chat-box {
        width: calc(100% - 20px);
        max-width: none;
        height: calc(100dvh - 20px);
        right: 10px;
        bottom: 10px;
        border-radius: 15px;
    }

    .chat-header {
        font-size: 13px;
    }

    .message {
        max-width: 86%;
        font-size: 11.5px;
    }
}


.callback-request {
    width: calc(100% - 16px);
    margin: 8px;
    padding: 10px;
    border: 1px solid #f1d9a7;
    border-radius: 12px;
    background: #fff8e8;
    color: #554315;
    font-size: 11px;
    line-height: 1.8;
    text-align: right;
}

.callback-request-title {
    font-weight: bold;
    margin-bottom: 4px;
}

.callback-request-row {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

.callback-request-row input {
    flex: 1;
    min-width: 0;
    border: 1px solid #d8c79f;
    border-radius: 18px;
    padding: 9px 10px;
    outline: none;
    direction: ltr;
    text-align: left;
    font-size: 11px;
}

.callback-request-row input:focus {
    border-color: #009688;
}

.callback-request-row button {
    border: 0;
    border-radius: 18px;
    background: #25d366;
    color: #fff;
    padding: 0 12px;
    min-height: 37px;
    cursor: pointer;
    font-size: 10.5px;
    white-space: nowrap;
}

.callback-request-status {
    min-height: 16px;
    margin-top: 5px;
    font-size: 10px;
    color: #777;
}


@keyframes sendConversationBlink {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(37, 211, 102, .45);
    }
    50% {
        opacity: .62;
        transform: scale(1.04);
        box-shadow: 0 0 0 7px rgba(37, 211, 102, 0);
    }
}

/* حالت نمایش داخل ویجت سایت اصلی */
body.embed-mode {
    background: transparent;
}

body.embed-mode .chat-box {
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: none;
    height: 100dvh;
    border-radius: 0;
    box-shadow: none;
}

body.embed-mode .waiting-status {
    background: #f0f7f5;
    border-radius: 13px;
    padding: 7px 10px;
    color: #4d6f68;
}


.header-actions{display:flex;gap:6px;align-items:center}.finish-chat-button{border:1px solid rgba(255,255,255,.75);background:transparent;color:#fff;border-radius:15px;padding:5px 9px;cursor:pointer;font-size:10px}.phone-prompt-overlay{position:fixed;inset:0;background:rgba(0,0,0,.38);display:flex;align-items:center;justify-content:center;z-index:9999;padding:18px}.phone-prompt-overlay[hidden]{display:none}.phone-prompt-card{position:relative;width:min(390px,100%);background:#fff;border-radius:18px;padding:22px;box-shadow:0 16px 50px rgba(0,0,0,.25);text-align:right}.phone-prompt-card h3{margin:0 0 8px;font-size:16px}.phone-prompt-card p{font-size:12px;line-height:1.9;color:#555}.phone-prompt-card input{width:100%;box-sizing:border-box;border:1px solid #ccc;border-radius:12px;padding:11px;direction:ltr;text-align:left;margin:8px 0}.phone-prompt-card>button:not(.phone-prompt-close){width:100%;border:0;border-radius:12px;background:#25d366;color:#fff;padding:11px;cursor:pointer}.phone-prompt-close{position:absolute;left:10px;top:8px;border:0;background:none;font-size:24px;cursor:pointer;color:#777}#phone-prompt-status{font-size:11px;min-height:18px;margin-top:7px}.conversation-ended-note{margin:10px;text-align:center;font-size:11px;color:#39734a}.chat-input.disabled{opacity:.55;pointer-events:none}


/* شروع دوباره پس از پایان گفتگو */
.conversation-ended-note {
    margin: 12px 10px;
    padding: 12px;
    text-align: center;
    font-size: 12px;
    line-height: 1.8;
    color: #39734a;
    background: #f2faf7;
    border: 1px solid #cfe8de;
    border-radius: 14px;
}

.start-new-conversation-button {
    display: inline-block;
    margin-top: 8px;
    border: 0;
    border-radius: 18px;
    background: #009688;
    color: #fff;
    padding: 9px 16px;
    cursor: pointer;
    font-family: inherit;
    font-size: 11px;
}

.start-new-conversation-button:disabled {
    opacity: .65;
    cursor: wait;
}


.ai-disclaimer{
display:block;
margin-top:6px;
padding-top:5px;
border-top:1px solid rgba(255,255,255,.12);
font-size:10px;
opacity:.55;
line-height:1.5;
}
