﻿/* ========== PORTAL-SAFE CHATBOT CSS - DARK THEME ========== */
/* Sadece chatbot elementlerini etkiler - portal stillerini bozmaz */

/* CSS Variables - Dark Theme Chatbot Renkleri */
:root {
    --chatbot-primary: #1F78B5; /* Mavi - butonlar için */
    --chatbot-success: #4DB3A4; /* Yeşil - mesaj kutuları için */
    --chatbot-danger: #ef4444; /* Red */
    --chatbot-warning: #f59e0b; /* Amber */
    --chatbot-info: #06b6d4; /* Cyan */
    --chatbot-dark:; /* Koyu gri */
    --chatbot-light: #f5f5f5; /* Açık gri */
    --chatbot-border: #e0e0e0; /* Kenarlık */
    --chatbot-text-dark: #333333; /* Koyu metin */
    --chatbot-text-muted: #666666; /* Soluk metin */
    --chatbot-bg-primary: #1a1a1a; /* Ana arka plan */
    --chatbot-bg-secondary: #2a2a2a; /* İkincil arka plan */
    --chatbot-bg-tertiary: #333333; /* Üçüncül arka plan */
}
/* En üste ekle */
html body .chat-trigger {
    border-radius: 7px !important;
}

html body .typing-dot {
    border-radius: 50% !important;
}

html body .message-bubble {
    border-radius: 12px !important;
}

/* Page Wrapper - Sadece chat açıkken etkilenir */
.page-wrapper {
    transition: margin-right 0.3s ease;
    width: 100%;
    min-height: 100vh;
    position: relative;
    overflow-x: auto;
}

/* ID selector ile daha spesifik */
#pageWrapper {
    transition: margin-right 0.3s ease !important;
}

    /* Inline style için güçlü kural */
    #pageWrapper[style*="margin-right"] {
        transition: margin-right 0.3s ease !important;
    }

/* Page container için özel kural */
.page-container.page-wrapper {
    transition: margin-right 0.3s ease !important;
}

    .page-container.page-wrapper.chat-open {
        /* margin-right JavaScript ile dinamik olarak ayarlanıyor */
        transition: margin-right 0.3s ease !important;
    }

/* Resize sırasında geçişleri kapat */
.page-wrapper.resizing,
.floating-chat.resizing {
    transition: none !important;
}

.floating-chat {
    z-index: 999 !important; /* 9999'dan düşür */
}
/* Floating Chat Window - Dark Theme + Resizable */
.floating-chat {
    position: fixed;
    top: 0;
    right: -650px;
    width: 650px;
    height: 100vh;
    background: var(--chatbot-bg-primary);
    /*box-shadow: -4px 0 20px rgba(0,0,0,0.4);*/
    border-left: 1px solid var(--chatbot-border);
    z-index: 9999;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    resize: horizontal;
    min-width: 300px;
    max-width: 1200px;
}

    .floating-chat.active {
        right: 0;
    }

/* Resize Handle */
.resize-handle {
    position: absolute;
    left: 0;
    top: 0;
    width: 5px;
    height: 100%;
    background: transparent;
    cursor: ew-resize;
    z-index: 10;
}

/*	.resize-handle:hover,
	.resize-handle.active {
		background: var(--chatbot-primary);
		opacity: 0.5;
	}*/

.floating-chat.resizing {
    transition: none !important;
}

/* Chatbot Header - Dark Theme */
.floating-chat .portlet-title {
    background: linear-gradient(135deg, var(--chatbot-primary), var(--chatbot-success));
    color: white;
    padding: 15px 20px;
    border-bottom: 2px solid rgba(255,255,255,0.2);
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    position: relative;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.floating-chat .caption {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 45px;
}

.floating-chat .caption-subject {
    color: white;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
    margin: 0;
}

.floating-chat .actions {
    display: flex;
    gap: 5px;
    position: relative;
    z-index: 101;
}

    .floating-chat .actions button {
        background: rgba(255,255,255,0.2);
        border: none;
        color: white;
        padding: 5px 8px;
        border-radius: 3px;
        cursor: pointer !important;
        transition: background 0.2s ease;
        position: relative;
        z-index: 102;
        pointer-events: auto !important;
    }

        .floating-chat .actions button:hover {
            background: rgba(255,255,255,0.3);
        }

/* Chatbot Body - Dark Theme */
.floating-chat .portlet-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: white;
    height: calc(100vh - 60px);
    position: relative;
    padding: 0;
}

