/* Hide legacy RC injected widget if ever loaded */
.rocketchat-widget[data-state="closed"] {
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    width: 0 !important;
    height: 0 !important;
    max-width: 0 !important;
    max-height: 0 !important;
    overflow: hidden !important;
    border: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

.rocketchat-widget {
    display: none !important;
}

/* ── Integrated support dock (BitHost theme) ── */
#sg-support-root {
    --sg-ease: cubic-bezier(.22, .61, .36, 1);
    --bh-paper: #f4f2ec;
    --bh-paper2: #e9e6dc;
    --bh-ink: #111110;
    --bh-ink2: #3a3936;
    --bh-muted: #77736a;
    --bh-line: #d6d2c6;
    --bh-red: #e1261c;
    --bh-red-d: #b81d14;
    --sg-dock-gap: 24px;
    --sg-ring: var(--bh-ink);
    --sg-ring-hi: rgba(225, 38, 28, 0.45);
    --sg-glass: var(--bh-paper);
    --brand: var(--bh-ink);
    --brand-hi: var(--bh-red);
    --brand-dim: rgba(225, 38, 28, 0.12);
    --brand-glow: rgba(225, 38, 28, 0.28);
    --text: var(--bh-ink);
    --text-dim: var(--bh-ink2);
    --text-faint: var(--bh-muted);
    --line-strong: var(--bh-line);
    --radius: 0;
    --radius-lg: 0;
    --radius-xl: 0;
    position: fixed;
    right: var(--sg-dock-gap);
    bottom: var(--sg-dock-gap);
    z-index: 1200;
    font-family: 'Archivo', system-ui, sans-serif;
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

#sg-support-root * {
    box-sizing: border-box;
}

.sg-support-shell {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: max-content;
    max-width: min(360px, calc(100vw - 32px));
    border-radius: 999px;
    overflow: hidden;
    border: 1px solid transparent;
    background: transparent;
    box-shadow: none;
    transition:
        border-radius 0.28s var(--sg-ease),
        border-color 0.28s var(--sg-ease),
        box-shadow 0.28s var(--sg-ease),
        background 0.28s var(--sg-ease);
}

.sg-support-shell.is-open {
    width: min(360px, calc(100vw - 32px));
    max-height: calc(100vh - (var(--sg-dock-gap) * 2));
    display: flex;
    flex-direction: column;
    border-radius: var(--radius-xl, 22px);
    border: 2px solid var(--bh-ink);
    background: var(--sg-glass);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: 8px 8px 0 var(--bh-ink);
}

.sg-support-menu,
.sg-support-panel {
    display: none;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transform: translateY(6px);
    transition:
        max-height 0.32s var(--sg-ease),
        opacity 0.24s var(--sg-ease),
        transform 0.28s var(--sg-ease);
}

.sg-support-menu.is-open,
.sg-support-panel.is-open {
    display: block;
    max-height: none;
    opacity: 1;
    transform: translateY(0);
}

.sg-support-shell.is-open > .sg-support-menu.is-open,
.sg-support-shell.is-open > .sg-support-panel.is-open,
.sg-support-shell.is-open > .sg-support-chat.is-open {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.sg-support-chat.is-open {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow: hidden;
    opacity: 1;
    transform: translateY(0);
}

.sg-support-menu-hd {
    padding: 16px 16px 8px;
}

.sg-support-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--brand-hi);
    margin: 0 0 4px;
}

.sg-support-eyebrow::before {
    content: "";
    width: 3px;
    height: 12px;
    border-radius: 999px;
    background: var(--bh-red);
}

.sg-support-menu-hd p:last-child {
    margin: 0;
    font-size: 12.5px;
    line-height: 1.4;
    color: var(--text-faint, #5f6b76);
}

.sg-support-menu-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 8px 12px 12px;
}

.sg-support-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 14px 10px 12px;
    border: 2px solid var(--bh-ink);
    border-radius: var(--radius-lg);
    background: #fffefa;
    color: inherit;
    font: inherit;
    text-align: center;
    cursor: pointer;
    transition:
        background 0.2s var(--sg-ease),
        border-color 0.2s var(--sg-ease),
        transform 0.2s var(--sg-ease);
}

