/* Chatly Free Frontend Styles */

#chatly-container {
    position: fixed;
    bottom: 20px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

#chatly-container[data-position="right"] { right: 20px; }
#chatly-container[data-position="left"] { left: 20px; }

/* Chat Button */
.chatly-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--chatly-color, #7B3F9E);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.chatly-button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0,0,0,0.2);
}

.chatly-button svg {
    width: 28px;
    height: 28px;
    fill: #fff;
}

.chatly-button.open svg:first-child { display: none; }
.chatly-button.open svg:last-child { display: block; }
.chatly-button svg:last-child { display: none; }

/* Welcome Bubble */
.chatly-welcome-bubble {
    position: absolute;
    bottom: 70px;
    background: #fff;
    padding: 12px 16px;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
    max-width: 220px;
    font-size: 14px;
    line-height: 1.4;
    animation: chatlyBubble 0.3s ease;
}

#chatly-container[data-position="right"] .chatly-welcome-bubble { right: 0; }
#chatly-container[data-position="left"] .chatly-welcome-bubble { left: 0; }

.chatly-welcome-bubble::after {
    content: '';
    position: absolute;
    bottom: -8px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid #fff;
}

#chatly-container[data-position="right"] .chatly-welcome-bubble::after { right: 20px; }
#chatly-container[data-position="left"] .chatly-welcome-bubble::after { left: 20px; }

.chatly-bubble-close {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 20px;
    height: 20px;
    background: #ddd;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 12px;
    line-height: 20px;
}

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

/* Chat Window */
.chatly-window {
    position: absolute;
    bottom: 70px;
    width: 380px;
    height: 500px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 5px 40px rgba(0,0,0,0.16);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: chatlyWindow 0.3s ease;
}

#chatly-container[data-position="right"] .chatly-window { right: 0; }
#chatly-container[data-position="left"] .chatly-window { left: 0; }

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

/* Header */
.chatly-header {
    background: var(--chatly-color, #7B3F9E);
    color: #fff;
    padding: 18px 20px;
    font-weight: 600;
    font-size: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chatly-header-close {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
    opacity: 0.8;
}

.chatly-header-close:hover { opacity: 1; }

/* Messages */
.chatly-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chatly-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    animation: chatlyMessage 0.3s ease;
}

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

.chatly-message.user {
    align-self: flex-end;
    background: var(--chatly-color, #7B3F9E);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chatly-message.assistant {
    align-self: flex-start;
    background: #f0f0f0;
    color: #333;
    border-bottom-left-radius: 4px;
}

.chatly-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

.chatly-typing span {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: chatlyTyping 1.4s infinite;
}

.chatly-typing span:nth-child(2) { animation-delay: 0.2s; }
.chatly-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes chatlyTyping {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-8px); }
}

/* Input Area */
.chatly-input-area {
    padding: 15px 20px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
}

.chatly-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 24px;
    padding: 12px 18px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.chatly-input:focus {
    border-color: var(--chatly-color, #7B3F9E);
}

.chatly-send {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: var(--chatly-color, #7B3F9E);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
}

.chatly-send:hover { opacity: 0.9; }
.chatly-send:disabled { opacity: 0.5; cursor: not-allowed; }

.chatly-send svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* Powered By - Free Version */
.chatly-powered {
    padding: 8px;
    text-align: center;
    font-size: 11px;
    color: #999;
    background: #fafafa;
    border-top: 1px solid #eee;
}

.chatly-powered a {
    color: #7B3F9E;
    text-decoration: none;
}

.chatly-powered a:hover { text-decoration: underline; }

/* Error Message */
.chatly-error {
    background: #fee;
    color: #c00;
    padding: 12px 16px;
    border-radius: 8px;
    margin: 10px;
    font-size: 13px;
    text-align: center;
}

.chatly-error a {
    color: #7B3F9E;
    font-weight: 600;
}

/* Mobile */
@media (max-width: 480px) {
    .chatly-window {
        width: calc(100vw - 40px);
        height: calc(100vh - 120px);
        max-height: 500px;
    }
}
