/* =====================================================================
   EazyStock floating support widget (v5.49)
   Theme-aware (light / dark via --ink-* + --surface-rgb), mobile bottom
   sheet, smooth open/close, no horizontal overflow. Launcher bottom-right
   on public pages; on the app it opens from the FAB / user menu.
   ===================================================================== */

.ez-support { font-family: inherit; }

/* ---------- launcher ---------- */
.ez-support__launch {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 1490;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0 18px 0 14px;
    height: 52px;
    border: none;
    border-radius: 26px;
    cursor: pointer;
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    box-shadow: 0 12px 28px -8px rgba(99, 102, 241, 0.6);
    transition: transform .2s ease, box-shadow .2s ease, opacity .2s ease, visibility .2s ease;
}
.ez-support__launch:hover { transform: translateY(-2px); box-shadow: 0 16px 34px -8px rgba(99, 102, 241, 0.7); }
.ez-support__launch:focus-visible { outline: none; box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.35); }
.ez-support__launch-ico { display: inline-flex; line-height: 1; }
.ez-support__launch-ico--close { display: none; }
.ez-support__launch-label { white-space: nowrap; }

/* Hidden when the app passes data-launcher="off" (opened from FAB/menu). */
.ez-support[data-launcher="off"] .ez-support__launch { display: none; }
/* Hide the launcher while the panel is open so they never overlap. */
.ez-support.is-open .ez-support__launch { opacity: 0; visibility: hidden; transform: scale(.85); }

/* v5.54 — notification badge (unread admin replies) on the launcher. */
.ez-support__badge {
    position: absolute; top: -6px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px;
    border-radius: 999px; background: #ef4444; color: #fff; font-size: 12px; font-weight: 800;
    line-height: 20px; text-align: center; font-variant-numeric: tabular-nums;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, .9);
}
.ez-support__badge[hidden] { display: none; }
/* Small open-session dot when a conversation is open but nothing is unread. */
.ez-support--has-open:not(.ez-support--has-unread) .ez-support__launch::after {
    content: ''; position: absolute; top: -3px; right: -1px; width: 12px; height: 12px;
    border-radius: 50%; background: #34d399; box-shadow: 0 0 0 2px rgba(99, 102, 241, .9);
}
/* Inline count badge on the app FAB "Contact support" item. */
.ez-support__fab-badge {
    margin-left: auto; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
    background: #ef4444; color: #fff; font-size: 11px; font-weight: 800; line-height: 18px;
    text-align: center; font-variant-numeric: tabular-nums;
}
.ez-support__fab-badge[hidden] { display: none; }
/* Per-session unread count in My Messages. */
.ez-support__session-count {
    margin-left: auto; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
    background: #ef4444; color: #fff; font-size: 11px; font-weight: 800; line-height: 18px;
    text-align: center; font-variant-numeric: tabular-nums;
}

/* ---------- panel ---------- */
.ez-support__panel {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 4600;                 /* above content/FAB/scroll-top; below cookie(5000)/popups(4800) */
    width: 370px;
    max-width: calc(100vw - 28px);
    max-height: min(620px, calc(100vh - 36px));
    display: flex;
    flex-direction: column;
    background: rgb(var(--surface-rgb, 255, 255, 255));
    border: 1px solid var(--ink-200, #e2e8f0);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 30px 70px -24px rgba(15, 23, 42, 0.45);
    opacity: 0;
    visibility: hidden;
    transform: translateY(14px) scale(0.98);
    transform-origin: bottom right;
    transition: opacity .22s ease, transform .22s ease, visibility .22s ease;
}
.ez-support.is-open .ez-support__panel {
    opacity: 1;
    visibility: visible;
    transform: none;
}

.ez-support__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 16px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    flex-shrink: 0;
}
.ez-support__head-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ez-support__avatar {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: 50%;
    background: rgba(255, 255, 255, 0.18); flex-shrink: 0;
}
.ez-support__head-text { min-width: 0; }
.ez-support__title { font-weight: 800; font-size: 15px; line-height: 1.2; }
.ez-support__sub { font-size: 12px; opacity: 0.9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ez-support__close {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; flex-shrink: 0;
    border: none; border-radius: 9px; cursor: pointer;
    background: rgba(255, 255, 255, 0.16); color: #fff;
    transition: background .15s ease;
}
.ez-support__close:hover { background: rgba(255, 255, 255, 0.3); }

.ez-support__body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 16px;
}
.ez-support__view { display: block; }