/* Messages Area - Dark Theme + Claude Style Scroll */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 15px;
    background: #f8f9fa;
    ; /* Koyu gri arka plan */
    border: none;
    border-radius: 0;
    margin: 0;
    position: relative;
    height: auto;
    /* Firefox - Claude style thin scrollbar */
    scrollbar-width: thin;
    scrollbar-color: rgba(140, 140, 140, 0.3) transparent;
}

    /* Webkit Scroll Bar - Claude Style (Always thin, subtle) */
    .chat-messages::-webkit-scrollbar {
        width: 6px;
    }

    .chat-messages::-webkit-scrollbar-track {
        background: transparent;
        margin: 5px 0;
    }

    .chat-messages::-webkit-scrollbar-thumb {
        background: rgba(140, 140, 140, 0.2);
        border-radius: 3px;
        transition: background 0.2s ease;
    }

        .chat-messages::-webkit-scrollbar-thumb:hover {
            background: rgba(140, 140, 140, 0.5);
        }

        .chat-messages::-webkit-scrollbar-thumb:active {
            background: rgba(140, 140, 140, 0.7);
        }

    .chat-messages:not(:hover)::-webkit-scrollbar-thumb {
        background: rgba(140, 140, 140, 0.08);
    }

@supports (scrollbar-width: thin) {
    .chat-messages {
        scrollbar-width: thin;
        scrollbar-color: rgba(140, 140, 140, 0.2) transparent;
    }

        .chat-messages:hover {
            scrollbar-color: rgba(140, 140, 140, 0.4) transparent;
        }
}

/* Message Bubbles - Dark Theme Dikdörtgen Kutucuklar */
.chat-message {
    margin-bottom: 24px;
    padding: 0 15px;
    animation: fadeInUp 0.3s ease;
}

    .chat-message.user,
    .chat-message.ai {
        display: block;
    }

    .chat-message.system {
        text-align: center;
    }

.message-container {
    width: 100%;
    display: block;
}

.message-bubble {
    width: 100%;
    padding: 20px 24px;
    border-radius: 8px;
    position: relative;
    word-wrap: break-word;
    font-size: 15px;
    line-height: 1.6;
}

.chat-message.user .message-bubble {
    background: rgba(31, 120, 181, 0.8);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(31, 120, 181, 0.3);
}

.chat-message.ai .message-bubble {
    background: rgb(60,175, 164,1);
    border: none;
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(77, 179, 164, 0.3);
}

