/* Chatbot Widget - نسخه اصلاح شده با z-index بالا */
.chatbot-widget {
    position: fixed;
    bottom: 100px;
    right: 20px;
    z-index: 999999 !important; /* خیلی بالا برای قرار گرفتن روی همه چیز */
    font-family: 'Vazirmatn', sans-serif;
}

.chatbot-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7c3aed, #4f46e5);
    border: none;
    color: white;
    font-size: 26px;
    cursor: pointer;
    box-shadow: 0 8px 30px rgba(124, 58, 237, 0.6);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    animation: float-bot 3s ease-in-out infinite;
    z-index: 999999 !important;
}

@keyframes float-bot {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.chatbot-toggle:hover {
    transform: scale(1.1) translateY(-5px);
    box-shadow: 0 12px 40px rgba(124, 58, 237, 0.7);
}

.chatbot-toggle .badge {
    position: absolute;
    top: -3px;
    right: -3px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse-badge 2s infinite;
}

@keyframes pulse-badge {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.3); }
}

/* ========== کانتینر چت ========== */
.chatbot-container {
    position: fixed !important;
    bottom: 180px !important;
    right: 20px !important;
    width: 400px !important;
    max-width: calc(100vw - 40px) !important;
    height: 550px !important;
    max-height: calc(100vh - 220px) !important;
    background: #0d0720 !important;
    border-radius: 20px !important;
    border: 1px solid rgba(124, 58, 237, 0.3) !important;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.9), 0 0 60px rgba(124, 58, 237, 0.15) !important;
    display: none !important;
    flex-direction: column !important;
    overflow: hidden !important;
    animation: slideUp 0.35s ease !important;
    direction: rtl !important;
    z-index: 999999 !important; /* خیلی بالا */
    transform-origin: bottom right !important;
}

.chatbot-container.active {
    display: flex !important;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.92);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ========== هدر ========== */
.chatbot-header {
    background: linear-gradient(135deg, #1a0f2e, #2a1a4a);
    padding: 14px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    border-bottom: 2px solid rgba(124, 58, 237, 0.2);
    min-height: 60px;
}

.chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatbot-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7c3aed, #4f46e5);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: white;
    flex-shrink: 0;
    box-shadow: 0 0 25px rgba(124, 58, 237, 0.3);
}

.chatbot-header-text h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 800;
    color: #fff;
    letter-spacing: 0.5px;
}

.chatbot-header-text p {
    margin: 0;
    font-size: 11px;
    color: #dbbaff;
    opacity: 0.7;
}

.chatbot-close {
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: #dbbaff;
    font-size: 18px;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 8px;
    transition: all 0.3s;
    flex-shrink: 0;
}

.chatbot-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

/* ========== پیام‌ها ========== */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px 16px;
    background: #0d0720;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
}

.chatbot-messages::-webkit-scrollbar {
    width: 4px;
}

.chatbot-messages::-webkit-scrollbar-track {
    background: rgba(124, 58, 237, 0.05);
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: #7c3aed;
    border-radius: 10px;
}

/* ========== پیام‌ها ========== */
.message {
    max-width: 88%;
    padding: 10px 14px;
    border-radius: 12px;
    word-wrap: break-word;
    animation: fadeInMessage 0.3s ease;
    line-height: 1.7;
    font-size: 13.5px;
}