.sg-support-option:hover {
    background: var(--brand-dim);
    border-color: var(--brand-glow);
    transform: translateY(-1px);
}

.sg-support-option-icon {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 0;
    background: var(--brand-dim);
    border: 2px solid var(--bh-ink);
    color: var(--bh-ink);
}

.sg-support-option-icon--bit .bh-bit-sm {
    width: 14px;
    height: 23px;
    display: block;
}

.sg-support-option-text strong {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 1px;
}

.sg-support-option-text span {
    display: block;
    font-size: 11px;
    color: var(--text-faint, #5f6b76);
}

.sg-support-panel-hd {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 14px 12px;
    border-bottom: 2px solid var(--bh-ink);
}

.sg-support-panel-hd h3 {
    flex: 1;
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -0.02em;
    text-align: center;
}

#sg-support-root .sg-support-logo.logo {
    display: inline-flex;
    align-items: center;
    gap: 0.32em;
    font-weight: 800;
    font-stretch: 112%;
    letter-spacing: -0.02em;
    font-size: 20px;
    line-height: 1;
    color: var(--bh-ink);
}

#sg-support-root .sg-support-logo.logo .tld {
    color: var(--bh-red);
}

#sg-support-root .sg-support-logo.logo svg {
    height: 0.95em;
    width: 0.57em;
    flex: none;
}

.sg-support-menu-hd .sg-support-logo {
    margin-bottom: 6px;
}

.sg-support-menu-tag {
    margin: 0;
    font-size: 12.5px;
    line-height: 1.4;
    color: var(--text-faint);
}

.sg-support-panel-brand {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-width: 0;
    text-align: center;
}

.sg-support-panel-brand .sg-support-logo {
    font-size: 17px;
}

.sg-support-panel-mode {
    font-family: 'IBM Plex Mono', ui-monospace, monospace;
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--bh-muted);
}


.sg-support-icon-btn {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--text-dim, #a0acb7);
    cursor: pointer;
    transition: background 0.15s var(--sg-ease), color 0.15s var(--sg-ease);
}

.sg-support-icon-btn:hover {
    background: var(--bh-paper2);
    color: var(--text);
}

.sg-support-form {
    padding: 14px 14px 16px;
    display: grid;
    gap: 12px;
}

#sg-support-panel.is-open .sg-support-form {
    max-height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.sg-support-form label {
    display: grid;
    gap: 6px;
    font-size: 11.5px;
    font-weight: 500;
    color: var(--text-dim, #a0acb7);
}

.sg-support-form input,
.sg-support-form textarea {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--bh-ink);
    border-radius: var(--radius);
    background: #fffefa;
    color: var(--text);
    font: inherit;
    font-size: 14px;
    transition: border-color 0.15s var(--sg-ease), box-shadow 0.15s var(--sg-ease);
}

.sg-support-form input:focus,
.sg-support-form textarea:focus {
    outline: none;
    border-color: var(--brand-hi);
    box-shadow: 0 0 0 3px var(--brand-dim);
}

.sg-support-form textarea {
    min-height: 88px;
    resize: vertical;
}

.sg-support-form .sg-support-submit {
    padding: 11px 16px;
    border: 2px solid var(--bh-ink);
    border-radius: var(--radius);
    background: var(--bh-ink);
    color: var(--bh-paper);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 24px rgba(17, 17, 16, 0.18);
    transition: background 0.2s var(--sg-ease), transform 0.2s var(--sg-ease), box-shadow 0.2s var(--sg-ease);
}

.sg-support-form .sg-support-submit:hover:not(:disabled) {
    background: var(--bh-red);
    border-color: var(--bh-red);
    transform: translateY(-1px);
    box-shadow: 4px 4px 0 var(--bh-ink);
}

.sg-support-form .sg-support-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.sg-support-status {
    margin: 0;
    font-size: 12.5px;
    min-height: 16px;
}