/* ---- welcome + compose ---- */
.ez-support__welcome-title { margin: 0 0 4px; font-weight: 800; color: var(--ink-900, #0f172a); font-size: 15px; }
.ez-support__welcome-text { margin: 0 0 14px; font-size: 13.5px; color: var(--ink-600, #475569); line-height: 1.5; }
.ez-support__form { display: flex; flex-direction: column; gap: 14px; }
.ez-support__field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ez-support__row { display: flex; gap: 10px; }
.ez-support__row .ez-support__field { flex: 1 1 0; }
.ez-support__label { font-size: 12.5px; font-weight: 600; color: var(--ink-700, #334155); }

.ez-support__topics { display: flex; flex-wrap: wrap; gap: 7px; }
.ez-support__topic { cursor: pointer; }
.ez-support__topic input { position: absolute; opacity: 0; pointer-events: none; }
.ez-support__topic-chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 11px; border-radius: 999px;
    border: 1px solid var(--ink-200, #e2e8f0);
    background: rgb(var(--surface-rgb, 255, 255, 255));
    color: var(--ink-700, #334155);
    font-size: 12.5px; font-weight: 600;
    transition: all .15s ease;
}
.ez-support__topic-chip .ez-ico { color: var(--ink-500, #64748b); }
.ez-support__topic input:checked + .ez-support__topic-chip {
    border-color: #6366f1;
    background: rgba(99, 102, 241, 0.1);
    color: #4338ca;
}
.ez-support__topic input:checked + .ez-support__topic-chip .ez-ico { color: #6366f1; }
.ez-support__topic input:focus-visible + .ez-support__topic-chip { box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25); }

.ez-support__input, .ez-support__textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--ink-200, #e2e8f0);
    border-radius: 10px;
    background: rgb(var(--surface-rgb, 255, 255, 255));
    color: var(--ink-900, #0f172a);
    font-size: 14px;
    font-family: inherit;
}
.ez-support__textarea { resize: vertical; min-height: 70px; }
.ez-support__input::placeholder, .ez-support__textarea::placeholder { color: var(--ink-400, #94a3b8); }
.ez-support__input:focus, .ez-support__textarea:focus {
    outline: none; border-color: #6366f1;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.14);
}
.ez-support__signedin {
    margin: 0; font-size: 12.5px; color: var(--ink-600, #475569);
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.ez-support__signedin .ez-ico { color: #10b981; }

.ez-support__err {
    font-size: 12.5px; color: #b91c1c;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: 9px; padding: 8px 11px;
}

.ez-support__send {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 11px 18px; border: none; border-radius: 11px; cursor: pointer;
    color: #fff; font-weight: 700; font-size: 14px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    transition: transform .15s ease, opacity .15s ease;
}
.ez-support__send.sm { padding: 9px 14px; font-size: 13px; }
.ez-support__send:hover { transform: translateY(-1px); }
.ez-support__send:disabled { opacity: 0.6; cursor: default; transform: none; }
.ez-support__send:focus-visible { outline: none; box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.3); }

/* ---- sent confirmation ---- */
.ez-support__sent { text-align: center; padding: 14px 6px; }
.ez-support__sent-ico {
    display: inline-flex; align-items: center; justify-content: center;
    width: 64px; height: 64px; margin-bottom: 12px;
    border-radius: 50%; color: #fff;
    background: linear-gradient(135deg, #10b981, #059669);
}
.ez-support__sent-title { margin: 0 0 6px; font-weight: 800; font-size: 17px; color: var(--ink-900, #0f172a); }
.ez-support__sent-text { margin: 0 0 8px; font-size: 13.5px; color: var(--ink-600, #475569); line-height: 1.5; }
.ez-support__sent-ref {
    margin: 0 0 14px; display: inline-block;
    font-size: 12.5px; font-weight: 700; color: #4338ca;
    background: rgba(99, 102, 241, 0.1); padding: 5px 12px; border-radius: 999px;
}
.ez-support__again {
    border: 1px solid var(--ink-200, #e2e8f0); background: transparent;
    color: var(--ink-700, #334155); font-weight: 600; font-size: 13px;
    padding: 9px 16px; border-radius: 10px; cursor: pointer;
}
.ez-support__again:hover { border-color: #6366f1; color: #4338ca; }

/* ---- thread (logged-in) ---- */
.ez-support__thread-meta { font-size: 12px; color: var(--ink-500, #64748b); margin-bottom: 10px; }
.ez-support__thread { display: flex; flex-direction: column; gap: 9px; margin-bottom: 12px; }
.ez-support__msg { max-width: 84%; padding: 9px 12px; border-radius: 13px; font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.ez-support__msg--user { align-self: flex-end; background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff; border-bottom-right-radius: 4px; }
.ez-support__msg--admin { align-self: flex-start; background: var(--ink-100, #f1f5f9); color: var(--ink-900, #0f172a); border-bottom-left-radius: 4px; }
.ez-support__msg-time { display: block; font-size: 10.5px; opacity: 0.7; margin-top: 3px; }
.ez-support__thread-empty { font-size: 13px; color: var(--ink-500, #64748b); text-align: center; padding: 20px 6px; }
.ez-support__reply { display: flex; gap: 8px; align-items: flex-end; }
.ez-support__reply .ez-support__textarea { min-height: 42px; }

/* ---- footer ---- */
.ez-support__foot {
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    flex-wrap: wrap;
    padding: 11px 16px;
    border-top: 1px solid var(--ink-200, #e2e8f0);
    background: rgba(var(--surface-rgb, 248, 250, 252), 0.6);
}
.ez-support__foot-link {
    display: inline-flex; align-items: center; gap: 6px;
    border: none; background: transparent; cursor: pointer;
    font-size: 12.5px; font-weight: 600; color: var(--ink-600, #475569);
    padding: 4px 2px;
}
.ez-support__foot-link:hover { color: #4338ca; }
.ez-support__wa {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 12.5px; font-weight: 700; color: #128c3e; text-decoration: none;
    padding: 6px 12px; border-radius: 999px;
    background: rgba(37, 211, 102, 0.12);
}
.ez-support__wa:hover { background: rgba(37, 211, 102, 0.22); }

/* ---------- dark mode ---------- */
html[data-theme="dark"] .ez-support__panel { border-color: var(--ez-border, #2a3350); }
html[data-theme="dark"] .ez-support__topic-chip { border-color: var(--ez-border, #2a3350); }
html[data-theme="dark"] .ez-support__topic input:checked + .ez-support__topic-chip { color: #c7d2fe; background: rgba(99, 102, 241, 0.2); }
html[data-theme="dark"] .ez-support__sent-ref { color: #c7d2fe; }
html[data-theme="dark"] .ez-support__foot-link:hover,
html[data-theme="dark"] .ez-support__again:hover { color: #c7d2fe; }
html[data-theme="dark"] .ez-support__msg--admin { background: var(--ink-100, #1f2740); }
html[data-theme="dark"] .ez-support__wa { color: #4ade80; }

/* Keep the public scroll-to-top button clear of the launcher. */
.public-shell .ez-totop { bottom: 86px; }
@media (max-width: 768px) {
    .public-shell .ez-totop { bottom: calc(78px + env(safe-area-inset-bottom)); }
}

/* ---------- mobile: bottom sheet ---------- */
@media (max-width: 575.98px) {
    .ez-support__launch { right: 14px; bottom: calc(14px + env(safe-area-inset-bottom)); height: 50px; }
    .ez-support__panel {
        right: 0; left: 0; bottom: 0;
        width: 100%; max-width: 100%;
        max-height: 90vh;
        border-radius: 18px 18px 0 0;
        border-left: none; border-right: none; border-bottom: none;
        transform: translateY(100%);
        transform-origin: bottom center;
    }
    .ez-support.is-open .ez-support__panel { transform: none; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    .ez-support__launch, .ez-support__panel, .ez-support__send { transition: opacity .12s ease, visibility .12s ease; }
    .ez-support.is-open .ez-support__panel,
    .ez-support__launch:hover, .ez-support__send:hover { transform: none; }
}

/* =====================================================================
   v5.50 — sessions list + back navigation + one-open banner
   ===================================================================== */
.ez-support__head-main { flex: 1 1 auto; }
.ez-support__back {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; flex-shrink: 0;
    border: none; border-radius: 9px; cursor: pointer;
    background: rgba(255, 255, 255, 0.16); color: #fff;
    transition: background .15s ease;
}
.ez-support__back:hover { background: rgba(255, 255, 255, 0.3); }

/* one-open-session banner (in compose) */
.ez-support__active-banner {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px; padding: 10px 12px; border-radius: 11px;
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.35);
    font-size: 12.5px; color: var(--ink-800, #1e293b);
}
.ez-support__active-banner > div { display: inline-flex; align-items: center; gap: 7px; }
.ez-support__active-banner .ez-ico { color: #d97706; }
.ez-support__banner-btn {
    border: none; cursor: pointer; font-weight: 700; font-size: 12.5px;
    color: #fff; background: #6366f1; padding: 6px 13px; border-radius: 8px;
}

/* session list */
.ez-support__sessions { display: flex; flex-direction: column; gap: 9px; }
.ez-support__session {
    display: block; width: 100%; text-align: left; cursor: pointer;
    background: rgb(var(--surface-rgb, 255, 255, 255));
    border: 1px solid var(--ink-200, #e2e8f0); border-radius: 12px;
    padding: 12px 13px; color: var(--ink-900, #0f172a);
    transition: border-color .15s ease, transform .12s ease;
}
.ez-support__session:hover { border-color: #6366f1; transform: translateY(-1px); }
.ez-support__session-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 5px; }
.ez-support__session-topic { font-weight: 700; font-size: 13.5px; }
.ez-support__session-dot { width: 8px; height: 8px; border-radius: 50%; background: #f59e0b; }
.ez-support__session-prev { font-size: 12.5px; color: var(--ink-600, #475569); line-height: 1.45; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.ez-support__session-meta { font-size: 11px; color: var(--ink-400, #94a3b8); margin-top: 5px; }

.ez-support__sbadge { font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.ez-support__sbadge.open { background: rgba(59, 130, 246, 0.16); color: #2563eb; }
.ez-support__sbadge.replied { background: rgba(16, 185, 129, 0.16); color: #059669; }
.ez-support__sbadge.closed { background: rgba(100, 116, 139, 0.18); color: var(--ink-500, #64748b); }

.ez-support__sessions-empty { text-align: center; padding: 30px 6px; }
.ez-support__empty-ico {
    display: inline-flex; align-items: center; justify-content: center;
    width: 56px; height: 56px; margin-bottom: 10px; border-radius: 50%;
    background: rgba(99, 102, 241, 0.1); color: #6366f1;
}
.ez-support__empty-title { margin: 0 0 4px; font-weight: 700; color: var(--ink-900, #0f172a); }
.ez-support__empty-text { margin: 0; font-size: 13px; color: var(--ink-500, #64748b); }

.ez-support__newbtn {
    display: inline-flex; align-items: center; gap: 6px; margin-top: 14px;
    border: 1px solid var(--ink-200, #e2e8f0); background: transparent;
    color: var(--ink-700, #334155); font-weight: 600; font-size: 13px;
    padding: 9px 15px; border-radius: 10px; cursor: pointer;
}
.ez-support__newbtn:hover { border-color: #6366f1; color: #4338ca; }

.ez-support__conv-meta { font-size: 12px; color: var(--ink-500, #64748b); margin-bottom: 10px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ez-support__closed-note {
    margin: 12px 0 0; padding: 10px 12px; border-radius: 10px;
    background: var(--ink-100, #f1f5f9); color: var(--ink-700, #334155);
    font-size: 12.5px; display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
}
.ez-support__link-btn { border: none; background: none; cursor: pointer; color: #4338ca; font-weight: 700; font-size: 12.5px; padding: 0; }
.ez-support__loading { text-align: center; padding: 24px 6px; font-size: 13px; color: var(--ink-500, #64748b); }

/* dark mode */
html[data-theme="dark"] .ez-support__session { border-color: var(--ez-border, #2a3350); }
html[data-theme="dark"] .ez-support__newbtn { border-color: var(--ez-border, #2a3350); }
html[data-theme="dark"] .ez-support__newbtn:hover,
html[data-theme="dark"] .ez-support__link-btn { color: #c7d2fe; }
html[data-theme="dark"] .ez-support__active-banner { color: var(--ink-800, #e2e8f0); }
html[data-theme="dark"] .ez-support__closed-note { background: var(--ink-100, #1f2740); }
