/* ==========================================================================
   QuickBidz Chat Widget — Styles
   Location: mods/css/chat-widget.css
   ========================================================================== */

/* ---------------------------------------------------------------------------
   Variables & Base
   --------------------------------------------------------------------------- */
:root {
    --qb-gold:       #DCB400;
    --qb-gold-hover: #c9a400;
    --qb-gold-light: #f5e9a0;
    --qb-black:      #000000;
    --qb-white:      #ffffff;
    --qb-gray-light: #f4f4f4;
    --qb-gray-mid:   #e0e0e0;
    --qb-text-dark:  #333333;
    --qb-text-light: #666666;
    --qb-shadow:     0 4px 24px rgba(0, 0, 0, 0.18);
    --qb-shadow-sm:  0 2px 8px rgba(0, 0, 0, 0.12);
    --qb-radius:     12px;
    --qb-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------------------------------------------------------------------------
   Floating Toggle Button
   --------------------------------------------------------------------------- */
#qb-chat-toggle {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 99998;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background-color: var(--qb-gold);
    color: var(--qb-white);
    border: none;
    cursor: pointer;
    box-shadow: var(--qb-shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    transition: background-color var(--qb-transition),
                transform var(--qb-transition),
                box-shadow var(--qb-transition);
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

#qb-chat-toggle:hover {
    background-color: var(--qb-gold-hover);
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(0, 0, 0, 0.22);
}

#qb-chat-toggle:active {
    transform: scale(0.96);
}

/* Notification badge */
#qb-chat-toggle .qb-chat-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background-color: #e74c3c;
    color: var(--qb-white);
    font-size: 11px;
    font-weight: 700;
    display: none;
    align-items: center;
    justify-content: center;
    line-height: 1;
    border: 2px solid var(--qb-white);
}

#qb-chat-toggle .qb-chat-badge.visible {
    display: flex;
}

/* ---------------------------------------------------------------------------
   Chat Panel
   --------------------------------------------------------------------------- */
#qb-chat-panel {
    position: fixed;
    bottom: 92px;
    left: 24px;
    z-index: 99999;
    width: 380px;
    height: 500px;
    max-height: calc(100vh - 120px);
    background-color: var(--qb-white);
    border-radius: var(--qb-radius);
    box-shadow: var(--qb-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transform-origin: bottom left;
    transition: opacity var(--qb-transition),
                visibility var(--qb-transition),
                transform var(--qb-transition);
}

#qb-chat-panel.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* ---------------------------------------------------------------------------
   Header
   --------------------------------------------------------------------------- */
#qb-chat-panel .qb-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background-color: var(--qb-black);
    color: var(--qb-gold);
    flex-shrink: 0;
}

#qb-chat-panel .qb-chat-header-title {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.3px;
    display: flex;
    align-items: center;
    gap: 8px;
}

#qb-chat-panel .qb-chat-header-title i {
    font-size: 16px;
}

#qb-chat-panel .qb-chat-close {
    background: none;
    border: none;
    color: var(--qb-gold);
    font-size: 20px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: opacity var(--qb-transition);
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

#qb-chat-panel .qb-chat-close:hover {
    opacity: 0.7;
}

/* ---------------------------------------------------------------------------
   Messages Area
   --------------------------------------------------------------------------- */
#qb-chat-panel .qb-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* Scrollbar styling */
#qb-chat-panel .qb-chat-messages::-webkit-scrollbar {
    width: 5px;
}

#qb-chat-panel .qb-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

#qb-chat-panel .qb-chat-messages::-webkit-scrollbar-thumb {
    background: var(--qb-gray-mid);
    border-radius: 3px;
}

/* Individual message bubble */
.qb-chat-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
    animation: qbChatFadeIn 0.25s ease-out;
}

.qb-chat-msg.user {
    align-self: flex-end;
    background-color: var(--qb-gold);
    color: var(--qb-text-dark);
    border-bottom-right-radius: 4px;
}

