/* ── Article Chat Widget (Floating) ──────────────────────────── */

.aia-widget-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #6C3CE1, #8B5CF6);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(108, 60, 225, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
    z-index: 99999;
}

.aia-widget-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(108, 60, 225, 0.45);
}

.aia-widget-toggle svg {
    width: 26px;
    height: 26px;
    transition: transform 0.3s;
}

.aia-widget-toggle.aia-open svg {
    transform: rotate(90deg);
}

/* Panel */
.aia-widget-panel {
    position: fixed;
    bottom: 92px;
    right: 24px;
    width: 380px;
    max-height: 520px;
    border-radius: 16px;
    background: #fff;
    border: 1px solid #E5E7EB;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.12);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 99998;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    animation: aiaSlideUp 0.3s ease;
}

.aia-widget-panel.aia-visible {
    display: flex;
}

@keyframes aiaSlideUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Widget header */
.aia-widget__header {
    padding: 14px 18px;
    background: linear-gradient(135deg, #6C3CE1, #8B5CF6);
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.aia-widget__header-icon {
    width: 28px;
    height: 28px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.aia-widget__header h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
}

.aia-widget__header p {
    margin: 2px 0 0;
    font-size: 11px;
    opacity: 0.85;
}

/* Widget messages */
.aia-widget__messages {
    flex: 1 1 auto;
    min-height: 200px;
    max-height: 320px;
    overflow-y: auto;
    padding: 14px 16px;
    background: #FAFBFC;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.aia-widget__messages::-webkit-scrollbar {
    width: 5px;
}
.aia-widget__messages::-webkit-scrollbar-thumb {
    background: #D1D5DB;
    border-radius: 3px;
}

.aia-w-msg {
    display: flex;
    max-width: 88%;
    animation: aiaFadeIn 0.25s ease;
}

@keyframes aiaFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.aia-w-msg--user   { align-self: flex-end; }
.aia-w-msg--assistant { align-self: flex-start; }

.aia-w-msg__body {
    padding: 10px 14px;
    border-radius: 12px;
    word-break: break-word;
    white-space: pre-wrap;
    font-size: 13px;
}

.aia-w-msg--user .aia-w-msg__body {
    background: #6C3CE1;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.aia-w-msg--assistant .aia-w-msg__body {
    background: #F3F4F6;
    color: #1A1A2E;
    border-bottom-left-radius: 4px;
}

.aia-w-msg--error .aia-w-msg__body {
    background: #FEF2F2;
    color: #991B1B;
    border-left: 3px solid #DC2626;
}

/* Widget thinking */
.aia-w-thinking {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: #F3F4F6;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
}

.aia-w-thinking__dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #6C3CE1;
    animation: aiaWidgetBounce 1.2s infinite;
}

.aia-w-thinking__dot:nth-child(2) { animation-delay: 0.15s; }
.aia-w-thinking__dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes aiaWidgetBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30%           { transform: translateY(-4px); opacity: 1; }
}

/* Widget input */
.aia-widget__input-area {
    display: flex;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid #E5E7EB;
    background: #fff;
}

.aia-widget__input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #E5E7EB;
    border-radius: 10px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    background: #FAFBFC;
    transition: border-color 0.2s;
}

.aia-widget__input:focus {
    border-color: #6C3CE1;
    box-shadow: 0 0 0 2px rgba(108, 60, 225, 0.1);
}

.aia-widget__send {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 10px;
    background: #6C3CE1;
    color: #fff;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}

.aia-widget__send:hover {
    background: #8B5CF6;
}

.aia-widget__send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Responsive */
@media (max-width: 480px) {
    .aia-widget-panel {
        width: calc(100vw - 32px);
        right: 16px;
        bottom: 84px;
        max-height: 70vh;
    }
    .aia-widget-toggle {
        right: 16px;
        bottom: 16px;
    }
}
