/* تنظیمات اصلی */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

#ai-chat-wrapper {
    position: fixed;
    bottom: 0;
    right: 0;
    z-index: 999;
    font-family: 'Vazir', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    direction: rtl;
}

/* دکمه شناور پایین */
#chat-toggle {
    position: fixed;
    bottom: 90px;
    right: 30px;
    width: 70px;
    height: 70px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #ff6b9d 100%);
    color: white;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.4),
        0 0 0 10px rgba(102, 126, 234, 0.1),
        0 0 0 20px rgba(102, 126, 234, 0.05);
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 100000;
    overflow: visible;
}

#chat-toggle:hover {
    transform: scale(1.15) rotate(10deg);
    box-shadow: 0 15px 40px rgba(102, 126, 234, 0.6),
        0 0 0 15px rgba(102, 126, 234, 0.15),
        0 0 0 30px rgba(102, 126, 234, 0.08);
}

.chat-icon-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.chat-pulse {
    position: absolute;
    top: -10px;
    right: -10px;
    left: -10px;
    bottom: -10px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    opacity: 0;
    animation: pulse-ring 2s infinite;
    z-index: -1;
}

.notification-badge {
    position: absolute;
    top: -8px;
    left: -8px;
    background: linear-gradient(135deg, #ff6b9d 0%, #ff4757 100%);
    color: white;
    font-size: 11px;
    font-weight: 800;
    padding: 4px 8px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 4px;
    box-shadow: 0 4px 12px rgba(255, 107, 157, 0.4);
    animation: notification-pulse 1.5s infinite;
    z-index: 2;
}

.notification-pulse {
    width: 6px;
    height: 6px;
    background: white;
    border-radius: 50%;
    animation: blink 1s infinite;
}

/* پنل چت - بازشونده از پایین */
#ai-chat-box {
    position: fixed;
    bottom: 100px;
    right: 25px;
    width: 420px;
    height: 0;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 25px 25px 25px 25px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.2),
        0 0 0 1px rgba(255, 255, 255, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    display: none;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(100px) scale(0.9);
    transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    border: 1px solid rgba(255, 255, 255, 0.3);
    z-index: 99998;
}

#ai-chat-box.active {
    height: 680px;
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* هدر چت */
.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    position: relative;
    overflow: hidden;
}

.chat-header::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.1) 50%, transparent 70%);
    animation: shimmer 3s infinite;
}

.chat-title {
    display: flex;
    align-items: center;
    gap: 15px;
}

.ai-avatar {
    position: relative;
    animation: float 3s ease-in-out infinite;
}

.ai-avatar-svg {
    filter: drop-shadow(0 8px 16px rgba(102, 126, 234, 0.4));
}

.chat-title-text h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 5px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4cd964;
    box-shadow: 0 0 10px #4cd964;
    animation: pulse 2s infinite;
}

.status-text {
    font-size: 13px;
    opacity: 0.9;
    font-weight: 500;
}

.header-actions {
    display: flex;
    gap: 10px;
}

.minimize-btn, .close-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.minimize-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.1);
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: rotate(90deg);
}

/* فرم ورود اطلاعات */
#ai-chat-start {
    padding: 30px;
    display: flex;
    flex-direction: column;
    gap: 0px;
    flex: 1;
    overflow-y: auto;
    background: linear-gradient(135deg, #f8f9ff 0%, #ffffff 100%);
}

.welcome-section {
    text-align: center;
    padding: 20px 0;
}

.welcome-icon {
    margin-bottom: 20px;
    animation: bounce 2s infinite;
}

.welcome-content h3 {
    color: #2d3748;
    margin-bottom: 12px;
    font-size: 24px;
    font-weight: 700;
}

.welcome-content p {
    color: #4a5568;
    font-size: 15px;
    line-height: 1.6;
    opacity: 0.9;
}

.input-section {
    background: white;
    padding: 25px;
    border-radius: 20px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(102, 126, 234, 0.1);
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 25px;
}

.input-with-icon {
    position: relative;
}

.input-icon {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
}

#ai-chat-start input {
    padding: 16px 50px 16px 20px;
    border-radius: 15px;
    border: 2px solid #e2e8f0;
    outline: none;
    width: 100%;
    font-size: 15px;
    transition: all 0.3s ease;
    background: white;
    color: #2d3748;
}

#ai-chat-start input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
    background: white;
}

#ai-chat-start input::placeholder {
    color: #a0aec0;
}

.features-section {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 25px;
    padding: 15px;
    background: #f7fafc;
    border-radius: 12px;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #4a5568;
}

.start-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 18px 30px;
    border-radius: 15px;
    cursor: pointer;
    font-weight: 600;
    font-size: 16px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.3);
    position: relative;
    overflow: hidden;
}

