/* TRENDFORU AI Chat — 2026 Edition */

.chat-widget,
.chat-widget *,
.chat-widget *::before,
.chat-widget *::after {
    box-sizing: border-box;
}

.chat-widget {
    position: fixed;
    bottom: 16px;
    right: 16px;
    z-index: 9999;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

@media (max-width: 480px) {
    .chat-widget { bottom: 12px; right: 12px; }
}

/* ── Toggle Button ── */
.chat-toggle {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: #0a0a0a;
    border: 1px solid rgba(255,255,255,.08);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .4s cubic-bezier(.34,1.56,.64,1);
    box-shadow: 0 6px 24px rgba(0,0,0,.3);
    position: relative;
}

.chat-toggle::before {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    background: conic-gradient(from 0deg, transparent 0%, rgba(255,255,255,.1) 50%, transparent 100%);
    animation: chatRing 4s linear infinite;
    opacity: 0;
    transition: opacity .3s;
}

.chat-toggle:hover::before { opacity: 1; }

@keyframes chatRing { to { transform: rotate(360deg); } }

.chat-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 8px 32px rgba(0,0,0,.4);
}

.chat-toggle:active {
    transform: scale(.95);
}

/* Notification pulse */
.chat-toggle::after {
    content: '';
    position: absolute;
    top: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    background: #22c55e;
    border-radius: 50%;
    border: 2px solid #0a0a0a;
    animation: chatPulse 3s ease infinite;
}

@keyframes chatPulse {
    0%, 70%, 100% { transform: scale(1); opacity: 1; }
    35% { transform: scale(1.3); opacity: .7; }
}

/* ── Panel ── */
.chat-panel {
    display: none;
    position: fixed;
    bottom: 80px;
    right: 16px;
    width: min(400px, calc(100vw - 32px));
    height: min(540px, calc(100vh - 120px));
    background: #0a0a0a;
    border: 1px solid rgba(255,255,255,.06);
    border-radius: 20px;
    overflow: hidden;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,.5), 0 0 0 1px rgba(255,255,255,.04);
    animation: chatOpen .4s cubic-bezier(.34,1.56,.64,1);
}

.chat-panel.open {
    display: flex;
}

@keyframes chatOpen {
    from { opacity: 0; transform: translateY(16px) scale(.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Header ── */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid rgba(255,255,255,.05);
    background: rgba(10,10,10,.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-header-dot {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(34,197,94,.4);
    animation: chatPulse 3s ease infinite;
}

.chat-header-title {
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 2px;
}

.chat-clear {
    background: none;
    border: none;
    color: rgba(255,255,255,.25);
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    transition: all .3s;
    display: flex;
    align-items: center;
}

.chat-clear:hover {
    color: rgba(255,255,255,.6);
    background: rgba(255,255,255,.06);
}

/* ── Messages ── */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar { width: 3px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,.08); border-radius: 2px; }

/* ── Message Bubbles ── */
.chat-msg {
    display: flex;
    max-width: 82%;
    animation: chatMsgIn .4s cubic-bezier(.16,1,.3,1);
}

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

.chat-msg--user { align-self: flex-end; }
.chat-msg--assistant { align-self: flex-start; }

.chat-msg-content {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 13px;
    line-height: 1.6;
    word-break: break-word;
    letter-spacing: .2px;
}

.chat-msg--user .chat-msg-content {
    background: #fff;
    color: #0a0a0a;
    border-bottom-right-radius: 4px;
    font-weight: 400;
}

.chat-msg--assistant .chat-msg-content {
    background: rgba(255,255,255,.05);
    color: rgba(255,255,255,.85);
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(255,255,255,.04);
}

/* Markdown */
.chat-msg-content strong { font-weight: 600; }
.chat-msg-content em { font-style: italic; color: rgba(255,255,255,.6); }
.chat-msg--user .chat-msg-content em { color: #666; }
.chat-msg-content a { color: #60a5fa; text-decoration: none; border-bottom: 1px solid rgba(96,165,250,.3); transition: border-color .3s; }
.chat-msg-content a:hover { border-color: #60a5fa; }

/* ── Typing ── */
.chat-typing {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 14px 18px;
    background: rgba(255,255,255,.05);
    border: 1px solid rgba(255,255,255,.04);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    animation: chatMsgIn .3s ease;
}

.chat-typing-dot {
    width: 6px;
    height: 6px;
    background: rgba(255,255,255,.3);
    border-radius: 50%;
    animation: chatBounce 1.4s ease infinite;
}

.chat-typing-dot:nth-child(2) { animation-delay: .15s; }
.chat-typing-dot:nth-child(3) { animation-delay: .3s; }

@keyframes chatBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: .3; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* ── Input ── */
.chat-form {
    display: flex;
    padding: 12px;
    gap: 8px;
    border-top: 1px solid rgba(255,255,255,.05);
    background: rgba(10,10,10,.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    flex-shrink: 0;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.chat-input {
    flex: 1;
    min-width: 0;
    background: rgba(255,255,255,.05);
    border: 1px solid rgba(255,255,255,.06);
    border-radius: 12px;
    padding: 10px 14px;
    color: #fff;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color .3s, box-shadow .3s;
}

.chat-input::placeholder { color: rgba(255,255,255,.2); }

.chat-input:focus {
    border-color: rgba(255,255,255,.15);
    box-shadow: 0 0 0 3px rgba(255,255,255,.03);
}

.chat-send {
    width: 40px;
    min-width: 40px;
    height: 40px;
    flex-shrink: 0;
    flex-grow: 0;
    border-radius: 10px;
    background: #fff;
    border: none;
    color: #0a0a0a;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all .3s cubic-bezier(.34,1.56,.64,1);
}

.chat-send:hover {
    transform: scale(1.06);
    box-shadow: 0 4px 16px rgba(255,255,255,.1);
}

.chat-send:active {
    transform: scale(.94);
}

.chat-send:disabled {
    opacity: .2;
    cursor: not-allowed;
    transform: none;
}

/* ── Mobile: fullscreen ── */
@media (max-width: 768px) {
    .chat-widget { bottom: 12px; right: 12px; }
    .chat-toggle { width: 48px; height: 48px; }

    .chat-panel {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: 100% !important;
        max-width: 100% !important;
        border-radius: 0 !important;
        border: none !important;
        box-shadow: none !important;
    }

    .chat-form {
        padding: 10px 12px;
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }
}
