/**
 * InvestGlobalBridge - AI Chatbot Widget CSS
 *
 * Floating chat bubble + chat window UI.
 * Uses .gb-chat-* prefix to avoid conflicts.
 */

/* =========================================================================
   CHAT BUBBLE (FAB)
   ========================================================================= */

.gb-chat-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #00C853, #00A843);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 200, 83, 0.4), 0 2px 8px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: gb-chat-pulse 2s infinite;
}

.gb-chat-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(0, 200, 83, 0.5), 0 4px 12px rgba(0, 0, 0, 0.4);
}

.gb-chat-fab:active {
    transform: scale(0.95);
}

.gb-chat-fab svg {
    width: 28px;
    height: 28px;
    fill: none;
    stroke: white;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.3s;
}

.gb-chat-fab.open svg.gb-chat-icon-open {
    display: none;
}

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

.gb-chat-fab.open svg.gb-chat-icon-close {
    display: block;
}

@keyframes gb-chat-pulse {
    0%, 100% { box-shadow: 0 4px 20px rgba(0, 200, 83, 0.4), 0 2px 8px rgba(0, 0, 0, 0.3); }
    50% { box-shadow: 0 4px 30px rgba(0, 200, 83, 0.6), 0 2px 12px rgba(0, 0, 0, 0.4); }
}

