/* HomeLink chat bubble — floating widget for resources.homelinkrouters.us
   Brand tokens align with the rest of the resources site (navy #0f2557,
   accent #1a6bff). Scoped under .hl-chat to avoid collisions with
   any host page styles. */

.hl-chat *, .hl-chat *::before, .hl-chat *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Closed bubble — pill in bottom-right corner.
   Defensive overrides (!important + explicit resets) so a host theme's button
   styles can't squish or hide it. Hard-coded to win against Shopify Horizon and
   similar themes that style all <button> elements globally. */
.hl-chat-bubble {
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    top: auto !important;
    left: auto !important;
    z-index: 2147483000 !important;
    background: #0f2557 !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: 999px !important;
    padding: 12px 18px 12px 16px !important;
    margin: 0 !important;
    width: auto !important;
    height: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    min-height: 0 !important;
    max-height: none !important;
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    line-height: 1.2 !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    white-space: nowrap !important;
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 8px !important;
    box-shadow: 0 4px 16px rgba(15, 37, 87, 0.25) !important;
    transition: transform 0.15s, box-shadow 0.15s !important;
    pointer-events: auto !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: none;
    text-decoration: none !important;
    box-sizing: border-box !important;
}
.hl-chat-bubble > * {
    pointer-events: none;
}
.hl-chat-bubble:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(15, 37, 87, 0.3);
}
.hl-chat-bubble-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* Open panel — hardened !important so a host theme can't override position. */
.hl-chat-panel {
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    top: auto !important;
    left: auto !important;
    z-index: 2147483000 !important;
    width: 380px !important;
    max-width: calc(100vw - 24px) !important;
    height: 560px !important;
    max-height: calc(100vh - 40px) !important;
    margin: 0 !important;
    background: #ffffff !important;
    border-radius: 16px !important;
    box-shadow: 0 12px 40px rgba(15, 37, 87, 0.25) !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
    color: #1a1a18 !important;
    pointer-events: auto !important;
    opacity: 1 !important;
    visibility: visible !important;
    box-sizing: border-box !important;
    transform: none !important;
}

/* Hidden classes MUST come after .hl-chat-bubble and .hl-chat-panel rules so
   that with equal specificity + !important, source-order makes them win. */
.hl-chat-bubble.hl-chat-bubble-hidden,
.hl-chat-bubble-hidden {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}
.hl-chat-panel.hl-chat-panel-hidden,
.hl-chat-panel-hidden {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Header */
.hl-chat-header {
    background: #0f2557;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #ffffff;
    flex-shrink: 0;
}
.hl-chat-header-title {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.2px;
}
.hl-chat-header-sub {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.55);
    margin-top: 2px;
}
.hl-chat-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}
.hl-chat-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

/* Message list */
.hl-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    /* Prevent scroll from leaking to the page behind the panel on desktop */
    overscroll-behavior: contain;
    flex-direction: column;
    gap: 10px;
    background: #f7f7f5;
}

.hl-chat-msg {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
}
.hl-chat-msg-user {
    background: #1a6bff;
    color: #ffffff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}
.hl-chat-msg-assistant {
    background: #ffffff;
    color: #1a1a18;
    border: 1px solid #e5e5e0;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

/* Typing indicator (three dots) */
.hl-chat-typing {
    align-self: flex-start;
    background: #ffffff;
    border: 1px solid #e5e5e0;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    padding: 12px 14px;
    display: flex;
    gap: 4px;
}
.hl-chat-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #6b6b66;
    animation: hl-chat-bounce 1.2s infinite;
}
.hl-chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.hl-chat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes hl-chat-bounce {
    0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
    30%           { opacity: 1;   transform: translateY(-3px); }
}

/* Consent card — appears inline when agent proposes a capture */
.hl-chat-consent {
    align-self: stretch;
    background: #ffffff;
    border: 1.5px solid #1a6bff;
    border-radius: 14px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.hl-chat-consent-title {
    font-size: 13px;
    font-weight: 600;
    color: #0f2557;
}
.hl-chat-consent-input {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid #e5e5e0;
    border-radius: 8px;
    font-family: inherit;
    font-size: 13px;
    color: #1a1a18;
    background: #f7f7f5;
    outline: none;
    transition: border-color 0.15s;
}
.hl-chat-consent-input:focus { border-color: #1a6bff; }
.hl-chat-consent-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    cursor: pointer;
}
.hl-chat-consent-row input {
    margin-top: 2px;
    flex-shrink: 0;
    accent-color: #1a6bff;
}
.hl-chat-consent-row span {
    font-size: 11.5px;
    color: #6b6b66;
    line-height: 1.55;
}
.hl-chat-consent-actions {
    display: flex;
    gap: 8px;
    margin-top: 2px;
}
.hl-chat-consent-btn {
    flex: 1;
    padding: 9px 14px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: background 0.15s;
}
.hl-chat-consent-btn-primary {
    background: #0f2557;
    color: #ffffff;
}
.hl-chat-consent-btn-primary:hover { background: #1a6bff; }
.hl-chat-consent-btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.hl-chat-consent-btn-secondary {
    background: #f7f7f5;
    color: #6b6b66;
    border: 1px solid #e5e5e0;
}
.hl-chat-consent-btn-secondary:hover { background: #e5e5e0; }

.hl-chat-consent-success {
    font-size: 13px;
    color: #10b981;
    font-weight: 500;
    padding: 4px 0;
}

/* Input bar */
.hl-chat-input-bar {
    border-top: 1px solid #e5e5e0;
    padding: 10px 12px;
    display: flex;
    gap: 8px;
    background: #ffffff;
    flex-shrink: 0;
}
.hl-chat-input {
    flex: 1;
    border: 1.5px solid #e5e5e0;
    border-radius: 10px;
    padding: 10px 12px;
    font-family: inherit;
    font-size: 13.5px;
    color: #1a1a18;
    background: #f7f7f5;
    outline: none;
    resize: none;
    max-height: 100px;
    line-height: 1.4;
    transition: border-color 0.15s;
}
.hl-chat-input:focus { border-color: #1a6bff; }
.hl-chat-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.hl-chat-send {
    background: #0f2557;
    color: #ffffff;
    border: none;
    border-radius: 10px;
    width: 38px;
    height: 38px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    align-self: flex-end;
    transition: background 0.15s;
}
.hl-chat-send:hover:not(:disabled) { background: #1a6bff; }
.hl-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Mobile — full-screen panel below ~480px */
@media (max-width: 480px) {
    .hl-chat-panel {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
    .hl-chat-bubble {
        bottom: 16px;
        right: 16px;
    }
}
