/* Chat Sistemi CSS */

/* Chat Panel - Sağ Taraf Sabit */
.chat-overlay {
    position: fixed;
    top: 0;
    right: 0;
    width: 400px;
    height: 100vh;
    background: transparent;
    z-index: 10000;
    transform: translateX(100%);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.chat-overlay.active {
    transform: translateX(0);
}

/* Chat Window */
.chat-window {
    width: 100%;
    height: 100vh;
    background: linear-gradient(135deg, rgba(42, 42, 62, 0.98) 0%, rgba(26, 26, 46, 0.99) 100%);
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Chat Header */
.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(99, 102, 241, 0.1) 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
}

.chat-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-dot {
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.2); }
}

.chat-title h3 {
    color: #ffffff;
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.chat-close {
    background: none;
    border: none;
    color: #9ca3af;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
}

.chat-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    transform: scale(1.1);
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    height: calc(100vh - 140px);
}

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

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

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

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

/* Message Item */
.message-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    animation: messageSlideIn 0.3s ease;
    margin-bottom: 15px;
    width: fit-content;
    max-width: 70%;
}

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

/* Other Users Messages - Left Side */
.message-item:not(.own) {
    align-self: flex-start;
    margin-right: auto;
    width: fit-content;
}

.message-item:not(.own) .message-header {
    justify-content: flex-start;
}

.message-item:not(.own) .message-content {
    background: linear-gradient(135deg, rgba(44, 62, 80, 0.9) 0%, rgba(52, 73, 94, 0.9) 100%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 18px 18px 18px 4px;
    color: #ffffff;
}

.message-item:not(.own) .message-username {
    color: #3b82f6;
    font-weight: 600;
    font-size: 14px;
}

/* Own Messages - Right Side */
.message-item.own {
    align-self: flex-end;
    margin-left: auto;
    width: fit-content;
}

.message-item.own .message-header {
    justify-content: flex-end;
    flex-direction: row-reverse;
}

.message-item.own .message-content {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.9) 0%, rgba(99, 102, 241, 0.9) 100%);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 18px 18px 4px 18px;
    color: #ffffff;
}

.message-item.own .message-username {
    color: #10b981;
    font-weight: 600;
    font-size: 14px;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    padding: 0 4px;
}

.message-username {
    font-weight: 600;
    font-size: 14px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.message-rank {
    font-size: 12px;
    font-weight: 500;
    margin-left: 8px;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    white-space: nowrap;
}

.message-time {
    color: #6b7280;
    font-size: 12px;
    font-weight: 400;
}

.message-content {
    padding: 12px 16px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
    position: relative;
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    width: fit-content;
    min-width: 60px;
    max-width: 100%;
}

/* Chat Input */
.chat-input {
    display: flex;
    gap: 12px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.02);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
}

.chat-text {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 12px 16px;
    color: #ffffff;
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
}

.chat-text::placeholder {
    color: #9ca3af;
}

.chat-text:focus {
    border-color: rgba(59, 130, 246, 0.5);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.chat-send {
    background: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
    border: none;
    border-radius: 12px;
    padding: 12px 20px;
    color: #ffffff;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 80px;
    position: relative;
    overflow: hidden;
}

.chat-send::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.chat-send:hover::before {
    left: 100%;
}

.chat-send:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.3);
}

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

.chat-send:disabled {
    background: #6b7280;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Loading States */
.chat-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: #9ca3af;
    font-size: 14px;
}

.chat-loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-top: 2px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 12px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Empty State */
.chat-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    color: #9ca3af;
}

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

.chat-empty-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #d1d5db;
}

.chat-empty-subtitle {
    font-size: 14px;
    opacity: 0.8;
}

/* Error State */
.chat-error {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: #ef4444;
    font-size: 14px;
    text-align: center;
}

