/* Dr Shafiei Chatbot - سازگار با وردپرس 5.9+ */
#drsc-chatbot-root {
    --drsc-primary: #0d6efd;
    --drsc-radius: 16px;
    font-family: Tahoma, "Segoe UI", sans-serif;
    direction: rtl;
    z-index: 99999;
    position: fixed;
    bottom: 24px;
}

#drsc-chatbot-root.drsc-right {
    right: 24px;
    left: auto;
}

#drsc-chatbot-root.drsc-left {
    left: 24px;
    right: auto;
}

/* دکمه شناور */
.drsc-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--drsc-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0,0,0,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.drsc-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(0,0,0,0.3);
}

.drsc-toggle svg {
    display: block;
}

/* پنجره چت */
.drsc-window {
    position: absolute;
    bottom: 76px;
    width: 360px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: var(--drsc-radius);
    box-shadow: 0 10px 40px rgba(0,0,0,0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #e5e7eb;
}

#drsc-chatbot-root.drsc-right .drsc-window {
    right: 0;
}

#drsc-chatbot-root.drsc-left .drsc-window {
    left: 0;
}

/* هدر */
.drsc-header {
    background: var(--drsc-primary);
    color: #fff;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-shrink: 0;
}

.drsc-header-info {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
}

.drsc-header-text {
    min-width: 0;
    overflow: hidden;
}

.drsc-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,0.4);
    background: #fff;
}

.drsc-title {
    font-size: 14px;
    font-weight: 700;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.drsc-status {
    font-size: 12px;
    opacity: 0.9;
}

.drsc-status-line {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    opacity: 0.95;
    margin-top: 2px;
}

.drsc-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.drsc-status-dot.drsc-online {
    background: #22c55e;
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.35);
}

.drsc-status-dot.drsc-offline {
    background: #94a3b8;
}

.drsc-hours {
    opacity: 0.85;
    font-size: 11px;
}

.drsc-whatsapp-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #25d366;
    color: #fff !important;
    font-size: 12.5px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 20px;
    text-decoration: none !important;
    transition: filter 0.15s ease;
}

.drsc-whatsapp-btn:hover {
    filter: brightness(1.08);
    color: #fff !important;
}

.drsc-whatsapp-btn svg {
    flex-shrink: 0;
}

.drsc-close {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    opacity: 0.85;
}

.drsc-close:hover {
    opacity: 1;
}

/* پیام‌ها */
.drsc-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.drsc-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.55;
    word-wrap: break-word;
}

.drsc-msg.bot {
    background: #fff;
    color: #1e293b;
    align-self: flex-start;
    border: 1px solid #e2e8f0;
    border-bottom-right-radius: 4px;
}

.drsc-msg.user {
    background: var(--drsc-primary);
    color: #fff;
    align-self: flex-end;
    border-bottom-left-radius: 4px;
}

.drsc-msg.system {
    background: #e0f2fe;
    color: #0369a1;
    align-self: center;
    font-size: 12.5px;
    text-align: center;
}

/* فرم لید — فشرده تا دکمه همیشه دیده شود */
.drsc-lead-form {
    padding: 10px 12px;
    background: #f1f5f9;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
    max-height: 52%;
    overflow-y: auto;
}

.drsc-lead-title {
    margin: 0 0 8px;
    font-size: 13px;
    font-weight: 600;
    color: #334155;
}

.drsc-lead-form input,
.drsc-lead-form textarea,
.drsc-lead-form select {
    width: 100%;
    padding: 8px 10px;
    margin-bottom: 6px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    box-sizing: border-box;
    direction: rtl;
    background: #fff;
}

.drsc-lead-form textarea {
    rows: 2;
    min-height: 40px;
    max-height: 56px;
    resize: none;
    line-height: 1.4;
}

.drsc-lead-form input:focus,
.drsc-lead-form textarea:focus,
.drsc-lead-form select:focus {
    outline: none;
    border-color: var(--drsc-primary);
}

