/**
 * Chat System Styles
 * Visual, game-integrated chat design (not classic messenger style)
 */

/* ========================================
   CHAT CONTAINER
   ======================================== */

#chat-screen {
    padding: 0;
    background: var(--dark-bg);
}

.chat-main-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--nav-height));
    max-height: calc(100vh - var(--nav-height));
}

/* ========================================
   OPT-IN PROMPT
   ======================================== */

#chat-opt-in-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    text-align: center;
    min-height: 400px;
}

.opt-in-icon {
    font-size: 5rem;
    margin-bottom: 1.5rem;
    filter: drop-shadow(0 0 30px var(--primary-glow));
    animation: float 3s ease-in-out infinite;
}

.opt-in-title {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 1rem;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.opt-in-description {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    max-width: 400px;
    line-height: 1.6;
}

.opt-in-benefits {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 2rem;
    text-align: left;
}

.benefit-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-sm);
}

.benefit-icon {
    font-size: 1.5rem;
}

.opt-in-actions {
    display: flex;
    gap: 1rem;
}

.opt-in-btn {
    padding: 1rem 2rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
}

.opt-in-btn.primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 20px var(--primary-glow);
}

.opt-in-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px var(--primary-glow);
}

.opt-in-btn.secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.opt-in-btn.secondary:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* ========================================
   CHANNEL SELECTOR
   ======================================== */

.chat-channels {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
    background: rgba(17, 24, 39, 0.6);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.chat-channel-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.chat-channel-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.chat-channel-btn.active {
    background: rgba(0, 242, 254, 0.1);
    border-color: var(--primary-color);
    color: var(--primary-color);
    box-shadow: 0 0 20px var(--primary-glow);
}

.channel-icon {
    font-size: 1.25rem;
}

/* ========================================
   MESSAGES CONTAINER
   ======================================== */

#chat-messages {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: linear-gradient(180deg, rgba(11, 15, 26, 0.5) 0%, rgba(11, 15, 26, 0.8) 100%);
    -webkit-overflow-scrolling: touch;
}

/* Custom scrollbar for chat */
#chat-messages::-webkit-scrollbar {
    width: 6px;
}

#chat-messages::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.03);
}

#chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 242, 254, 0.3);
    border-radius: 3px;
}

#chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 242, 254, 0.5);
}

/* ========================================
   MESSAGE BUBBLES
   ======================================== */

.chat-message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: messageSlideIn 0.3s ease;
}

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

.chat-message.own-message {
    align-self: flex-end;
}

.chat-message.other-message {
    align-self: flex-start;
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
    padding: 0 0.5rem;
}

.message-username {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary-color);
}

.message-time {
    font-size: 0.625rem;
    color: var(--text-muted);
}

.message-text {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    line-height: 1.5;
    word-wrap: break-word;
    position: relative;
}

.own-message .message-text {
    background: rgba(0, 242, 254, 0.15);
    border: 1px solid rgba(0, 242, 254, 0.3);
    color: var(--text-primary);
    border-bottom-right-radius: 4px;
}

.other-message .message-text {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.message-report {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: transparent;
    border: none;
    font-size: 0.875rem;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.2s ease;
    padding: 0.25rem;
}

.message-report:hover {
    opacity: 1;
}

/* ========================================
   SYSTEM MESSAGES
   ======================================== */

.chat-message.system-message {
    align-self: center;
    max-width: 90%;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    background: rgba(168, 85, 247, 0.1);
    border: 1px solid rgba(168, 85, 247, 0.3);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(10px);
}

.system-message .message-icon {
    font-size: 1.5rem;
    filter: drop-shadow(0 0 10px var(--secondary-glow));
}

.system-message .message-text {
    padding: 0;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    text-align: center;
}

/* ========================================
   MESSAGE INPUT
   ======================================== */

.chat-input-container {
    padding: 1rem;
    background: rgba(17, 24, 39, 0.8);
    backdrop-filter: blur(16px);
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

#chat-message-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.875rem 1rem;
    color: var(--text-primary);
    font-size: 0.9375rem;
    resize: none;
    max-height: 120px;
    min-height: 44px;
    transition: all 0.3s ease;
}

#chat-message-input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 20px var(--primary-glow);
}

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

#chat-send-btn {
    padding: 0.875rem 1.5rem;
    background: var(--gradient-primary);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 16px var(--primary-glow);
    min-width: 56px;
}

#chat-send-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px var(--primary-glow);
}

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

#chat-send-btn.sent {
    animation: buttonPulse 0.3s ease;
}

@keyframes buttonPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(0.95); }
}

/* ========================================
   RATE LIMIT WARNING
   ======================================== */

.rate-limit-warning {
    position: fixed;
    bottom: calc(var(--nav-height) + 80px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(239, 68, 68, 0.95);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 600;
    box-shadow: 0 4px 20px rgba(239, 68, 68, 0.5);
    z-index: 1000;
    animation: slideUpFade 0.3s ease;
}

@keyframes slideUpFade {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* ========================================
   EMPTY STATE
   ======================================== */

.chat-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    text-align: center;
    color: var(--text-muted);
}

.chat-empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.chat-empty-text {
    font-size: 0.875rem;
}

/* ========================================
   MOBILE OPTIMIZATIONS
   ======================================== */

@media (max-width: 768px) {
    .chat-channels {
        padding: 0.75rem;
    }
    
    .chat-channel-btn {
        padding: 0.625rem 1rem;
        font-size: 0.8125rem;
    }
    
    #chat-messages {
        padding: 0.75rem;
    }
    
    .chat-message {
        max-width: 90%;
    }
    
    .message-text {
        font-size: 0.8125rem;
    }
    
    .chat-input-container {
        padding: 0.75rem;
    }
    
    #chat-send-btn {
        padding: 0.75rem 1.25rem;
    }
}

/* ========================================
   MODERATION INDICATORS
   ======================================== */

.muted-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-md);
    color: var(--danger-color);
    font-size: 0.875rem;
    margin: 1rem;
}

.muted-icon {
    font-size: 1.25rem;
}

/* ========================================
   TYPING INDICATOR
   ======================================== */

.typing-indicator {
    display: flex;
    gap: 0.25rem;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    max-width: 60px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-8px);
    }
}
