/* ============================================
   متغیرهای پایه
   ============================================ */
:root {
    --afc-primary: #25D366;
    --afc-bg: #ffffff;
    --afc-text: #1f2937;
    --afc-text-muted: #6b7280;
    --afc-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --afc-shadow-lg: 0 20px 40px -10px rgba(0, 0, 0, 0.15), 0 10px 20px -10px rgba(0, 0, 0, 0.1);
    --afc-radius: 16px;
    --afc-radius-sm: 12px;
}

/* ============================================
   ریست و تنظیمات عمومی
   ============================================ */
.afc-wrapper * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ============================================
   کانتینر اصلی
   ============================================ */
.afc-wrapper {
    position: fixed !important;
    bottom: 24px !important;
    z-index: 999999 !important;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    direction: rtl;
    line-height: 1.5;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-perspective: 1000;
    perspective: 1000;
    pointer-events: auto !important;
    -webkit-tap-highlight-color: transparent;
}

.afc-wrapper.afc-right {
    right: 24px !important;
    left: auto !important;
}

.afc-wrapper.afc-left {
    left: 24px !important;
    right: auto !important;
}

/* ============================================
   دکمه اصلی شناور
   ============================================ */
.afc-main-btn {
    width: 64px !important;
    height: 64px !important;
    border-radius: 50% !important;
    background: var(--afc-primary, #25D366) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15), 0 2px 6px rgba(0, 0, 0, 0.1) !important;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1) !important;
    border: none !important;
    outline: none !important;
    position: relative !important;
    z-index: 1000000 !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    touch-action: manipulation !important;
    user-select: none !important;
    -webkit-user-select: none !important;
}

.afc-main-btn:hover {
    transform: scale(1.08) !important;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2), 0 4px 10px rgba(0, 0, 0, 0.1) !important;
}

.afc-main-btn:active {
    transform: scale(0.95) !important;
}

.afc-main-btn svg {
    width: 30px !important;
    height: 30px !important;
    fill: #ffffff !important;
    transition: transform 0.3s ease !important;
    pointer-events: none !important;
}

.afc-wrapper.afc-open .afc-main-btn svg {
    transform: rotate(135deg) !important;
}

.afc-main-btn img.afc-custom-icon {
    width: 100% !important;
    height: 100% !important;
    border-radius: 50% !important;
    object-fit: cover !important;
    pointer-events: none !important;
}

/* ============================================
   انیمیشن پالس دکمه اصلی
   ============================================ */
@keyframes afc-pulse-ring {
    0% {
        transform: scale(0.9);
        opacity: 0.7;
    }
    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

.afc-main-btn::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--afc-primary, #25D366);
    animation: afc-pulse-ring 2s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
    z-index: -1;
    pointer-events: none;
}

.afc-wrapper.afc-open .afc-main-btn::before,
.afc-main-btn.afc-pulse-stopped::before {
    animation: none;
    display: none;
}

/* ============================================
   منوی کشویی
   ============================================ */
.afc-menu {
    position: absolute !important;
    bottom: 84px !important;
    right: 0 !important;
    width: 340px !important;
    background: var(--afc-bg, #ffffff) !important;
    border-radius: var(--afc-radius, 16px) !important;
    box-shadow: var(--afc-shadow-lg, 0 20px 40px -10px rgba(0, 0, 0, 0.15)) !important;
    padding: 20px !important;
    opacity: 0 !important;
    visibility: hidden !important;
    transform: translateY(20px) scale(0.95) !important;
    transition: all 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
    pointer-events: none !important;
    max-height: 70vh !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    border: 1px solid rgba(0, 0, 0, 0.05) !important;
    -webkit-overflow-scrolling: touch !important;
}

.afc-wrapper.afc-left .afc-menu {
    right: auto !important;
    left: 0 !important;
}

.afc-wrapper.afc-open .afc-menu {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0) scale(1) !important;
    pointer-events: auto !important;
}

