/* AI Chat Assistant - Modern Frontend Widget */
:root {
    --aica-primary: #2563EB;
    --aica-secondary: #1E40AF;
    --aica-header-bg: #2563EB;
    --aica-user-bg: #2563EB;
    --aica-user-text: #FFFFFF;
    --aica-ai-bg: #F3F4F6;
    --aica-ai-text: #1F2937;
    --aica-btn-bg: #2563EB;
    --aica-btn-hover: #1D4ED8;
    --aica-font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --aica-width: 380px;
    --aica-height: 580px;
    --aica-radius: 16px;
    --aica-shadow: 0 12px 36px rgba(0, 0, 0, 0.16);
}

/* Positions */
#aica-widget-root {
    position: fixed;
    z-index: 999999;
    font-family: var(--aica-font);
    line-height: 1.5;
    box-sizing: border-box;
}

#aica-widget-root *, #aica-widget-root *::before, #aica-widget-root *::after {
    box-sizing: border-box;
}

.aica-position-bottom_right {
    bottom: 24px;
    right: 24px;
}

.aica-position-bottom_left {
    bottom: 24px;
    left: 24px;
}

/* Floating Launcher Button */
.aica-launcher-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--aica-btn-bg);
    color: #FFFFFF;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 18px rgba(37, 99, 235, 0.35);
    position: relative;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.2s;
    outline: none;
}

.aica-launcher-btn:hover {
    background-color: var(--aica-btn-hover);
    transform: scale(1.06);
}

.aica-pulse-ring {
    position: absolute;
    top: -4px; left: -4px; right: -4px; bottom: -4px;
    border-radius: 50%;
    border: 2px solid var(--aica-btn-bg);
    animation: aica-pulse 2.2s infinite;
    pointer-events: none;
    opacity: 0.8;
}

@keyframes aica-pulse {
    0% { transform: scale(0.95); opacity: 0.8; }
    50% { transform: scale(1.2); opacity: 0; }
    100% { transform: scale(0.95); opacity: 0; }
}

/* Chat Box Window */
.aica-chat-box {
    position: absolute;
    bottom: 74px;
    width: var(--aica-width);
    height: var(--aica-height);
    background: #FFFFFF;
    border-radius: var(--aica-radius);
    box-shadow: var(--aica-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.25s;
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.aica-position-bottom_right .aica-chat-box {
    right: 0;
    transform-origin: bottom right;
}

.aica-position-bottom_left .aica-chat-box {
    left: 0;
    transform-origin: bottom left;
}

.aica-chat-box.aica-hidden {
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.94);
    pointer-events: none;
}

/* Header */
.aica-chat-header {
    background: var(--aica-header-bg);
    color: #FFFFFF;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.aica-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.aica-header-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: visible;
}

.aica-header-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.aica-status-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #10B981;
    border: 2px solid var(--aica-header-bg);
}

.aica-bot-name {
    margin: 0;
    font-size: var(--aica-header-title-size, 15px);
    font-family: var(--aica-header-title-font, inherit);
    font-weight: 600;
    line-height: 1.2;
    color: var(--aica-header-title-color, #FFFFFF);
}

.aica-bot-status {
    font-size: 11px;
    opacity: 0.9;
    color: #E0E7FF;
}

.aica-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.aica-action-btn {
    background: transparent;
    border: none;
    color: #FFFFFF;
    cursor: pointer;
    opacity: 0.8;
    padding: 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s, background 0.2s;
}

.aica-action-btn:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.15);
}

.aica-header-wa-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #10B981;
    color: #FFFFFF !important;
    text-decoration: none !important;
    padding: 4px 9px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.2;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(16, 185, 129, 0.3);
    margin-right: 4px;
}

.aica-header-wa-btn:hover {
    background: #059669;
    transform: translateY(-1px);
}

.aica-header-wa-btn.aica-hidden {
    display: none !important;
}

.aica-msg-admin {
    align-self: flex-start;
}

.aica-msg-admin .aica-bubble {
    background: #EFF6FF !important;
    color: #1E3A8A !important;
    border-left: 3px solid #2563EB !important;
    border-bottom-left-radius: 4px;
}

