/* QVA customer support Messenger + floating tools — loaded on every storefront page via
   views/partials/livechat-assistant.php. Same UI as the distributor messenger (views/distributor). */
/* --- Customer support messenger (same UI as the distributor messenger, views/distributor) --- */
.qva-messenger {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 2000;
    display: grid;
    width: min(560px, calc(100vw - 32px));
    height: min(680px, calc(100vh - 32px));
    overflow: hidden;
    border: 1px solid #d8deea;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 24px 80px rgba(15, 23, 42, .22);
    transform: translateX(calc(100% + 32px));
    opacity: 0;
    pointer-events: none;
    transition: transform .26s ease, opacity .2s ease;
}
.qva-messenger.is-open { transform: translateX(0); opacity: 1; pointer-events: auto; }
.qva-messenger__thread {
    display: grid;
    grid-template-rows: 64px minmax(0, 1fr) auto;
    min-width: 0;
    min-height: 0;
    background: #fff;
}
.qva-messenger__thread-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 64px;
    padding: 12px 18px;
    border-bottom: 1px solid #e3e7ef;
}
.qva-messenger__thread-head > div { display: flex; align-items: center; gap: 10px; min-width: 0; }
.qva-messenger__title { display: grid; min-width: 0; }
.qva-messenger__title strong { color: #191b23; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qva-messenger__title small { color: #5f6675; font-weight: 700; font-size: 12px; }
.qva-messenger__thread-head button {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: #5c6473;
    cursor: pointer;
}
.qva-messenger__avatar {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    border: 1px solid #cbd7ef;
    border-radius: 999px;
    background: #eef4ff;
    color: #003f9f;
    font-weight: 900;
}
.qva-messenger__body { overflow-y: auto; padding: 22px 24px; background: #f7f8fb; }
.qva-messenger__empty {
    display: grid;
    place-items: center;
    gap: 6px;
    padding: 24px 0;
    color: #5f6675;
    text-align: center;
}
.qva-messenger__empty p { margin: 0; font-size: 13px; }
.qva-messenger__empty .material-symbols-outlined { color: #c9d0df; font-size: 46px; }
.qva-chat-date { margin: 10px 0 14px; color: #a1a8b5; font-size: 12px; font-weight: 800; text-align: center; }
.qva-chat-card {
    max-width: 430px;
    margin: 0 auto 22px;
    border-radius: 12px;
    padding: 14px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(15, 23, 42, .06);
}
.qva-chat-card p { margin: 0; color: #5f6675; font-size: 13px; line-height: 1.45; }
.qva-chat-order { display: grid; grid-template-columns: 44px 1fr; gap: 10px; align-items: center; margin-bottom: 10px; }
.qva-chat-order > .material-symbols-outlined {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: #eef2fb;
    color: #003f9f;
}
.qva-chat-order span { display: block; color: #003f9f; font-size: 12px; font-weight: 900; }
.qva-chat-order h4 { margin: 2px 0 0; font-size: 15px; text-transform: capitalize; }
.qva-chat-bubble {
    width: fit-content;
    max-width: min(78%, 420px);
    margin: 10px 0;
    border-radius: 13px;
    padding: 11px 14px;
    color: #20242e;
    font-size: 14px;
    line-height: 1.45;
    overflow-wrap: anywhere;
}
.qva-chat-bubble small { display: block; margin-top: 6px; color: #8a92a1; font-size: 11px; font-weight: 800; }
.qva-chat-bubble.is-support { background: #fff; box-shadow: 0 2px 8px rgba(15, 23, 42, .04); }
.qva-chat-bubble.is-user { margin-left: auto; background: #dcecff; }
.qva-messenger__composer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 82px;
    gap: 8px;
    align-items: end;
    padding: 12px 16px 16px;
    border-top: 1px solid #e3e7ef;
    background: #fff;
}
.qva-messenger__composer textarea {
    min-width: 0;
    min-height: 54px;
    max-height: 140px;
    resize: vertical;
    border: 0;
    border-radius: 10px;
    padding: 12px 14px;
    background: #f4f5f8;
    color: #191b23;
    font: inherit;
}
.qva-messenger__send {
    align-self: center;
    min-height: 38px;
    border: 0;
    border-radius: 999px;
    background: #0057d9;
    color: #fff;
    font: inherit;
    font-weight: 900;
    cursor: pointer;
}
.qva-messenger__send:disabled { opacity: .6; cursor: wait; }

/* --- Floating tools (same as the distributor's .dist-floating-tools) --- */
.qva-floating-tools {
    position: fixed;
    right: 18px;
    bottom: 72px;
    z-index: 1500;
    display: grid;
    width: 94px;
    overflow: hidden;
    border: 1px solid #e3e7ef;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 12px 30px rgba(15, 23, 42, .12);
}
.qva-floating-tools a,
.qva-floating-tools button {
    position: relative;
    display: grid;
    place-items: center;
    gap: 5px;
    min-height: 72px;
    width: 100%;
    border: 0;
    border-bottom: 1px solid #e3e7ef;
    background: #fff;
    color: #313642;
    font: inherit;
    text-decoration: none;
    cursor: pointer;
}
.qva-floating-tools a:last-child,
.qva-floating-tools button:last-child { border-bottom: 0; }
.qva-floating-tools .material-symbols-outlined { color: #0057d9; }
.qva-floating-tools small { font-size: 12px; }
.qva-floating-tools a:hover,
.qva-floating-tools button:hover { background: #f5f8ff; }
.qva-floating-tools__badge {
    position: absolute;
    top: 8px;
    right: 14px;
    min-width: 20px;
    border-radius: 999px;
    padding: 1px 6px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 900;
    line-height: 16px;
}

/* --- Two-pane messenger: thread + orders list (distributor layout) --- */
.qva-messenger.is-split {
    grid-template-columns: minmax(0, 1fr) 320px;
    width: min(980px, calc(100vw - 32px));
    height: min(720px, calc(100vh - 32px));
}
.qva-messenger.is-split .qva-messenger__thread { border-right: 1px solid #e3e7ef; }
.qva-messenger__list {
    display: grid;
    grid-template-rows: 64px auto auto minmax(0, 1fr);
    min-width: 0;
    min-height: 0;
    background: #fff;
}
.qva-messenger__list header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 64px;
    padding: 12px 18px;
    border-bottom: 1px solid #e3e7ef;
}
.qva-messenger__list header > div { display: flex; align-items: center; gap: 10px; }
.qva-messenger__list header strong { color: #191b23; font-size: 17px; }
.qva-messenger__list header button {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: #5c6473;
    cursor: pointer;
}
.qva-messenger.is-split .qva-messenger__thread-head [data-qva-close-messenger] { display: none; }
.qva-messenger__search {
    display: grid;
    grid-template-columns: 28px 1fr;
    align-items: center;
    gap: 8px;
    margin: 10px;
    border-radius: 10px;
    padding: 9px 12px;
    background: #f5f7fb;
    color: #687183;
}
.qva-messenger__search input { min-width: 0; border: 0; outline: 0; background: transparent; font: inherit; }
.qva-messenger__notice {
    display: grid;
    grid-template-columns: 22px 1fr;
    gap: 8px;
    margin: 0 10px 10px;
    border-radius: 8px;
    padding: 10px;
    background: #eaf2ff;
    color: #1d355d;
    font-size: 12px;
    line-height: 1.35;
}
.qva-messenger__notice .material-symbols-outlined { color: #0057d9; font-size: 20px; }
.qva-messenger__contacts { overflow-y: auto; padding: 0 10px 12px; }
.qva-messenger__muted { margin: 10px; color: #5f6675; font-size: 13px; }
.qva-contact {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    width: 100%;
    border: 0;
    border-radius: 10px;
    padding: 10px;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.qva-contact:hover,
.qva-contact.is-active { background: #eef4ff; }
.qva-contact .qva-messenger__avatar .material-symbols-outlined { font-size: 20px; }
.qva-contact__copy { min-width: 0; }
.qva-contact__copy strong,
.qva-contact__copy span,
.qva-contact__copy small { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.qva-contact__copy strong { font-size: 14px; color: #191b23; }
.qva-contact__copy span { margin-top: 2px; color: #003f9f; font-size: 12px; font-weight: 900; text-transform: capitalize; }
.qva-contact__copy small { margin-top: 3px; color: #4c5566; font-size: 12px; }
.qva-contact__meta { display: grid; justify-items: end; gap: 6px; align-self: start; }
.qva-contact__meta time { color: #7c8493; font-size: 11px; font-weight: 800; }
.qva-contact__unread {
    min-width: 20px;
    border-radius: 999px;
    padding: 1px 6px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 900;
    text-align: center;
}
.qva-chat-card a { color: #0057d9; font-weight: 700; }
.qva-messenger__composer[hidden] { display: none; }
.qva-messenger__empty a { color: #0057d9; font-weight: 700; font-size: 13px; }


@media (max-width: 600px) {
    .qva-messenger {
        inset: 8px 0 0;
        width: 100%;
        height: auto;
        border-radius: 22px 22px 0 0;
        transform: translateY(calc(100% + 24px));
    }
    .qva-messenger.is-open { transform: translateY(0); }
    .qva-messenger__body { padding: 14px; }
    .qva-messenger__composer { padding: 10px; grid-template-columns: minmax(0, 1fr) 72px; }
    .qva-messenger.is-split { grid-template-columns: 1fr; grid-template-rows: 220px minmax(0, 1fr); width: 100%; height: auto; }
    .qva-messenger.is-split .qva-messenger__list { grid-row: 1; grid-template-rows: 56px auto minmax(0, 1fr); border-bottom: 1px solid #e3e7ef; }
    .qva-messenger.is-split .qva-messenger__thread { grid-row: 2; border-right: 0; }
    .qva-messenger.is-split .qva-messenger__thread-head { display: none; }
    .qva-messenger.is-split .qva-messenger__thread { grid-template-rows: minmax(0, 1fr) auto; }
    .qva-messenger__notice { display: none; }
    .qva-messenger__contacts { display: flex; gap: 8px; overflow-x: auto; overflow-y: hidden; }
    .qva-contact { flex: 0 0 240px; }
    .qva-floating-tools { right: 12px; bottom: 92px; width: 64px; border-radius: 16px; }
    .qva-floating-tools a { display: none; }
    .qva-floating-tools button { min-height: 60px; }
    .qva-floating-tools small { font-size: 10px; }
    .qva-floating-tools__badge { right: 6px; top: 4px; }
}

/* Draggable floating tools: move up/down the right edge (grip bar on top). */
.qva-floating-tools.is-draggable,
.admin-floating-tools.is-draggable { touch-action: none; cursor: grab; padding-top: 10px; }
.qva-floating-tools.is-draggable::before,
.admin-floating-tools.is-draggable::before {
    content: '';
    position: absolute;
    top: 5px;
    left: 50%;
    width: 28px;
    height: 4px;
    margin-left: -14px;
    border-radius: 999px;
    background: #c9d0df;
}
.qva-floating-tools.is-draggable,
.admin-floating-tools.is-draggable { user-select: none; -webkit-user-select: none; }
.qva-floating-tools.is-dragging,
.admin-floating-tools.is-dragging { cursor: grabbing; box-shadow: 0 18px 40px rgba(15, 23, 42, .28); }
.qva-floating-tools.is-dragging *,
.admin-floating-tools.is-dragging * { pointer-events: none; }
