/* ChainBETs AI Chat Widget */

.cb-chat-bubble {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #5DBE5D, #4da64d);
    border: none;
    cursor: pointer;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(93, 190, 93, 0.3);
    transition: transform 0.2s, box-shadow 0.2s;
}

.cb-chat-bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(93, 190, 93, 0.45);
}

.cb-chat-bubble svg {
    width: 26px;
    height: 26px;
    fill: #0A0F0D;
}

.cb-chat-bubble.open svg.icon-chat { display: none; }
.cb-chat-bubble:not(.open) svg.icon-close { display: none; }

/* Panel */
.cb-chat-panel {
    position: fixed;
    bottom: 5.5rem;
    right: 1.5rem;
    width: 400px;
    max-width: calc(100vw - 2rem);
    height: 520px;
    max-height: calc(100vh - 7rem);
    background: #0A0F0D;
    border: 1px solid #1a2e1a;
    border-radius: 1rem;
    z-index: 99;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.25s, transform 0.25s;
}

.cb-chat-panel.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Header */
.cb-chat-header {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid #1a2e1a;
    display: flex;
    align-items: center;
    gap: 0.625rem;
    flex-shrink: 0;
}

.cb-chat-header .avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, #5DBE5D, #D4A528);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 800;
    color: #0A0F0D;
}

.cb-chat-header .info h4 {
    font-size: 0.875rem;
    font-weight: 600;
    color: #e5e7eb;
    margin: 0;
}

.cb-chat-header .info p {
    font-size: 0.6875rem;
    color: #5DBE5D;
    margin: 0;
}

.cb-chat-context {
    padding: 0.375rem 1rem;
    background: #111916;
    border-bottom: 1px solid #1a2e1a;
    font-size: 0.6875rem;
    color: #6b7280;
    flex-shrink: 0;
}

.cb-chat-context span {
    color: #D4A528;
    font-weight: 500;
}

/* Messages */
.cb-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    scrollbar-width: thin;
    scrollbar-color: #1a2e1a transparent;
}

.cb-msg {
    max-width: 85%;
    padding: 0.625rem 0.875rem;
    border-radius: 0.75rem;
    font-size: 0.8125rem;
    line-height: 1.5;
    word-wrap: break-word;
}

.cb-msg.assistant {
    align-self: flex-start;
    background: #111916;
    border: 1px solid #1a2e1a;
    color: #d1d5db;
}

.cb-msg.user {
    align-self: flex-end;
    background: #1a3a1a;
    border: 1px solid #2d5a2d;
    color: #e5e7eb;
}

.cb-msg.system {
    align-self: center;
    background: transparent;
    color: #6b7280;
    font-size: 0.75rem;
    font-style: italic;
    padding: 0.25rem;
}

.cb-msg .action-btn {
    display: inline-block;
    margin-top: 0.5rem;
    padding: 0.25rem 0.75rem;
    background: rgba(93, 190, 93, 0.15);
    border: 1px solid #5DBE5D;
    border-radius: 0.375rem;
    color: #5DBE5D;
    font-size: 0.75rem;
    cursor: pointer;
    transition: background 0.15s;
}

.cb-msg .action-btn:hover {
    background: rgba(93, 190, 93, 0.25);
}

/* Typing indicator */
.cb-typing {
    display: flex;
    gap: 4px;
    padding: 0.625rem 0.875rem;
    align-self: flex-start;
}

.cb-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #5DBE5D;
    animation: cbBounce 1.2s infinite;
}

.cb-typing span:nth-child(2) { animation-delay: 0.15s; }
.cb-typing span:nth-child(3) { animation-delay: 0.3s; }

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

/* Input */
.cb-chat-input {
    padding: 0.75rem;
    border-top: 1px solid #1a2e1a;
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.cb-chat-input textarea {
    flex: 1;
    background: #111916;
    border: 1px solid #1a2e1a;
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    color: #e5e7eb;
    font-size: 0.8125rem;
    resize: none;
    outline: none;
    min-height: 38px;
    max-height: 100px;
    font-family: inherit;
    line-height: 1.4;
}

.cb-chat-input textarea:focus {
    border-color: #5DBE5D;
}

.cb-chat-input textarea::placeholder {
    color: #4b5563;
}

.cb-chat-input button {
    width: 38px;
    height: 38px;
    border-radius: 0.5rem;
    background: #5DBE5D;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    flex-shrink: 0;
}

.cb-chat-input button:hover {
    background: #4da64d;
}

.cb-chat-input button:disabled {
    background: #1a2e1a;
    cursor: not-allowed;
}

.cb-chat-input button svg {
    width: 18px;
    height: 18px;
    fill: #0A0F0D;
}

/* Quick actions */
.cb-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    padding: 0 1rem 0.75rem;
}

.cb-quick-actions button {
    padding: 0.25rem 0.625rem;
    background: #111916;
    border: 1px solid #1a2e1a;
    border-radius: 1rem;
    color: #9ca3af;
    font-size: 0.6875rem;
    cursor: pointer;
    transition: all 0.15s;
}

.cb-quick-actions button:hover {
    border-color: #5DBE5D;
    color: #5DBE5D;
}

/* Mobile */
@media (max-width: 640px) {
    .cb-chat-panel {
        bottom: 0;
        right: 0;
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        border: none;
    }

    .cb-chat-bubble {
        bottom: 1rem;
        right: 1rem;
    }
}
