/* Chatbox CSS Variables */
:root {
    --chatbox-gradient-start: #667eea;
    --chatbox-gradient-end: #764ba2;
    --chatbox-danger: #ff2d5f;
    --chatbox-text-muted: #a892ee;
}

/* Floating Chat Button */
.floating-chat-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chatbox-gradient-start) 0%, var(--chatbox-gradient-end) 100%);
    border: none;
    color: white;
    font-size: 1.8rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.floating-chat-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.floating-chat-btn:active {
    transform: scale(0.95);
}

.floating-chat-btn.has-unread {
    animation: pulseButton 2s infinite;
}

@keyframes pulseButton {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 6px 25px rgba(102, 126, 234, 0.8), 0 0 30px rgba(102, 126, 234, 0.6);
    }
}

#unread-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--chatbox-danger);
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: bold;
    animation: bounce 1s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

/* Chat Modal */
.chat-modal-content {
    width: 90%;
    max-width: 400px;
    height: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
    background: var(--secondary-bg);
}

/* Position chat in bottom-right on medium+ screens */
@media (min-width: 768px) {
    #chat-modal {
        align-items: flex-end;
        justify-content: flex-end;
        padding: 20px;
    }
    
    .chat-modal-content {
        margin-bottom: 100px; /* Space above floating button */
        margin-right: 20px;
        max-width: 400px;
        animation: slideInFromRight 0.3s ease-out;
    }
    
    @keyframes slideInFromRight {
        from {
            opacity: 0;
            transform: translateX(100px);
        }
        to {
            opacity: 1;
            transform: translateX(0);
        }
    }
}

.chat-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    background: var(--secondary-bg);
    border-bottom: 1px solid var(--glass-border);
    color: var(--text-color);
    border-radius: 16px 16px 0 0;
}

.chat-modal-header h3 {
    margin: 0;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

#chat-messages {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: var(--primary-bg);
}

.message {
    max-width: 70%;
    padding: 0.75rem 1rem;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    word-wrap: break-word;
    animation: messageSlideIn 0.2s ease-out;
}

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

.message.own {
    align-self: flex-end;
    background: var(--accent-color);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.opponent {
    align-self: flex-start;
    background: var(--secondary-bg);
    color: var(--text-color);
    border: 1px solid var(--glass-border);
    border-bottom-left-radius: 4px;
}

.message-header {
    font-size: 0.75rem;
    font-weight: 600;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.message-text {
    font-size: 0.95rem;
    line-height: 1.4;
    margin-bottom: 0.25rem;
}

.message-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    align-self: flex-end;
    width: 100%;
}

.message-time {
    font-size: 0.7rem;
    opacity: 0.7;
}

.seen-indicator {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6); /* White with transparency for sent */
    transition: color 0.3s;
    display: inline-block;
    min-width: 20px;
}

.seen-indicator.seen {
    color: rgba(255, 255, 255, 1); /* Solid white for seen */
}

#chat-input-area {
    padding: 1rem;
    background: var(--secondary-bg);
    border-top: 1px solid var(--glass-border);
    display: flex;
    gap: 0.75rem;
    border-radius: 0 0 16px 16px;
}

#chat-input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 2px solid var(--glass-border);
    border-radius: 24px;
    outline: none;
    font-size: 0.95rem;
    background: var(--primary-bg);
    color: var(--text-color);
    transition: border-color 0.2s;
}

#chat-input:focus {
    border-color: var(--chatbox-gradient-start);
}

#chat-input::placeholder {
    color: var(--chatbox-text-muted);
}

#chat-send-btn {
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, var(--chatbox-gradient-start) 0%, var(--chatbox-gradient-end) 100%);
    color: white;
    border: none;
    border-radius: 24px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

#chat-send-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

#chat-send-btn:active {
    transform: translateY(0);
}
