/**
 * ========================================
 * TREASURE ISLAND - PIRATE CHAT MODULE
 * ========================================
 * Afilli 1v1 Chat System - Glassmorphism Theme
 * Version: 1.0
 * Date: 2026-02-14
 */

/* ==================== CHAT BUTTON (Online User Card'a eklenecek) ==================== */
.ouc-btn-chat {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 24px;
    border-radius: 12px;
    border: none;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    width: 100%;
    justify-content: center;
}

.ouc-btn-chat:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.ouc-btn-chat:active {
    transform: translateY(0);
}

/* ==================== CHAT CONTAINER ==================== */
#chat-windows-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    gap: 12px;
    z-index: 9999;
    pointer-events: none;
}

#chat-windows-container > * {
    pointer-events: auto;
}

/* ==================== SINGLE CHAT WINDOW ==================== */
.chat-window {
    width: 340px;
    height: 480px;
    background: linear-gradient(135deg, 
        rgba(26, 77, 109, 0.95) 0%, 
        rgba(45, 127, 168, 0.95) 50%, 
        rgba(74, 159, 200, 0.95) 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.1) inset,
        0 20px 60px rgba(26, 77, 109, 0.6);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: chatWindowSlideIn 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    transition: all 0.3s ease;
}

.chat-window.minimized {
    height: 60px;
    animation: chatWindowMinimize 0.3s ease;
}

@keyframes chatWindowSlideIn {
    from {
        transform: translateY(100%) scale(0.8);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

@keyframes chatWindowMinimize {
    from {
        height: 480px;
    }
    to {
        height: 60px;
    }
}

/* ==================== CHAT HEADER ==================== */
.chat-header {
    background: linear-gradient(135deg, 
        rgba(26, 77, 109, 0.9) 0%, 
        rgba(45, 127, 168, 0.9) 100%);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    cursor: pointer;
    user-select: none;
    position: relative;
    overflow: hidden;
}

.chat-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(255, 255, 255, 0.1), 
        transparent);
    animation: shimmer 3s infinite;
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

.chat-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 2px solid rgba(255, 215, 0, 0.6);
    object-fit: cover;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    position: relative;
    animation: avatarPulse 2s ease-in-out infinite;
}

@keyframes avatarPulse {
    0%, 100% { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3); }
    50% { box-shadow: 0 4px 20px rgba(255, 215, 0, 0.5); }
}

.chat-user-info {
    flex: 1;
    min-width: 0;
}

.chat-username {
    font-size: 15px;
    font-weight: 700;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-status {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4caf50;
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.8);
    animation: statusPulse 2s ease-in-out infinite;
}

@keyframes statusPulse {
    0%, 100% { 
        transform: scale(1);
        box-shadow: 0 0 10px rgba(76, 175, 80, 0.8);
    }
    50% { 
        transform: scale(1.2);
        box-shadow: 0 0 20px rgba(76, 175, 80, 1);
    }
}

.chat-header-actions {
    display: flex;
    gap: 8px;
}

.chat-header-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
}

.chat-header-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.1);
}

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

/* ==================== MESSAGES AREA ==================== */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: linear-gradient(180deg, 
        rgba(26, 77, 109, 0.3) 0%, 
        rgba(45, 127, 168, 0.2) 100%);
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 215, 0, 0.5) rgba(255, 255, 255, 0.1);
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 215, 0, 0.5);
    border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 215, 0, 0.7);
}

/* Empty state */
.chat-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: rgba(255, 255, 255, 0.6);
    text-align: center;
    padding: 20px;
}

.chat-empty-state-icon {
    font-size: 64px;
    margin-bottom: 16px;
    animation: floatBottle 3s ease-in-out infinite;
}

@keyframes floatBottle {
    0%, 100% { transform: translateY(0) rotate(-5deg); }
    50% { transform: translateY(-10px) rotate(5deg); }
}

.chat-empty-state-text {
    font-size: 14px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 8px;
}

.chat-empty-state-hint {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
}