.drsc-lead-actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.drsc-btn-primary {
    flex: 1;
    padding: 9px 10px;
    background: var(--drsc-primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.drsc-btn-primary:hover {
    filter: brightness(1.08);
}

.drsc-btn-secondary {
    flex: 0 0 auto;
    padding: 9px 12px;
    background: transparent;
    color: #64748b;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
}

/* وقتی فرم باز است پیام‌ها جمع می‌شوند */
.drsc-window.drsc-form-open .drsc-messages {
    flex: 1 1 auto;
    min-height: 60px;
    max-height: 28%;
}

.drsc-window.drsc-form-open .drsc-quick {
    display: none !important;
}

.drsc-window.drsc-form-open .drsc-input-area,
.drsc-window.drsc-form-open .drsc-footer-actions {
    display: none !important;
}

/* ورودی */
.drsc-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid #e2e8f0;
    background: #fff;
}

#drsc-input {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 13.5px;
    font-family: inherit;
    outline: none;
    direction: rtl;
}

#drsc-input:focus {
    border-color: var(--drsc-primary);
}

.drsc-send {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--drsc-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.drsc-send:hover {
    filter: brightness(1.1);
}

.drsc-send:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* فوتر */
.drsc-footer-actions {
    padding: 8px 14px 12px;
    text-align: center;
    background: #fff;
    border-top: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.drsc-link-btn {
    background: none;
    border: none;
    color: var(--drsc-primary);
    font-size: 12.5px;
    cursor: pointer;
    text-decoration: underline;
    padding: 4px;
}

.drsc-link-btn:hover {
    opacity: 0.85;
}

/* تایپینگ */
.drsc-typing {
    display: flex;
    gap: 4px;
    padding: 8px 12px;
    align-self: flex-start;
}

.drsc-typing span {
    width: 7px;
    height: 7px;
    background: #94a3b8;
    border-radius: 50%;
    animation: drsc-bounce 1.2s infinite ease-in-out;
}

.drsc-typing span:nth-child(2) { animation-delay: 0.15s; }
.drsc-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes drsc-bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-6px); }
}

/* موبایل */
@media (max-width: 480px) {
    #drsc-chatbot-root {
        bottom: 16px;
    }
    #drsc-chatbot-root.drsc-right { right: 12px; }
    #drsc-chatbot-root.drsc-left  { left: 12px; }

    .drsc-window {
        width: calc(100vw - 24px);
        height: calc(100vh - 100px);
        bottom: 70px;
        border-radius: 12px;
    }

    .drsc-toggle {
        width: 54px;
        height: 54px;
    }
}

.drsc-status-line {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.drsc-close {
    flex-shrink: 0;
}

.drsc-quick {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 12px;
    background: #fff;
    border-top: 1px solid #f1f5f9;
}

.drsc-chip {
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    color: #334155;
    border-radius: 16px;
    padding: 6px 10px;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
}

.drsc-chip:hover {
    border-color: var(--drsc-primary);
    color: var(--drsc-primary);
}

.drsc-lead-form select {
    width: 100%;
    padding: 9px 12px;
    margin-bottom: 8px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
}

body.drsc-chat-open {
    overflow: hidden;
}

@media (max-width: 768px) {
    #drsc-chatbot-root {
        bottom: 12px;
        right: 12px;
        left: auto;
    }
    #drsc-chatbot-root.drsc-left {
        left: 12px;
        right: auto;
    }

    .drsc-window {
        position: fixed !important;
        top: 8px !important;
        bottom: 8px !important;
        left: 8px !important;
        right: 8px !important;
        width: auto !important;
        height: auto !important;
        max-width: none !important;
        max-height: none !important;
        border-radius: 12px !important;
    }

    .drsc-header {
        padding: 8px 10px;
    }

    .drsc-avatar {
        width: 32px;
        height: 32px;
    }

    .drsc-title {
        font-size: 13px;
    }

    .drsc-hours {
        display: none;
    }

    .drsc-toggle {
        width: 52px;
        height: 52px;
    }
}


/* آیکون ربات روی دکمه شناور */
.drsc-toggle {
    overflow: hidden;
    animation: drsc-pulse 2.4s ease-in-out infinite;
}

.drsc-toggle .drsc-toggle-img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

.drsc-toggle .drsc-icon-chat {
    display: block;
}

@keyframes drsc-pulse {
    0%, 100% { transform: scale(1); box-shadow: 0 4px 20px rgba(0,0,0,0.25); }
    50% { transform: scale(1.06); box-shadow: 0 6px 28px rgba(0,0,0,0.32); }
}

.drsc-toggle:hover {
    animation: none;
}
