/* =========================================================
   PRIME DATA GH - support chat widget
   Loaded AFTER style.css / extras.css. Only adds new classes;
   does not override any existing rule. Uses the same colour
   tokens as the rest of the site (--bg, --surface, --border,
   --text, --muted, --blue, --teal ...).

   z-index reference (see extras.css for the rest of the stack):
     bottom-nav 20, this launcher 22, consent 30, toast 40,
     this backdrop/sheet 55/65 (same tier as the payment sheet).
========================================================= */

body.cx-support-open {
    overflow: hidden;
}

/* ---------- Floating launcher ---------- */

.cx-support-launcher {
    position: fixed;
    right: 16px;
    bottom: calc(96px + env(safe-area-inset-bottom));
    z-index: 22;
    width: 54px;
    height: 54px;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--blue), var(--teal));
    color: #ffffff;
    box-shadow: 0 14px 28px -10px rgba(18, 99, 184, 0.55);
    transition: transform 0.15s ease, opacity 0.15s ease;
}

.cx-support-launcher:active {
    transform: scale(0.94);
}

.cx-support-launcher:focus-visible {
    outline: 2px solid var(--teal);
    outline-offset: 2px;
}

.cx-support-launcher svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

/* On pages without a bottom nav (none of the widget's pages currently lack one,
   but this keeps the button clear of the safe area if that ever changes). */
.login-page ~ .cx-support-launcher,
.signup-page ~ .cx-support-launcher {
    bottom: calc(20px + env(safe-area-inset-bottom));
}

/* ---------- Backdrop + sheet ---------- */

.cx-support-backdrop {
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(3, 6, 12, 0.72);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.cx-support-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

.cx-support-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 65;
    display: flex;
    flex-direction: column;
    max-width: 480px;
    height: min(640px, 84vh);
    height: min(640px, 84dvh);
    margin: 0 auto;
    padding: 10px 16px calc(14px + env(safe-area-inset-bottom));
    background: var(--surface);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -20px 40px -20px rgba(0, 0, 0, 0.6);
    transform: translateY(100%);
    transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.cx-support-sheet.open {
    transform: translateY(0);
}

.cx-support-handle {
    width: 40px;
    height: 4px;
    margin: 0 auto 10px;
    border-radius: 999px;
    background: var(--border);
    flex-shrink: 0;
}

.cx-support-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.cx-support-header h2 {
    font-family: "Space Grotesk", -apple-system, BlinkMacSystemFont, Arial, sans-serif;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.2px;
}

.cx-support-close {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--bg);
    color: var(--muted);
}

.cx-support-close svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
}

/* ---------- Message list ---------- */

.cx-support-list {
    flex: 1;
    overflow-y: auto;
    padding: 14px 2px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cx-support-status {
    padding: 10px 2px;
    color: var(--muted);
    font-size: 13.5px;
    line-height: 1.5;
    text-align: center;
}

.cx-msg {
    max-width: 82%;
    padding: 10px 13px;
    border-radius: var(--radius-md);
    font-size: 14.5px;
    line-height: 1.45;
}

.cx-msg p {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.cx-msg-time {
    display: block;
    margin-top: 4px;
    font-size: 11px;
    opacity: 0.65;
}

.cx-msg-customer {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--blue), var(--teal));
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.cx-msg-admin {
    align-self: flex-start;
    background: var(--surface-focus);
    border: 1px solid var(--border);
    color: var(--text);
    border-bottom-left-radius: 4px;
}

/* ---------- Composer ---------- */

.cx-support-form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.cx-support-input {
    flex: 1;
    max-height: 96px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg);
    color: var(--text);
    font: inherit;
    font-size: 14.5px;
    line-height: 1.4;
    resize: none;
}

.cx-support-input:focus-visible {
    outline: none;
    border-color: var(--border-focus);
}

.cx-support-send {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--blue), var(--teal));
    color: #ffffff;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.cx-support-send:active {
    transform: scale(0.94);
}

.cx-support-send:disabled {
    opacity: 0.6;
}

.cx-support-send svg {
    width: 19px;
    height: 19px;
    fill: currentColor;
}

@media print {
    .cx-support-launcher,
    .cx-support-backdrop,
    .cx-support-sheet {
        display: none !important;
    }
}
