/* استایل باکس پرسش و پاسخ هوشمند */
.ai-qa-box-container {
    max-width: 700px;
    margin: 30px auto;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    direction: rtl;
}

.ai-qa-box-header {
    text-align: center;
    margin-bottom: 25px;
    color: #ffffff;
}

.ai-qa-box-title {
    font-size: 24px;
    font-weight: 700;
    margin: 0 0 10px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #ffffff;
}

.ai-qa-icon {
    width: 28px;
    height: 28px;
    stroke: #ffffff;
    fill: none;
}

.ai-qa-box-subtitle {
    font-size: 14px;
    opacity: 0.9;
    color: #ffffff;
}

.ai-qa-box-stats {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 12px 20px;
    margin-bottom: 20px;
    text-align: center;
}

.ai-qa-remaining {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #ffffff;
    font-size: 14px;
    font-weight: 500;
}

.ai-qa-remaining svg {
    width: 16px;
    height: 16px;
}


.ai-qa-hidden {
    display: none !important;
}

.ai-qa-input-wrapper input[type="tel"] {
    width: 100%;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    font-size: 15px;
    font-family: inherit;
    transition: all 0.3s ease;
    direction: rtl;
    box-sizing: border-box;
}

.ai-qa-input-wrapper input[type="tel"]:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.ai-qa-box-form {
    background: #ffffff;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.ai-qa-input-wrapper {
    position: relative;
    margin-bottom: 15px;
}

.ai-qa-input-wrapper textarea {
    width: 100%;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    font-size: 15px;
    font-family: inherit;
    resize: vertical;
    transition: all 0.3s ease;
    direction: rtl;
    box-sizing: border-box;
}

.ai-qa-input-wrapper textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.ai-qa-char-counter {
    position: absolute;
    bottom: 10px;
    left: 15px;
    font-size: 12px;
    color: #999;
    background: rgba(255, 255, 255, 0.9);
    padding: 2px 8px;
    border-radius: 10px;
}

.ai-qa-char-counter span {
    font-weight: 600;
}

.ai-qa-submit-btn {
    width: 100%;
    padding: 15px 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    position: relative;
    overflow: hidden;
}

.ai-qa-submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.3);
}

.ai-qa-submit-btn:active {
    transform: translateY(0);
}

.ai-qa-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.ai-qa-btn-loader {
    display: flex;
    align-items: center;
}

.ai-qa-spinner {
    width: 20px;
    height: 20px;
    animation: rotate 2s linear infinite;
}

.ai-qa-spinner-path {
    stroke: #ffffff;
    stroke-linecap: round;
    animation: dash 1.5s ease-in-out infinite;
}

@keyframes rotate {
    100% {
        transform: rotate(360deg);
    }
}

@keyframes dash {
    0% {
        stroke-dasharray: 1, 150;
        stroke-dashoffset: 0;
    }
    50% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -35;
    }
    100% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -124;
    }
}

.ai-qa-messages {
    margin-top: 25px;
    max-height: 500px;
    overflow-y: auto;
    padding-right: 5px;
}

.ai-qa-message {
    background: #ffffff;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    animation: slideIn 0.3s ease;
    direction: rtl;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-qa-message-question {
    border-right: 4px solid #667eea;
    background: linear-gradient(135deg, #f5f7fa 0%, #ffffff 100%);
}

.ai-qa-message-answer {
    border-right: 4px solid #48bb78;
    background: linear-gradient(135deg, #f0fff4 0%, #ffffff 100%);
}

.ai-qa-message-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    font-weight: 600;
    font-size: 14px;
    color: #4a5568;
}

.ai-qa-message-header svg {
    width: 18px;
    height: 18px;
}

.ai-qa-message-question .ai-qa-message-header {
    color: #667eea;
}

.ai-qa-message-answer .ai-qa-message-header {
    color: #48bb78;
}

.ai-qa-message-content {
    color: #2d3748;
    line-height: 1.8;
    font-size: 15px;
}

.ai-qa-error {
    background: #fed7d7;
    color: #c53030;
    padding: 15px 20px;
    border-radius: 12px;
    margin-top: 20px;
    border-right: 4px solid #c53030;
    direction: rtl;
    font-size: 14px;
    animation: slideIn 0.3s ease;
}

/* اسکرول بار سفارشی */
.ai-qa-messages::-webkit-scrollbar {
    width: 8px;
}

.ai-qa-messages::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.ai-qa-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 10px;
}

.ai-qa-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* ریسپانسیو */
@media (max-width: 768px) {
    .ai-qa-box-container {
        margin: 20px 15px;
        padding: 20px;
    }
    
    .ai-qa-box-title {
        font-size: 20px;
    }
    
    .ai-qa-box-form {
        padding: 15px;
    }
}

/* --- شناور: دکمه و پنل چت --- */
.ai-qa-floating-wrapper {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
}

.ai-qa-fab {
    position: relative;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 16px 40px rgba(102, 126, 234, 0.45);
    overflow: hidden;
    padding: 0;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.ai-qa-fab:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 20px 45px rgba(102, 126, 234, 0.55);
}

.ai-qa-fab-bg {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.25), transparent 50%);
    pointer-events: none;
}

.ai-qa-fab-avatar {
    position: absolute;
    inset: 6px;
    border-radius: 50%;
    background: #fff url('chat-avatar.jpg') center center / cover no-repeat;
    box-shadow: inset 0 0 0 2px rgba(255,255,255,0.6);
}

.ai-qa-panel {
    width: min(420px, 92vw);
    max-height: min(80vh, 720px);
    background: #f7f8fb;
    border-radius: 18px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.18);
    overflow: hidden;
    display: none;
    flex-direction: column;
    border: 1px solid rgba(255,255,255,0.25);
}

.ai-qa-panel.open {
    display: flex;
    animation: panelFadeIn 0.25s ease;
}

@keyframes panelFadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.ai-qa-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

.ai-qa-panel-title {
    font-weight: 700;
    font-size: 16px;
}

.ai-qa-panel-close {
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    font-size: 18px;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.ai-qa-panel-close:hover {
    background: rgba(255,255,255,0.25);
}

.ai-qa-panel-body {
    padding: 12px 12px 16px;
    overflow-y: auto;
}

.ai-qa-panel-body .ai-qa-box-container {
    box-shadow: none;
    margin: 0;
}

.ai-qa-panel-body .ai-qa-messages {
    max-height: 360px;
}

@media (max-width: 640px) {
    .ai-qa-floating-wrapper {
        bottom: 64px;
        right: 16px;
    }
    .ai-qa-fab {
        width: 58px;
        height: 58px;
    }
}