/* هدر منو */
.afc-menu-header {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid #f3f4f6;
}

.afc-menu-header h3 {
    margin: 0 0 4px 0;
    font-size: 17px;
    font-weight: 600;
    color: var(--afc-text, #1f2937);
    line-height: 1.4;
}

.afc-menu-header p {
    margin: 0;
    font-size: 13px;
    color: var(--afc-text-muted, #6b7280);
    line-height: 1.5;
}

/* ============================================
   لیست آیتم‌های تماس
   ============================================ */
.afc-contacts-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.afc-contact-item {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    padding: 12px !important;
    border-radius: var(--afc-radius-sm, 12px) !important;
    transition: all 0.2s ease !important;
    text-decoration: none !important;
    background: transparent !important;
    cursor: pointer !important;
    -webkit-tap-highlight-color: transparent !important;
    touch-action: manipulation !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    outline: none !important;
    border: 1px solid transparent !important;
}

.afc-contact-item:hover,
.afc-contact-item:focus {
    background: #f9fafb !important;
    border-color: #e5e7eb !important;
    transform: translateX(-4px) !important;
}

.afc-contact-item:active {
    background: #f3f4f6 !important;
    transform: scale(0.98) !important;
}

/* تصویر کارشناس */
.afc-agent-img {
    width: 52px !important;
    height: 52px !important;
    border-radius: 50% !important;
    background: linear-gradient(135deg, #e5e7eb 0%, #d1d5db 100%) !important;
    flex-shrink: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: #9ca3af !important;
    overflow: hidden !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08) !important;
}

.afc-agent-img img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    border-radius: 50% !important;
}

.afc-agent-img svg {
    width: 26px !important;
    height: 26px !important;
    fill: currentColor !important;
}

/* اطلاعات کارشناس */
.afc-agent-info {
    flex: 1 !important;
    min-width: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 2px !important;
}

.afc-agent-name {
    font-size: 15px !important;
    font-weight: 600 !important;
    color: var(--afc-text, #1f2937) !important;
    margin: 0 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    line-height: 1.3 !important;
}

.afc-agent-number {
    font-size: 13px !important;
    color: var(--afc-text-muted, #6b7280) !important;
    margin: 0 !important;
    direction: ltr !important;
    text-align: right !important;
    font-variant-numeric: tabular-nums !important;
    line-height: 1.4 !important;
}

/* دکمه تماس */
.afc-call-btn {
    width: 40px !important;
    height: 40px !important;
    border-radius: 50% !important;
    background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    transition: all 0.2s ease !important;
    box-shadow: 0 2px 6px rgba(34, 197, 94, 0.2) !important;
}

.afc-call-btn svg {
    width: 20px !important;
    height: 20px !important;
    fill: #16a34a !important;
    transition: transform 0.2s ease !important;
}

.afc-contact-item:hover .afc-call-btn,
.afc-contact-item:focus .afc-call-btn {
    transform: scale(1.1) !important;
    box-shadow: 0 4px 10px rgba(34, 197, 94, 0.3) !important;
}

.afc-contact-item:hover .afc-call-btn svg,
.afc-contact-item:focus .afc-call-btn svg {
    transform: scale(1.1) !important;
}

/* ============================================
   سیستم نوتیفیکیشن (Toast)
   ============================================ */
.afc-toast-container {
    position: fixed !important;
    bottom: 24px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    z-index: 9999999 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    pointer-events: none !important;
    width: 90% !important;
    max-width: 400px !important;
}

.afc-toast {
    background: #1f2937 !important;
    color: #ffffff !important;
    padding: 14px 20px !important;
    border-radius: var(--afc-radius-sm, 12px) !important;
    font-size: 14px !important;
    white-space: nowrap !important;
    opacity: 0 !important;
    transform: translateY(20px) !important;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2) !important;
    font-family: system-ui, -apple-system, sans-serif !important;
    direction: rtl !important;
    text-align: center !important;
    pointer-events: auto !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.afc-toast.show {
    opacity: 1 !important;
    transform: translateY(0) !important;
}

/* ============================================
   واکنش‌گرا - تبلت (768px - 1024px)
   ============================================ */
@media (max-width: 1024px) {
    .afc-wrapper {
        bottom: 120px !important;
    }

    .afc-wrapper.afc-right {
        right: 20px !important;
    }

    .afc-wrapper.afc-left {
        left: 20px !important;
    }

    .afc-main-btn {
        width: 72px !important;
        height: 72px !important;
    }

    .afc-main-btn svg {
        width: 34px !important;
        height: 34px !important;
    }

    .afc-menu {
        width: 320px !important;
        bottom: 92px !important;
        padding: 18px !important;
    }

    .afc-agent-img {
        width: 48px !important;
        height: 48px !important;
    }

    .afc-call-btn {
        width: 38px !important;
        height: 38px !important;
    }
}

/* ============================================
   واکنش‌گرا - موبایل (کمتر از 768px)
   ============================================ */
@media (max-width: 768px) {
    .afc-wrapper {
        bottom: 120px !important;
    }

    .afc-wrapper.afc-right {
        right: 16px !important;
    }

    .afc-wrapper.afc-left {
        left: 16px !important;
    }

    .afc-main-btn {
        width: 68px !important;
        height: 68px !important;
    }

    .afc-main-btn svg {
        width: 32px !important;
        height: 32px !important;
    }

    .afc-menu {
        width: calc(100vw - 32px) !important;
        max-width: 340px !important;
        bottom: 88px !important;
        padding: 16px !important;
    }

    .afc-menu-header h3 {
        font-size: 16px !important;
    }

    .afc-menu-header p {
        font-size: 12px !important;
    }

    .afc-contact-item {
        padding: 10px !important;
        gap: 10px !important;
    }

    .afc-agent-img {
        width: 44px !important;
        height: 44px !important;
    }

    .afc-agent-name {
        font-size: 14px !important;
    }

    .afc-agent-number {
        font-size: 12px !important;
    }

    .afc-call-btn {
        width: 36px !important;
        height: 36px !important;
    }

    .afc-call-btn svg {
        width: 18px !important;
        height: 18px !important;
    }

    .afc-toast-container {
        bottom: 16px !important;
    }

    .afc-toast {
        padding: 12px 16px !important;
        font-size: 13px !important;
    }
}

/* ============================================
   واکنش‌گرا - موبایل کوچک (کمتر از 480px)
   ============================================ */
@media (max-width: 480px) {
    .afc-wrapper {
        bottom: 120px !important;
    }

    .afc-wrapper.afc-right {
        right: 12px !important;
    }

    .afc-wrapper.afc-left {
        left: 12px !important;
    }

    .afc-main-btn {
        width: 64px !important;
        height: 64px !important;
    }

    .afc-main-btn svg {
        width: 30px !important;
        height: 30px !important;
    }

    .afc-menu {
        width: calc(100vw - 24px) !important;
        bottom: 84px !important;
        padding: 14px !important;
    }

    .afc-contact-item {
        padding: 8px !important;
        gap: 8px !important;
    }

    .afc-agent-img {
        width: 40px !important;
        height: 40px !important;
    }

    .afc-agent-img svg {
        width: 22px !important;
        height: 22px !important;
    }

    .afc-call-btn {
        width: 34px !important;
        height: 34px !important;
    }

    .afc-call-btn svg {
        width: 16px !important;
        height: 16px !important;
    }
}

/* ============================================
   واکنش‌گرا - ارتفاع کم (کمتر از 600px)
   ============================================ */
@media (max-height: 600px) {
    .afc-menu {
        max-height: 60vh !important;
    }
}

/* ============================================
   واکنش‌گرا - حالت افقی (Landscape)
   ============================================ */
@media (max-height: 500px) and (orientation: landscape) {
    .afc-menu {
        max-height: 80vh !important;
        bottom: 70px !important;
    }
}