.qb-chat-msg.assistant {
    align-self: flex-start;
    background-color: var(--qb-gray-light);
    color: var(--qb-text-dark);
    border-bottom-left-radius: 4px;
}

/* Welcome message styling */
.qb-chat-msg.assistant.welcome {
    font-size: 13px;
    color: var(--qb-text-light);
}

@keyframes qbChatFadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---------------------------------------------------------------------------
   Typing Indicator
   --------------------------------------------------------------------------- */
.qb-chat-typing {
    display: none;
    align-self: flex-start;
    padding: 12px 18px;
    background-color: var(--qb-gray-light);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    gap: 4px;
    align-items: center;
}

.qb-chat-typing.visible {
    display: flex;
}

.qb-chat-typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background-color: #999;
    animation: qbTypingBounce 1.4s infinite ease-in-out both;
}

.qb-chat-typing-dot:nth-child(1) {
    animation-delay: 0s;
}

.qb-chat-typing-dot:nth-child(2) {
    animation-delay: 0.16s;
}

.qb-chat-typing-dot:nth-child(3) {
    animation-delay: 0.32s;
}

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

/* ---------------------------------------------------------------------------
   Input Area
   --------------------------------------------------------------------------- */
#qb-chat-panel .qb-chat-input-area {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-top: 1px solid var(--qb-gray-mid);
    background-color: var(--qb-white);
    flex-shrink: 0;
    gap: 8px;
}

#qb-chat-panel .qb-chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--qb-gray-mid);
    border-radius: 24px;
    font-size: 14px;
    font-family: inherit;
    color: var(--qb-text-dark);
    outline: none;
    transition: border-color var(--qb-transition);
    background-color: var(--qb-gray-light);
    resize: none;
}

#qb-chat-panel .qb-chat-input:focus {
    border-color: var(--qb-gold);
    background-color: var(--qb-white);
}

#qb-chat-panel .qb-chat-input::placeholder {
    color: #aaa;
}

#qb-chat-panel .qb-chat-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--qb-gold);
    color: var(--qb-white);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    transition: background-color var(--qb-transition),
                transform var(--qb-transition);
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

#qb-chat-panel .qb-chat-send:hover {
    background-color: var(--qb-gold-hover);
    transform: scale(1.05);
}

#qb-chat-panel .qb-chat-send:active {
    transform: scale(0.95);
}

#qb-chat-panel .qb-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ---------------------------------------------------------------------------
   Error Message
   --------------------------------------------------------------------------- */
.qb-chat-msg.error {
    align-self: center;
    background-color: #fff3f3;
    color: #c0392b;
    border: 1px solid #f5c6cb;
    border-radius: 8px;
    font-size: 13px;
    text-align: center;
    max-width: 90%;
}

/* ---------------------------------------------------------------------------
   Mobile Responsive — Full Width Below 480px
   --------------------------------------------------------------------------- */
@media (max-width: 480px) {
    #qb-chat-toggle {
        bottom: 16px;
        left: 16px;
        width: 50px;
        height: 50px;
        font-size: 22px;
    }

    #qb-chat-panel {
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
        transform-origin: bottom center;
    }

    #qb-chat-panel.open {
        transform: translateY(0) scale(1);
    }

    #qb-chat-panel .qb-chat-header {
        padding: 16px;
        border-radius: 0;
    }

    #qb-chat-panel .qb-chat-messages {
        padding: 12px;
    }

    .qb-chat-msg {
        max-width: 90%;
    }

    #qb-chat-panel .qb-chat-input-area {
        padding: 10px 12px;
        /* Safe area for iOS devices with home indicator */
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    }
}

/* ---------------------------------------------------------------------------
   Reduced Motion
   --------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    #qb-chat-toggle,
    #qb-chat-panel,
    .qb-chat-msg,
    .qb-chat-typing-dot {
        animation-duration: 0s !important;
        transition-duration: 0.1s !important;
    }
}
