/* =========================================
   GWC AI Chat Widget – Modern Dark UI v2.0
   ========================================= */

:root {
    --gwc-primary: #020617;
    --gwc-user-bg: #6d28d9;
    --gwc-bot-bg: #1e293b;
    --gwc-bot-border: rgba(148,163,184,.2);
    --gwc-text: #e2e8f0;
    --gwc-muted: #64748b;
    --gwc-accent: #22c55e;
    --gwc-radius: 16px;
    --gwc-font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ROOT */
.gwc-ai2-chat-root {
    position: fixed;
    z-index: 9999999;
    right: 24px;
    bottom: 24px;
    font-family: var(--gwc-font);
}

/* ---- FLOATING BUTTON ---- */
.gwc-ai2-floating-btn {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    background: linear-gradient(135deg, #1e40af, #111827);
    box-shadow: 0 8px 24px rgba(0,0,0,.45), 0 0 0 3px rgba(99,102,241,.3);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .2s ease, box-shadow .2s ease;
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 9999999;
}
.gwc-ai2-floating-btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 12px 30px rgba(0,0,0,.5), 0 0 0 4px rgba(99,102,241,.45);
}
.gwc-ai2-floating-icon-svg {
    width: 36px;
    height: 36px;
    display: block;
    pointer-events: none;
}

/* ---- EXTERNAL CLOSE (red pill below window) ---- */
.gwc-ai2-external-close {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: #dc2626;
    color: #fff;
    font-size: 20px;
    font-weight: 300;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0,0,0,.35);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    position: fixed;
    right: 24px;
    bottom: 29px;
    z-index: 10000000;
    padding: 0;
    text-align: center;
}
.gwc-ai2-external-close:hover { background: #b91c1c; transform: scale(1.1); }

.gwc-ai2-hidden { display: none !important; }

/* ---- CHAT WINDOW ---- */
.gwc-ai2-chat-window {
    width: 390px;
    max-height: 620px;
    background: #0d1117;
    color: var(--gwc-text);
    border-radius: var(--gwc-radius);
    box-shadow: 0 24px 60px rgba(0,0,0,.8), 0 0 0 1px rgba(255,255,255,.06);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: fixed;
    right: 24px;
    bottom: 90px;
    z-index: 9999999;
}

/* ---- HEADER ---- */
.gwc-ai2-chat-header {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    background: linear-gradient(135deg, #0f172a, #1e1b4b);
    border-bottom: 1px solid rgba(255,255,255,.06);
    flex-shrink: 0;
    position: relative;
}
.gwc-ai2-chat-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    margin-right: 12px;
    background: #1e40af;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(99,102,241,.5);
    padding: 5px;
}
.gwc-ai2-chat-title { flex: 1; padding-right: 44px; }
.gwc-ai2-chat-name { font-weight: 700; font-size: 15px; color: #f1f5f9; letter-spacing: .3px; }
.gwc-ai2-chat-status {
    font-size: 11px;
    color: #94a3b8;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}
.gwc-ai2-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--gwc-accent);
    box-shadow: 0 0 6px var(--gwc-accent);
    animation: pulse-dot 2s infinite;
}
@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: .5; }
}

/* close button inside header */
.gwc-ai2-chat-close.internal {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(220,38,38,.85);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 300;
    line-height: 1;
    cursor: pointer;
    transition: all .2s;
    z-index: 10;
    padding: 0;
    text-align: center;
}
.gwc-ai2-chat-close.internal:hover {
    background: #dc2626;
    transform: translateY(-50%) scale(1.1);
}

