/* Chat Widget Styles - Glassmorphism Design */
:root {
    --primary-color: #6366f1;
    --primary-glow: rgba(99, 102, 241, 0.4);
    --secondary-color: #8b5cf6;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --glass-bg: rgba(10, 15, 30, 0.75);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-color: #ffffff;
    --text-muted: rgba(255, 255, 255, 0.6);
}

.chat-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: 'Vazirmatn', sans-serif;
    direction: rtl;
}

.chat-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 8px 32px rgba(99, 102, 241, 0.4);
    transition: all 0.3s ease;
    position: relative;
}

.chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 40px rgba(99, 102, 241, 0.6);
}

.chat-button i {
    font-size: 24px;
    color: white;
}

.new-message-indicator {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 22px;
    height: 22px;
    background: linear-gradient(135deg, var(--danger-color), #dc2626);
    color: white;
    border-radius: 50%;
    font-size: 11px;
    display: none;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.5);
}

.chat-popup {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 500px;
    background: var(--glass-bg);
    backdrop-filter: blur(25px) saturate(150%);
    -webkit-backdrop-filter: blur(25px) saturate(150%);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    display: none;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.chat-popup.active {
    display: flex;
}

.chat-header {
    padding: 16px 20px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-title {
    font-weight: 600;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.close-chat {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.close-chat:hover {
    background: rgba(255, 255, 255, 0.3);
}

.chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    /* Increased gap for read status space */
    background: rgba(0, 0, 0, 0.15);
}

.chat-messages::-webkit-scrollbar {
    width: 5px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}

.message {
    padding: 10px 14px;
    border-radius: 14px;
    max-width: 80%;
    word-wrap: break-word;
    font-size: 14px;
    line-height: 1.4;
    position: relative;
    /* For absolute positioning of read status */
    margin-bottom: 5px;
}

.message-content {
    line-height: 1.4;
    margin-bottom: 4px;
}

.message-time {
    font-size: 10px;
    opacity: 0.7;
}

.read-status {
    font-size: 12px;
    position: absolute;
    bottom: -18px;
    left: 5px;
    /* Outside to the left */
    display: flex;
    align-items: center;
    gap: 2px;
    opacity: 0.8;
}

.user-message {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border-bottom-left-radius: 4px;
}

.support-message {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-bottom-right-radius: 4px;
}

.system-message {
    align-self: center;
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    font-size: 12px;
    text-align: center;
}

.chat-status {
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.2);
    border-top: 1px solid var(--glass-border);
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-input {
    display: flex;
    padding: 12px 16px;
    gap: 10px;
    background: rgba(0, 0, 0, 0.2);
    border-top: 1px solid var(--glass-border);
}

.input-field {
    flex: 1;
    padding: 12px 16px;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.08);
    color: white;
    outline: none;
    font-size: 14px;
    transition: all 0.3s ease;
}

.input-field:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 15px var(--primary-glow);
}

.input-field::placeholder {
    color: var(--text-muted);
}

.input-field:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.send-button {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border: none;
    color: white;
    font-size: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.send-button:hover:not(:disabled) {
    transform: scale(1.05);
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.login-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 30px;
    color: var(--text-muted);
}

.login-message i {
    font-size: 48px;
    margin-bottom: 16px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-message p {
    margin-bottom: 16px;
    font-size: 14px;
    line-height: 1.6;
}

.login-button {
    padding: 12px 24px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.login-button:hover {
    transform: translateY(-2px);
}

@media (max-width: 480px) {
    .chat-container {
        bottom: 15px;
        right: 15px;
    }

    .chat-popup {
        width: calc(100vw - 30px);
        height: calc(100vh - 120px);
        max-height: 550px;
        bottom: 70px;
        right: 0;
        border-radius: 20px;
    }

    .chat-button {
        width: 55px;
        height: 55px;
    }

    .chat-button i {
        font-size: 22px;
    }

    .chat-header {
        padding: 14px 16px;
    }

    .message {
        max-width: 85%;
        padding: 8px 12px;
    }

    .input-field {
        padding: 10px 14px;
    }

    .send-button {
        width: 40px;
        height: 40px;
    }
}