/* =============================================
   QResort Chat Widget — Brand UI
   ============================================= */

:root {
    --qc-dark:        #414350;
    --qc-dark-deep:   #414350;
    --qc-accent:      #9C7E61;
    --qc-accent-light:#9C7E61;
    --qc-white:       #ffffff;
    --qc-bg:          #f5f4f2;
    --qc-text:        #2e2f3a;
    --qc-text-light:  #8a8897;
    --qc-border:      #e4e2de;
    --qc-shadow:      0 8px 32px rgba(65, 67, 80, 0.22);
    --qc-shadow-sm:   0 2px 10px rgba(65, 67, 80, 0.12);
    --qc-radius:      16px;
    --qc-radius-sm:   12px;
    --qc-font:        -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --qc-transition:  0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- Widget Container — anchored to bottom-right corner ---- */
#qresort-chat-widget {
    position: fixed;
    bottom: 0;
    right: 28px;
    z-index: 99999;
    font-family: var(--qc-font);
}

/* ---- Toggle — footer tab style ---- */
#qresort-chat-toggle {
    background: linear-gradient(135deg, var(--qc-dark), var(--qc-accent));
    color: var(--qc-white);
    border: none;
    border-radius: 10px 10px 0 0;
    padding: 11px 20px 11px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 13.5px;
    font-weight: 600;
    font-family: var(--qc-font);
    letter-spacing: 0.2px;
    box-shadow: 0 -3px 14px rgba(65, 67, 80, 0.28);
    transition: filter var(--qc-transition), box-shadow var(--qc-transition);
    outline: none;
    white-space: nowrap;
    position: relative;
    /* subtle pulse on the shadow */
    animation: qc-tab-pulse 3s ease-in-out infinite;
}

#qresort-chat-toggle:hover {
    filter: brightness(1.1);
    box-shadow: 0 -4px 20px rgba(65, 67, 80, 0.38);
    animation: none;
}

#qresort-chat-toggle.is-open {
    animation: none;
    background: linear-gradient(135deg, var(--qc-dark), var(--qc-accent));
}

/* Icon inside tab */
#qresort-chat-toggle svg {
    width: 18px;
    height: 18px;
    fill: var(--qc-white);
    flex-shrink: 0;
    transition: transform var(--qc-transition);
}

#qresort-chat-toggle.is-open svg {
    transform: rotate(90deg) scale(0.9);
}

/* Notification dot */
#qresort-chat-toggle::after {
    content: '';
    position: absolute;
    top: -4px;
    right: -4px;
    width: 11px;
    height: 11px;
    background: #e8624a;
    border-radius: 50%;
    border: 2px solid var(--qc-white);
    transition: opacity var(--qc-transition);
}

#qresort-chat-toggle.is-open::after,
#qresort-chat-toggle.no-badge::after {
    opacity: 0;
}

@keyframes qc-tab-pulse {
    0%, 100% { box-shadow: 0 -3px 14px rgba(65, 67, 80, 0.28); }
    50%       { box-shadow: 0 -5px 22px rgba(156, 126, 97, 0.45); }
}

/* ---- Chat Window ---- */
#qresort-chat-window {
    position: absolute;
    right: 0;
    bottom: 100%;
    width: 360px;
    max-height: 520px;
    background: var(--qc-white);
    border-radius: var(--qc-radius) var(--qc-radius) 0 0;
    box-shadow: var(--qc-shadow);
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    overflow: hidden;

    /* Slide-up animation from the bottom */
    transform-origin: bottom center;
    transform: scaleY(0.92) translateY(12px);
    opacity: 0;
    pointer-events: none;
    transition: transform var(--qc-transition), opacity var(--qc-transition);
}

#qresort-chat-window.is-visible {
    transform: scaleY(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}

/* ---- Header ---- */
#qresort-chat-header {
    background: linear-gradient(135deg, var(--qc-dark), var(--qc-accent));
    padding: 13px 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

#qresort-chat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

#qresort-chat-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255,255,255,0.12);
    border: 2px solid rgba(255,255,255,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: var(--qc-white);
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

#qresort-chat-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--qc-white);
    line-height: 1.2;
}

#qresort-chat-status {
    font-size: 11px;
    color: rgba(255,255,255,0.72);
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}

.qresort-status-dot {
    width: 7px;
    height: 7px;
    background: #5ddb8a;
    border-radius: 50%;
    display: inline-block;
    animation: qc-status-blink 2s ease-in-out infinite;
}

@keyframes qc-status-blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.45; }
}

#qresort-chat-close {
    background: rgba(255,255,255,0.12);
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--qc-transition);
    flex-shrink: 0;
    outline: none;
}

