/* Public styles for Chatbot Pro */
#cbp-widget-root {
    position: fixed;
    z-index: 999999;
    font-family: "Vazirmatn", "IRANSans", Tahoma, sans-serif;
}

/*
 * Theme-compatibility reset
 * بعضی قالب‌ها (مثل Woodmart) روی button/input/textarea استایل‌های سراسری اعمال می‌کنند
 * که باعث خراب شدن ابعاد/پدینگ/پس‌زمینه دکمه‌ها و ورودی‌های ویجت می‌شود.
 * این ریست فقط داخل ریشه ویجت اعمال می‌شود تا به سایر بخش‌های سایت آسیبی نزند.
 */
#cbp-widget-root,
#cbp-widget-root * {
    box-sizing: border-box;
}

#cbp-widget-root button,
#cbp-widget-root input,
#cbp-widget-root textarea {
    font-family: inherit;
}

#cbp-widget-root button {
    -webkit-appearance: none;
    appearance: none;
    background: none;
    border: 0;
    padding: 0;
    margin: 0;
    line-height: 1;
}

/* Positions */
.cbp-position-bottom-right {
    bottom: var(--cbp-offset-y, 20px);
    right: var(--cbp-offset-x, 20px);
}
.cbp-position-bottom-left {
    bottom: var(--cbp-offset-y, 20px);
    left: var(--cbp-offset-x, 20px);
}
.cbp-position-top-right {
    top: var(--cbp-offset-y, 20px);
    right: var(--cbp-offset-x, 20px);
}
.cbp-position-top-left {
    top: var(--cbp-offset-y, 20px);
    left: var(--cbp-offset-x, 20px);
}

/* Window anchoring (prevent overflow on left / handle top positions) */
.cbp-position-bottom-left .cbp-chat-window,
.cbp-position-top-left .cbp-chat-window {
    left: 0;
    right: auto;
}

.cbp-position-top-right .cbp-chat-window,
.cbp-position-top-left .cbp-chat-window {
    top: 80px;
    bottom: auto;
}

.cbp-position-bottom-left .cbp-chat-window {
    transform-origin: bottom left;
}
.cbp-position-bottom-right .cbp-chat-window {
    transform-origin: bottom right;
}
.cbp-position-top-left .cbp-chat-window {
    transform-origin: top left;
}
.cbp-position-top-right .cbp-chat-window {
    transform-origin: top right;
}

/* Launcher button */
.cbp-launcher {
    width: 60px;
    height: 60px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: flex-end;
    background: #4f46e5;
    color: #fff;
    cursor: pointer;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.35);
    transition: transform 0.25s ease, box-shadow 0.25s ease, opacity 0.2s ease;
    animation: cbp-pop-in 0.45s ease-out;
}

.cbp-launcher:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 24px 55px rgba(15, 23, 42, 0.4);
}

.cbp-launcher-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 11px;
    font-weight: 500;
    text-align: center;
}

.cbp-launcher-icon {
    width: 26px;
    height: 26px;
    border-radius: 999px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: center;
    background: radial-gradient(circle at 30% 30%, #ffffff, rgba(255,255,255,0.1));
}

.cbp-launcher-icon svg {
    width: 18px;
    height: 18px;
}

/* Chat window */
.cbp-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    left: auto;
    width: 360px;
    max-width: 92vw;
    max-height: 520px;
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.35);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    animation: cbp-window-in 0.25s ease-out;
}

.cbp-chat-header {
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, rgba(79,70,229,1), rgba(56,189,248,1));
    color: #fff;
}

