/* ================= متغیرها ================= */
.fse-wrapper {
    --fse-primary: #2c4bff;
    --fse-primary-hover: #1a35cc;
    --fse-green: #10b981;
    position: fixed;
    bottom: 30px;
    z-index: 99999;
    direction: rtl;
    font-family: 'Vazirmatn', Tahoma, sans-serif;
}

.fse-wrapper.fse-pos-right { right: 30px; left: auto; }
.fse-wrapper.fse-pos-left  { left: 30px; right: auto; }

.fse-wrapper * { margin: 0; padding: 0; box-sizing: border-box; }

/* =========================================================
   دکمه شناور — حالت پیش‌فرض (دایره)
   ========================================================= */
.fse-fab {
    background: var(--fse-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    width: 70px;
    height: 70px;
    border-radius: 50px;
    padding: 0;
    box-shadow: 0 10px 25px rgba(44, 75, 255, 0.4);
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                border-radius 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                padding 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    outline: none;
    touch-action: manipulation;
}

/* =========================================================
   ★ حالت باز (فقط با کلاس active) — با !important برای اطمینان ★
   ========================================================= */
.fse-wrapper.active .fse-fab {
    width: 285px !important;
    padding: 0 15px !important;
    border-radius: 35px !important;
    justify-content: flex-start !important;
}

.fse-fab-content {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    gap: 0;
    transition: gap 0.3s ease;
}

.fse-wrapper.active .fse-fab-content {
    justify-content: flex-start !important;
    gap: 12px !important;
}

.fse-fab-icon {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    color: currentColor;
}

.fse-fab-icon svg { width: 32px; height: 32px; }

/* آیکون‌های پیش‌فرض و ضربدر */
.fse-icon-default { display: flex; }
.fse-icon-close   { display: none; width: 32px; height: 32px; }

.fse-wrapper.active .fse-icon-default { display: none !important; }
.fse-wrapper.active .fse-icon-close   { display: block !important; }

/* نقطه سبز داخل دکمه */
.fse-fab .fse-status-dot { display: block; }
.fse-wrapper.active .fse-fab .fse-status-dot { display: none !important; }

/* نقطه سبز عمومی */
.fse-status-dot {
    position: absolute;
    top: -2px;
    left: -2px;
    width: 14px;
    height: 14px;
    background-color: var(--fse-green);
    border: 2px solid var(--fse-primary);
    border-radius: 50%;
    animation: fse-pulse 2s infinite;
}

.fse-status-dot.fse-status-inline {
    position: static;
    border: none;
    width: 10px;
    height: 10px;
    animation: none;
    display: inline-block !important;
    border-radius: 50%;
    background-color: var(--fse-green);
}

@keyframes fse-pulse {
    0%   { transform: scale(1); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70%  { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* متن‌های دکمه */
.fse-fab-text {
    display: flex;
    flex-direction: column;
    text-align: right;
    white-space: nowrap;
    max-width: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-width 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
}

.fse-wrapper.active .fse-fab-text {
    max-width: 200px !important;
    opacity: 1 !important;
}

.fse-fab-title { font-size: 0.95rem; font-weight: 700; }
.fse-fab-subtitle { font-size: 0.75rem; opacity: 0.85; }

/* ================= پنجره چت ================= */
.fse-chat-window {
    position: absolute;
    bottom: 90px;
    width: 380px;
    background: #fff;
    border-radius: 24px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(20px) scale(0.95);
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.3s;
    display: flex;
    flex-direction: column;
}

.fse-wrapper.fse-pos-right .fse-chat-window { right: 0; transform-origin: bottom right; }
.fse-wrapper.fse-pos-left  .fse-chat-window { left: 0; transform-origin: bottom left; }

.fse-wrapper.active .fse-chat-window {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    transform: translateY(0) scale(1) !important;
}

/* هدر */
.fse-chat-header {
    background: var(--fse-primary);
    color: #fff;
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.fse-header-info { display: flex; align-items: center; gap: 12px; }

.fse-header-icon {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
}

.fse-header-icon svg { width: 24px; height: 24px; }

.fse-header-text h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 4px; }
.fse-header-text p  { font-size: 0.75rem; opacity: 0.9; display: flex; align-items: center; gap: 6px; }

.fse-chat-close-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #fff;
    flex-shrink: 0;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.fse-chat-close-btn:hover { background: rgba(255, 255, 255, 0.3); }
.fse-chat-close-btn svg   { width: 18px; height: 18px; stroke: currentColor; }

/* بدنه */
.fse-chat-body { padding: 24px; background: #fff; }

.fse-chat-desc {
    font-size: 0.85rem;
    color: #64748b;
    line-height: 1.6;
    margin-bottom: 20px;
    text-align: center;
}

/* باکس تماس */
.fse-contact-box {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #eef2ff;
    padding: 14px 16px;
    border-radius: 16px;
    text-decoration: none;
    color: inherit;
    margin-bottom: 24px;
    flex-wrap: nowrap;
}

.fse-box-icon {
    width: 44px;
    height: 44px;
    background: #fff;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.fse-box-icon svg { width: 22px; height: 22px; }

.fse-box-text {
    display: flex;
    flex-direction: row;
    align-items: center;
    flex-grow: 1;
    gap: 10px;
}

.fse-box-text span   { font-size: 0.85rem; color: #64748b; font-weight: 500; white-space: nowrap; }
.fse-box-text strong { font-size: 1rem; color: #1e293b; direction: ltr; text-align: left; margin-right: auto; white-space: nowrap; }

/* پیام‌رسان‌ها */
.fse-messengers { margin-bottom: 24px; }
.fse-section-title { display: block; font-size: 0.85rem; color: #64748b; margin-bottom: 12px; }

.fse-messengers-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.fse-messenger-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px 8px;
    background: #f8fafc;
    border-radius: 12px;
    text-decoration: none;
    color: #1e293b;
    border: 1px solid transparent;
    transition: background 0.3s, border-color 0.3s, transform 0.3s;
}

.fse-messenger-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--fse-messenger-icon-color, #25D366);
}

.fse-messenger-icon svg {
    width: 28px;
    height: 28px;
    fill: var(--fse-messenger-icon-color, #25D366);
}

.fse-messenger-label { font-size: 0.75rem; font-weight: 500; }

/* دکمه مشاوره */
.fse-consultation-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    background: var(--fse-primary);
    color: #fff;
    padding: 16px;
    border-radius: 12px;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.95rem;
    transition: background 0.3s;
}

.fse-consultation-btn svg   { width: 20px; height: 20px; stroke: currentColor; }

/* ================= موبایل ================= */
@media (max-width: 480px) {
    .fse-wrapper.fse-pos-right { right: 15px; }
    .fse-wrapper.fse-pos-left  { left: 15px; }

    /* پنجره چت: وسط صفحه با ۱۵ پیکسل حاشیه از دو طرف */
    .fse-wrapper .fse-chat-window {
        position: fixed !important;
        bottom: 85px !important;
        left: 15px !important;
        right: 15px !important;
        width: auto !important;
        max-width: none !important;
        transform-origin: bottom center !important;
    }

    /* ★ دکمه باز شده در موبایل ★ */
    .fse-wrapper.active .fse-fab {
        width: 240px !important;
        height: 58px !important;
        padding: 0 12px !important;
        border-radius: 29px !important;
    }

    .fse-fab { height: 58px; }
    .fse-fab-icon { width: 34px; height: 34px; }
    .fse-fab-icon svg { width: 24px; height: 24px; }
    .fse-icon-close { width: 24px; height: 24px; }
    .fse-fab-title { font-size: 0.78rem; }
    .fse-fab-subtitle { font-size: 0.62rem; }

    .fse-wrapper.active .fse-fab-text {
        max-width: 150px !important;
        opacity: 1 !important;
    }

    .fse-chat-body { padding: 18px 16px; }
    .fse-chat-header { padding: 16px 18px; }
    .fse-header-icon { width: 38px; height: 38px; }
    .fse-header-icon svg { width: 20px; height: 20px; }
    .fse-header-text h3 { font-size: 1rem; }
    .fse-messengers-grid { gap: 8px; }
    .fse-messenger-item { padding: 10px 4px; }
    .fse-messenger-icon svg { width: 24px; height: 24px; }
    .fse-messenger-label { font-size: 0.7rem; }
}