/* آیکون شناور چت */
#tp-chat-icon {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: #0073aa;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 9999;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 115, 170, 0.3);
    border: 3px solid #fff;
}

#tp-chat-icon:hover {
    background: #005a87;
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 115, 170, 0.4);
}

#tp-chat-icon svg {
    width: 28px;
    height: 28px;
    fill: #fff;
}

/* باکس چت */
#tp-chat-box {
    display: none;
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 350px;
    height: 500px;
    max-height: 80vh;
    background: #1E2A38;
    color: #f0f0f0;
    border: 1px solid #444;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    flex-direction: column;
    overflow: hidden;
    z-index: 9998;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

#tp-chat-box.open {
    display: flex;
    animation: chatSlideUp 0.3s ease;
}

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

/* هدر باکس */
#tp-chat-box h4 {
    margin: 0;
    padding: 15px;
    background: linear-gradient(135deg, #263544, #1c2a3a);
    color: #fff;
    border-bottom: 1px solid #555;
    position: relative;
    font-size: 16px;
    font-weight: 600;
    text-align: center;
}

#tp-chat-close {
    position: absolute;
    top: 50%;
    left: 15px;
    transform: translateY(-50%);
    font-size: 24px;
    color: #dc3545;
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

#tp-chat-close:hover {
    background: rgba(220, 53, 69, 0.1);
}

#tp-status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 8px;
    background: #28a745;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* بخش پیام‌ها */
#tp-chat-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background: #1B2735;
    font-size: 14px;
    line-height: 1.5;
}

/* اسکرول بار سفارشی */
#tp-chat-messages::-webkit-scrollbar {
    width: 6px;
}

#tp-chat-messages::-webkit-scrollbar-track {
    background: #2c3e50;
}

#tp-chat-messages::-webkit-scrollbar-thumb {
    background: #0073aa;
    border-radius: 3px;
}

#tp-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #005a87;
}

/* پیام کاربر */
.tp-msg-user {
    background: linear-gradient(135deg, #2C3E50, #34495E);
    color: #fff;
    padding: 10px 14px;
    border-radius: 18px 18px 18px 4px;
    margin: 8px 0;
    text-align: left;
    max-width: 85%;
    word-wrap: break-word;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* پیام ادمین */
.tp-msg-admin {
    background: linear-gradient(135deg, #0073aa, #005a87);
    color: #fff;
    padding: 10px 14px;
    border-radius: 18px 18px 4px 18px;
    margin: 8px 0;
    text-align: right;
    max-width: 85%;
    margin-left: auto;
    word-wrap: break-word;
    box-shadow: 0 2px 8px rgba(0, 115, 170, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.tp-msg-admin strong {
    color: #aee2ff;
    margin-left: 4px;
}

/* پیام سیستمی */
.tp-msg-system {
    background: transparent;
    color: #bbb;
    font-style: italic;
    padding: 8px;
    margin: 10px 0;
    text-align: center;
    font-size: 12px;
    border-top: 1px solid #444;
    border-bottom: 1px solid #444;
}

/* ورودی‌ها */
#tp-chat-inputs {
    padding: 15px;
    border-top: 1px solid #555;
    background: #1E2A38;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#tp-chat-message {
    width: 100%;
    min-height: 60px;
    max-height: 120px;
    padding: 12px;
    background: #2A3B4D;
    color: #fff;
    border: 1px solid #555;
    border-radius: 8px;
    font-size: 14px;
    resize: vertical;
    font-family: inherit;
    transition: border-color 0.2s;
}

#tp-chat-message:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.2);
}

#tp-chat-message::placeholder {
    color: #aaa;
}

#tp-send-btn {
    background: linear-gradient(135deg, #28a745, #218838);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
}

#tp-send-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #218838, #1e7e34);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.4);
}

#tp-send-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.end-chat {
    background: linear-gradient(135deg, #dc3545, #c82333);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
}

.end-chat:hover:not(:disabled) {
    background: linear-gradient(135deg, #c82333, #bd2130);
    transform: translateY(-1px);
}

.end-chat:disabled {
    background: #6c757d;
    cursor: not-allowed;
}

/* ریسپانسیو */
@media (max-width: 480px) {
    #tp-chat-box {
        width: calc(100vw - 40px);
        right: 20px;
        left: 20px;
        bottom: 80px;
    }
    
    #tp-chat-icon {
        bottom: 20px;
        right: 20px;
        width: 50px;
        height: 50px;
    }
    
    #tp-chat-icon svg {
        width: 24px;
        height: 24px;
    }
}

/* انیمیشن برای پیام‌های جدید */
@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tp-msg-user, .tp-msg-admin, .tp-msg-system {
    animation: messageSlideIn 0.3s ease;
}