/* Aidly Chat Widget Styles */
:root {
    --aidly-primary: #3b82f6;
    --aidly-primary-dark: #2563eb;
    --aidly-gradient-blue: linear-gradient(135deg, #3b82f6, #60a5fa);
    --aidly-gradient-purple: linear-gradient(135deg, #9333ea, #ec4899);
    --aidly-gradient-green: linear-gradient(135deg, #16a34a, #10b981);
    --aidly-gradient-orange: linear-gradient(135deg, #ea580c, #dc2626);
    --aidly-gradient-default: linear-gradient(135deg, #3b82f6, #9333ea);
}

#aidly-chat-widget-root {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

/* Widget Button */
.aidly-widget-button {
    position: fixed;
    bottom: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s, box-shadow 0.2s;
    z-index: 999999;
}

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

.aidly-widget-button[data-position="right"] {
    right: 24px;
}

.aidly-widget-button[data-position="left"] {
    left: 24px;
}

.aidly-widget-button svg {
    width: 24px;
    height: 24px;
    color: white;
}

/* Theme Colors */
.aidly-theme-blue { background: var(--aidly-gradient-blue); }
.aidly-theme-purple { background: var(--aidly-gradient-purple); }
.aidly-theme-green { background: var(--aidly-gradient-green); }
.aidly-theme-orange { background: var(--aidly-gradient-orange); }
.aidly-theme-gradient { background: var(--aidly-gradient-default); }
.aidly-theme-custom { background: var(--aidly-gradient-default); }

/* Chat Window */
.aidly-chat-window {
    position: fixed;
    bottom: 96px;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 120px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 999998;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
}

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

.aidly-chat-window[data-position="right"] {
    right: 24px;
}

.aidly-chat-window[data-position="left"] {
    left: 24px;
}

/* Chat Header */
.aidly-chat-header {
    padding: 16px;
    color: white;
    display: flex;
    align-items: center;
    gap: 12px;
}

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

.aidly-chat-header .aidly-info {
    flex: 1;
}

.aidly-chat-header .aidly-name {
    font-weight: 500;
    font-size: 14px;
}

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

.aidly-chat-header .aidly-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ade80;
}

.aidly-chat-header .aidly-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.aidly-chat-header .aidly-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Messages Container */
.aidly-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f9fafb;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Message Bubble */
.aidly-message {
    display: flex;
    gap: 8px;
    max-width: 85%;
}

.aidly-message.aidly-bot {
    align-self: flex-start;
}

.aidly-message.aidly-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.aidly-message .aidly-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
}

.aidly-message.aidly-bot .aidly-bubble {
    background: white;
    border-top-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.aidly-message.aidly-user .aidly-bubble {
    color: white;
    border-top-right-radius: 4px;
}

.aidly-message .aidly-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #e0e7ff, #f3e8ff);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.aidly-message.aidly-user .aidly-avatar {
    display: none;
}

/* Quick Replies */
.aidly-quick-replies {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-left: 40px;
}

.aidly-quick-reply {
    padding: 10px 16px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    font-size: 13px;
    cursor: pointer;
    text-align: left;
    transition: border-color 0.2s, background 0.2s;
}

.aidly-quick-reply:hover {
    border-color: #3b82f6;
    background: #f0f9ff;
}

/* Typing Indicator */
.aidly-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border-radius: 16px;
    border-top-left-radius: 4px;
    width: fit-content;
}

.aidly-typing span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #9ca3af;
    animation: aidly-bounce 1.4s infinite ease-in-out;
}

.aidly-typing span:nth-child(1) { animation-delay: -0.32s; }
.aidly-typing span:nth-child(2) { animation-delay: -0.16s; }

@keyframes aidly-bounce {
    0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* Input Area */
.aidly-input-area {
    padding: 16px;
    border-top: 1px solid #e5e7eb;
    background: white;
    display: flex;
    gap: 8px;
}

.aidly-input-area input {
    flex: 1;
    padding: 12px 16px;
    border: none;
    background: #f3f4f6;
    border-radius: 12px;
    font-size: 14px;
    outline: none;
}

.aidly-input-area input:focus {
    background: #e5e7eb;
}

.aidly-input-area button {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
}

.aidly-input-area button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.aidly-input-area button svg {
    width: 20px;
    height: 20px;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .aidly-chat-window {
        bottom: 0;
        left: 0 !important;
        right: 0 !important;
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .aidly-widget-button {
        bottom: 16px;
    }

    .aidly-widget-button[data-position="right"] {
        right: 16px;
    }

    .aidly-widget-button[data-position="left"] {
        left: 16px;
    }
}
