/**
 * KA Chatbot - Style CSS
 *
 * @package KA_Chatbot_Site
 */

.ka-chatbot-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 380px;
    max-width: calc(100vw - 40px);
    max-height: 600px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.ka-chatbot-container.ka-chatbot-minimized {
    max-height: 60px;
    overflow: hidden;
}

.ka-chatbot-container.ka-chatbot-minimized .ka-chatbot-messages,
.ka-chatbot-container.ka-chatbot-minimized .ka-chatbot-typing,
.ka-chatbot-container.ka-chatbot-minimized .ka-chatbot-input-container {
    display: none;
}

/* Styl osadzony (embedded) */
.ka-chatbot-container.ka-chatbot-embedded {
    position: relative;
    bottom: auto;
    right: auto;
    width: 100%;
    max-width: 100%;
    margin: 20px 0;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.ka-chatbot-container.ka-chatbot-embedded .ka-chatbot-header {
    cursor: default;
}

.ka-chatbot-container.ka-chatbot-embedded .ka-chatbot-toggle {
    display: none;
}

.ka-chatbot-container.ka-chatbot-embedded .ka-chatbot-messages {
    max-height: 500px;
    min-height: 300px;
}

/* Header */
.ka-chatbot-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    padding: var(--ka-chatbot-header-padding, 16px) 20px;
    border-radius: 16px 16px 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
}

/* Jeśli ustawiono kolor przez style attribute, użyj go zamiast gradientu */
.ka-chatbot-header[style*="background"] {
    background: var(--ka-chatbot-header-color, #6a11cb) !important;
}

.ka-chatbot-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.ka-chatbot-toggle {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #ffffff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    line-height: 1;
    transition: background 0.2s ease;
}

.ka-chatbot-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
}

.ka-chatbot-toggle-icon {
    display: block;
}

/* Messages Container */
.ka-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    max-height: 400px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8f9fa;
}

.ka-chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.ka-chatbot-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.ka-chatbot-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.ka-chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Message */
.ka-chatbot-message {
    display: flex;
    animation: messageSlideIn 0.3s ease;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ka-chatbot-message-user {
    justify-content: flex-end;
}

.ka-chatbot-message-assistant {
    justify-content: flex-start;
}

.ka-chatbot-message-system {
    justify-content: center;
    margin: 8px 0;
}

.ka-chatbot-message-content {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    line-height: 1.5;
    font-size: 14px;
}

.ka-chatbot-message-user .ka-chatbot-message-content {
    background: var(--ka-chatbot-user-bg, #7b5bf2);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.ka-chatbot-message-assistant .ka-chatbot-message-content {
    background: var(--ka-chatbot-response-bg, #ffffff);
    color: #333333;
    border: 1px solid #e0e0e0;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.ka-chatbot-message-system .ka-chatbot-message-content {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffc107;
    border-radius: 12px;
    font-size: 13px;
    font-style: italic;
    text-align: center;
    padding: 10px 14px;
    max-width: 90%;
}

/* Typing Indicator */
.ka-chatbot-typing {
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f8f9fa;
    border-top: 1px solid #e0e0e0;
}

.ka-chatbot-typing-text {
    font-size: 13px;
    color: #666666;
    font-style: italic;
}

.ka-chatbot-typing-dots {
    display: flex;
    gap: 4px;
}

.ka-chatbot-typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #667eea;
    animation: typingDot 1.4s infinite ease-in-out;
}

.ka-chatbot-typing-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.ka-chatbot-typing-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typingDot {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Input Container */
.ka-chatbot-input-container {
    display: flex;
    padding: 16px;
    gap: 8px;
    background: #ffffff;
    border-top: 1px solid #e0e0e0;
    border-radius: 0 0 16px 16px;
}

.ka-chatbot-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e0e0e0;
    border-radius: 24px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.ka-chatbot-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.ka-chatbot-input:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
}

.ka-chatbot-send {
    width: 44px;
    height: 44px;
    border: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    flex-shrink: 0;
}

/* Jeśli ustawiono kolor przez style attribute, użyj go zamiast gradientu */
.ka-chatbot-send[style*="background"] {
    background: var(--ka-chatbot-button-color, #6a11cb) !important;
}

.ka-chatbot-send:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.ka-chatbot-send:active:not(:disabled) {
    transform: scale(0.95);
}

.ka-chatbot-send:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.ka-chatbot-send svg {
    width: 20px;
    height: 20px;
}

/* Error Message */
.ka-chatbot-error {
    padding: 16px;
    background: #fee;
    color: #c33;
    border: 1px solid #fcc;
    border-radius: 8px;
    margin: 20px;
}

/* Responsive */
@media (max-width: 768px) {
    .ka-chatbot-container {
        width: calc(100vw - 20px);
        right: 10px;
        bottom: 10px;
        max-height: calc(100vh - 20px);
    }

    .ka-chatbot-messages {
        max-height: calc(100vh - 200px);
    }
}