/* ---- BODY ---- */
.gwc-ai2-chat-body {
    flex: 1;
    padding: 16px 14px;
    overflow-y: auto;
    background: #0d1117;
    scrollbar-width: thin;
    scrollbar-color: #1e293b transparent;
}
.gwc-ai2-chat-body::-webkit-scrollbar { width: 4px; }
.gwc-ai2-chat-body::-webkit-scrollbar-track { background: transparent; }
.gwc-ai2-chat-body::-webkit-scrollbar-thumb { background: #1e293b; border-radius: 4px; }

.gwc-ai2-messages {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ---- MESSAGE ROW WRAPPER ---- */
.gwc-ai2-msg-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    width: 100%;
}
/* Bot row: avatar LEFT, bubble RIGHT */
.gwc-ai2-msg-row.bot-row {
    flex-direction: row;
    justify-content: flex-start;
}
/* User row: bubble on left, avatar on right, all pushed to the right */
.gwc-ai2-msg-row.user-row {
    flex-direction: row;
    justify-content: flex-end;
}

/* Bot mini-avatar */
.gwc-ai2-msg-avatar {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 50%;
    background: #1e40af;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 4px;
    box-sizing: border-box;
    box-shadow: 0 0 0 2px rgba(99,102,241,.4);
    align-self: flex-end;
}
.gwc-ai2-msg-avatar svg { width: 24px; height: 24px; display: block; }
.gwc-ai2-msg-avatar.user-avatar { background: var(--gwc-user-bg); padding: 5px; }

/* Bubble wrapper */
.gwc-ai2-msg-bubble-wrap {
    display: flex;
    flex-direction: column;
    max-width: calc(100% - 44px); /* full width minus avatar+gap */
}
.gwc-ai2-msg-row.user-row .gwc-ai2-msg-bubble-wrap {
    align-items: flex-end;
}
.gwc-ai2-msg-row.bot-row .gwc-ai2-msg-bubble-wrap {
    align-items: flex-start;
}

/* ---- BUBBLE ---- */
.gwc-ai2-message {
    max-width: 100%;
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.55;
    word-wrap: break-word;
    white-space: pre-wrap;
}
.gwc-ai2-message.bot {
    background: #1e293b;
    color: #e2e8f0;
    border: 1px solid rgba(148,163,184,.15);
    border-bottom-left-radius: 4px;
}
.gwc-ai2-message.user {
    background: var(--gwc-user-bg);
    color: #ede9fe;
    border-bottom-right-radius: 4px;
}

/* Message timestamp */
.gwc-ai2-msg-time {
    font-size: 10px;
    color: var(--gwc-muted);
    margin-top: 3px;
    display: block;
    padding: 0 4px;
}

/* Formatting helpers */
.gwc-ai2-message strong { font-weight: 700; }
.gwc-ai2-message a { color: #818cf8; text-decoration: underline; }
.gwc-chat-list { margin: 8px 0 !important; padding-left: 20px !important; list-style-type: disc !important; display: block !important; }
.gwc-chat-list li { margin-bottom: 4px !important; display: list-item !important; }

/* ---- TYPING INDICATOR ---- */
.gwc-ai2-typing-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 12px 16px;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    background: #1e293b;
    border: 1px solid rgba(148,163,184,.15);
    width: fit-content;
}
.gwc-ai2-typing-indicator > span {
    width: 7px;
    height: 7px;
    background: #64748b;
    border-radius: 50%;
    opacity: 0;
    animation: typing-bounce 1.3s infinite;
}
.gwc-ai2-typing-indicator > span:nth-child(1) { animation-delay: 0s; }
.gwc-ai2-typing-indicator > span:nth-child(2) { animation-delay: .22s; }
.gwc-ai2-typing-indicator > span:nth-child(3) { animation-delay: .44s; }
@keyframes typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: .6; }
    30% { transform: translateY(-5px); opacity: 1; }
}

/* ---- FOOTER ---- */
.gwc-ai2-chat-footer {
    padding: 12px 14px;
    display: flex;
    align-items: flex-end;
    background: #0d1117;
    border-top: 1px solid rgba(255,255,255,.06);
    flex-shrink: 0;
}

/* Input wrapper: takes up full width, button is positioned inside */
.gwc-ai2-input-wrap {
    position: relative;
    flex: 1;
    display: flex;
    align-items: flex-end;
}

.gwc-ai2-input {
    width: 100%;
    border-radius: 22px;
    border: 1px solid rgba(148,163,184,.25);
    padding: 10px 52px 10px 16px; /* right padding makes room for the button */
    font-size: 14px;
    background: #1e293b;
    color: #e2e8f0;
    outline: none;
    resize: none;
    height: 44px;
    min-height: 44px;
    max-height: 100px;
    line-height: 1.5;
    min-width: 0;
    transition: border-color .2s;
    font-family: var(--gwc-font);
    box-sizing: border-box;
}
.gwc-ai2-input:focus { border-color: rgba(99,102,241,.5); }
.gwc-ai2-input::placeholder { color: #94a3b8; }

.gwc-ai2-send-btn {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    background: var(--gwc-user-bg);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    font-size: 15px;
    transition: background .2s, transform .15s;
    box-shadow: 0 2px 8px rgba(109,40,217,.5);
    flex-shrink: 0;
}
.gwc-ai2-send-btn:hover { background: #5b21b6; transform: translateY(-50%) scale(1.08); }

/* disclaimer */
.gwc-ai2-disclaimer {
    font-size: 10px;
    color: #475569;
    text-align: center;
    padding: 4px 14px 12px;
    background: #0d1117;
    flex-shrink: 0;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 640px) {
    .gwc-ai2-chat-window { right: 8px; left: 8px; width: auto; bottom: 82px; max-height: 72vh; }
    .gwc-ai2-floating-btn { right: 16px; bottom: 16px; }
    .gwc-ai2-external-close { right: 16px; bottom: 20px; }
    .gwc-ai2-input { font-size: 16px !important; }
}