/* Widget container */
.botlyx-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    line-height: 1.4;
    font-size: 14px;
    z-index: 9999;
}

.botlyx-widget.right {
    right: 20px;
}

.botlyx-widget.left {
    left: 20px;
}

/* Widget Button */
.botlyx-widget-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: #4f46e5;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease;
}

.botlyx-widget-button:hover {
    transform: scale(1.05);
}

.botlyx-widget-button svg {
    width: 30px;
    height: 30px;
}

/* Chat Window */
.botlyx-chat-window {
    position: absolute;
    bottom: 100px;
    right: 0;
    width: 350px;
    height: 500px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.3s ease;
}

.botlyx-widget.left .botlyx-chat-window {
    right: auto;
    left: 0;
}

.botlyx-chat-window.hidden {
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
}

/* Chat Header */
.botlyx-chat-header {
    background: #4f46e5;
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.botlyx-header-content {
    display: flex;
    align-items: center;
}

.botlyx-chat-title {
    font-weight: 600;
    white-space: nowrap;
}

.botlyx-header-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.botlyx-language-select {
    padding: 4px 8px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 80px;
    max-width: 120px;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 24px;
}

.botlyx-language-select:hover {
    background-color: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
}

.botlyx-language-select:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.5);
    background-color: rgba(255, 255, 255, 0.15);
}

.botlyx-language-select option {
    background-color: #4f46e5;
    color: white;
}

.botlyx-close-button {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}

/* Chat Messages */
.botlyx-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.botlyx-message {
    max-width: 80%;
    padding: 10px 15px;
    border-radius: 12px;
    word-wrap: break-word;
}

.botlyx-message.user {
    background: #4f46e5;
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.botlyx-message.bot {
    background: #f3f4f6;
    color: #1f2937;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

/* Message Status */
.botlyx-message-status {
    font-size: 0.8em;
    margin-top: 4px;
    opacity: 0.7;
}

/* Voice Chat Button */
.botlyx-voice-button {
    background: #4f46e5;
    color: white;
    border: none;
    border-radius: 8px;
    width: 36px;
    height: 36px;
    padding: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}

.botlyx-voice-button:hover {
    background: #4338ca;
}

.botlyx-voice-button.recording {
    background-color: #dc2626;
    animation: pulse 1.5s infinite;
}

.botlyx-voice-button svg {
    width: 20px;
    height: 20px;
}

/* Typing Indicator */
.botlyx-typing-indicator {
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.botlyx-typing-indicator.hidden {
    display: none;
}

.botlyx-typing-indicator span {
    width: 8px;
    height: 8px;
    background: #4f46e5;
    border-radius: 50%;
    display: inline-block;
    animation: typing 1.4s infinite ease-in-out;
}

.botlyx-typing-indicator span:nth-child(1) { animation-delay: 0s; }
.botlyx-typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.botlyx-typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Chat Input */
.botlyx-chat-input {
    padding: 15px;
    background: white;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.botlyx-message-input {
    flex: 1;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 8px 12px;
    resize: none;
    max-height: 120px;
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
}

.botlyx-message-input:focus {
    outline: none;
    border-color: #4f46e5;
}

/* Send Button */
.botlyx-send-button {
    background: #4f46e5;
    color: white;
    border: none;
    border-radius: 8px;
    width: 36px;
    height: 36px;
    padding: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}

.botlyx-send-button:hover {
    background: #4338ca;
}

.botlyx-send-button svg {
    width: 20px;
    height: 20px;
}

/* Theme: Dark */
.botlyx-widget.theme-dark .botlyx-chat-window {
    background: #1f2937;
    color: #f3f4f6;
}

.botlyx-widget.theme-dark .botlyx-chat-header {
    background: #111827;
}

.botlyx-widget.theme-dark .botlyx-message.bot {
    background: #374151;
    color: #f3f4f6;
}

.botlyx-widget.theme-dark .botlyx-chat-input {
    background: #1f2937;
    border-top-color: #374151;
}

.botlyx-widget.theme-dark .botlyx-message-input {
    background: #374151;
    border-color: #4b5563;
    color: #f3f4f6;
}

.botlyx-widget.theme-dark .botlyx-message-input:focus {
    border-color: #6366f1;
}

.botlyx-widget.theme-dark .botlyx-language-select {
    background-color: rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.2);
}

.botlyx-widget.theme-dark .botlyx-language-select:hover {
    background-color: rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.3);
}

.botlyx-widget.theme-dark .botlyx-language-select option {
    background-color: #111827;
}

/* Loading States */
#device-frame.loading {
    position: relative;
}

#device-frame.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

#device-frame.loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 4px solid #f3f4f6;
    border-top: 4px solid #4f46e5;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 1001;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Theme: Dark Loading State */
.theme-dark #device-frame.loading::after {
    background: rgba(31, 41, 55, 0.8);
}

.theme-dark #device-frame.loading::before {
    border-color: #374151;
    border-top-color: #6366f1;
}

/* Submit button styles */
.botlyx-submit-button {
    position: relative !important;
    z-index: 10000 !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* Edit Title Styles */
.botlyx-edit-title-button {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    margin-left: 10px;
    font-size: 16px;
}
.botlyx-chat-title-input {
    border: none;
    background: transparent;
    color: inherit;
    font-size: 1em;
    font-weight: 600;
    margin-left: 8px;
    border-bottom: 1px solid transparent;
    transition: border-bottom 0.2s ease;
}
.botlyx-chat-title-input:focus {
    outline: none;
    border-bottom: 1px solid #fff;
}

/* Responsive Design */
@media (max-width: 480px) {
    .botlyx-chat-window {
        width: calc(100vw - 40px);
        height: calc(100vh - 120px);
        bottom: 80px;
    }
    
    .botlyx-widget.right .botlyx-chat-window,
    .botlyx-widget.left .botlyx-chat-window {
        right: 20px;
        left: 20px;
    }
    
    .botlyx-widget-button {
        width: 50px;
        height: 50px;
    }
    
    .botlyx-widget-button svg {
        width: 25px;
        height: 25px;
    }

    .botlyx-header-content {
        gap: 8px;
    }

    .botlyx-chat-title {
        font-size: 14px;
    }

    .botlyx-language-select {
        font-size: 12px;
        padding: 2px 20px 2px 4px;
        min-width: 70px;
    }
}
