#gc-chat-widget {
    position: fixed;
    bottom: 20px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.4;
    box-sizing: border-box;
}
#gc-chat-widget *,
#gc-chat-widget *::before,
#gc-chat-widget *::after {
    box-sizing: border-box;
}
#gc-chat-widget.gc-position-right { right: 20px; }
#gc-chat-widget.gc-position-left  { left: 20px; }

/* Nút mở/đóng — luôn nằm dưới cửa sổ chat, không bị đè */
#gc-chat-toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--gc-color, #2563eb);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(0,0,0,0.25);
    transition: transform 0.15s ease;
    padding: 0;
    margin: 0;
    position: relative;
    z-index: 2;
}
#gc-chat-toggle:hover { transform: scale(1.06); }
#gc-chat-toggle svg {
    display: block;
    flex-shrink: 0;
    pointer-events: none;
}

/* Cửa sổ chat — cách nút toggle một khoảng rõ ràng */
#gc-chat-window {
    position: absolute;
    bottom: 70px; /* 56px nút + ~14px khoảng cách */
    width: 340px;
    max-width: calc(100vw - 40px);
    height: 460px;
    max-height: min(70vh, calc(100vh - 100px));
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 35px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 1;
}
.gc-position-right #gc-chat-window { right: 0; }
.gc-position-left  #gc-chat-window { left: 0; }

#gc-chat-header {
    background: var(--gc-color, #2563eb);
    color: #fff;
    padding: 12px 16px;
    font-weight: 600;
    font-size: 15px;
    flex-shrink: 0;
    line-height: 1.3;
}

#gc-chat-messages {
    flex: 1 1 auto;
    min-height: 0; /* quan trọng để flex không đẩy input phình to */
    overflow-y: auto;
    padding: 12px 14px;
    background: #f7f8fa;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.gc-msg {
    max-width: 82%;
    padding: 8px 12px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.gc-msg-user {
    align-self: flex-end;
    background: var(--gc-color, #2563eb);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.gc-msg-bot {
    align-self: flex-start;
    background: #fff;
    color: #222;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
}
.gc-msg-typing {
    align-self: flex-start;
    background: #fff;
    border: 1px solid #e5e7eb;
    padding: 10px 14px;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
}
.gc-typing-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    margin-right: 3px;
    border-radius: 50%;
    background: #9ca3af;
    animation: gc-blink 1.2s infinite ease-in-out;
}
.gc-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.gc-typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes gc-blink {
    0%, 80%, 100% { opacity: 0.3; }
    40% { opacity: 1; }
}

/* Hàng nhập tin — compact, không phình cao */
#gc-chat-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #e5e7eb;
    background: #fff;
    flex-shrink: 0;
}

#gc-chat-input {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    height: 40px !important;
    min-height: 40px !important;
    max-height: 80px !important;
    resize: none;
    border: 1px solid #d1d5db;
    border-radius: 20px;
    padding: 9px 14px;
    font-size: 13.5px;
    line-height: 1.35;
    font-family: inherit;
    outline: none;
    background: #fff;
    color: #222;
    margin: 0;
    box-shadow: none;
    overflow-y: auto;
}
#gc-chat-input:focus {
    border-color: var(--gc-color, #2563eb);
}

/* Nút gửi — luôn có icon trắng rõ */
#gc-chat-send {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    border-radius: 50%;
    background: var(--gc-color, #2563eb) !important;
    color: #fff !important;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0;
    margin: 0;
    box-shadow: none;
    line-height: 0;
}
#gc-chat-send svg {
    display: block;
    width: 18px;
    height: 18px;
    fill: #fff !important;
    color: #fff !important;
    pointer-events: none;
    flex-shrink: 0;
}
#gc-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
#gc-chat-send:hover:not(:disabled) {
    filter: brightness(1.08);
}

@media (max-width: 480px) {
    #gc-chat-window {
        width: calc(100vw - 24px);
        height: min(75vh, calc(100vh - 90px));
        bottom: 66px;
    }
    #gc-chat-widget.gc-position-right { right: 12px; }
    #gc-chat-widget.gc-position-left  { left: 12px; }
}
