/* AI-Era Chat Widget Styles */

.aiera-chat-container {
    position: fixed;
    z-index: 2147483000;
    font-family: var(--aiera-font, 'Public Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif);
}

.aiera-chat-container[data-position='bottom-right'] {
    bottom: 20px;
    right: 20px;
}

.aiera-chat-container[data-position='bottom-left'] {
    bottom: 20px;
    left: 20px;
}

/* Toggle Button */
.aiera-chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--aiera-primary, #3b82f6);
    border: none;
    color: white;
    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;
}

.aiera-chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.aiera-chat-toggle svg {
    width: 24px;
    height: 24px;
}

/* Chat Window */
.aiera-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 500px;
    background: var(--aiera-bg, #ffffff);
    border-radius: var(--aiera-radius, 8px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.aiera-chat-container[data-position='bottom-left'] .aiera-chat-window {
    right: auto;
    left: 0;
}

/* Header */
.aiera-chat-header {
    padding: 16px;
    background: var(--aiera-primary, #3b82f6);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.aiera-chat-title {
    font-weight: 600;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.aiera-status-dot {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.aiera-chat-close {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.aiera-chat-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

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

.aiera-message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: var(--aiera-radius, 8px);
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.aiera-message-user {
    align-self: flex-end;
    background: var(--aiera-primary, #3b82f6);
    color: white;
    border-bottom-right-radius: 4px;
}

.aiera-message-bot {
    align-self: flex-start;
    background: #ffffff;
    color: var(--aiera-text, #1e293b);
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
}

.aiera-message-content {
    white-space: normal !important;
    overflow-wrap: anywhere;
    line-break: auto;
}

.aiera-message-content > * {
    max-width: 100%;
}

.aiera-message-content p,
.aiera-message-content ul,
.aiera-message-content ol,
.aiera-message-content pre,
.aiera-message-content blockquote {
    margin: 0 0 10px;
}

.aiera-message-content p:last-child,
.aiera-message-content ul:last-child,
.aiera-message-content ol:last-child,
.aiera-message-content pre:last-child,
.aiera-message-content blockquote:last-child {
    margin-bottom: 0;
}

.aiera-message-content a {
    color: inherit;
    text-decoration: underline;
}

.aiera-message-content code {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 4px;
    border-radius: 4px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
}

.aiera-message-content pre {
    overflow-x: auto;
    background: rgba(15, 23, 42, 0.06);
    border-radius: 6px;
    padding: 8px 10px;
}

/* Sources */
.aiera-sources {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.aiera-source-link {
    font-size: 12px;
    color: var(--aiera-primary, #3b82f6);
    text-decoration: none;
    padding: 4px 8px;
    background: rgba(59, 130, 246, 0.1);
    border-radius: 4px;
    transition: background 0.2s;
}

.aiera-source-link:hover {
    background: rgba(59, 130, 246, 0.2);
}

/* Input Area */
.aiera-chat-input-area {
    padding: 16px;
    border-top: 1px solid #e2e8f0;
    background: #ffffff;
}

.aiera-chat-form {
    display: flex;
    gap: 8px;
}

.aiera-chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e2e8f0;
    border-radius: var(--aiera-radius, 8px);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.aiera-chat-input:focus {
    border-color: var(--aiera-primary, #3b82f6);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.aiera-chat-submit {
    width: 44px;
    height: 44px;
    border-radius: var(--aiera-radius, 8px);
    background: var(--aiera-primary, #3b82f6);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s, transform 0.2s;
}

.aiera-chat-submit:hover {
    opacity: 0.9;
}

.aiera-chat-submit:active {
    transform: scale(0.95);
}

.aiera-chat-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Typing Indicator */
.aiera-typing-indicator {
    padding: 8px 16px;
    display: flex;
    gap: 4px;
    align-self: flex-start;
}

.aiera-typing-indicator span {
    width: 8px;
    height: 8px;
    background: #94a3b8;
    border-radius: 50%;
    animation: aiera-typing 1.4s infinite;
}

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

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

@keyframes aiera-typing {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-4px);
    }
}

/* Lead Form */
.aiera-lead-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.aiera-lead-form h4 {
    margin: 0 0 8px;
    font-size: 14px;
    font-weight: 600;
}

.aiera-lead-form input,
.aiera-lead-form textarea {
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.aiera-lead-form input:focus,
.aiera-lead-form textarea:focus {
    border-color: var(--aiera-primary, #3b82f6);
}

.aiera-lead-form textarea {
    resize: vertical;
    min-height: 80px;
}

.aiera-btn-submit {
    padding: 12px;
    background: var(--aiera-primary, #3b82f6);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.aiera-btn-submit:hover {
    opacity: 0.9;
}

.aiera-success {
    color: #22c55e;
    font-weight: 600;
    text-align: center;
    padding: 20px;
}

/* Interactive Elements */
.aiera-interactive {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 8px;
}

.aiera-slider-group,
.aiera-checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.aiera-slider-group label,
.aiera-checkbox-group label {
    font-size: 13px;
    color: #64748b;
}

.aiera-choice-hint {
    font-size: 12px;
    color: #64748b;
    margin: 2px 0 0;
}

.aiera-step-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.aiera-step-question label {
    display: block;
    margin: 6px 0;
}

.aiera-step-other {
    width: 100%;
    margin-top: 6px;
    padding: 8px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 13px;
}

.aiera-price-slider {
    width: 100%;
    accent-color: var(--aiera-primary, #3b82f6);
}

/* Error State */
.aiera-error {
    background: #fef2f2;
    color: #dc2626;
    padding: 12px 16px;
    border-radius: var(--aiera-radius, 8px);
    font-size: 14px;
}

/* Responsive */
@media (max-width: 480px) {
    .aiera-chat-window {
        width: calc(100vw - 32px);
        height: calc(100vh - 140px);
        right: -8px;
    }
    
    .aiera-chat-container[data-position='bottom-left'] .aiera-chat-window {
        right: auto;
        left: -8px;
    }
    
    .aiera-message {
        max-width: 90%;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .aiera-chat-messages {
        background: #1e293b;
    }
    
    .aiera-message-bot {
        background: #334155;
        border-color: #475569;
        color: #f1f5f9;
    }
    
    .aiera-chat-input {
        background: #334155;
        border-color: #475569;
        color: #f1f5f9;
    }
    
    .aiera-chat-input-area {
        background: #1e293b;
        border-color: #475569;
    }
    
    .aiera-lead-form input,
    .aiera-lead-form textarea {
        background: #334155;
        border-color: #475569;
        color: #f1f5f9;
    }
}