/* =============================================================================
   SEKCJA 1: KONTENER GŁÓWNY I POZYCJE
   ============================================================================= */
#jdev-ai-agent {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

#jdev-ai-agent.bottom-right { bottom: 20px; right: 20px; }
#jdev-ai-agent.bottom-left { bottom: 20px; left: 20px; }
#jdev-ai-agent.top-right { top: 20px; right: 20px; }
#jdev-ai-agent.top-left { top: 20px; left: 20px; }

/* =============================================================================
   SEKCJA 2: PRZYCISK TOGGLE - UIKIT STYLE
   ============================================================================= */
#jdev-ai-agent .toggle-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--jdev-primary-color, #2B6CB0);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: white;
    padding: 0;
}

#jdev-ai-agent .toggle-btn:hover {
    transform: scale(1.1);
    background: var(--jdev-primary-hover, #1E4E8C);
    box-shadow: 0 6px 20px rgba(0,0,0,0.25);
}

/* =============================================================================
   SEKCJA 3: WIDGET CHATA
   ============================================================================= */
#jdev-ai-widget {
    width: 380px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    overflow: hidden;
    display: none;
    position: absolute;
    bottom: 80px;
    right: 0;
    height: 500px;
    border: 1px solid #e5e7eb;
}

#jdev-ai-agent.bottom-left #jdev-ai-widget { right: auto; left: 0; }
#jdev-ai-agent.top-right #jdev-ai-widget { bottom: auto; top: 80px; }
#jdev-ai-agent.top-left #jdev-ai-widget { bottom: auto; top: 80px; right: auto; left: 0; }

#jdev-ai-widget.visible {
    display: flex;
    flex-direction: column;
    animation: jdevSlideInUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes jdevSlideInUp {
    from { 
        opacity: 0; 
        transform: translateY(20px) scale(0.95); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0) scale(1); 
    }
}

/* =============================================================================
   SEKCJA 4: NAGŁÓWEK Z UIKIT IKONAMI
   ============================================================================= */
.chat-header {
    padding: 16px 20px;
    background: var(--jdev-primary-color, #2B6CB0);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.chat-header h3 {
    margin: 0;
    font-size: 1.2em;
    font-weight: 600;
}

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

.clear-history-btn,
.close-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.clear-history-btn:hover,
.close-btn:hover {
    background: rgba(255,255,255,0.15);
    transform: scale(1.1);
}

/* UIKit Icons Base Styles */
[uk-icon] {
    display: inline-block;
    width: 1em;
    height: 1em;
    vertical-align: middle;
}

/* =============================================================================
   SEKCJA 5: WIADOMOŚCI I CZAT
   ============================================================================= */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message {
    padding: 12px 16px;
    border-radius: 18px;
    max-width: 85%;
    word-wrap: break-word;
    line-height: 1.4;
    animation: jdevMessageSlide 0.3s ease;
    position: relative;
}

@keyframes jdevMessageSlide {
    from { 
        opacity: 0; 
        transform: translateY(8px) scale(0.98); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0) scale(1); 
    }
}

.message.bot {
    background: white;
    align-self: flex-start;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.message.user {
    background: var(--jdev-primary-color, #2B6CB0);
    color: white;
    align-self: flex-end;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.message.error {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
    align-self: center;
    max-width: 90%;
    font-size: 0.9em;
}

.message-content {
    margin-bottom: 4px;
}

.message-time {
    font-size: 0.75em;
    opacity: 0.7;
    margin-top: 6px;
    text-align: right;
}

/* =============================================================================
   SEKCJA 6: ANIMACJA PISANIA - UIKIT STYLE
   ============================================================================= */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #6b7280;
    font-style: italic;
}

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

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

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes jdevTypingBounce {
    0%, 80%, 100% { 
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% { 
        transform: scale(1);
        opacity: 1;
    }
}

/* =============================================================================
   SEKCJA 7: POLE WEJŚCIA I PRZYCISK
   ============================================================================= */
.chat-input-area {
    display: flex;
    padding: 16px;
    border-top: 1px solid #e5e7eb;
    background: white;
    gap: 12px;
    flex-shrink: 0;
}

.chat-input-area textarea {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    height: 50px;
    max-height: 120px;
    transition: all 0.2s ease;
    line-height: 1.4;
}

.chat-input-area textarea:focus {
    outline: none;
    border-color: var(--jdev-primary-color, #2B6CB0);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.send-btn {
    padding: 0 18px;
    background: var(--jdev-primary-color, #2B6CB0);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.send-btn:hover {
    background: var(--jdev-primary-hover, #1E4E8C);
    transform: translateY(-1px);
}

.send-btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    transform: none;
}

/* =============================================================================
   SEKCJA 8: NOTYFIKACJE UIKIT STYLE
   ============================================================================= */
.jdev-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #10B981;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000000;
    animation: jdevSlideInRight 0.3s ease;
}

.jdev-notification.error {
    background: #EF4444;
}

@keyframes jdevSlideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* =============================================================================
   SEKCJA 9: RESPONSYWNOŚĆ
   ============================================================================= */
@media (max-width: 480px) {
    #jdev-ai-widget {
        width: calc(100vw - 40px);
        height: 70vh;
        bottom: 80px;
        right: 20px;
        left: 20px;
    }
    
    .chat-header {
        padding: 12px 16px;
    }
    
    .chat-messages {
        padding: 16px;
    }
}