.chat-message.system .message-bubble {
    background: rgba(51, 51, 51, 0.9);
    color: #ffffff;
    border: 1px solid var(--chatbot-dark);
    font-size: 14px;
    padding: 10px 16px;
    max-width: 90%;
    text-align: center;
    margin: 0 auto;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Message Header - Dark Theme */
.message-header {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}

.message-sender {
    font-size: 13px;
    font-weight: 600;
    color: #b0b0b0;
}

    .message-sender i {
        font-size: 16px;
    }

.chat-message.user .message-sender {
    color: #1F78B5;
    font-weight: 700;
}

.chat-message.ai .message-sender {
    color: #4DB3A4;
    font-weight: 700;
}

.message-time {
    font-size: 12px;
    color: #333333;
    margin-left: auto;
    opacity: 0.8;
}

/* Typing Indicator - Dark Theme Minimal Stil */
/* Typing Indicator */
.typing-indicator {
    display: none;
    padding: 0 15px 10px 15px;
    margin: 0;
    animation: fadeInUp 0.3s ease;
    background: #f8f9fa;
    flex-shrink: 0;
}

    .typing-indicator.active {
        display: block;
    }

.typing-bubble {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 8px 0;
    display: flex;
    align-items: center;
    gap: 8px;
    width: auto;
    justify-content: flex-start;
}

    .typing-bubble span {
        font-size: 13px;
        color: #666;
        font-style: italic;
        margin-right: 5px;
    }

/* Typing dots */
.typing-dots {
    display: flex;
    gap: 6px;
    align-items: center;
    padding-left: 10px;
}

.typing-dot {
    width: 10px;
    height: 10px;
    border-radius: 50% !important;
    background: var(--chatbot-success);
    animation: typing 1.8s infinite;
    opacity: 0.4;
}

    .typing-dot:nth-child(1) {
        animation-delay: 0s;
    }

    .typing-dot:nth-child(2) {
        animation-delay: 0.2s;
    }

    .typing-dot:nth-child(3) {
        animation-delay: 0.4s;
    }

@keyframes typing {
    0%, 70%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    35% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Input Area */
.chat-input-area {
    display: flex;
    padding: 20px;
    background: #ffffff;
    border-top: 1px solid var(--chatbot-border);
    margin: 0;
    flex-shrink: 0;
    min-height: 100px;
    align-items: stretch;
}

.input-wrapper {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
    min-height: 80px;
}

.chat-input {
    width: 100%;
    padding: 16px 60px 16px 16px;
    border: 1px solid var(--chatbot-border);
    border-radius: 6px !important;
    resize: none;
    font-size: 14px;
    line-height: 1.5;
    min-height: 60px;
    max-height: 200px;
    transition: all 0.2s ease;
    background: #ffffff;
    color: #333;
    font-family: inherit;
    outline: none;
    overflow-y: hidden;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(140, 140, 140, 0.2) transparent;
}

    /* Textarea Webkit Scrollbar - Claude Style */
    .chat-input::-webkit-scrollbar {
        width: 6px;
    }

    .chat-input::-webkit-scrollbar-track {
        background: transparent;
        margin: 5px 0;
    }

    .chat-input::-webkit-scrollbar-thumb {
        background: rgba(140, 140, 140, 0.15);
        border-radius: 3px;
        transition: background 0.2s ease;
    }

    .chat-input:hover::-webkit-scrollbar-thumb {
        background: rgba(140, 140, 140, 0.3);
    }

    .chat-input::-webkit-scrollbar-thumb:hover {
        background: rgba(140, 140, 140, 0.5);
    }

    .chat-input::-webkit-scrollbar-thumb:active {
        background: rgba(140, 140, 140, 0.7);
    }

    .chat-input:not(:hover)::-webkit-scrollbar-thumb {
        background: rgba(140, 140, 140, 0.05);
    }

    .chat-input:focus {
        border-color: #1F78B5;
        box-shadow: 0 0 0 2px rgba(51, 122, 183, 0.2);
    }

    .chat-input::placeholder {
        color: #333333;
        font-size: 15px;
    }

.send-btn {
    position: absolute;
    right: 12px;
    top: 0;
    bottom: 0;
    margin: auto;
    width: 40px;
    height: 40px;
    border-radius: 6px;
    background: var(--chatbot-success);
    border: none;
    color: white;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(77, 179, 164, 0.4);
    z-index: 10;
}

    .send-btn:hover:not(:disabled) {
        background: #42a094;
        transform: scale(1.05);
        box-shadow: 0 3px 8px rgba(77, 179, 164, 0.6);
    }

    /* Claude Tarzı Button Disable */
    .send-btn:disabled,
    .send-btn.ai-responding {
        background: rgba(136, 136, 136, 0.6) !important;
        cursor: not-allowed !important;
        opacity: 0.4 !important;
        transform: none !important;
        pointer-events: none !important;
        box-shadow: none !important;
        color: rgba(255, 255, 255, 0.5) !important;
    }

        .send-btn[disabled]:hover,
        .send-btn:disabled:hover,
        .send-btn.ai-responding:hover {
            background: rgba(136, 136, 136, 0.6) !important;
            transform: none !important;
            opacity: 0.4 !important;
            box-shadow: none !important;
        }

/* Input alanı AI yanıt verirken - Claude Tarzı */
.chat-input[disabled] {
    background-color: rgba(51, 51, 51, 0.5) !important;
    cursor: not-allowed !important;
    opacity: 0.6 !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
    color: rgba(255, 255, 255, 0.6) !important;
}

/* Chat Trigger Button - Dark Theme */
.chat-trigger {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 100px;
    height: 100px;
    border-radius: 7px !important,;
    background: linear-gradient(135deg, var(--chatbot-primary), var(--chatbot-success));
    border: none;
    color: white;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(38, 166, 154, 0.3);
    z-index: 1000;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

    .chat-trigger:hover {
        background: linear-gradient(135deg, var(--chatbot-primary), var(--chatbot-success));
        transform: scale(1.05);
    }

    .chat-trigger.hidden {
        transform: scale(0);
        opacity: 0;
    }

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive - Mobile */
@media (max-width: 768px) {
    .page-wrapper.chat-open {
        margin-right: 0 !important; /* Mobilde sayfa kaymasın */
    }

    .floating-chat {
        width: 100vw !important;
        right: -100vw;
        resize: none; /* Mobilde resize kapalı */
    }

    .resize-handle {
        display: none; /* Mobilde gizle */
    }

    .floating-chat.active {
        right: 0 !important;
    }

    .message-bubble {
        max-width: 85%;
        font-size: 14px;
    }

    .chat-input {
        font-size: 14px;
        min-height: 70px;
    }
}

/* Resizing sırasında butonları koruma */
.floating-chat.resizing .portlet-title button {
    pointer-events: auto !important;
    z-index: 1000 !important;
}

.nav > li > a:hover {
    background: none !important;
}

.new-chat-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.loading-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--chatbot-primary);
    border-radius: 50% !important;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* chat-manager.css */
.documents-loading {
    padding: 10px 15px;
    background: #f8f9fa;
}

.loading-bubble {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: rgba(77, 179, 164, 0.1);
    border-radius: 8px;
    font-size: 13px;
    color: #4DB3A4;
}
