/* استایل ویجت چت */
#chat-support-widget {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 380px;
    height: 500px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-right: 4px solid var(--secondary-color-1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    display: none;
    flex-direction: column;
    z-index: 1000;
    overflow: hidden;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

#chat-support-widget.active {
    display: flex;
    animation: chatSlideIn 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes chatSlideIn {
    0% {
        opacity: 0;
        transform: translateY(20px) scale(0.9) translateX(-20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1) translateX(0);
    }
}

/* نشانگر مبدأ چت - اصلاح شده */
.chat-origin-indicator {
    position: absolute;
    bottom: -8px;
    right: 25px;
    width: 16px;
    height: 16px;
    background: var(--secondary-color-1);
    transform: rotate(45deg);
    border-radius: 2px;
    z-index: 1001;
}

/* هدر چت */
.chat-header {
    background: rgba(83, 130, 102, 0.9);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-logo {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--secondary-color-1);
    object-fit: cover;
}

.chat-title {
    display: flex;
    flex-direction: column;
    color: var(--light-text);
}

.chat-title span {
    font-weight: bold;
    font-size: 1.1rem;
}

.chat-subtitle {
    font-size: 0.8rem;
    opacity: 0.8;
    margin-top: 2px;
}

.chat-actions {
    display: flex;
    gap: 8px;
}

.chat-minimize,
.chat-close {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: var(--light-text);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.chat-minimize:hover,
.chat-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

/* بدنه چت */
.chat-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.05);
}

.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* استایل پیام‌ها */
.message {
    display: flex;
    gap: 12px;
    max-width: 85%;
    animation: messageSlide 0.3s ease;
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.support {
    align-self: flex-start;
}

.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--secondary-color-1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-color);
    font-size: 1.1rem;
    flex-shrink: 0;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.message.user .message-avatar {
    background: var(--primary-color);
    color: var(--light-text);
}

.message-content {
    background: rgba(255, 255, 255, 0.1);
    padding: 12px 16px;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
}

.message.user .message-content {
    background: rgba(199, 166, 98, 0.25);
    border: 1px solid rgba(199, 166, 98, 0.4);
}

.message-text {
    color: var(--light-text);
    line-height: 1.5;
    margin-bottom: 5px;
}

.message-time {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
    text-align: left;
}

.message.user .message-time {
    text-align: right;
}

.welcome-message {
    align-self: center;
    max-width: 90%;
    text-align: center;
    background: rgba(83, 130, 102, 0.2);
    border-radius: 15px;
    padding: 10px;
    border: 1px solid rgba(83, 130, 102, 0.3);
}

.welcome-message .message-content {
    background: none;
    border: none;
    padding: 5px;
}

/* فوتور چت */
.chat-footer {
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.1);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-input-container {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

#chat-input {
    flex: 1;
    padding: 12px 18px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 25px;
    color: var(--light-text);
    font-size: 0.9rem;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
}

#chat-input:focus {
    outline: none;
    border-color: var(--secondary-color-1);
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 0 0 2px rgba(199, 166, 98, 0.2);
}

#chat-input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.send-btn {
    background: var(--secondary-color-1);
    color: var(--text-color);
    border: none;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1.1rem;
    box-shadow: 0 4px 12px rgba(199, 166, 98, 0.3);
}

.send-btn:hover {
    background: var(--primary-color);
    color: var(--light-text);
    transform: scale(1.05) translateY(-2px);
    box-shadow: 0 6px 15px rgba(83, 130, 102, 0.4);
}

.send-btn:active {
    transform: scale(0.95) translateY(0);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.chat-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7);
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4CAF50;
    animation: statusPulse 2s infinite;
}

@keyframes statusPulse {
    0% { 
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.7);
    }
    50% {
        transform: scale(1.2);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(76, 175, 80, 0);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0);
    }
}

/* دکمه باز کردن چت */
.chat-toggle-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 70px;
    height: 70px;
    background: linear-gradient(135deg, var(--secondary-color-1), var(--primary-color));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 8px 25px rgba(199, 166, 98, 0.4);
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    z-index: 999;
    color: var(--text-color);
    font-size: 1.6rem;
    border: 3px solid rgba(255, 255, 255, 0.2);
}

.chat-toggle-btn:hover {
    transform: scale(1.15) rotate(5deg);
    box-shadow: 0 12px 35px rgba(199, 166, 98, 0.6);
}

.chat-toggle-btn:active {
    transform: scale(1.05) rotate(0deg);
}

.chat-toggle-btn.active {
    transform: scale(0.9);
    opacity: 0.7;
}

/* باکس راهنما - کاملاً رسپانسیو شده */
.chat-tooltip {
    position: absolute;
    bottom: calc(100% + 15px);
    right: 50%;
    transform: translateX(50%);
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    pointer-events: none;
    z-index: 1000;
    min-width: 160px;
}