.sg-support-status.is-ok { color: var(--ok, #34d399); }
.sg-support-status.is-err { color: var(--err, #ef4444); }

.sg-support-optional {
    font-weight: 400;
    color: var(--text-faint, #5f6b76);
}

/* ── Live chat panel ── */
.sg-support-chat {
    min-height: 0;
}

.sg-support-chat.is-open .sg-support-panel-hd {
    flex-shrink: 0;
}

.sg-support-chat-start {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 0 14px 16px;
    -webkit-overflow-scrolling: touch;
}

.sg-support-chat-welcome {
    margin: 0 0 10px;
    font-size: 12.5px;
    line-height: 1.45;
    color: var(--text-dim, #a0acb7);
}

.sg-support-chat-start-form {
    padding: 0;
}

.sg-support-chat-start-form textarea {
    min-height: 64px;
}

.sg-support-chat-active {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
}

.sg-support-chat-messages {
    flex: 1;
    min-height: 180px;
    max-height: 280px;
    overflow-y: auto;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scroll-behavior: smooth;
}

.sg-support-chat-bubble-row {
    display: flex;
}

.sg-support-chat-bubble-row.is-visitor {
    justify-content: flex-end;
}

.sg-support-chat-bubble-row.is-agent {
    justify-content: flex-start;
}

.sg-support-chat-bubble {
    max-width: 88%;
    padding: 8px 11px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.4;
}

.sg-support-chat-bubble-row.is-visitor .sg-support-chat-bubble {
    background: var(--bh-ink);
    color: var(--bh-paper);
    border: 2px solid var(--bh-ink);
}

.sg-support-chat-bubble-row.is-agent .sg-support-chat-bubble {
    background: #fffefa;
    border: 2px solid var(--bh-line);
}

.sg-support-chat-sender {
    display: block;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--brand-hi);
    margin-bottom: 3px;
}

.sg-support-chat-text {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
}

.sg-support-chat-compose {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px 14px;
    border-top: 2px solid var(--bh-ink);
}

.sg-support-chat-compose textarea {
    flex: 1;
    min-height: 40px;
    max-height: 96px;
    padding: 9px 11px;
    border: 2px solid var(--bh-ink);
    border-radius: var(--radius);
    background: #fffefa;
    color: var(--text);
    font: inherit;
    font-size: 13px;
    resize: none;
    transition: border-color 0.15s var(--sg-ease), box-shadow 0.15s var(--sg-ease);
}

.sg-support-chat-compose textarea:focus {
    outline: none;
    border-color: var(--brand-hi);
    box-shadow: 0 0 0 3px var(--brand-dim);
}

.sg-support-chat-send {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border: 2px solid var(--bh-ink);
    border-radius: 0;
    background: var(--bh-ink);
    color: var(--bh-paper);
    cursor: pointer;
    box-shadow: 0 4px 24px rgba(17, 17, 16, 0.18);
    transition: opacity 0.15s var(--sg-ease);
}

.sg-support-chat-send:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* Launcher = dock footer; attached to content above when open */
.sg-support-launcher {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    flex-shrink: 0;
    padding: 0 18px 0 14px;
    height: 52px;
    border: 2px solid var(--bh-ink);
    border-radius: 0;
    background: var(--bh-ink);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    color: var(--bh-paper);
    box-shadow: 6px 6px 0 var(--bh-red);
    cursor: pointer;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -0.01em;
    transition:
        border-color 0.2s var(--sg-ease),
        border-radius 0.28s var(--sg-ease),
        box-shadow 0.2s var(--sg-ease),
        background 0.2s var(--sg-ease);
}

.sg-support-shell:not(.is-open) .sg-support-launcher:hover {
    background: var(--bh-red);
    border-color: var(--bh-red);
    transform: translateY(-2px);
    box-shadow: 6px 6px 0 var(--bh-ink);
}

.sg-support-shell.is-open .sg-support-launcher {
    border: none;
    border-top: 2px solid var(--bh-ink);
    border-radius: 0;
    box-shadow: none;
    background: var(--bh-paper2);
    color: var(--bh-ink);
    backdrop-filter: none;
}

.sg-support-launcher-icon {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--brand-dim);
    border: 1px solid var(--brand-glow);
    color: var(--brand-hi);
    flex-shrink: 0;
}

.sg-support-launcher-label {
    flex: 1;
    text-align: left;
}

.sg-support-live-dot {
    position: relative;
    width: 7px;
    height: 7px;
    flex-shrink: 0;
}

.sg-support-live-dot::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: var(--brand-hi);
    box-shadow: 0 0 0 0 rgba(225, 38, 28, 0.55);
    animation: sg-support-ping 2s ease-out infinite;
}

.sg-support-launcher-chevron {
    display: grid;
    place-items: center;
    color: var(--text-faint, #5f6b76);
    opacity: 0;
    transform: rotate(0deg);
    transition: opacity 0.2s var(--sg-ease), transform 0.28s var(--sg-ease);
}

.sg-support-shell.is-open .sg-support-launcher-chevron {
    opacity: 1;
    transform: rotate(180deg);
}

.sg-support-shell.is-open .sg-support-live-dot {
    display: none;
}

@keyframes sg-support-ping {
    0% { box-shadow: 0 0 0 0 rgba(225, 38, 28, 0.5); }
    70% { box-shadow: 0 0 0 6px rgba(225, 38, 28, 0); }
    100% { box-shadow: 0 0 0 0 rgba(225, 38, 28, 0); }
}

/* In the chat app the composer owns the bottom edge. Below ~1600px the
   920px composer column reaches into the dock's corner, so lift the dock
   above the composer line — otherwise the launcher can cover Send. */
@media (max-width: 1600px) {
    body.app #sg-support-root {
        bottom: calc(var(--sg-dock-gap) + 104px + env(safe-area-inset-bottom));
    }
}

@media (max-width: 980px) {
    /* Mobile composer is taller (16px textarea + safe-area). Lift the dock so
       the launcher does not sit on top of Send in /chat. */
    body.app #sg-support-root {
        bottom: calc(var(--sg-dock-gap) + 148px + env(safe-area-inset-bottom));
    }
}

@media (max-width: 480px) {
    #sg-support-root {
        --sg-dock-gap: 14px;
    }

    .sg-support-shell.is-open {
        width: calc(100vw - 28px);
    }

    .sg-support-shell:not(.is-open) .sg-support-launcher-label {
        display: none;
    }

    .sg-support-shell:not(.is-open) .sg-support-launcher {
        width: 52px;
        padding: 0;
        justify-content: center;
    }

    /* Both must be display:none, not just hidden. The chevron is only
       opacity:0 while collapsed, so it kept claiming 16px plus the flex gap
       inside the 52px circle — 58px of content in a 52px box, which
       justify-content:center resolved by pushing the icon 3px past the left
       edge of the button. */
    .sg-support-shell:not(.is-open) .sg-support-live-dot,
    .sg-support-shell:not(.is-open) .sg-support-launcher-chevron {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    #sg-support-root,
    .sg-support-shell,
    .sg-support-menu,
    .sg-support-panel,
    .sg-support-launcher,
    .sg-support-option,
    .sg-support-launcher-chevron {
        transition: none;
    }

    .sg-support-live-dot::before {
        animation: none;
    }

}

/* Profile avatar on launcher — photo only until the dock is open */
.sg-support-shell:not(.is-open) .sg-support-launcher-label,
.sg-support-shell:not(.is-open) .sg-support-live-dot,
.sg-support-shell:not(.is-open) .sg-support-launcher-chevron {
    display: none;
}

.sg-support-launcher--avatar {
    padding: 6px;
    gap: 0;
    min-height: 52px;
    height: 52px;
    width: 52px;
    justify-content: center;
    border-radius: 50%;
}

.sg-support-launcher-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid var(--bh-paper);
    box-shadow: 0 2px 8px rgba(17, 17, 16, 0.2);
}

.sg-support-launcher-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.sg-support-shell.is-open .sg-support-launcher--avatar {
    width: 100%;
    border-radius: 0;
    padding: 0 18px 0 14px;
    justify-content: flex-start;
    gap: 10px;
}

.sg-support-shell.is-open .sg-support-launcher-avatar {
    display: none;
}

.sg-support-shell.is-open .sg-support-launcher-label {
    display: block;
    flex: 1;
    text-align: left;
}

body.sh-nav-open #sg-support-root {
    visibility: hidden;
    pointer-events: none;
}