.cbp-chat-header-main {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cbp-chat-avatar {
    width: 34px;
    height: 34px;
    border-radius: 999px;
    background: rgba(255,255,255,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: flex-end;
}

.cbp-chat-avatar svg {
    width: 20px;
    height: 20px;
}

.cbp-chat-header-text {
    display: flex;
    flex-direction: column;
}

.cbp-chat-title {
    font-size: 13px;
    font-weight: 700;
}

.cbp-chat-subtitle {
    font-size: 11px;
    opacity: 0.9;
}

.cbp-chat-close {
    /* override aggressive theme button styles */
    background: transparent !important;
    border: none !important;
    color: #e5e7eb !important;
    cursor: pointer;
    padding: 4px !important;
    width: 28px !important;
    height: 28px !important;
    min-width: 28px !important;
    min-height: 28px !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 700;
    line-height: 1;
}

/* Messages */
.cbp-chat-body {
    padding: 10px 12px;
    background: #f3f4f6;
    flex: 1;
    overflow-y: auto;
}

.cbp-message {
    margin-bottom: 8px;
    display: flex;
    flex-direction: column;
    max-width: 90%;
}

.cbp-message-meta {
    font-size: 9px;
    margin-bottom: 3px;
    color: #6b7280;
}

.cbp-message-text {
    border-radius: 14px;
    padding: 8px 10px;
    font-size: 13px;
    line-height: 1.7;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.cbp-message-user {
    align-items: flex-end;
    margin-left: 0;
    margin-right: auto;
}

.cbp-message-user .cbp-message-text {
    background: #4f46e5;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.cbp-message-bot {
    align-items: flex-start;
}

.cbp-message-bot .cbp-message-text {
    background: #ffffff;
    color: #111827;
    border-bottom-left-radius: 4px;
}

/* Typing indicator */
.cbp-typing {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.cbp-typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: #9ca3af;
    animation: cbp-typing 1s infinite ease-in-out;
}

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

/* Footer input */
.cbp-chat-footer {
    border-top: 1px solid #e5e7eb;
    padding: 8px 10px;
    background: #ffffff;

    position: relative;
}

.cbp-input-wrap {
    display: flex;
    align-items: flex-end;
    gap: 6px;
}

.cbp-input {
    flex: 1;
    width: 100% !important;
    box-sizing: border-box !important;

    /* Avoid theme overrides that turn the textarea into a huge pill/oval (e.g. Woodmart) */
    border-radius: 12px !important;

    border: 1px solid #e5e7eb !important;
    padding: 10px 12px !important;
    margin: 0 !important;

    font-size: 16px; /* مهم برای جلوگیری از زوم ناخواسته در موبایل (iOS) */
    line-height: 1.4 !important;

    min-height: 42px !important;
    height: auto !important;
    resize: none;
    overflow-y: auto !important;
    max-height: 80px;

    background: #ffffff !important;
    color: #111827;
    outline: none;
    box-shadow: none !important;
}

.cbp-input:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.18) !important;
    border-color: rgba(79, 70, 229, 0.65) !important;
}

.cbp-send-btn {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    min-height: 32px !important;
    border-radius: 999px !important;
    border: none !important;
    cursor: pointer;
    display: flex !important;
    align-items: center;
    justify-content: center;
    align-self: flex-end;
    padding: 0 !important;
    background: #4f46e5 !important;
    color: #fff !important;
    line-height: 1;
}

.cbp-send-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.cbp-send-btn.cbp-loading {
    opacity: 0.85;
    cursor: default;
}

.cbp-spinner {
    width: 16px;
    height: 16px;
    border-radius: 999px;
    border: 2px solid rgba(255,255,255,0.6);
    border-top-color: rgba(255,255,255,1);
    animation: cbpSpin 0.8s linear infinite;
    display: inline-block;
}

@keyframes cbpSpin {
    to { transform: rotate(360deg); }
}

/* Status & errors */
.cbp-status-bar {
    font-size: 11px;
    color: #6b7280;
    padding: 4px 10px 6px;
}

.cbp-status-error {
    color: #b91c1c;
}

/* Sizes */
.cbp-size-small .cbp-chat-window {
    width: 300px;
    max-height: 420px;
}

.cbp-size-medium .cbp-chat-window {
    width: 360px;
    max-height: 520px;
}

.cbp-size-large .cbp-chat-window {
    width: 420px;
    max-height: 580px;
}

/* Dark mode */
.cbp-dark .cbp-chat-window {
    background: #020617;
    color: #e5e7eb;
    box-shadow: 0 24px 70px rgba(0,0,0,0.85);
}

.cbp-dark .cbp-chat-body {
    background: #020617;
}

.cbp-dark .cbp-message-bot .cbp-message-text {
    background: #111827;
    color: #e5e7eb;
}

.cbp-dark .cbp-message-user .cbp-message-text {
    background: #4f46e5;
}

.cbp-dark .cbp-chat-footer {
    background: #020617;
    border-color: #111827;
}

.cbp-dark .cbp-input {
    background: #020617 !important;
    color: #e5e7eb !important;
    border-color: #1f2937 !important;
}

/* Mobile tweaks */
@media (max-width: 600px) {
    .cbp-chat-window {
        bottom: 80px;
        right: 0;
        left: auto;
        width: calc(100vw - 24px);
        max-height: 80vh;
    }
}

/* Animations */
@keyframes cbp-pop-in {
    0% { transform: scale(0.7); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes cbp-window-in {
    0% { transform: translateY(20px) scale(0.96); opacity: 0; }
    100% { transform: translateY(0) scale(1); opacity: 1; }
}

@keyframes cbp-typing {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
    40% { transform: translateY(-3px); opacity: 1; }
}

/* Iran block overlay */
.cbp-iran-block {
    font-size: 12px;
    color: #b91c1c;
    background: #fee2e2;
    border-radius: 10px;
    padding: 6px 10px;
    margin: 4px 10px 8px;
}


/* Small credit text */
.cbp-chat-credit {
    margin-top: 6px;
    font-size: 11px;
    opacity: 0.6;
    text-align: center;
    direction: rtl;
}
.cbp-chat-credit a {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px dotted rgba(255,255,255,0.5);
}


.cbp-launcher-icon img.cbp-icon-image,
.cbp-chat-avatar img.cbp-icon-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    border-radius: 999px;
}



/* Pre-chat form */
.cbp-prechat {
    margin: 4px 0 6px;
    padding: 6px 8px;
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.06), rgba(56, 189, 248, 0.04));
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.5);
}

