/* Chatbot Widget Styles - Integrated */
:root {
    /* Mapowanie zmiennych widgetu na zmienne portfolio lub definicja własnych */
    --bot-msg-bg: var(--light-gray, #f3f4f6);
    --user-msg-bg: var(--primary-color, #6366f1);
    --bot-text-color: var(--dark-color, #1f2937);
    --bot-white: var(--light-color, #ffffff);
}

/* Chatbot Widget Container */
.chatbot-widget {
    position: fixed;
    bottom: 30px; /* Dopasowane do quick-contact-btn */
    right: 30px;
    z-index: 200000; /* Dopasowane do quick-contact-btn z styles.css */
    font-family: 'Inter', sans-serif;
}

/* Launcher Button */
.chat-launcher {
    width: 60px;
    height: 60px;
    background: var(--primary-color, #6366f1);
    border-radius: 50%;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, background 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    /* Animation pulse like original quick contact */
    animation: pulse-bot 2s infinite;
}

@keyframes pulse-bot {
    0% { box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4); }
    50% { box-shadow: 0 4px 20px rgba(99, 102, 241, 0.6), 0 0 0 10px rgba(99, 102, 241, 0.1); }
    100% { box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4); }
}

.chat-launcher:hover {
    transform: scale(1.1);
    background: var(--secondary-color, #4f46e5);
}

.chat-launcher i {
    color: var(--bot-white);
    font-size: 24px;
}

.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    font-size: 12px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    border: 2px solid var(--bot-white);
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {transform: translateY(0);}
    40% {transform: translateY(-5px);}
    60% {transform: translateY(-3px);}
}

/* Chat Window */
.chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    height: 500px;
    background: var(--bot-white);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    transform: scale(0);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.19, 1, 0.22, 1);
    visibility: hidden;
    border: 1px solid var(--border-color, #e5e7eb);
}

.chat-window.active {
    transform: scale(1);
    opacity: 1;
    visibility: visible;
}

/* Header */
.chat-header {
    background: var(--primary-color, #6366f1);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--bot-white);
}

.header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.avatar {
    position: relative;
    width: 40px;
    height: 40px;
}

.avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.5);
}

.status-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
    background: #10b981;
    border-radius: 50%;
    border: 2px solid var(--primary-color, #6366f1);
}

.header-info h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    color: white;
}

.status-text {
    font-size: 0.75rem;
    opacity: 0.9;
    display: block;
    color: rgba(255,255,255,0.9);
}

.close-chat {
    background: none;
    border: none;
    color: var(--bot-white);
    cursor: pointer;
    font-size: 1.2rem;
    opacity: 0.8;
    transition: opacity 0.2s;
    padding: 0;
}

.close-chat:hover {
    opacity: 1;
}

/* Messages Area */
.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f9fafb; /* Light gray background for messages */
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Dark mode adjustment if needed, assuming styles.css handles it via variables */
:root[data-theme="dark"] .chat-messages {
    background: var(--light-gray);
}

.message {
    max-width: 80%;
    display: flex;
    flex-direction: column;
    animation: slideIn 0.3s ease;
}

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

.message.bot {
    align-self: flex-start;
}

.message.user {
    align-self: flex-end;
}

.message-content {
    padding: 10px 15px;
    border-radius: 15px;
    font-size: 0.9rem;
    line-height: 1.4;
    position: relative;
    word-wrap: break-word;
}

.message.bot .message-content {
    background: var(--bot-msg-bg);
    color: var(--bot-text-color);
    border-bottom-left-radius: 5px;
    border: 1px solid rgba(0,0,0,0.05);
}

.message.user .message-content {
    background: var(--user-msg-bg);
    color: white;
    border-bottom-right-radius: 5px;
}

.message-time {
    font-size: 0.7rem;
    color: var(--gray-color, #6b7280);
    margin-top: 5px;
    margin-left: 5px;
}

.message.user .message-time {
    text-align: right;
    margin-right: 5px;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 10px 15px;
    background: var(--bot-msg-bg);
    border-radius: 15px;
    width: fit-content;
    border-bottom-left-radius: 5px;
    margin-bottom: 10px;
    border: 1px solid rgba(0,0,0,0.05);
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: #9ca3af;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.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%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

/* Input Area */
.chat-input-area {
    padding: 15px;
    background: var(--bot-white);
    border-top: 1px solid var(--border-color, #e5e7eb);
}

.quick-replies {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 10px;
    margin-bottom: 5px;
    scrollbar-width: none; 
    -ms-overflow-style: none;
}

.quick-replies::-webkit-scrollbar { 
    display: none; 
}

.reply-btn {
    background: var(--light-gray, #eef2ff);
    color: var(--primary-color, #6366f1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
}

.reply-btn:hover {
    background: var(--primary-color, #6366f1);
    color: white;
    border-color: var(--primary-color, #6366f1);
}

.input-wrapper {
    display: flex;
    gap: 10px;
}

#userInput {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 25px;
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s;
    background: var(--bot-white);
    color: var(--bot-text-color);
}

#userInput:focus {
    border-color: var(--primary-color, #6366f1);
}

#sendMessage {
    width: 40px;
    height: 40px;
    background: var(--primary-color, #6366f1);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

#sendMessage:hover {
    transform: scale(1.1);
    background: var(--secondary-color, #4f46e5);
}

#sendMessage:active {
    transform: scale(0.9);
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    .chat-window {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        right: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
        z-index: 200005; /* Higher than button on mobile */
        transform-origin: bottom right;
    }
    
    .chatbot-widget {
        position: static; /* Reset positioning context so window is viewport-relative if needed, though fixed works anyway */
        width: 0;
        height: 0;
    }
    
    .chat-launcher {
        position: fixed;
        bottom: 20px;
        right: 20px;
        z-index: 200000;
    }

    /* Lift launcher if cookie banner is visible - handled by JS or parent CSS */
    .cookie-banner-visible .chat-launcher {
        bottom: 100px;
    }
}