/* Основні стилі чат-віджета */
.wp-chat-n8n-widget {
    position: fixed;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.wp-chat-n8n-widget.position-bottom-right {
    bottom: 20px;
    right: 20px;
}

.wp-chat-n8n-widget.position-bottom-left {
    bottom: 20px;
    left: 20px;
}

/* Кнопка чату */
.wp-chat-n8n-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--chat-primary-color, #0084ff);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.wp-chat-n8n-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.wp-chat-n8n-button svg {
    width: 30px;
    height: 30px;
    fill: white;
}

.wp-chat-n8n-button .close-icon {
    display: none;
}

.wp-chat-n8n-button.active .chat-icon {
    display: none;
}

.wp-chat-n8n-button.active .close-icon {
    display: block;
}

/* Вікно чату */
.wp-chat-n8n-window {
    position: absolute;
    bottom: 80px;
    width: 380px;
    height: 550px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.wp-chat-n8n-widget.position-bottom-right .wp-chat-n8n-window {
    right: 0;
}

.wp-chat-n8n-widget.position-bottom-left .wp-chat-n8n-window {
    left: 0;
}

.wp-chat-n8n-window.active {
    display: flex;
    animation: slideUp 0.3s ease;
}

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

/* Заголовок чату */
.wp-chat-n8n-header {
    background: var(--chat-primary-color, #0084ff);
    color: white;
    padding: 20px;
    font-weight: 600;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.wp-chat-n8n-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.wp-chat-n8n-header-icon {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wp-chat-n8n-header-icon svg {
    width: 18px;
    height: 18px;
    fill: white;
}

/* Кнопка закриття чату */
.wp-chat-n8n-close {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: opacity 0.2s;
}

.wp-chat-n8n-close:hover {
    opacity: 0.8;
}

.wp-chat-n8n-close svg {
    width: 24px;
    height: 24px;
    fill: white;
}

/* Тіло чату - повідомлення */
.wp-chat-n8n-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f5f5f5;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

.wp-chat-n8n-messages::-webkit-scrollbar-track {
    background: transparent;
}

.wp-chat-n8n-messages::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

/* Повідомлення */
.wp-chat-message {
    display: flex;
    margin-bottom: 8px;
    gap: 10px;
    align-items: flex-end;
}

.wp-chat-message.user {
    justify-content: flex-start;
}

.wp-chat-message.bot {
    justify-content: flex-end;
    flex-direction: row-reverse;
}

/* Аватари */
.wp-chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wp-chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.wp-chat-avatar-default {
    background: #e2e8f0;
}

.wp-chat-message.user .wp-chat-avatar-default {
    background: #718096;
}

.wp-chat-message.bot .wp-chat-avatar-default {
    background: var(--chat-primary-color, #0084ff);
}
    background: #718096;
}

.wp-chat-avatar-default svg {
    width: 20px;
    height: 20px;
    fill: white;
}

.wp-chat-message-content {
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    font-size: 14px;
    line-height: 1.4;
    white-space: pre-wrap;
}

.wp-chat-message.user .wp-chat-message-content {
    background: #e2e8f0;
    color: #2d3748;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    max-width: calc(95% - 46px);
    width: 100%;
    text-align: left;
}

.wp-chat-message.bot .wp-chat-message-content {
    background: var(--chat-primary-color, #0084ff);
    color: white;
    border-bottom-right-radius: 4px;
    max-width: calc(95% - 46px);
    width: 100%;
    text-align: right;
}

/* Індикатор набору */
.wp-chat-typing {
    display: none;
    padding: 12px 16px;
    background: white;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    width: fit-content;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.wp-chat-typing.active {
    display: block;
}

.wp-chat-typing-dots {
    display: flex;
    gap: 4px;
}

.wp-chat-typing-dot {
    width: 8px;
    height: 8px;
    background: #cbd5e0;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

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

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Форма введення */
.wp-chat-n8n-input-area {
    padding: 16px;
    background: white;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.wp-chat-n8n-input {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    resize: none;
    max-height: 100px;
    min-height: 40px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.wp-chat-n8n-input:focus {
    border-color: var(--chat-primary-color, #0084ff);
}

.wp-chat-n8n-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--chat-primary-color, #0084ff);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.wp-chat-n8n-send:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 132, 255, 0.3);
}

.wp-chat-n8n-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.wp-chat-n8n-send svg {
    width: 20px;
    height: 20px;
    fill: white;
}

/* Привітальне повідомлення */
.wp-chat-welcome {
    text-align: center;
    padding: 20px;
    color: #718096;
}

.wp-chat-welcome h3 {
    margin: 0 0 8px 0;
    color: #2d3748;
    font-size: 16px;
}

.wp-chat-welcome p {
    margin: 0;
    font-size: 14px;
}

/* Мобільна адаптація */
@media (max-width: 480px) {
    .wp-chat-n8n-window {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .wp-chat-n8n-widget.position-bottom-left .wp-chat-n8n-window,
    .wp-chat-n8n-widget.position-bottom-right .wp-chat-n8n-window {
        left: 0;
        right: 0;
    }
    
    /* На мобільних ховаємо основну кнопку коли чат відкритий */
    .wp-chat-n8n-window.active ~ .wp-chat-n8n-button {
        display: none;
    }
    
    /* Робимо кнопку закриття більш помітною */
    .wp-chat-n8n-close {
        padding: 8px;
    }
    
    .wp-chat-n8n-close svg {
        width: 28px;
        height: 28px;
    }
}
