/* Chatbox CSS */

/* CSS Custom Properties with defaults */
#yapuka-chatbox {
    --chatbox-primary: #007cba;
    --chatbox-header-bg: #007cba;
    --chatbox-header-text: #ffffff;
    --chatbox-button-bg: #007cba;
    --chatbox-button-text: #ffffff;
    --chatbox-user-msg-bg: #007cba;
    --chatbox-user-msg-text: #ffffff;
    --chatbox-bot-msg-bg: #f1f1f1;
    --chatbox-bot-msg-text: #333333;
}

/* Hide chatbox container initially */
#yapuka-chatbox {
    display: none !important;
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 350px;
    max-width: 90vw;
    z-index: 99999;
}

/* Chatbox window */
.yapuka-chatbox-window {
    background: white;
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
    height: 500px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s, transform 0.3s;
}

/* Show when active class is added */
.yapuka-chatbox-window.active {
    opacity: 1;
    transform: translateY(0);
    display: flex !important;
}

#yapuka-chatbox:has(.yapuka-chatbox-window.active) {
    display: block !important;
}

/* Position variations */
.yapuka-chatbox-bottom-right {
    bottom: 20px;
    right: 20px;
}

.yapuka-chatbox-bottom-left {
    bottom: 20px;
    left: 20px;
}

.yapuka-chatbox-top-right {
    top: 20px;
    right: 20px;
}

.yapuka-chatbox-top-left {
    top: 20px;
    left: 20px;
}

/* Header */
.yapuka-chatbox-header {
    background: var(--chatbox-header-bg, #007cba);
    color: var(--chatbox-header-text, white);
    padding: 15px;
    border-radius: 10px 10px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.yapuka-chatbox-title {
    font-weight: bold;
    font-size: 16px;
}

.yapuka-chatbox-close {
    background: none;
    border: none;
    color: var(--chatbox-header-text, white);
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
}

.yapuka-chatbox-close:hover {
    opacity: 0.8;
}

/* Messages area */
.yapuka-chatbox-messages, .chatbox-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background: #f5f5f5;
}

.chatbox-welcome {
    background: white;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 10px;
}

.chatbox-message {
    margin-bottom: 15px;
    display: flex;
    align-items: flex-start;
}

.chatbox-message.user {
    justify-content: flex-end;
}

.chatbox-message.bot {
    justify-content: flex-start;
}

.chatbox-message-content {
    max-width: 70%;
    padding: 10px 15px;
    border-radius: 15px;
    word-wrap: break-word;
}

.chatbox-message.user .chatbox-message-content {
    background: var(--chatbox-user-msg-bg, #007cba);
    color: var(--chatbox-user-msg-text, white);
    border-bottom-right-radius: 5px;
}

.chatbox-message.bot .chatbox-message-content {
    background: var(--chatbox-bot-msg-bg, white);
    color: var(--chatbox-bot-msg-text, #333);
    border-bottom-left-radius: 5px;
}

/* Clickable option buttons */
.chatbox-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 15px;
    justify-content: flex-start;
}

.chatbox-option-btn {
    background: #f0f4f8;
    border: 1px solid var(--chatbox-primary, #007cba);
    color: var(--chatbox-primary, #007cba);
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chatbox-option-btn:hover {
    background: var(--chatbox-primary, #007cba);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 124, 186, 0.3);
}

.chatbox-option-btn:active {
    transform: translateY(0);
}

/* Input area */
.yapuka-chatbox-input-container {
    padding: 15px;
    background: white;
    border-top: 1px solid #e0e0e0;
    border-radius: 0 0 10px 10px;
    display: flex;
    gap: 10px;
}

.yapuka-chatbox-input, .chatbox-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 10px 15px;
    font-size: 14px;
    outline: none;
}

.yapuka-chatbox-input:focus, .chatbox-input:focus {
    border-color: var(--chatbox-primary, #007cba);
}

.yapuka-chatbox-send, .chatbox-send {
    background: var(--chatbox-primary, #007cba);
    color: white;
    border: none;
    border-radius: 20px;
    padding: 10px 20px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.2s, filter 0.2s;
}

.yapuka-chatbox-send:hover, .chatbox-send:hover {
    filter: brightness(0.85);
}

/* Toggle button */
.yapuka-chatbox-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: var(--chatbox-button-bg, #007cba);
    border: none;
    border-radius: 50%;
    color: var(--chatbox-button-text, white);
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(0,0,0,0.3);
    z-index: 99998;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, filter 0.2s;
}

.yapuka-chatbox-toggle:hover {
    transform: scale(1.1);
    filter: brightness(0.85);
}

/* Position variations for toggle */
.yapuka-chatbox-toggle-bottom-right {
    bottom: 20px;
    right: 20px;
}

.yapuka-chatbox-toggle-bottom-left {
    bottom: 20px;
    left: 20px;
}

.yapuka-chatbox-toggle-top-right {
    top: 20px;
    right: 20px;
}

.yapuka-chatbox-toggle-top-left {
    top: 20px;
    left: 20px;
}

/* Theme variations */
.chatbox-theme-dark {
    background: #2d2d2d;
}

.chatbox-theme-dark .yapuka-chatbox-header {
    background: #1a1a1a;
}

.chatbox-theme-dark .chatbox-messages {
    background: #2d2d2d;
}

.chatbox-theme-dark .chatbox-welcome,
.chatbox-theme-dark .chatbox-message.bot .chatbox-message-content {
    background: #3d3d3d;
    color: #e0e0e0;
}

.chatbox-theme-dark .yapuka-chatbox-input-container {
    background: #1a1a1a;
    border-top-color: #444;
}

.chatbox-theme-dark .chatbox-input {
    background: #2d2d2d;
    color: white;
    border-color: #444;
}

/* Mobile responsiveness */
@media (max-width: 480px) {
    #yapuka-chatbox {
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
        border-radius: 0;
    }

    .yapuka-chatbox-header {
        border-radius: 0;
    }

    .yapuka-chatbox-input-container {
        border-radius: 0;
    }
}

/* Typing indicator */
#chatbox-typing {
    display: none;
    padding: 10px;
    font-style: italic;
    color: #666;
}

#chatbox-typing.active {
    display: block;
}

/* Avatar */
.chatbox-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    margin-right: 10px;
}

/* Animations */
@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Loading dots animation */
@keyframes loadingDots {
    0% { content: '.'; }
    33% { content: '..'; }
    66% { content: '...'; }
}

.loading::after {
    content: '.';
    animation: loadingDots 1.5s infinite;
}