@keyframes fadeInMessage {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-bot {
    align-self: flex-start;
    background: #1a0f2e;
    border: 1px solid rgba(124, 58, 237, 0.15);
    border-bottom-left-radius: 4px;
    color: #e8e0f0;
}

.message-bot strong {
    color: #dbbaff;
}

.message-user {
    align-self: flex-end;
    background: linear-gradient(135deg, #7c3aed, #5b21b6);
    color: white;
    border-bottom-right-radius: 4px;
}

.message-time {
    font-size: 9px;
    opacity: 0.5;
    margin-top: 4px;
    display: block;
    direction: ltr;
    text-align: left;
}

.message-user .message-time {
    color: rgba(255, 255, 255, 0.6);
}

/* ========== تایپ ========== */
.typing-indicator {
    display: none;
    align-self: flex-start;
    background: #1a0f2e;
    padding: 10px 16px;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(124, 58, 237, 0.1);
    gap: 6px;
    align-items: center;
}

.typing-indicator.active {
    display: flex;
}

.typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #7c3aed;
    animation: typingBounce 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

.typing-indicator span:last-child {
    color: #dbbaff;
    font-size: 12px;
    margin-right: 8px;
    opacity: 0.7;
}

@keyframes typingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.3;
    }
    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* ========== ورودی ========== */
.chatbot-input-area {
    padding: 10px 14px 14px;
    background: #0d0720;
    border-top: 1px solid rgba(124, 58, 237, 0.1);
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.chatbot-input-area input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid rgba(124, 58, 237, 0.2);
    border-radius: 10px;
    font-size: 13px;
    font-family: 'Vazirmatn', sans-serif;
    outline: none;
    transition: all 0.3s;
    background: #1a0f2e;
    color: #e8e0f0;
    direction: rtl;
    min-width: 0;
}

.chatbot-input-area input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.chatbot-input-area input:focus {
    border-color: #7c3aed;
    box-shadow: 0 0 20px rgba(124, 58, 237, 0.1);
    background: #22143a;
}

.chatbot-input-area button {
    padding: 10px 18px;
    background: linear-gradient(135deg, #7c3aed, #4f46e5);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    flex-shrink: 0;
}

.chatbot-input-area button:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 20px rgba(124, 58, 237, 0.4);
}

.chatbot-input-area button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

/* ========== دکمه تلفن ========== */
.floating-call {
    z-index: 999998 !important;
    bottom: 100px !important;
}

/* ========== RESPONSIVE ========== */

/* تبلت و موبایل بزرگ */
@media (max-width: 992px) {
    .chatbot-container {
        width: 380px !important;
        height: 500px !important;
        max-height: calc(100vh - 200px) !important;
        bottom: 170px !important;
    }
}

/* موبایل */
@media (max-width: 768px) {
    .chatbot-widget {
        bottom: 80px;
        right: 12px;
    }
    
    .chatbot-toggle {
        width: 52px;
        height: 52px;
        font-size: 22px;
    }
    
    .chatbot-container {
        position: fixed !important;
        width: 100% !important;
        max-width: 100% !important;
        height: 100% !important;
        max-height: 100% !important;
        bottom: 0 !important;
        right: 0 !important;
        left: 0 !important;
        top: 0 !important;
        border-radius: 0 !important;
        border: none !important;
        z-index: 999999 !important;
        animation: slideUpMobile 0.35s ease !important;
    }
    
    @keyframes slideUpMobile {
        from {
            opacity: 0;
            transform: translateY(50px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
    
    .chatbot-header {
        padding: 12px 14px;
        min-height: 54px;
        border-radius: 0 !important;
    }
    
    .chatbot-avatar {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
    
    .chatbot-header-text h3 {
        font-size: 14px;
    }
    
    .chatbot-header-text p {
        font-size: 10px;
    }
    
    .chatbot-messages {
        padding: 12px 14px;
    }
    
    .message {
        font-size: 13px;
        padding: 9px 12px;
        max-width: 92%;
    }
    
    .chatbot-input-area {
        padding: 8px 12px 12px;
    }
    
    .chatbot-input-area input {
        font-size: 14px;
        padding: 10px 12px;
    }
    
    .chatbot-input-area button {
        padding: 10px 16px;
        min-width: 42px;
        font-size: 15px;
    }
    
    .floating-call {
        bottom: 80px !important;
    }
}

/* موبایل خیلی کوچک */
@media (max-width: 400px) {
    .chatbot-widget {
        bottom: 70px;
        right: 10px;
    }
    
    .chatbot-toggle {
        width: 48px;
        height: 48px;
        font-size: 20px;
    }
    
    .chatbot-container {
        bottom: 0 !important;
    }
    
    .chatbot-header {
        padding: 10px 12px;
        min-height: 48px;
    }
    
    .chatbot-header-text h3 {
        font-size: 13px;
    }
    
    .chatbot-messages {
        padding: 10px 12px;
    }
    
    .message {
        font-size: 12.5px;
        padding: 8px 11px;
        max-width: 95%;
    }
    
    .chatbot-input-area {
        padding: 6px 10px 10px;
        gap: 6px;
    }
    
    .chatbot-input-area input {
        font-size: 13px;
        padding: 8px 10px;
    }
    
    .chatbot-input-area button {
        padding: 8px 14px;
        min-width: 38px;
        font-size: 14px;
    }
}

/* صفحه‌های بسیار بلند (مثل آیفون 14 Pro Max) */
@media (max-height: 700px) {
    .chatbot-container {
        height: 80vh !important;
        max-height: 80vh !important;
        bottom: 80px !important;
    }
}

@media (max-height: 600px) {
    .chatbot-container {
        height: 70vh !important;
        max-height: 70vh !important;
        bottom: 70px !important;
    }
}

/* صفحه‌های بسیار عریض */
@media (min-width: 1400px) {
    .chatbot-container {
        width: 450px !important;
        height: 600px !important;
        max-height: calc(100vh - 200px) !important;
    }
}