/* ==================== MESSAGE BUBBLE ==================== */
.message-bubble {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
    position: relative;
    animation: messagePop 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

@keyframes messagePop {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Incoming message (friend's message) */
.message-bubble.incoming {
    align-self: flex-start;
    background: linear-gradient(135deg, 
        rgba(255, 255, 255, 0.95) 0%, 
        rgba(244, 228, 193, 0.95) 100%);
    color: #333;
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(255, 215, 0, 0.3);
}

.message-bubble.incoming::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: -8px;
    width: 0;
    height: 0;
    border: 8px solid transparent;
    border-right-color: rgba(255, 255, 255, 0.95);
    border-bottom-color: rgba(255, 255, 255, 0.95);
    border-bottom-right-radius: 4px;
}

/* Outgoing message (my message) */
.message-bubble.outgoing {
    align-self: flex-end;
    background: linear-gradient(135deg, 
        rgba(102, 126, 234, 0.95) 0%, 
        rgba(118, 75, 162, 0.95) 100%);
    color: white;
    border-bottom-right-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.message-bubble.outgoing::before {
    content: '';
    position: absolute;
    bottom: 0;
    right: -8px;
    width: 0;
    height: 0;
    border: 8px solid transparent;
    border-left-color: rgba(118, 75, 162, 0.95);
    border-bottom-color: rgba(118, 75, 162, 0.95);
    border-bottom-left-radius: 4px;
}

.message-time {
    font-size: 10px;
    opacity: 0.7;
    margin-top: 4px;
    text-align: right;
}

.message-bubble.incoming .message-time {
    color: #666;
}

.message-bubble.outgoing .message-time {
    color: rgba(255, 255, 255, 0.9);
}

/* ==================== TYPING INDICATOR ==================== */
.typing-indicator {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.9);
    padding: 12px 16px;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    animation: messagePop 0.3s ease;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #667eea;
    animation: typingBounce 1.4s ease-in-out 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);
    }
}

/* ==================== INPUT AREA ==================== */
.chat-input-area {
    padding: 14px;
    background: linear-gradient(135deg, 
        rgba(26, 77, 109, 0.8) 0%, 
        rgba(45, 127, 168, 0.8) 100%);
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.chat-input-wrapper {
    flex: 1;
    position: relative;
}

.chat-input {
    width: 100%;
    min-height: 38px;
    max-height: 100px;
    padding: 10px 40px 10px 14px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.95);
    color: #333;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    overflow-y: auto;
    transition: all 0.2s ease;
    scrollbar-width: none;
}

.chat-input::-webkit-scrollbar {
    display: none;
}

.chat-input:focus {
    outline: none;
    border-color: rgba(255, 215, 0, 0.6);
    box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.2);
}

.chat-input::placeholder {
    color: #999;
}

.emoji-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}

.emoji-btn:hover {
    transform: translateY(-50%) scale(1.2);
}

.send-btn {
    width: 42px;
    height: 42px;
    border: none;
    background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
    color: #333;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(255, 215, 0, 0.4);
    flex-shrink: 0;
}

.send-btn:hover {
    transform: scale(1.1) rotate(15deg);
    box-shadow: 0 6px 16px rgba(255, 215, 0, 0.6);
}

.send-btn:active {
    transform: scale(0.95) rotate(0deg);
}

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

/* ==================== EMOJI PICKER (Simple) ==================== */
.emoji-picker {
    position: absolute;
    bottom: 50px;
    right: 0;
    background: white;
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    display: none;
    z-index: 10;
    max-width: 280px;
    animation: emojiPickerSlideUp 0.2s ease;
}

.emoji-picker.active {
    display: block;
}

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

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
    max-height: 200px;
    overflow-y: auto;
}

.emoji-item {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.emoji-item:hover {
    background: #f0f0f0;
    transform: scale(1.2);
}

/* ==================== NOTIFICATION BADGE ==================== */
.chat-notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: linear-gradient(135deg, #f44336 0%, #e91e63 100%);
    color: white;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(244, 67, 54, 0.5);
    animation: badgePulse 2s ease-in-out infinite;
    z-index: 10;
}

@keyframes badgePulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 2px 8px rgba(244, 67, 54, 0.5);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 4px 12px rgba(244, 67, 54, 0.8);
    }
}

