﻿/* === Container === */

.ai-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    height: calc(100vh - 40px);
    width: 420px;
    display: flex;
    flex-direction: column;
    border-radius: 16px;
    background: radial-gradient(circle at top left, #0f172a 0, #020617 40%, #020617 100%);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(148, 163, 184, 0.25);
    overflow: hidden;
    z-index: 999999;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    transform: translateY(0);
    opacity: 1;
    transition: transform 0.26s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.26s ease;
}

.ai-widget-hidden {
    transform: translateY(30px) scale(0.97);
    opacity: 0;
    pointer-events: none;
}

/* === Header === */

.ai-widget-header {
    flex-shrink: 0;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, rgba(59,130,246,0.35), rgba(56,189,248,0.25));
    border-bottom: 1px solid rgba(148, 163, 184, 0.4);
    backdrop-filter: blur(12px);
}

.ai-widget-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-widget-avatar {
    width: 30px;
    height: 30px;
    border-radius: 999px;
    background: radial-gradient(circle at 30% 20%, #22c55e, #16a34a);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.85);
}

.ai-widget-header-text {
    display: flex;
    flex-direction: column;
}

.ai-widget-title {
    font-weight: 600;
    font-size: 14px;
    color: #e5e7eb;
}

.ai-widget-subtitle {
    font-size: 11px;
    color: #cbd5f5;
    opacity: 0.9;
}

.ai-widget-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-widget-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: #22c55e;
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
    animation: ai-pulse 1.8s infinite;
}

.ai-widget-status-text {
    font-size: 11px;
    color: #e5e7eb;
    opacity: 0.9;
}

.ai-widget-close {
    background: transparent;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #cbd5f5;
    padding: 0 2px;
    line-height: 1;
    border-radius: 999px;
    transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

    .ai-widget-close:hover {
        background: rgba(15, 23, 42, 0.4);
        color: #ffffff;
        transform: scale(1.05);
    }

/* === Body === */

.ai-widget-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* === History Area === */

.ai-widget-reply {
    flex: 1;
    overflow-y: auto;
    padding: 12px 12px 8px 12px;
    background: radial-gradient(circle at top, rgba(15,23,42,0.6), rgba(15,23,42,1) 55%);
    font-size: 13px;
    line-height: 1.4;
    color: #e5e7eb;
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.8) transparent;
}

    .ai-widget-reply::-webkit-scrollbar {
        width: 6px;
    }

    .ai-widget-reply::-webkit-scrollbar-track {
        background: transparent;
    }

    .ai-widget-reply::-webkit-scrollbar-thumb {
        background: rgba(148, 163, 184, 0.8);
        border-radius: 999px;
    }

.ai-widget-placeholder {
    color: #64748b;
    font-size: 13px;
}

/* === Messages === */

.ai-widget-message {
    margin-bottom: 10px;
    display: flex;
}

.ai-widget-message-inner {
    max-width: 90%;
}

.ai-widget-message-user {
    justify-content: flex-end;
}

.ai-widget-message-assistant {
    justify-content: flex-start;
}

.ai-widget-message-user .ai-widget-message-inner {
    margin-left: auto;
    text-align: right;
}

.ai-widget-message-assistant .ai-widget-message-inner {
    margin-right: auto;
}

.ai-widget-label {
    display: block;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin-bottom: 4px;
    opacity: 0.7;
}

.ai-widget-message-user .ai-widget-label {
    color: #a5b4fc;
}

.ai-widget-message-assistant .ai-widget-label {
    color: #67e8f9;
}

.ai-widget-bubble {
    padding: 8px 10px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
    position: relative;
}

/* User bubble */
.ai-widget-message-user .ai-widget-bubble {
    background: linear-gradient(135deg, #4f46e5, #6366f1);
    color: #f9fafb;
    border-bottom-right-radius: 4px;
}

/* Assistant bubble */
.ai-widget-message-assistant .ai-widget-bubble {
    background: radial-gradient(circle at top left, #0f172a, #020617);
    border: 1px solid rgba(148, 163, 184, 0.4);
    border-bottom-left-radius: 4px;
}

/* === Input Row === */

.ai-widget-input-row {
    display: flex;
    flex-shrink: 0;
    gap: 6px;
    padding: 8px 10px 10px;
    border-top: 1px solid rgba(148, 163, 184, 0.4);
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.95), rgba(15, 23, 42, 1));
}

.ai-widget-input {
    flex: 1;
    padding: 8px 10px;
    font-size: 13px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.7);
    background: rgba(15, 23, 42, 0.8);
    color: #e5e7eb;
    outline: none;
    transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

    .ai-widget-input::placeholder {
        color: #64748b;
    }

    .ai-widget-input:focus {
        border-color: #60a5fa;
        box-shadow: 0 0 0 1px rgba(96, 165, 250, 0.8), 0 0 0 4px rgba(37, 99, 235, 0.28);
        background: rgba(15, 23, 42, 0.95);
    }

/* Buttons */

.ai-widget-send,
.ai-widget-clear {
    border-radius: 999px;
    border: none;
    font-size: 12px;
    padding: 8px 12px;
    cursor: pointer;
    font-weight: 500;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.16s ease, transform 0.12s ease, box-shadow 0.16s ease, opacity 0.16s ease;
}

/* Primary button */
.ai-widget-send {
    background: linear-gradient(135deg, #2563eb, #38bdf8);
    color: #f9fafb;
    box-shadow: 0 8px 16px rgba(37, 99, 235, 0.4);
}

    .ai-widget-send:hover:not(:disabled) {
        transform: translateY(-1px);
        box-shadow: 0 10px 20px rgba(37, 99, 235, 0.55);
    }

    .ai-widget-send:active:not(:disabled) {
        transform: translateY(0);
        box-shadow: 0 4px 8px rgba(37, 99, 235, 0.45);
    }

    .ai-widget-send:disabled {
        opacity: 0.6;
        cursor: default;
        box-shadow: none;
    }

/* Clear button */
.ai-widget-clear {
    background: rgba(239, 68, 68, 0.12);
    color: #fecaca;
    border: 1px solid rgba(248, 113, 113, 0.65);
}

    .ai-widget-clear:hover {
        background: rgba(248, 113, 113, 0.25);
    }

/* === Typing indicator === */

.ai-typing {
    display: inline-flex;
    gap: 2px;
    font-size: 18px;
    letter-spacing: 1px;
}

    .ai-typing span {
        display: inline-block;
        animation: ai-blink 1.4s infinite both;
    }

        .ai-typing span:nth-child(2) {
            animation-delay: 0.2s;
        }

        .ai-typing span:nth-child(3) {
            animation-delay: 0.4s;
        }

/* === Rich text helpers === */

.ai-text-italic {
    font-style: italic;
}

.ai-text-link {
    color: #38bdf8;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

    .ai-text-link:hover {
        text-decoration-thickness: 2px;
    }

/* === Animations === */

@keyframes ai-blink {
    0% {
        opacity: 0.25;
        transform: translateY(0);
    }

    20% {
        opacity: 1;
        transform: translateY(-1px);
    }

    100% {
        opacity: 0.25;
        transform: translateY(0);
    }
}

@keyframes ai-pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.85);
    }

    70% {
        transform: scale(1.15);
        box-shadow: 0 0 0 8px rgba(34, 197, 94, 0);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
    }
}