.aica-admin-badge {
    font-size: 10.5px;
    font-weight: 700;
    color: #2563EB;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Messages Body */
.aica-messages-body {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background: #F9FAFB;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.aica-msg-row {
    display: flex;
    flex-direction: column;
    max-width: 82%;
    animation: aica-fadeIn 0.25s ease-out;
}

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

.aica-msg-user {
    align-self: flex-end;
}

.aica-msg-ai {
    align-self: flex-start;
}

.aica-bubble {
    padding: 10px 14px;
    border-radius: 14px;
    font-family: var(--aica-font, inherit);
    font-size: var(--aica-font-size, 14px);
    line-height: 1.5;
    word-break: break-word;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.aica-bubble strong {
    font-weight: 700;
    color: inherit;
}

.aica-msg-user .aica-bubble {
    background: var(--aica-user-bg);
    color: var(--aica-user-text);
    border-bottom-right-radius: 4px;
}

.aica-msg-ai .aica-bubble {
    background: var(--aica-ai-bg);
    color: var(--aica-ai-text);
    border-bottom-left-radius: 4px;
}

.aica-msg-time {
    font-size: 10px;
    color: #9CA3AF;
    margin-top: 4px;
    align-self: flex-end;
}

.aica-msg-ai .aica-msg-time {
    align-self: flex-start;
}

/* WhatsApp & CTA Card */
.aica-cta-card {
    background: #FFFFFF;
    border: 1px solid #E5E7EB;
    border-radius: 10px;
    padding: 12px;
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}

.aica-cta-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #10B981;
    color: #FFFFFF !important;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    padding: 9px 14px;
    border-radius: 8px;
    transition: background 0.2s;
    border: none;
    cursor: pointer;
}

.aica-cta-btn:hover {
    background: #059669;
}

/* Lead Capture Inline Form */
.aica-lead-form {
    background: #FFFFFF;
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    padding: 14px;
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.aica-lead-form input, .aica-lead-form textarea {
    width: 100%;
    padding: 8px 10px;
    font-size: 12.5px;
    border: 1px solid #D1D5DB;
    border-radius: 6px;
    outline: none;
}

.aica-lead-form input:focus, .aica-lead-form textarea:focus {
    border-color: var(--aica-primary);
}

.aica-lead-submit-btn {
    background: var(--aica-primary);
    color: #FFFFFF;
    border: none;
    padding: 8px;
    font-size: 12.5px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
}

/* Quick Questions Carousel */
.aica-quick-questions {
    padding: 6px 14px 10px 14px;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    white-space: nowrap;
    background: #F9FAFB;
    scrollbar-width: none;
}

.aica-quick-questions::-webkit-scrollbar {
    display: none;
}

.aica-quick-btn {
    background: #FFFFFF;
    border: 1px solid #E5E7EB;
    color: #374151;
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 999px;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
}

.aica-quick-btn:hover {
    border-color: var(--aica-primary);
    color: var(--aica-primary);
    background: #EFF6FF;
}

/* Typing Indicator */
.aica-typing-indicator {
    padding: 8px 16px;
    background: #F9FAFB;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: #6B7280;
}

.aica-typing-indicator.aica-hidden {
    display: none;
}

.aica-typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #9CA3AF;
    animation: aica-bounce 1.4s infinite ease-in-out;
}

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

@keyframes aica-bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

.aica-typing-text {
    margin-left: 6px;
}

/* Input Form */
.aica-input-form {
    padding: 12px 14px;
    border-top: 1px solid #E5E7EB;
    background: #FFFFFF;
}

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

.aica-input-wrapper:focus-within {
    border-color: var(--aica-primary);
    background: #FFFFFF;
}

.aica-user-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 13.5px;
    outline: none;
    resize: none;
    padding: 6px 0;
    max-height: 80px;
    font-family: inherit;
    line-height: 1.4;
    color: #1F2937;
}

.aica-send-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--aica-primary);
    color: #FFFFFF;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
}

.aica-send-btn:hover {
    background: var(--aica-secondary);
}

.aica-privacy-footer {
    padding: 4px 14px 8px 14px;
    text-align: center;
    font-size: 10px;
    color: #9CA3AF;
    background: #FFFFFF;
}

/* Responsive Mobile Screen Overlay */
@media (max-width: 480px) {
    .aica-chat-box {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100vw !important;
        height: 100vh !important;
        height: 100dvh !important;
        border-radius: 0;
        margin: 0;
    }
}