.cbp-prechat-title {
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 4px;
    color: #0f172a;
}

.cbp-prechat-input {
    width: auto;
    box-sizing: border-box;
    margin-bottom: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.7);
    background: #ffffff;
    font-size: 16px; /* مهم برای جلوگیری از زوم ناخواسته در موبایل */
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.cbp-prechat-input::placeholder {
    color: #9ca3af;
}

.cbp-prechat-input:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 1px rgba(79, 70, 229, 0.22);
    background-color: #ffffff;
}

.cbp-prechat-buttons {
    display: flex;
    gap: 6px;
    margin-top: 2px;
}

.cbp-prechat-submit,
.cbp-prechat-skip {
    flex: 1;
    border-radius: 999px;
    border: none;
    cursor: pointer;
    font-size: 12px;
    padding: 6px 8px;
}

.cbp-prechat-submit {
    background: #4f46e5;
    color: #fff;
}

.cbp-prechat-skip {
    background: rgba(148, 163, 184, 0.15);
    color: #475569;
}
/* Disable input when pre-chat is required */
.cbp-input-wrap.cbp-input-disabled {
    opacity: 0.5;
    pointer-events: none;
}


/* Override credit visibility for customizable text */
.cbp-chat-credit {
    display: none;
}
.cbp-chat-credit.cbp-chat-credit-custom {
    display: block;
}