.chat-toggle-btn:hover .chat-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateX(50%) translateY(-5px);
}

.tooltip-arrow {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid rgba(83, 130, 102, 0.95);
}

.tooltip-content {
    background: rgba(83, 130, 102, 0.95);
    backdrop-filter: blur(10px);
    color: var(--light-text);
    padding: 12px 18px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-right: 3px solid var(--secondary-color-1);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: bold;
    white-space: nowrap;
    animation: tooltipGlow 3s infinite;
    text-align: center;
}

@keyframes tooltipGlow {
    0%, 100% {
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    }
    50% {
        box-shadow: 0 8px 25px rgba(199, 166, 98, 0.4);
    }
}

.tooltip-content i {
    color: var(--secondary-color-1);
    font-size: 1.1rem;
}

.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: linear-gradient(135deg, #ff4757, #ff3742);
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: badgeBounce 2s infinite;
    border: 2px solid rgba(255, 255, 255, 0.3);
    font-weight: bold;
}

@keyframes badgeBounce {
    0%, 20%, 50%, 80%, 100% { 
        transform: translateY(0) scale(1); 
    }
    40% { 
        transform: translateY(-5px) scale(1.1); 
    }
    60% { 
        transform: translateY(-3px) scale(1.05); 
    }
}

/* اسکرول بار سفارشی */
.chat-body::-webkit-scrollbar {
    width: 6px;
}

.chat-body::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.chat-body::-webkit-scrollbar-thumb {
    background: var(--secondary-color-1);
    border-radius: 3px;
}

.chat-body::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* رسپانسیو برای تبلت */
@media (max-width: 1024px) {
    #chat-support-widget {
        width: 350px;
        height: 450px;
        right: 20px;
        bottom: 90px;
    }
    
    .chat-toggle-btn {
        width: 65px;
        height: 65px;
        right: 20px;
        bottom: 20px;
        font-size: 1.5rem;
    }
    
    .chat-origin-indicator {
        right: 20px;
        bottom: -7px;
    }
}

/* رسپانسیو برای موبایل */
@media (max-width: 768px) {
    #chat-support-widget {
        width: calc(100vw - 40px);
        height: 70vh;
        right: 20px;
        bottom: 90px;
        left: 20px;
        border-radius: 15px;
    }
    
    .chat-origin-indicator {
        right: 25px;
        bottom: -6px;
    }
    
    .chat-toggle-btn {
        width: 60px;
        height: 60px;
        right: 15px;
        bottom: 15px;
        font-size: 1.4rem;
    }
    
    .chat-header {
        padding: 12px 15px;
    }
    
    .chat-body {
        padding: 15px;
    }
    
    .chat-footer {
        padding: 12px 15px;
    }
    
    .message {
        max-width: 90%;
    }
    
    .tooltip-content {
        font-size: 0.9rem;
        padding: 10px 15px;
        white-space: nowrap;
    }
    
    /* مخفی کردن راهنما در موبایل برای جلوگیری از مشکلات نمایش */
    .chat-tooltip {
        display: none;
    }
}

/* رسپانسیو برای موبایل کوچک */
@media (max-width: 480px) {
    #chat-support-widget {
        width: calc(100vw - 20px);
        right: 10px;
        left: 10px;
        height: 75vh;
        bottom: 80px;
    }
    
    .chat-toggle-btn {
        width: 55px;
        height: 55px;
        right: 10px;
        bottom: 10px;
        font-size: 1.3rem;
    }
    
    .notification-badge {
        width: 20px;
        height: 20px;
        font-size: 0.7rem;
    }
    
    .chat-origin-indicator {
        right: 15px;
        bottom: -5px;
        width: 12px;
        height: 12px;
    }
    
    .chat-tooltip {
        display: none;
    }
}

/* رسپانسیو برای لپ‌تاپ‌های کوچک */
@media (max-width: 1366px) and (min-width: 1025px) {
    #chat-support-widget {
        right: 20px;
        bottom: 90px;
    }
    
    .chat-toggle-btn {
        right: 20px;
        bottom: 20px;
    }
}

/* انیمیشن‌های پیشرفته */
@keyframes floatAnimation {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    50% { transform: translateY(-5px) rotate(2deg); }
}

.chat-toggle-btn {
    animation: floatAnimation 4s ease-in-out infinite;
}

/* افکت‌های ویژه برای حالت فعال */
#chat-support-widget.active .chat-header {
    background: linear-gradient(135deg, rgba(83, 130, 102, 0.95), rgba(109, 158, 155, 0.9));
}

/* ترانزیشن برای پیام‌های جدید */
.message.new-message {
    animation: newMessagePop 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes newMessagePop {
    0% {
        opacity: 0;
        transform: scale(0.8) translateY(20px);
    }
    70% {
        transform: scale(1.05) translateY(-5px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}