/**
 * World Chat Styles
 * Modular CSS for chat functionality
 */

/* Chat Tab Container - positioned separately from .content */
#chat-tab {
    display: none;
    flex-direction: column;
    height: calc(100vh - 60px);
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--pixel-bg);
    z-index: 1;
}

#chat-tab.active {
    display: flex;
}

/* Chat Header */
.chat-header {
    padding: 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 0;
    margin-bottom: 0;
    flex-shrink: 0;
}

.chat-title {
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 4px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-subtitle {
    font-size: 13px;
    opacity: 0.9;
    margin: 0;
}

/* Messages Container */
.chat-messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 0 16px;
    margin-bottom: 0;
    min-height: 200px;
}

.chat-messages-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 8px 0;
}

/* Individual Message */
.chat-message-item {
    background: var(--pixel-bg-light);
    border-radius: 12px;
    padding: 10px 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    animation: fadeInUp 0.3s ease;
    border: 2px solid var(--pixel-border);
    position: relative;
    padding-left: 16px;
}

.chat-message-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--pixel-primary);
    border-radius: 16px 0 0 16px;
}

/* Current User Message - Brighter Background */
.chat-message-item.current-user {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: 2px solid #8b5cf6;
}

.chat-message-item.current-user::before {
    background: #fbbf24;
}

.chat-message-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    flex-wrap: wrap;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--pixel-border);
}

.chat-avatar {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid var(--pixel-primary);
    object-fit: cover;
    flex-shrink: 0;
    background: var(--pixel-primary);
    display: block;
}

.chat-username {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 8px;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* VIP Username - Gold Color */
.chat-username.vip-user {
    color: #FFD700;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.5);
}

/* VIP on current user message - brighter gold */
.chat-message-item.current-user .chat-username.vip-user {
    color: #FDE047;
    text-shadow: 0 0 10px rgba(253, 224, 71, 0.6);
}

.chat-user-title {
    font-size: 7px;
    font-weight: 500;
    padding: 1px 3px;
    border-radius: 2px;
}

/* Title Rarity Colors */
.chat-user-title.rarity-common {
    color: #B0B0B0;
    background: rgba(176, 176, 176, 0.15);
}

.chat-user-title.rarity-rare {
    color: #4CAF50;
    background: rgba(76, 175, 80, 0.15);
}

.chat-user-title.rarity-epic {
    color: #9C27B0;
    background: rgba(156, 39, 176, 0.15);
}

.chat-user-title.rarity-legendary {
    color: #FFD700;
    background: rgba(255, 215, 0, 0.15);
}

/* Current user messages - brighten title colors on purple background */
.chat-message-item.current-user .chat-user-title.rarity-common {
    color: #E0E0E0;
    background: rgba(224, 224, 224, 0.2);
}

.chat-message-item.current-user .chat-user-title.rarity-rare {
    color: #66FF6B;
    background: rgba(102, 255, 107, 0.2);
}

.chat-message-item.current-user .chat-user-title.rarity-epic {
    color: #D946EF;
    background: rgba(217, 70, 239, 0.2);
}

.chat-message-item.current-user .chat-user-title.rarity-legendary {
    color: #FDE047;
    background: rgba(253, 224, 71, 0.2);
}

.chat-timestamp {
    font-size: 4px !important;
    line-height: 1 !important;
    color: var(--text-secondary);
    margin-left: auto;
    font-family: system-ui, -apple-system, sans-serif !important;
}

.chat-message-text {
    color: var(--text-primary);
    font-size: 9px;
    line-height: 1.3;
    word-wrap: break-word;
    white-space: pre-wrap;
    padding: 2px 0;
}

/* Current User Message Text - Brighter */
.chat-message-item.current-user .chat-username,
.chat-message-item.current-user .chat-message-text,
.chat-message-item.current-user .chat-timestamp {
    color: #ffffff;
}

.chat-message-item.current-user .chat-timestamp {
    font-size: 4px !important;
    line-height: 1 !important;
    font-family: system-ui, -apple-system, sans-serif !important;
}

.chat-message-item.current-user .chat-user-title {
    color: #fbbf24;
    background: rgba(251, 191, 36, 0.2);
}

.chat-message-item.current-user .chat-message-header {
    border-bottom-color: rgba(255, 255, 255, 0.2);
}

.chat-message-item.current-user .chat-avatar {
    border-color: #fbbf24;
}

/* Empty State */
.chat-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    height: 100%;
}

.chat-empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.chat-empty-text {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.chat-empty-subtext {
    font-size: 13px;
    color: var(--text-tertiary);
}

/* Input Container */
.chat-input-container {
    padding: 12px 16px;
    background: var(--card-bg);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.chat-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.chat-input-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-message-input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-size: 14px;
    background: var(--bg-primary);
    color: var(--text-primary);
    resize: none;
    min-height: 44px;
    max-height: 100px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.chat-message-input:focus {
    outline: none;
    border-color: #667eea;
}

.chat-message-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chat-char-count {
    font-size: 11px;
    color: var(--text-secondary);
    text-align: right;
    padding-right: 4px;
}

.chat-send-btn {
    padding: 12px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 20px;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
    height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-send-btn:hover:not(:disabled) {
    transform: scale(1.05);
}

.chat-send-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Feedback Messages */
.chat-feedback {
    padding: 8px 16px;
    margin: 0;
    border-radius: 0;
    font-size: 13px;
    text-align: center;
    display: none;
    animation: fadeIn 0.3s ease;
    flex-shrink: 0;
    position: absolute;
    top: 72px;
    left: 0;
    right: 0;
    z-index: 100;
}

.chat-error {
    background: #ff444420;
    color: #ff4444;
    border: 1px solid #ff444440;
}

.chat-success {
    background: #4caf5020;
    color: #4caf50;
    border: 1px solid #4caf5040;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Scrollbar Styling */
.chat-messages-container::-webkit-scrollbar {
    width: 6px;
}

.chat-messages-container::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages-container::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.chat-messages-container::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* Responsive */
@media (max-width: 480px) {
    .chat-header {
        padding: 12px;
    }
    
    .chat-title {
        font-size: 18px;
    }
    
    .chat-messages-container {
        padding: 0 12px;
    }
    
    .chat-input-container {
        padding: 10px 12px;
    }
    
    .chat-send-btn {
        min-width: 40px;
        height: 40px;
        font-size: 18px;
    }
}
