/* AIMagic Chat Widget CSS */
.aimagic-widget-wrap { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }
.aimagic-widget-wrap * { box-sizing: border-box; margin: 0; padding: 0; }

/* Floating button */
.aimagic-launcher { position: fixed; z-index: 9998; width: 60px; height: 60px; border-radius: 50%; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 20px rgba(0,0,0,.2); transition: transform .2s, box-shadow .2s; }
.aimagic-launcher:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(0,0,0,.25); }
.aimagic-launcher svg { width: 26px; height: 26px; fill: white; transition: opacity .2s; }
.aimagic-launcher .aim-close-icon { display: none; }
.aimagic-launcher.open .aim-chat-icon { display: none; }
.aimagic-launcher.open .aim-close-icon { display: block; }

/* Position variants */
.aimagic-pos-bottom-right { bottom: 24px; right: 24px; }
.aimagic-pos-bottom-left  { bottom: 24px; left: 24px; }
.aimagic-pos-top-right    { top: 24px; right: 24px; }
.aimagic-pos-top-left     { top: 24px; left: 24px; }

/* Chat window */
.aimagic-window { position: fixed; z-index: 9999; width: 360px; max-height: 580px; background: white; border-radius: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.18); display: flex; flex-direction: column; overflow: hidden; transition: all .3s cubic-bezier(.34,1.56,.64,1); transform-origin: bottom right; transform: scale(0) translateY(20px); opacity: 0; pointer-events: none; }
.aimagic-window.open { transform: scale(1) translateY(0); opacity: 1; pointer-events: all; }
.aimagic-pos-bottom-right .aimagic-window { bottom: 96px; right: 24px; }
.aimagic-pos-bottom-left  .aimagic-window { bottom: 96px; left: 24px; transform-origin: bottom left; }
.aimagic-pos-top-right    .aimagic-window { top: 96px; right: 24px; transform-origin: top right; }
.aimagic-pos-top-left     .aimagic-window { top: 96px; left: 24px; transform-origin: top left; }

/* Inline variant */
.aimagic-inline .aimagic-window { position: static; transform: none; opacity: 1; pointer-events: all; max-height: 500px; border-radius: 16px; }
.aimagic-inline .aimagic-launcher { display: none; }

/* Header */
.aimagic-header { padding: 16px 18px; display: flex; align-items: center; gap: 12px; color: white; flex-shrink: 0; }
.aimagic-avatar { width: 38px; height: 38px; border-radius: 50%; background: rgba(255,255,255,.25); display: flex; align-items: center; justify-content: center; font-size: 18px; overflow: hidden; flex-shrink: 0; }
.aimagic-avatar img { width: 100%; height: 100%; object-fit: cover; }
.aimagic-header-info .aimagic-bot-name { font-weight: 700; font-size: 15px; }
.aimagic-header-info .aimagic-online { font-size: 12px; opacity: .85; display: flex; align-items: center; gap: 5px; }
.aimagic-header-info .aimagic-online::before { content: ''; width: 7px; height: 7px; background: #4ade80; border-radius: 50%; display: inline-block; }
.aimagic-close-btn { margin-left: auto; background: rgba(255,255,255,.2); border: none; color: white; width: 30px; height: 30px; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 16px; transition: background .2s; }
.aimagic-close-btn:hover { background: rgba(255,255,255,.35); }

/* Messages */
.aimagic-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; scroll-behavior: smooth; }
.aimagic-messages::-webkit-scrollbar { width: 4px; }
.aimagic-messages::-webkit-scrollbar-track { background: transparent; }
.aimagic-messages::-webkit-scrollbar-thumb { background: #e5e7eb; border-radius: 99px; }
.aimagic-msg { display: flex; gap: 8px; max-width: 85%; animation: aimFadeIn .25s ease; }
.aimagic-msg.bot  { align-self: flex-start; }
.aimagic-msg.user { align-self: flex-end; flex-direction: row-reverse; }
.aimagic-msg-avatar { width: 28px; height: 28px; border-radius: 50%; background: #f3f4f6; display: flex; align-items: center; justify-content: center; font-size: 13px; flex-shrink: 0; margin-top: auto; }
.aimagic-msg-bubble { padding: 10px 14px; border-radius: 16px; font-size: 14px; line-height: 1.55; word-break: break-word; }
.aimagic-msg.bot  .aimagic-msg-bubble { background: #f3f4f6; color: #1f2937; border-bottom-left-radius: 4px; }
.aimagic-msg.user .aimagic-msg-bubble { color: white; border-bottom-right-radius: 4px; }
.aimagic-msg-time { font-size: 11px; color: #9ca3af; margin-top: 4px; }

/* Typing indicator */
.aimagic-typing .aimagic-msg-bubble { display: flex; align-items: center; gap: 4px; padding: 12px 16px; }
.aimagic-dot { width: 8px; height: 8px; border-radius: 50%; background: #9ca3af; animation: aimBounce 1.2s infinite; }
.aimagic-dot:nth-child(2) { animation-delay: .2s; }
.aimagic-dot:nth-child(3) { animation-delay: .4s; }

/* Lead form */
.aimagic-lead-form { background: #f8f9ff; border-radius: 12px; padding: 16px; margin: 8px 0; border: 1px solid #e5e7eb; }
.aimagic-lead-form h4 { font-size: 14px; font-weight: 700; margin-bottom: 12px; }
.aimagic-lead-field { margin-bottom: 10px; }
.aimagic-lead-field label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 4px; color: #374151; }
.aimagic-lead-field input { width: 100%; padding: 8px 10px; border: 1.5px solid #e5e7eb; border-radius: 8px; font-size: 13px; transition: border-color .2s; }
.aimagic-lead-field input:focus { outline: none; border-color: var(--aim-primary, #6C63FF); }
.aimagic-lead-submit { width: 100%; padding: 10px; border: none; border-radius: 8px; color: white; font-weight: 700; font-size: 14px; cursor: pointer; margin-top: 8px; transition: opacity .2s; }
.aimagic-lead-submit:hover { opacity: .9; }

/* Input area */
.aimagic-input-area { padding: 12px 14px; border-top: 1px solid #f0f0f0; display: flex; gap: 8px; align-items: flex-end; flex-shrink: 0; }
.aimagic-textarea { flex: 1; border: 1.5px solid #e5e7eb; border-radius: 10px; padding: 9px 12px; font-size: 14px; resize: none; max-height: 100px; min-height: 40px; font-family: inherit; line-height: 1.4; transition: border-color .2s; }
.aimagic-textarea:focus { outline: none; border-color: #6C63FF; }
.aimagic-send-btn { width: 40px; height: 40px; border-radius: 10px; border: none; color: white; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: transform .15s, opacity .15s; }
.aimagic-send-btn:hover { transform: scale(1.08); }
.aimagic-send-btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.aimagic-send-btn svg { width: 18px; height: 18px; fill: white; }

/* Branding */
.aimagic-branding { text-align: center; padding: 6px; font-size: 11px; color: #9ca3af; flex-shrink: 0; }
.aimagic-branding a { color: #6C63FF; text-decoration: none; font-weight: 600; }

/* Animations */
@keyframes aimFadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes aimBounce { 0%, 80%, 100% { transform: translateY(0); } 40% { transform: translateY(-6px); } }

/* Mobile */
@media (max-width: 480px) {
    .aimagic-window { width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; bottom: 0 !important; right: 0 !important; left: 0 !important; top: 0 !important; }
    .aimagic-pos-bottom-right .aimagic-window,
    .aimagic-pos-bottom-left  .aimagic-window { bottom: 0; }
}