.gb-chat-fab.open {
    animation: none;
    background: linear-gradient(135deg, #37474F, #263238);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

/* Notification badge */
.gb-chat-fab-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    background: #FF5252;
    color: white;
    border-radius: 50%;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #071A35;
    animation: gb-chat-badge-pop 0.3s ease;
}

@keyframes gb-chat-badge-pop {
    0% { transform: scale(0); }
    70% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* =========================================================================
   CHAT WINDOW
   ========================================================================= */

.gb-chat-window {
    position: fixed;
    bottom: 96px;
    right: 24px;
    z-index: 99998;
    width: 400px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 140px);
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: #0A1628;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.3);
    transform: scale(0.9) translateY(20px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.gb-chat-window.open {
    transform: scale(1) translateY(0);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* =========================================================================
   CHAT HEADER
   ========================================================================= */

.gb-chat-header {
    background: linear-gradient(135deg, #0D2345, #0A1628);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.gb-chat-header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, #00C853, #00A843);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.gb-chat-header-avatar svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: white;
    stroke-width: 2;
}

.gb-chat-header-info {
    flex: 1;
    min-width: 0;
}

.gb-chat-header-name {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    font-size: 15px;
    color: #fff;
    line-height: 1.2;
}

.gb-chat-header-status {
    font-size: 12px;
    color: #00C853;
    display: flex;
    align-items: center;
    gap: 5px;
    line-height: 1.2;
    margin-top: 2px;
}

.gb-chat-header-status::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #00C853;
    display: inline-block;
    animation: gb-chat-status-blink 2s infinite;
}

@keyframes gb-chat-status-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.gb-chat-header-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: rgba(255, 255, 255, 0.06);
    color: #B6C5DD;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.gb-chat-header-close:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.gb-chat-header-close svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
}

/* =========================================================================
   CHAT MESSAGES
   ========================================================================= */

.gb-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
    background: #0A1628;
}

.gb-chat-messages::-webkit-scrollbar {
    width: 5px;
}

.gb-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.gb-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.gb-chat-msg {
    display: flex;
    gap: 8px;
    max-width: 88%;
    animation: gb-chat-msg-in 0.3s ease;
}

@keyframes gb-chat-msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.gb-chat-msg.bot {
    align-self: flex-start;
}

.gb-chat-msg.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.gb-chat-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 2px;
}

.gb-chat-msg.bot .gb-chat-msg-avatar {
    background: linear-gradient(135deg, #00C853, #00A843);
}

.gb-chat-msg.user .gb-chat-msg-avatar {
    background: linear-gradient(135deg, #1565C0, #0D47A1);
}

.gb-chat-msg-avatar svg {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: white;
    stroke-width: 2;
}

.gb-chat-msg-bubble {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.55;
    word-break: break-word;
}

.gb-chat-msg.bot .gb-chat-msg-bubble {
    background: #0D2345;
    color: #E0E8F0;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-top-left-radius: 4px;
}

.gb-chat-msg.user .gb-chat-msg-bubble {
    background: linear-gradient(135deg, #00C853, #00A843);
    color: #fff;
    border-top-right-radius: 4px;
}

.gb-chat-msg-bubble strong,
.gb-chat-msg-bubble b {
    color: #00C853;
    font-weight: 600;
}

.gb-chat-msg.user .gb-chat-msg-bubble strong,
.gb-chat-msg.user .gb-chat-msg-bubble b {
    color: #fff;
}

.gb-chat-msg-bubble ul,
.gb-chat-msg-bubble ol {
    margin: 6px 0;
    padding-left: 18px;
}

.gb-chat-msg-bubble li {
    margin-bottom: 3px;
}

.gb-chat-msg-bubble code {
    background: rgba(0, 200, 83, 0.1);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 12.5px;
    color: #00C853;
}

.gb-chat-msg.user .gb-chat-msg-bubble code {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

/* =========================================================================
   TYPING INDICATOR
   ========================================================================= */

.gb-chat-typing {
    display: flex;
    gap: 8px;
    max-width: 88%;
    align-self: flex-start;
    animation: gb-chat-msg-in 0.3s ease;
}

.gb-chat-typing-dots {
    background: #0D2345;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    border-top-left-radius: 4px;
    padding: 12px 18px;
    display: flex;
    gap: 5px;
    align-items: center;
}

.gb-chat-typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #00C853;
    animation: gb-chat-typing-bounce 1.4s infinite ease-in-out;
}

.gb-chat-typing-dot:nth-child(1) { animation-delay: 0s; }
.gb-chat-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.gb-chat-typing-dot:nth-child(3) { animation-delay: 0.4s; }

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

/* =========================================================================
   SUGGESTION CHIPS
   ========================================================================= */

.gb-chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px 16px 12px;
    background: #0A1628;
    flex-shrink: 0;
}

.gb-chat-suggestions:empty {
    display: none;
}

.gb-chat-chip {
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid rgba(0, 200, 83, 0.3);
    background: rgba(0, 200, 83, 0.06);
    color: #00C853;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.gb-chat-chip:hover {
    background: rgba(0, 200, 83, 0.15);
    border-color: rgba(0, 200, 83, 0.5);
    transform: translateY(-1px);
}

/* =========================================================================
   CHAT INPUT
   ========================================================================= */

.gb-chat-input-area {
    padding: 12px 16px;
    background: #0D2345;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-shrink: 0;
}

.gb-chat-input-wrap {
    flex: 1;
    position: relative;
}

.gb-chat-input {
    width: 100%;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: #0A1628;
    color: #E0E8F0;
    font-size: 13.5px;
    font-family: 'Inter', sans-serif;
    outline: none;
    resize: none;
    max-height: 100px;
    min-height: 40px;
    line-height: 1.4;
    transition: border-color 0.2s;
}

.gb-chat-input::placeholder {
    color: #546E8A;
}

.gb-chat-input:focus {
    border-color: rgba(0, 200, 83, 0.5);
}

.gb-chat-send {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, #00C853, #00A843);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.gb-chat-send:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 10px rgba(0, 200, 83, 0.4);
}

.gb-chat-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.gb-chat-send svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Powered by */
.gb-chat-powered {
    text-align: center;
    padding: 6px;
    background: #0D2345;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
    flex-shrink: 0;
}

.gb-chat-powered span {
    font-size: 10px;
    color: #546E8A;
    letter-spacing: 0.3px;
}

.gb-chat-powered strong {
    color: #9BB0C8;
}

/* =========================================================================
   MOBILE RESPONSIVE
   ========================================================================= */

@media (max-width: 480px) {
    .gb-chat-fab {
        bottom: 16px;
        right: 16px;
        width: 54px;
        height: 54px;
    }

    .gb-chat-window {
        bottom: 0;
        right: 0;
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }

    .gb-chat-msg {
        max-width: 92%;
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    .gb-chat-window {
        width: 360px;
        right: 12px;
        bottom: 88px;
    }
}

/* =========================================================================
   USER DASHBOARD OVERLAP FIX
   ========================================================================= */

body.has-mobile-nav .gb-chat-fab {
    bottom: 80px;
}

@media (max-width: 480px) {
    body.has-mobile-nav .gb-chat-fab {
        bottom: 76px;
        right: 16px;
    }
}
