/**
 * Premium AI Chat Widget Styles
 * Developed by Cosmopower (Dimitrios Konstantinidis - cosmopower.gr)
 */

#cosmopower-ai-chat-root {
    /* Variables overridden by JS if needed */
    --widget-color: #4f46e5;
    --widget-bg: rgba(255, 255, 255, 0.85);
    --widget-text-dark: #1e293b;
    --widget-text-light: #f8fafc;
    --widget-border: rgba(226, 232, 240, 0.8);
    --widget-shadow: 0 12px 24px -4px rgba(0, 0, 0, 0.15), 0 8px 16px -4px rgba(0, 0, 0, 0.1);

    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Floating Chat Bubble Button */
.cosmopower-chat-bubble {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--widget-color);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.25s;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.cosmopower-chat-bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

.cosmopower-chat-bubble svg {
    width: 28px;
    height: 28px;
    fill: #ffffff;
    transition: transform 0.3s;
}

.cosmopower-chat-bubble.open svg {
    transform: rotate(90deg);
}

/* Chat Window */
.cosmopower-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 520px;
    border-radius: 16px;
    background: var(--widget-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--widget-border);
    box-shadow: var(--widget-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.3s cubic-bezier(0.165, 0.84, 0.44, 1), opacity 0.3s;
}

.cosmopower-chat-window.open {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: auto;
}

/* Chat Window Header */
.cosmopower-chat-header {
    background: var(--widget-color);
    color: var(--widget-text-light);
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.cosmopower-chat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cosmopower-chat-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.cosmopower-chat-title-group h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.2;
}

.cosmopower-chat-status {
    font-size: 11px;
    opacity: 0.8;
    display: flex;
    align-items: center;
    gap: 4px;
}

.cosmopower-chat-status-dot {
    width: 6px;
    height: 6px;
    background: #10b981;
    border-radius: 50%;
}

.cosmopower-chat-close {
    background: none;
    border: none;
    color: var(--widget-text-light);
    cursor: pointer;
    font-size: 20px;
    opacity: 0.7;
    transition: opacity 0.2s;
    padding: 0;
    line-height: 1;
}

.cosmopower-chat-close:hover {
    opacity: 1;
}

/* Chat Messages Body */
.cosmopower-chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: rgba(255, 255, 255, 0.3);
}

/* Scrollbar styling */
.cosmopower-chat-messages::-webkit-scrollbar {
    width: 6px;
}
.cosmopower-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
.cosmopower-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

/* Message Bubbles */
.cosmopower-chat-msg {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 13.5px;
    line-height: 1.5;
    word-break: break-word;
    animation: messageSlideIn 0.25s ease-out;
}

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

.cosmopower-chat-msg.bot {
    align-self: flex-start;
    background: #ffffff;
    color: var(--widget-text-dark);
    border: 1px solid rgba(226, 232, 240, 0.8);
    border-top-left-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.cosmopower-chat-msg.user {
    align-self: flex-end;
    background: var(--widget-color);
    color: var(--widget-text-light);
    border-top-right-radius: 4px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

/* Typing Indicator */
.cosmopower-typing-indicator {
    align-self: flex-start;
    background: #ffffff;
    padding: 12px 16px;
    border-radius: 12px;
    border-top-left-radius: 4px;
    border: 1px solid rgba(226, 232, 240, 0.8);
    display: flex;
    gap: 4px;
}

.cosmopower-typing-indicator span {
    width: 6px;
    height: 6px;
    background: var(--widget-text-dark);
    opacity: 0.4;
    border-radius: 50%;
    animation: typingBounce 1s infinite alternate;
}

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

@keyframes typingBounce {
    from { transform: translateY(0); }
    to { transform: translateY(-6px); }
}

/* Chat Input Footer */
.cosmopower-chat-footer {
    padding: 12px 16px;
    background: #ffffff;
    border-top: 1px solid var(--widget-border);
}

.cosmopower-chat-input-wrapper {
    display: flex;
    align-items: center;
    background: #f1f5f9;
    border-radius: 24px;
    padding: 4px 6px 4px 14px;
    border: 1px solid transparent;
    transition: border-color 0.2s;
}

.cosmopower-chat-input-wrapper:focus-within {
    border-color: var(--widget-color);
    background: #ffffff;
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.1);
}

.cosmopower-chat-input-wrapper input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px 0;
    font-size: 13.5px;
    color: var(--widget-text-dark);
    outline: none;
    box-shadow: none !important;
}

.cosmopower-chat-send-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--widget-color);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
    padding: 0;
}

.cosmopower-chat-send-btn:hover {
    background: var(--widget-color);
    filter: brightness(0.9);
}

.cosmopower-chat-send-btn svg {
    width: 16px;
    height: 16px;
    fill: #ffffff;
}

/* Developer citation */
.cosmopower-chat-citation {
    text-align: center;
    font-size: 10px;
    color: #94a3b8;
    padding: 4px 0 8px 0;
    background: #ffffff;
}

.cosmopower-chat-citation a {
    color: #64748b;
    text-decoration: none;
    font-weight: 600;
}

/* Responsive check */
@media (max-width: 480px) {
    #cosmopower-ai-chat-root {
        bottom: 0;
        right: 0;
        left: 0;
    }
    
    .cosmopower-chat-bubble {
        position: fixed;
        bottom: 20px;
        right: 20px;
    }

    .cosmopower-chat-window {
        position: fixed;
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
        transform: translateY(100%);
    }

    .cosmopower-chat-window.open {
        transform: translateY(0);
    }
}
