/* 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 (single unit, expands upward) ── */
#sg-support-root {
    --sg-ease: cubic-bezier(.22, .61, .36, 1);
    --sg-ring: rgba(255, 255, 255, 0.08);
    --sg-ring-hi: rgba(45, 165, 104, 0.35);
    --sg-glass: rgba(13, 20, 26, 0.94);
    --sg-dock-gap: 20px;
    position: fixed;
    right: var(--sg-dock-gap);
    bottom: var(--sg-dock-gap);
    z-index: 99990;
    font-family: var(--sans, Inter, system-ui, sans-serif);
    color: var(--text, #eef2f6);
    -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-color: var(--sg-ring);
    background:
        radial-gradient(120% 80% at 100% 0%, rgba(45, 165, 104, 0.08), transparent 55%),
        var(--sg-glass);
    backdrop-filter: blur(16px) saturate(1.2);
    -webkit-backdrop-filter: blur(16px) saturate(1.2);
    box-shadow:
        var(--shadow-3, 0 30px 80px rgba(0, 0, 0, 0.55)),
        0 0 0 1px rgba(255, 255, 255, 0.03) inset;
}

.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, #2da568);
    margin: 0 0 4px;
}

.sg-support-eyebrow::before {
    content: "";
    width: 18px;
    height: 1px;
    background: var(--brand-hi, #2da568);
}

.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: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-lg, 16px);
    background: rgba(255, 255, 255, 0.03);
    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: rgba(45, 165, 104, 0.08);
    border-color: var(--brand-glow, rgba(45, 165, 104, 0.18));
    transform: translateY(-1px);
}

.sg-support-option-icon {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--brand-dim, rgba(45, 165, 104, 0.1));
    border: 1px solid var(--brand-glow, rgba(45, 165, 104, 0.18));
    color: var(--brand-hi, #2da568);
}

.sg-support-option-text strong {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text, #eef2f6);
    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: 1px solid rgba(255, 255, 255, 0.06);
}

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

.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: rgba(255, 255, 255, 0.06);
    color: var(--text, #eef2f6);
}

.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: 1px solid var(--line-strong, #2a333c);
    border-radius: var(--radius, 10px);
    background: rgba(10, 13, 16, 0.55);
    color: var(--text, #eef2f6);
    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, #2da568);
    box-shadow: 0 0 0 3px var(--brand-dim, rgba(45, 165, 104, 0.1));
}

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

.sg-support-form .sg-support-submit {
    padding: 11px 16px;
    border: none;
    border-radius: var(--radius, 10px);
    background: var(--brand, #1a7f4c);
    color: #fff;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1) inset, 0 4px 14px rgba(26, 127, 76, 0.35);
}

.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(--brand, #1a7f4c);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.sg-support-chat-bubble-row.is-agent .sg-support-chat-bubble {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-bottom-left-radius: 4px;
}

.sg-support-chat-sender {
    display: block;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--brand-hi, #2da568);
    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: 1px solid rgba(255, 255, 255, 0.06);
}

.sg-support-chat-compose textarea {
    flex: 1;
    min-height: 40px;
    max-height: 96px;
    padding: 9px 11px;
    border: 1px solid var(--line-strong, #2a333c);
    border-radius: var(--radius, 10px);
    background: rgba(10, 13, 16, 0.55);
    color: var(--text, #eef2f6);
    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, #2da568);
    box-shadow: 0 0 0 3px var(--brand-dim, rgba(45, 165, 104, 0.1));
}

.sg-support-chat-send {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border: none;
    border-radius: 10px;
    background: var(--brand, #1a7f4c);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(26, 127, 76, 0.35);
    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: 1px solid var(--sg-ring);
    border-radius: 999px;
    background:
        radial-gradient(120% 100% at 0% 0%, rgba(45, 165, 104, 0.12), transparent 50%),
        var(--sg-glass);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    color: var(--text, #eef2f6);
    box-shadow: var(--shadow-2, 0 12px 32px rgba(0, 0, 0, 0.45));
    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 {
    border-color: var(--sg-ring-hi);
    box-shadow:
        var(--shadow-2, 0 12px 32px rgba(0, 0, 0, 0.45)),
        0 0 28px -8px rgba(45, 165, 104, 0.4);
}

.sg-support-shell.is-open .sg-support-launcher {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0;
    box-shadow: none;
    background: rgba(0, 0, 0, 0.15);
    backdrop-filter: none;
}

.sg-support-launcher-icon {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--brand-dim, rgba(45, 165, 104, 0.1));
    border: 1px solid var(--brand-glow, rgba(45, 165, 104, 0.18));
    color: var(--brand-hi, #2da568);
    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, #2da568);
    box-shadow: 0 0 0 0 rgba(45, 165, 104, 0.5);
    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(45, 165, 104, 0.45); }
    70% { box-shadow: 0 0 0 6px rgba(45, 165, 104, 0); }
    100% { box-shadow: 0 0 0 0 rgba(45, 165, 104, 0); }
}

@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;
    }

    .sg-support-shell:not(.is-open) .sg-support-live-dot {
        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;
    }
}