#qresort-chat-close:hover {
    background: rgba(255,255,255,0.25);
}

#qresort-chat-close svg {
    width: 15px;
    height: 15px;
    fill: var(--qc-white);
}

/* ---- Messages Area ---- */
#qresort-chat-messages {
    flex: 1;
    padding: 16px 14px 8px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
    scroll-behavior: smooth;
    background: var(--qc-bg);
}

#qresort-chat-messages::-webkit-scrollbar       { width: 3px; }
#qresort-chat-messages::-webkit-scrollbar-track  { background: transparent; }
#qresort-chat-messages::-webkit-scrollbar-thumb  { background: var(--qc-border); border-radius: 4px; }

/* ---- Message Bubbles ---- */
.qresort-msg {
    display: flex;
    align-items: flex-end;
    gap: 7px;
    animation: qc-msg-in 0.22s ease-out both;
}

@keyframes qc-msg-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.qresort-msg-bot  { align-self: flex-start; }
.qresort-msg-user { align-self: flex-end; flex-direction: row-reverse; }

.qresort-msg-icon {
    width: 27px;
    height: 27px;
    border-radius: 50%;
    background: var(--qc-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    color: var(--qc-white);
    flex-shrink: 0;
}

.qresort-msg-bubble {
    max-width: 76%;
    padding: 10px 14px;
    border-radius: var(--qc-radius-sm);
    font-size: 13.5px;
    line-height: 1.55;
    word-break: break-word;
}

.qresort-msg-bot .qresort-msg-bubble {
    background: var(--qc-white);
    color: var(--qc-text);
    border-bottom-left-radius: 4px;
    box-shadow: var(--qc-shadow-sm);
}

.qresort-msg-user .qresort-msg-bubble {
    background: var(--qc-dark);
    color: var(--qc-white);
    border-bottom-right-radius: 4px;
}

.qresort-msg-bubble a {
    color: var(--qc-accent-light);
    text-decoration: underline;
    word-break: break-all;
}

/* ---- Typing Indicator ---- */
#qresort-chat-typing {
    padding: 4px 14px 8px 48px;
    display: flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
    background: var(--qc-bg);
}

#qresort-chat-typing span {
    display: inline-block;
    width: 7px;
    height: 7px;
    background: var(--qc-accent);
    border-radius: 50%;
    opacity: 0.45;
    animation: qc-typing 1.2s ease-in-out infinite;
}

#qresort-chat-typing span:nth-child(1) { animation-delay: 0s; }
#qresort-chat-typing span:nth-child(2) { animation-delay: 0.2s; }
#qresort-chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes qc-typing {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.45; }
    40%            { transform: translateY(-5px); opacity: 1; }
}

/* ---- Footer / Input ---- */
#qresort-chat-footer {
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-top: 1px solid var(--qc-border);
    background: var(--qc-white);
    flex-shrink: 0;
}

#qresort-chat-input {
    flex: 1;
    height: 40px;
    padding: 0 14px;
    border: 1.5px solid var(--qc-border);
    border-radius: 20px;
    font-size: 13.5px;
    font-family: var(--qc-font);
    color: var(--qc-text);
    background: var(--qc-bg);
    outline: none;
    transition: border-color var(--qc-transition), background var(--qc-transition);
}

#qresort-chat-input:focus {
    border-color: var(--qc-accent);
    background: var(--qc-white);
}

#qresort-chat-input::placeholder { color: var(--qc-text-light); }
#qresort-chat-input:disabled     { opacity: 0.55; cursor: not-allowed; }

#qresort-chat-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--qc-dark), var(--qc-accent));
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform var(--qc-transition), opacity var(--qc-transition);
    outline: none;
}

#qresort-chat-send:hover    { transform: scale(1.08); }
#qresort-chat-send:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

#qresort-chat-send svg {
    width: 17px;
    height: 17px;
    fill: var(--qc-white);
    margin-left: 2px;
}

/* ---- Powered by ---- */
#qresort-chat-powered {
    text-align: center;
    font-size: 10px;
    color: var(--qc-text-light);
    padding: 4px 0 7px;
    letter-spacing: 0.3px;
    background: var(--qc-white);
}

/* ---- Mobile ---- */
@media (max-width: 420px) {
    #qresort-chat-widget {
        right: 12px;
    }

    #qresort-chat-window {
        width: calc(100vw - 24px);
        max-height: 72vh;
    }

    #qresort-chat-toggle {
        font-size: 12.5px;
        padding: 10px 14px 10px 12px;
    }
}