/* FAQ */
.cbp-faq-entry {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;

    max-width: calc(100% - 40px);
    width: fit-content;
    /* floating (doesn't take a full line) */
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: -34px;
    z-index: 6;

    margin: 0 !important;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 800;
    line-height: 1;
    cursor: pointer;

    /* hard reset (avoid site/theme overriding button styles) */
    border: 1px solid rgba(0,0,0,0.10) !important;
    background: rgba(255,255,255,0.88) !important;
    color: #0f172a !important;
    outline: 0 !important;
    box-shadow: none !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.cbp-dark .cbp-faq-entry {
    background: rgba(2,6,23,0.55) !important;
    border-color: rgba(255,255,255,0.14) !important;
    color: rgba(255,255,255,0.92) !important;
}
.cbp-faq-panel {
    display: none;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    overflow: hidden;
    max-height: calc(100% - 110px);
}

.cbp-chat-wrapper.cbp-show-faq .cbp-chat-body {
    display: none;
}

.cbp-chat-wrapper.cbp-show-faq .cbp-faq-panel {
    display: flex;
}

.cbp-faq-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.cbp-faq-title {
    font-weight: 800;
    font-size: 13px;
    opacity: 0.95;
}

.cbp-faq-back {
    border: 0 !important;
    background: transparent !important;
    padding: 2px 0 !important;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: rgba(15,23,42,0.90);
    opacity: 0.9;
}

.cbp-faq-back:hover{opacity:1; text-decoration: underline;}

.cbp-faq-back-ico{font-size: 14px; line-height: 1;}
.cbp-faq-back-txt{line-height: 1;}



.cbp-faq-list {
    overflow: auto;
    max-height: calc(100% - 44px);
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-right: 2px;
}

.cbp-faq-item {
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 14px;
    overflow: hidden;
    background: rgba(255,255,255,0.70);
}

.cbp-dark .cbp-faq-item {
    border-color: rgba(255,255,255,0.12);
    background: rgba(2,6,23,0.60);
}

.cbp-faq-q{
    color:#0f172a !important;

    width: 100%;
    text-align: right;
    appearance: none;
    -webkit-appearance: none;
    border: 0 !important;
    outline: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
    padding: 11px 12px;
    cursor: pointer;
    font-weight: 800;
    font-size: 13px;
    color: inherit;
    display: block;
}

.cbp-faq-q:hover {
    background: rgba(0,0,0,0.04);
}

.cbp-dark .cbp-faq-q:hover {
    background: rgba(255,255,255,0.06);
}

.cbp-faq-a {
    display: none;
    padding: 0 12px 12px 12px;
    font-size: 13px;
    line-height: 1.7;
    opacity: 0.92;
}

.cbp-faq-item.cbp-open .cbp-faq-a {
    display: block;
}

.cbp-widget button.cbp-faq-q {
    border: 0 !important;
}
.cbp-widget button.cbp-faq-q{border:0 !important;}

.cbp-faq-q:active, .cbp-faq-q:focus { color: #0f172a !important; }
.cbp-dark .cbp-faq-q:active, .cbp-dark .cbp-faq-q:focus { color: rgba(255,255,255,0.92) !important; }

/* FAQ color overrides */
.cbp-faq-q{color:#0f172a !important;}
.cbp-dark .cbp-faq-q{color:rgba(255,255,255,0.92) !important;}


.cbp-chat-wrapper.cbp-show-faq .cbp-faq-entry{display:none !important;}

.cbp-dark .cbp-faq-back{color: rgba(255,255,255,0.92) !important;}


/* Rich results inside chat messages */
.cbp-message-text .cbp-rich-lead {
    margin-bottom: 8px;
    line-height: 1.5;
}
.cbp-rich-results {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.cbp-rich-card {
    display: flex;
    gap: 10px;
    padding: 10px;
    border: 1px solid rgba(0,0,0,.08);
    border-radius: 12px;
    text-decoration: none;
    color: inherit;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}
.cbp-rich-thumb {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 10px;
    flex: 0 0 auto;
}
.cbp-rich-body {
    flex: 1 1 auto;
    min-width: 0;
}
.cbp-rich-title {
    font-weight: 700;
    line-height: 1.35;
    word-break: break-word;
    overflow-wrap: anywhere;
}
.cbp-rich-meta, .cbp-rich-price, .cbp-rich-excerpt {
    margin-top: 4px;
    font-size: 12px;
    opacity: .85;
    line-height: 1.35;
    word-break: break-word;
    overflow-wrap: anywhere;
}
.cbp-rich-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: flex-start;
}
.cbp-rich-btn {
    white-space: nowrap;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid rgba(0,0,0,.12);
    background: rgba(0,0,0,.04);
    cursor: pointer;
    font-size: 12px;
}
@media (max-width: 420px) {
    .cbp-rich-card {
        flex-wrap: wrap;
    }
    .cbp-rich-actions {
        width: 100%;
    }
    .cbp-rich-btn {
        width: 100%;
        text-align: center;
    }
}
