/* Widget Design Tokens (Matching User Palette) */
:root {
    --widget-yellow: #ffd664;
    --widget-yellow-light: #ffe999;
    --widget-yellow-dark: #e6bc3a;
    --widget-dark: #0a0a0a;
    --widget-bg: #0d0d0d;
    --widget-card: #141414;
    --widget-card-hover: #1b1b1b;
    --widget-border: rgba(255, 255, 255, 0.08);
    --widget-text-gray: #888888;
    --widget-text-light: #cccccc;
    --widget-white: #ffffff;
    --widget-radius: 20px;
    --widget-radius-lg: 28px;
    --widget-transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* Chat Button Bubble */
#apex-chat-bubble {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--widget-yellow);
    box-shadow: 0 8px 32px rgba(255, 214, 100, 0.3);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: var(--widget-transition);
}

#apex-chat-bubble:hover {
    transform: scale(1.1) rotate(5deg);
    background: var(--widget-yellow-light);
    box-shadow: 0 12px 40px rgba(255, 214, 100, 0.4);
}

#apex-chat-bubble svg {
    width: 28px;
    height: 28px;
    fill: var(--widget-dark);
}

/* Chat Container Window */
#apex-chat-container {
    position: fixed;
    bottom: 105px;
    right: 30px;
    width: 380px;
    height: 520px;
    max-height: calc(100vh - 140px);
    background: rgba(20, 20, 20, 0.95);
    backdrop-filter: blur(16px);
    border: 1px solid var(--widget-border);
    border-radius: var(--widget-radius-lg);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    overflow: hidden;
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    pointer-events: none;
    transition: var(--widget-transition);
}

#apex-chat-container.active {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: auto;
}

/* Chat Header */
.apex-chat-header {
    padding: 20px;
    background: var(--widget-card);
    border-bottom: 1px solid var(--widget-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.apex-chat-avatar {
    width: 38px;
    height: 38px;
    background: var(--widget-yellow);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    color: var(--widget-dark);
    font-size: 16px;
}

.apex-chat-title-group {
    display: flex;
    flex-direction: column;
}

.apex-chat-title {
    font-weight: 600;
    font-size: 16px;
    color: var(--widget-white);
}

.apex-chat-status {
    font-size: 12px;
    color: var(--widget-text-gray);
    display: flex;
    align-items: center;
    gap: 6px;
}

.apex-chat-status::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #00e676;
    box-shadow: 0 0 8px #00e676;
}

.apex-chat-close-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--widget-text-light);
    transition: var(--widget-transition);
}

.apex-chat-close-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--widget-white);
}

/* Chat Body (Messages Area) */
.apex-chat-messages {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.apex-chat-messages::-webkit-scrollbar {
    width: 5px;
}
.apex-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
.apex-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}
.apex-chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--widget-yellow);
}

/* Message Bubbles */
.apex-msg-row {
    display: flex;
    width: 100%;
}

.apex-msg-row.user {
    justify-content: flex-end;
}

.apex-msg-row.bot {
    justify-content: flex-start;
}

.apex-msg-bubble {
    max-width: 80%;
    padding: 14px 18px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
    white-space: pre-wrap;
}

.apex-msg-row.user .apex-msg-bubble {
    background: var(--widget-yellow);
    color: var(--widget-dark);
    border-radius: 20px 20px 4px 20px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(255, 214, 100, 0.1);
}

.apex-msg-row.bot .apex-msg-bubble {
    background: var(--widget-card);
    color: var(--widget-text-light);
    border: 1px solid var(--widget-border);
    border-radius: 20px 20px 20px 4px;
}

.apex-msg-bubble a {
    color: var(--widget-yellow-light);
    text-decoration: underline;
}

.apex-msg-bubble ul, .apex-msg-bubble ol {
    margin-left: 20px;
    margin-top: 5px;
    margin-bottom: 5px;
}

/* Typing Indicator */
.apex-typing-bubble {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 16px 20px;
}

.apex-typing-dot {
    width: 8px;
    height: 8px;
    background: var(--widget-text-gray);
    border-radius: 50%;
    animation: apexTyping 1.4s infinite ease-in-out both;
}

.apex-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.apex-typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes apexTyping {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* Chat Input Footer */
.apex-chat-input-area {
    padding: 16px 20px;
    background: var(--widget-card);
    border-top: 1px solid var(--widget-border);
    display: flex;
    gap: 12px;
    align-items: center;
}

.apex-chat-input {
    flex-grow: 1;
    background: var(--widget-bg);
    border: 1px solid var(--widget-border);
    border-radius: var(--widget-radius);
    padding: 12px 18px;
    color: var(--widget-white);
    font-size: 14px;
    outline: none;
    transition: var(--widget-transition);
}

.apex-chat-input:focus {
    border-color: var(--widget-yellow);
    box-shadow: 0 0 10px rgba(255, 214, 100, 0.05);
}

.apex-chat-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--widget-yellow);
    border: none;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: var(--widget-transition);
    flex-shrink: 0;
}

.apex-chat-send-btn:hover {
    background: var(--widget-yellow-light);
    transform: scale(1.05);
}

.apex-chat-send-btn svg {
    width: 18px;
    height: 18px;
    fill: var(--widget-dark);
    transform: translateX(1px);
}

/* Responsive Styles for small screens */
@media (max-width: 480px) {
    #apex-chat-container {
        width: calc(100% - 40px);
        height: calc(100vh - 120px);
        bottom: 80px;
        right: 20px;
    }
    #apex-chat-bubble {
        bottom: 15px;
        right: 20px;
    }
}