.chat-error-icon {
    margin-right: 8px;
    font-size: 16px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .chat-overlay {
        width: 100%;
        transform: translateX(100%);
    }
    
    .chat-overlay.active {
        transform: translateX(0);
    }
    
    .chat-window {
        width: 100%;
    }
    
    .chat-header {
        padding: 15px 20px;
        position: sticky;
        top: 0;
        z-index: 10002;
    }
    
    .chat-title h3 {
        font-size: 16px;
    }
    
    .chat-messages {
        padding: 15px;
        height: calc(100vh - 120px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch; /* iOS için smooth scroll */
    }
    
    .chat-input {
        padding: 15px;
        position: sticky;
        bottom: 0;
        z-index: 10001;
    }
    
    .message-content {
        padding: 10px 14px;
        font-size: 13px;
    }
    
    /* Mobil için input alanı iyileştirmeleri */
    .chat-text {
        font-size: 16px; /* iOS'ta zoom'u önlemek için */
        -webkit-appearance: none;
        border-radius: 12px;
    }
    
    .chat-send {
        -webkit-appearance: none;
        border-radius: 12px;
    }
}

/* Mobil Klavye Desteği */
@media (max-width: 768px) {
    /* Android için klavye açıldığında */
    .chat-overlay.keyboard-open {
        height: 100vh;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        transform: none;
    }
    
    .chat-window.keyboard-open {
        height: 100vh;
        display: flex;
        flex-direction: column;
        position: relative;
    }
    
    .chat-messages.keyboard-open {
        flex: 1;
        height: auto;
        min-height: 0;
        padding-bottom: 80px; /* Input alanı için ekstra boşluk */
    }
    
    .chat-input.keyboard-open {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(42, 42, 62, 0.98);
        backdrop-filter: blur(20px);
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        z-index: 10001;
        padding: 15px;
        margin: 0;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
    }
    
    /* iPhone için özel düzenlemeler */
    @supports (-webkit-touch-callout: none) {
        .chat-overlay.keyboard-open {
            height: 100vh;
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            transform: none;
        }
        
        .chat-window.keyboard-open {
            height: 100vh;
            display: flex;
            flex-direction: column;
            position: relative;
        }
        
        .chat-messages.keyboard-open {
            flex: 1;
            height: auto;
            min-height: 0;
            padding-bottom: 100px; /* iPhone için daha fazla boşluk */
        }
        
        .chat-input.keyboard-open {
            position: fixed !important;
            bottom: 0 !important;
            left: 0 !important;
            right: 0 !important;
            background: rgba(42, 42, 62, 0.98) !important;
            backdrop-filter: blur(20px) !important;
            border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
            z-index: 10001 !important;
            padding: 15px !important;
            margin: 0 !important;
            box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3) !important;
            /* iPhone için safe area desteği */
            padding-bottom: calc(15px + env(safe-area-inset-bottom)) !important;
            transform: none !important;
        }
        
        /* iPhone için gönder butonu boyutunu küçült */
        .chat-send.keyboard-open {
            min-width: 60px !important;
            max-width: 80px !important;
            padding: 10px 12px !important;
            font-size: 13px !important;
            height: 40px !important;
            line-height: 1 !important;
            display: flex !important;
            align-items: center !important;
            justify-content: center !important;
        }
        
        /* iPhone için input alanı boyutunu ayarla */
        .chat-text.keyboard-open {
            font-size: 16px !important;
            line-height: 1.4 !important;
            height: 40px !important;
            padding: 8px 12px !important;
            margin-bottom: 0 !important;
        }
        
        /* iPhone için ek güvenlik alanı */
        .chat-input.keyboard-open .chat-text {
            margin-bottom: 0 !important;
        }
        
        /* iPhone için input container boyutunu sabitle */
        .chat-input.keyboard-open {
            height: auto !important;
            min-height: 70px !important;
            max-height: 80px !important;
        }
    }
    
    /* Android için viewport height ayarı */
    @supports not (-webkit-touch-callout: none) {
        .chat-overlay.keyboard-open {
            height: 100vh;
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            transform: none;
        }
        
        .chat-window.keyboard-open {
            height: 100vh;
            display: flex;
            flex-direction: column;
            position: relative;
        }
        
        .chat-messages.keyboard-open {
            flex: 1;
            height: auto;
            min-height: 0;
            padding-bottom: 100px; /* Android için daha fazla boşluk */
        }
        
        .chat-input.keyboard-open {
            position: fixed !important;
            bottom: 10px !important;
            left: 10px !important;
            right: 10px !important;
            background: rgba(42, 42, 62, 0.98) !important;
            backdrop-filter: blur(20px) !important;
            border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
            z-index: 10001 !important;
            padding: 15px !important;
            margin: 0 !important;
            box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3) !important;
            transform: none !important;
            border-radius: 12px !important;
        }
        
        /* Android için gönder butonu boyutunu ayarla */
        .chat-send.keyboard-open {
            min-width: 70px !important;
            max-width: 90px !important;
            padding: 12px 16px !important;
            font-size: 14px !important;
            height: 44px !important;
            line-height: 1 !important;
            display: flex !important;
            align-items: center !important;
            justify-content: center !important;
        }
        
        /* Android için input alanı boyutunu ayarla */
        .chat-text.keyboard-open {
            font-size: 16px !important;
            line-height: 1.4 !important;
            height: 44px !important;
            padding: 10px 14px !important;
            margin-bottom: 0 !important;
        }
        
        /* Android için input container boyutunu sabitle */
        .chat-input.keyboard-open {
            height: auto !important;
            min-height: 74px !important;
            max-height: 84px !important;
        }
    }
    
    /* Chrome için özel düzenlemeler */
    @media screen and (-webkit-min-device-pixel-ratio: 0) {
        .chat-overlay.keyboard-open {
            height: 100vh;
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            transform: none;
        }
        
        .chat-window.keyboard-open {
            height: 100vh;
            display: flex;
            flex-direction: column;
            position: relative;
        }
        
        .chat-messages.keyboard-open {
            flex: 1;
            height: auto;
            min-height: 0;
            padding-bottom: 90px; /* Chrome için daha fazla boşluk */
        }
        
        .chat-input.keyboard-open {
            position: fixed;
            bottom: 0;
            left: 0;
            right: 0;
            background: rgba(42, 42, 62, 0.98);
            backdrop-filter: blur(20px);
            border-top: 1px solid rgba(255, 255, 255, 0.1);
            z-index: 10001;
            padding: 15px;
            margin: 0;
            box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
            /* Chrome için viewport height ayarı */
            padding-bottom: 15px;
        }
        
        /* Chrome için input alanı iyileştirmeleri */
        .chat-text.keyboard-open {
            font-size: 16px;
            line-height: 1.4;
            -webkit-appearance: none;
            border-radius: 12px;
        }
        
        .chat-send.keyboard-open {
            min-width: 70px;
            padding: 12px 16px;
            -webkit-appearance: none;
            border-radius: 12px;
        }
    }
    
    /* Genel mobil iyileştirmeler */
    .chat-text.keyboard-open {
        font-size: 16px; /* iOS'ta zoom'u önlemek için */
        line-height: 1.4;
    }
    
    .chat-send.keyboard-open {
        min-width: 70px;
        padding: 12px 16px;
    }
}

/* Chat Button in Navbar */
.btn-aux {
    background: transparent;
    border: none;
    border-radius: 10px;
    padding: 8px 12px;
    color: #ffffff;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    z-index: 10001;
}

.btn-aux::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: transparent;
    transition: left 0.5s;
}

.btn-aux:hover::before {
    left: 100%;
}

.btn-aux:hover {
    background: transparent;
    border: none;
    transform: none;
    box-shadow: none;
}

.btn-aux:active {
    transform: none;
}

/* Notification Badge for Chat */
.chat-notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: #ffffff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse 2s infinite;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    color: #9ca3af;
    font-size: 12px;
    font-style: italic;
}

.typing-dots {
    display: flex;
    gap: 2px;
}

.typing-dot {
    width: 4px;
    height: 4px;
    background: #9ca3af;
    border-radius: 50%;
    animation: typingPulse 1.4s infinite;
}

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

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

@keyframes typingPulse {
    0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
    30% { opacity: 1; transform: scale(1); }
}
