/* Support Hub adds only its own surfaces; the host supplies Bootstrap/Metronic. */
.support-hub {
    --sh-bg: var(--bs-body-bg, #fff); --sh-fg: var(--bs-body-color, #252f4a);
    --sh-muted: var(--bs-secondary-color, #78829d); --sh-border: var(--bs-border-color, #e8eaf0);
    --sh-soft: var(--bs-tertiary-bg, #f5f8fa); --sh-primary: var(--bs-primary, #1b84ff);
    color: var(--sh-fg); font-family: inherit; font-size: 14px; line-height: 1.5;
}
.support-hub *, .support-hub *::before, .support-hub *::after { box-sizing: border-box; }
.support-hub [hidden] { display: none !important; }
.support-hub button, .support-hub input, .support-hub textarea, .support-hub select { font: inherit; }
.support-hub button { cursor: pointer; }
.support-hub button:disabled { cursor: default; opacity: .6; }
.support-hub summary:focus-visible, .support-hub button:focus-visible, .support-hub input:focus-visible, .support-hub textarea:focus-visible, .support-hub select:focus-visible { outline: 2px solid var(--sh-primary); outline-offset: 3px; }
.support-hub-sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.support-hub-widget { --sh-divider: var(--bs-gray-300, var(--sh-border)); position: fixed; right: 24px; bottom: 24px; z-index: 1050; width: min(390px, calc(100vw - 32px)); pointer-events: none; }
.support-hub-widget > * { pointer-events: auto; }
.support-hub .support-hub-launcher { position: relative; display: flex; align-items: center; justify-content: center; gap: 0; width: 48px; min-width: 48px; max-width: 100%; height: 48px; margin-left: auto; border-radius: 28px; padding: 0 12px !important; font-weight: 600; transition: width .25s ease; }
.support-hub-launcher-icon { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 22px; width: 22px; height: 24px; font-size: 22px; line-height: 1; }
.support-hub-launcher-label { display: block; min-width: 0; max-width: 0; margin-left: 0; overflow: hidden; white-space: nowrap; opacity: 0; transition: max-width .25s ease, margin-left .25s ease, opacity .2s ease; }
.support-hub .support-hub-launcher:focus-visible { width: 192px; }
.support-hub-launcher:focus-visible .support-hub-launcher-label { max-width: 160px; margin-left: 8px; opacity: 1; }
@media (hover: hover) {
    .support-hub .support-hub-launcher:hover { width: 192px; }
    .support-hub-launcher:hover .support-hub-launcher-label { max-width: 160px; margin-left: 8px; opacity: 1; }
}
.support-hub-launcher .support-hub-unread { position: absolute; top: -5px; right: -5px; padding: 3px 5px; border: 1px solid var(--sh-primary); line-height: 1.2; pointer-events: none; }
.support-hub-connection { display: flex; align-items: baseline; gap: 6px; color: var(--sh-muted); }
.support-hub-connection-icon { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 15px; width: 15px; height: 15px; align-self: flex-start; margin-top: 2px; border: 1.5px solid transparent; border-radius: 50%; font-size: 11px; font-weight: 700; line-height: 1; }
.support-hub-connection[data-state="connected"] .support-hub-connection-icon { color: var(--bs-success, #17c653); border-color: currentColor; }
.support-hub-connection[data-state="unavailable"] .support-hub-connection-icon { color: var(--bs-danger, #f8285a); border-color: currentColor; }
.support-hub-panel { display: flex; flex-direction: column; background: var(--sh-bg); border: 1px solid var(--sh-border); border-radius: 14px; margin-bottom: 14px; max-height: min(740px, calc(100dvh - 110px)); overflow: hidden; }
.support-hub-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px !important; min-height: auto !important; border-bottom: 1px solid var(--sh-border); }
.support-hub-heading h2 { display: block; }
.support-hub-toolbar { display: flex; align-items: center; gap: 8px; padding: 8px 14px; }
.support-hub-toolbar > label { flex: 1; min-width: 0; }
.support-hub-notice { padding: 10px 18px; margin: 0; background: var(--sh-soft); font-size: 12px; }
.support-hub-error { padding: 10px 18px; margin: 0; font-size: 13px; }
.support-hub-retry { margin: 8px 18px; align-self: flex-start; }
.support-hub-messages { overflow-y: auto; overscroll-behavior: contain; padding: 20px; flex: 1 1 auto; min-height: 120px; }
.support-hub-widget .support-hub-messages { min-height: 140px; }
.support-hub-empty { padding: 24px 6px; text-align: center; font-size: 13px; }
.support-hub-message { display: flex; flex-direction: column; align-items: flex-start; margin: 0 0 18px; }
.support-hub-message:last-child { margin-bottom: 0; }
.support-hub-message.is-agent { align-items: flex-end; }
.support-hub-message-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; margin-bottom: 5px; color: var(--sh-muted); font-size: 11px; }
.support-hub-message-author { color: var(--sh-fg); font-weight: 600; font-size: 12px; }
.support-hub-message-body { padding: 10px 14px; border-radius: 4px 12px 12px; background: var(--sh-soft); max-width: 92%; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; }
.support-hub-message.is-agent .support-hub-message-body { background: var(--bs-primary-bg-subtle, #e9f3ff); border-radius: 12px 4px 12px 12px; }
.support-hub-message.is-pending { opacity: .7; }
.support-hub-message-status { color: var(--sh-muted); font-size: 11px; padding-top: 3px; }
.support-hub-composer { padding: 16px 20px !important; flex: 0 0 auto; background: var(--sh-bg); }
.support-hub-contact { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; border: 0; padding: 0; margin: 0 0 8px; }
.support-hub-contact label { min-width: 0; font-size: 12px; }
.support-hub-message-label { display: block; margin-bottom: 8px; font-size: 12px; }
.support-hub-message-label textarea { width: 100%; resize: vertical; min-height: 64px; max-height: 160px; }
.support-hub-sendbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.support-hub-recaptcha-notice { margin: 8px 0 0; font-size: 11px; line-height: 1.4; }
/* Google renders the badge outside the widget; its replacement notice enables this rule. */
body:has(.support-hub-widget [data-sh="recaptcha-notice"]:not([hidden])) .grecaptcha-badge { visibility: hidden !important; }
.support-hub-send-status { margin: 5px 0 0; font-size: 11px; min-height: 1em; }
.support-hub-unread { border-radius: 20px; min-width: 20px; }
.support-hub-inbox { background: var(--sh-bg); border: 1px solid var(--sh-border); border-radius: 12px; overflow: hidden; }
.support-hub-widget .support-hub-heading { padding: 16px !important; flex-wrap: nowrap; border-bottom: 1px solid var(--sh-divider); }
.support-hub-widget .support-hub-heading > div { min-width: 0; }
.support-hub-widget [data-sh="widget-title"] { overflow-wrap: anywhere; }
.support-hub-widget .support-hub-heading [data-sh-action="hide"] { flex: 0 0 32px; width: 32px; height: 32px; padding: 0 !important; }
.support-hub-widget .support-hub-toolbar { padding: 12px 16px; border-bottom: 1px solid var(--sh-divider); }
.support-hub-widget .support-hub-toolbar > label { margin: 0; }
.support-hub-widget .support-hub-toolbar .form-select { min-height: 36px; font-size: 13px; }
.support-hub-widget .support-hub-toolbar .btn { flex: 0 0 auto; min-height: 36px; padding: 8px 12px !important; font-size: 13px; }
.support-hub-widget .support-hub-notice { padding: 0; margin: 4px 0 0; background: transparent; color: var(--sh-muted); }
.support-hub-widget .support-hub-notice[data-state="closed"] { color: var(--bs-warning-text-emphasis, var(--sh-fg)); font-weight: 500; }
.support-hub-widget .support-hub-error { padding: 10px 16px; }
.support-hub-widget .support-hub-messages { padding: 16px; }
.support-hub-widget [data-sh-action="history"], .support-hub-widget [data-sh-action="older-conversations"] { align-self: center; width: calc(100% - 32px); min-height: 32px; margin: 0 16px 12px; padding: 6px 12px !important; border-radius: 6px; font-size: 12px; }
.support-hub-widget [data-sh-action="older-conversations"] { margin-top: 10px; }
.support-hub-widget .support-hub-composer { padding: 14px 16px !important; border-top: 1px solid var(--sh-divider); }
.support-hub-widget .support-hub-sendbar { padding-top: 8px; border-top: 1px solid var(--sh-divider); }
.support-hub .support-hub-field-error { margin-top: 0; font-size: 12px; line-height: 1.4; color: var(--bs-form-invalid-color, var(--bs-danger, #f8285a)); }
.support-hub .form-control.is-invalid { border-color: var(--bs-form-invalid-border-color, var(--bs-danger, #f8285a)); }
.support-hub .form-control.is-invalid:focus-visible { outline-color: var(--bs-form-invalid-border-color, var(--bs-danger, #f8285a)); }
.support-hub-widget .support-hub-contact label { display: flex; flex-direction: column; gap: 4px; margin: 0; }
/* Leave room for the textarea focus outline (2px plus its 3px offset). */
.support-hub-widget .support-hub-message-label { display: flex; flex-direction: column; gap: 8px; }
.support-hub-widget .support-hub-sendbar .btn { min-height: 36px; padding: 8px 12px !important; }
.support-hub-widget .support-hub-retry { margin-left: 16px; margin-right: 16px; }
.support-hub-preferences { position: relative; flex: 0 0 auto; }
.support-hub-preferences > summary { display: flex; align-items: center; justify-content: center; width: 34px; height: 34px; padding: 0 !important; list-style: none; cursor: pointer; }
.support-hub-preferences > summary::-webkit-details-marker { display: none; }
.support-hub-preferences[open] > summary { color: var(--sh-primary); background: var(--sh-soft); }
.support-hub-preferences-panel { position: absolute; z-index: 10; top: calc(100% + 8px); right: 0; width: min(280px, calc(100vw - 64px)); max-height: calc(100dvh - 120px); overflow-y: auto; padding: 18px; border: 1px solid var(--sh-border); border-radius: 10px; background: var(--sh-bg); color: var(--sh-fg); text-align: left; }
.support-hub-preferences-panel .form-check { margin: 0; }
.support-hub-forwarding { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; margin: 16px 0 0; padding: 14px 0 0; border: 0; border-top: 1px solid var(--sh-border); min-width: 0; font-size: 12px; }
.support-hub-forwarding legend { float: none; width: auto; margin: 0 0 2px; padding: 0; font-size: 12px; }
.support-hub-alert-preference { display: flex; flex-direction: column; gap: 4px; }
.support-hub-alert-status { max-width: 230px; font-size: 11px; }
.support-hub-reply-tools { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; min-width: 0; }
.support-hub-reply-caption { flex: 0 0 auto; margin: 0 !important; font-size: 12px; }
.support-hub-canned-replies { flex: 0 1 260px; min-width: 0; margin: 0 0 0 auto; font-size: 12px; }
.support-hub-canned-replies select { width: 100%; min-width: 0; }
.support-hub .support-hub-canned-edit { display: flex; align-items: center; justify-content: center; flex: 0 0 32px; width: 32px; height: 32px; padding: 0 !important; }
.support-hub-inbox .support-hub-message-label { display: flex; flex-direction: column; gap: 8px; }
.support-hub-agent-tools { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.support-hub-availability-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.support-hub-availability-controls > .form-check { white-space: nowrap; }
.support-hub-workspace { display: grid; grid-template-columns: minmax(240px, 29%) 1fr; min-height: 570px; height: min(760px, calc(100dvh - 220px)); }
.support-hub-sidebar { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--sh-border); }
.support-hub-filter { display: flex; flex-direction: column; gap: 8px; padding: 16px; border-bottom: 1px solid var(--sh-border); }
.support-hub-filter label { margin: 0; }
.support-hub-conversations { overflow-y: auto; flex: 1; padding: 8px; }
.support-hub-conversation { display: block; width: 100%; border: 0; border-radius: 8px; background: transparent; color: inherit; text-align: left; padding: 10px 12px; margin-bottom: 4px; }
.support-hub-conversation:hover { background: var(--sh-soft); }
.support-hub-conversation[aria-current="true"] { background: var(--bs-primary-bg-subtle, #e9f3ff); }
.support-hub-conversation-line { display: flex; justify-content: space-between; gap: 8px; align-items: center; margin-bottom: 2px; }
.support-hub-conversation-line > strong { flex: 1 1 auto; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.support-hub-conversation-state { flex: 0 1 auto; max-width: 48%; color: var(--sh-muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.support-hub-conversation.is-read .support-hub-conversation-name { font-weight: 500; }
.support-hub-conversation.is-unread { box-shadow: inset 3px 0 var(--sh-primary); background: var(--bs-primary-bg-subtle, #e9f3ff); }
.support-hub-conversation.is-unread .support-hub-conversation-name { font-weight: 700; }
.support-hub-conversation.is-unread .support-hub-conversation-preview { color: var(--sh-fg); font-weight: 500; }
.support-hub-unread-count { min-width: 22px; border-radius: 12px; justify-content: center; }
.support-hub-conversation-line > .badge { flex: 0 0 auto; }
.support-hub-conversation-preview { color: var(--sh-muted); font-size: 12px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.support-hub-conversation-status { color: var(--sh-muted); font-size: 11px; margin-top: 4px; }
.support-hub-thread { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.support-hub-conversation-pane { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; min-width: 0; }
.support-hub-thread-heading { display: flex; justify-content: space-between; flex-wrap: wrap; align-items: center; gap: 12px; padding: 16px 20px; min-height: 88px; }
.support-hub-thread-tools { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; max-width: 100%; }
.support-hub-mark-unread { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.support-hub-assignment { font-size: 11px; max-width: 100%; }
.support-hub-assignment select { width: 280px; max-width: 100%; }
.support-hub-inbox .support-hub-messages { min-height: 220px; }
[data-bs-theme="dark"] .support-hub { --sh-soft: var(--bs-tertiary-bg, #1e2539); }
[data-bs-theme="dark"] .support-hub .support-hub-message.is-agent .support-hub-message-body,
[data-bs-theme="dark"] .support-hub .support-hub-conversation[aria-current="true"] { background: var(--bs-primary-bg-subtle, #17334f); }
@media (max-width: 720px) {
    .support-hub-widget { right: 16px; bottom: 16px; }
    .support-hub-widget .support-hub-panel .support-hub-heading { display: grid; grid-template-columns: minmax(0, 1fr) 36px; align-items: start; gap: 12px; padding: 16px !important; }
    .support-hub-widget .support-hub-heading > div { display: flex; flex-direction: column; gap: 4px; }
    .support-hub-widget .support-hub-heading .support-hub-notice { margin: 0; }
    .support-hub-widget .support-hub-panel [data-sh-action="hide"] { width: 36px; height: 36px; }
    .support-hub-widget .support-hub-toolbar { flex-wrap: wrap; align-items: stretch; gap: 10px; }
    .support-hub-widget .support-hub-toolbar > label { flex: 1 1 160px; }
    .support-hub-widget .support-hub-toolbar .form-select { height: 40px; }
    .support-hub-widget .support-hub-toolbar .btn { flex: 1 1 140px; min-height: 40px; font-size: 14px; }
    .support-hub-heading { padding: 14px !important; flex-wrap: wrap; }
    .support-hub-agent-tools { gap: 10px; }
    .support-hub-workspace { grid-template-columns: 1fr; height: auto; min-height: 0; }
    .support-hub-sidebar { border-right: 0; border-bottom: 1px solid var(--sh-border); max-height: 260px; }
    .support-hub-filter { padding: 12px; }
    .support-hub-thread { min-height: 480px; max-height: 740px; }
    .support-hub-thread-heading { padding: 12px; }
    .support-hub-composer { padding: 12px !important; }
    /* Keep the closed launcher in place; the open customer chat fills the viewport. */
    .support-hub-widget .support-hub-panel {
        position: fixed; inset: var(--sh-viewport-top, 0px) auto auto var(--sh-viewport-left, 0px); width: var(--sh-viewport-width, 100%); height: 100vh; height: var(--sh-viewport-height, 100dvh);
        max-height: none; margin: 0; border: 0; border-radius: 0; overscroll-behavior: none; touch-action: manipulation;
        padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
    }
    /* Readable controls avoid automatic input-focus zoom on mobile browsers. */
    .support-hub-widget .support-hub-panel .form-control, .support-hub-widget .support-hub-panel .form-select { font-size: 16px; }
    .support-hub-widget .support-hub-panel > * { flex-shrink: 0; }
    .support-hub-widget .support-hub-messages { min-height: 0; flex: 1 1 0; }
    .support-hub-widget .support-hub-composer { min-height: 0; flex-shrink: 1; overflow-y: auto; overscroll-behavior: contain; }
    .support-hub-widget .support-hub-panel:not([hidden]) + .support-hub-launcher { display: none; }
}
/* Inline errors need room on short screens; let chat history shrink and scroll. */
@media (max-height: 700px) {
    .support-hub-widget.has-validation-errors .support-hub-messages { min-height: 0; flex-basis: 0; }
    .support-hub-widget.has-validation-errors .support-hub-composer { flex-shrink: 1; min-height: 0; overflow-y: auto; }
}
@media (prefers-reduced-motion: reduce) {
    .support-hub * { scroll-behavior: auto !important; }
    .support-hub .support-hub-launcher, .support-hub-launcher-label { transition: none; }
}

/* The manager fills the conversation pane; only its fields scroll when needed. */
.support-hub-canned-manager { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; min-width: 0; background: var(--sh-bg); }
.support-hub-canned-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px; flex: 0 0 auto; }
.support-hub-canned-fields { display: flex; flex-direction: column; gap: 20px; padding: 20px; flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.support-hub-canned-details { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.support-hub-canned-manager .form-label { display: flex; flex-direction: column; gap: 8px; min-width: 0; margin: 0; }
.support-hub-canned-message { flex: 1 0 200px; }
.support-hub-canned-message textarea { flex: 1 1 auto; width: 100%; min-height: 170px; max-height: none; resize: vertical; }
.support-hub-canned-footer { padding: 16px 20px; flex: 0 0 auto; }
.support-hub-canned-manager .support-hub-sendbar { justify-content: flex-end; }
.support-hub-canned-manager [data-sh-action="canned-delete"] { margin-right: auto; }
.support-hub-canned-manager [data-sh="canned-status"]:not(:empty) { margin-top: 8px; }
@media (max-width: 720px) {
    .support-hub-canned-heading, .support-hub-canned-fields, .support-hub-canned-footer { padding: 16px; }
    .support-hub-canned-details { grid-template-columns: minmax(0, 1fr); }
}