/* ==================== ONLINE AVATAR UNREAD BADGE ==================== */
.online-avatar-unread-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    background: linear-gradient(135deg, #f44336 0%, #e91e63 100%);
    color: white;
    border-radius: 10px;
    padding: 2px 5px;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(244, 67, 54, 0.5);
    animation: badgePulse 2s ease-in-out infinite;
    z-index: 15;
    border: 2px solid white;
}

/* ==================== MESSAGE BOTTLE NOTIFICATION ==================== */
#message-bottle-notification {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

#message-bottle-notification.active {
    display: flex;
}

.message-bottle-card {
    background: linear-gradient(135deg, 
        rgba(26, 77, 109, 0.98) 0%, 
        rgba(45, 127, 168, 0.98) 50%, 
        rgba(74, 159, 200, 0.98) 100%);
    backdrop-filter: blur(20px);
    border: 2px solid rgba(255, 215, 0, 0.3);
    border-radius: 24px;
    padding: 32px;
    max-width: 380px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    position: relative;
    overflow: hidden;
    animation: bottleFloat 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes bottleFloat {
    0% {
        transform: translateY(-100%) rotate(-30deg) scale(0.5);
        opacity: 0;
    }
    50% {
        transform: translateY(20px) rotate(5deg) scale(1.05);
    }
    100% {
        transform: translateY(0) rotate(0deg) scale(1);
        opacity: 1;
    }
}

.message-bottle-shimmer {
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(255, 255, 255, 0.2), 
        transparent);
    animation: shimmerSlide 2s infinite;
}

@keyframes shimmerSlide {
    0% { left: -100%; }
    100% { left: 100%; }
}

.message-bottle-icon {
    font-size: 72px;
    text-align: center;
    margin-bottom: 16px;
    animation: bottleRock 2s ease-in-out infinite;
}

@keyframes bottleRock {
    0%, 100% { 
        transform: rotate(-5deg);
    }
    50% { 
        transform: rotate(5deg);
    }
}

.message-bottle-title {
    font-size: 24px;
    font-weight: 800;
    color: white;
    text-align: center;
    margin-bottom: 12px;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.message-bottle-from {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.8);
    text-align: center;
    margin-bottom: 20px;
}

.message-bottle-preview {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 24px;
    color: white;
    font-size: 14px;
    line-height: 1.6;
    max-height: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    position: relative;
}

.message-bottle-preview::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: linear-gradient(to bottom, transparent, rgba(26, 77, 109, 0.9));
}

.message-bottle-actions {
    display: flex;
    gap: 12px;
}

.message-bottle-btn {
    flex: 1;
    padding: 14px;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.message-bottle-btn-primary {
    background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
    color: #333;
    box-shadow: 0 4px 12px rgba(255, 215, 0, 0.4);
}

.message-bottle-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(255, 215, 0, 0.6);
}

.message-bottle-btn-secondary {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.message-bottle-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.message-bottle-btn:active {
    transform: translateY(0);
}

/* ==================== SCROLL TO BOTTOM BUTTON ==================== */
.scroll-to-bottom {
    position: absolute;
    bottom: 80px;
    right: 16px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.3s ease;
    z-index: 10;
}

.scroll-to-bottom.visible {
    display: flex;
    animation: bounceIn 0.3s ease;
}

.scroll-to-bottom:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(255, 215, 0, 0.6);
}

@keyframes bounceIn {
    from {
        transform: scale(0);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* ==================== MOBILE RESPONSIVE ==================== */
@media (max-width: 768px) {
    #chat-windows-container {
        bottom: 10px;
        right: 10px;
        left: 10px;
        flex-direction: column-reverse;
    }
    
    .chat-window {
        width: 100%;
        max-width: 100%;
        height: 70vh;
        max-height: 500px;
    }
    
    .chat-window.minimized {
        height: 56px;
    }
    
    .message-bubble {
        max-width: 85%;
    }
}

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