.start-btn::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.2) 50%, transparent 70%);
    transform: translateX(100%);
}

@media (max-width: 768px) {
    .start-btn span {
        font-size: 14px;
    }
}

.start-btn:hover::before {
    animation: slide 1s ease;
}

.start-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
}

.btn-icon {
    transition: transform 0.3s ease;
}

.start-btn:hover .btn-icon {
    transform: translateX(5px);
}

/* بخش پیام‌ها */
.messages {
    flex: 1;
    overflow-y: auto;
    padding: 25px;
    height: 400px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    background: linear-gradient(180deg, #f8f9ff 0%, #ffffff 100%);
}

.messages .user, .messages .ai {
    max-width: 85%;
    padding: 18px 20px;
    border-radius: 22px;
    position: relative;
    animation: messageIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(10px);
}

.messages .user {
    align-self: flex-end;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 22px 22px 5px 22px;
}

.messages .ai {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.95);
    color: #2d3748;
    border-radius: 5px 22px 22px 22px;
    border: 1px solid rgba(102, 126, 234, 0.1);
}

.message-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.ai-avatar.small {
    width: 24px;
    height: 24px;
}

.ai-name {
    font-weight: 600;
    font-size: 14px;
    color: #667eea;
}

.message-content p {
    margin: 0;
    line-height: 1.6;
    font-size: 15px;
}

.timestamp {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.7);
    margin-top: 8px;
    text-align: left;
}

.messages .ai .timestamp {
    color: #a0aec0;
    text-align: right;
}

/* ورودی پیام */
.input-area {
    padding: 20px;
    left: 50%;
    transform: translateX(-50%);
    position: fixed;
    bottom: 0;
    background: white;
    border-top: 1px solid rgba(102, 126, 234, 0.1);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.05);
}

.input-container {
    display: flex;
    gap: 12px;
    margin-bottom: 15px;
}

.attach-btn, .send-btn {
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.attach-btn:hover {
    border-color: #667eea;
    background: #f8f9ff;
}

.send-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.send-btn:hover {
    transform: scale(1.1) rotate(15deg);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.input-area input {
    flex: 1;
    border-radius: 25px;
    padding: 16px 20px;
    border: 2px solid #e2e8f0;
    outline: none;
    font-size: 15px;
    transition: all 0.3s ease;
    background: #f8f9ff;
    color: #2d3748;
}

.input-area input:focus {
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

.input-area input::placeholder {
    color: #a0aec0;
}

.suggestions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.suggestion-label {
    font-size: 12px;
    color: #718096;
    font-weight: 500;
}

.suggestion-chips {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.suggestion-chip {
    padding: 8px 16px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    font-size: 13px;
    color: #4a5568;
    cursor: pointer;
    transition: all 0.3s ease;
}

.suggestion-chip:hover {
    background: #f8f9ff;
    border-color: #667eea;
    color: #667eea;
    transform: translateY(-2px);
}

/* انیمیشن‌ها */
@keyframes pulse-ring {
    0% {
        transform: scale(0.8);
        opacity: 0.5;
    }

    80%, 100% {
        transform: scale(1.4);
        opacity: 0;
    }
}

@keyframes notification-pulse {
    0%, 100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

@keyframes slide {
    to {
        transform: translateX(-100%);
    }
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.9);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

@keyframes blink {
    0%, 100% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }
}

/* اسکرول بار سفارشی */
.messages::-webkit-scrollbar {
    width: 8px;
}

.messages::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
}

.messages::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
}

.messages::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
}

/* ریسپانسیو */
@media (max-width: 480px) {
    #chat-toggle {
        bottom: 90px;
        right: 20px;
        width: 60px;
        height: 60px;
    }

    #ai-chat-box {
        width: calc(100vw - 40px);
        right: 20px;
        bottom: 90px;
    }

    #ai-chat-box.active {
        height: 85vh;
    }

    .messages .user, .messages .ai {
        max-width: 90%;
    }
}

/* تاریکی پس زمینه هنگام باز بودن چت */
.chat-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    z-index: 997;
    display: none;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* استایل‌های اضافی */
.error {
    border-color: #ff4757 !important;
    animation: shake 0.5s ease;
}

.error-message {
    color: #ff4757;
    font-size: 12px;
    margin-top: 5px;
    animation: fadeInUp 0.3s ease;
}

.typing-message {
    opacity: 0.8;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    margin-top: 10px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #667eea;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }

    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-5px);
    }

    20%, 40%, 60%, 80% {
        transform: translateX(5px);
    }
}

@keyframes typing {
    0%, 80%, 100% {
        opacity: 0;
        transform: scale(0.8);
    }

    40% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-out {
    animation: fadeOut 0.3s ease forwards;
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }

    to {
        opacity: 0;
        transform: translateY(-20px);
    }
}