/* =========================================================
   HASHSTACK CHATBOT WIDGET - styles
   Works with your existing chat JS (no JS changes needed).
   Selectors use IDs on purpose, so your site's global CSS
   (header, section, input, button rules) cannot break it.
   ========================================================= */

#hs-chat-launcher,
#hs-chat-panel {
    --hsc-blue: #0489F9;
    --hsc-green: #0FDA90;
    --hsc-navy: #051532;
    --hsc-line: #e3eaf4;
    --hsc-soft: #f4f8fd;
    font-family: 'Poppins', sans-serif;
    box-sizing: border-box;
}
#hs-chat-panel *, #hs-chat-panel *::before, #hs-chat-panel *::after { box-sizing: border-box; }


/* =========================================================
   LAUNCHER  ("Chat with us" button)
   - starts as a round icon, the label slides out every few
     seconds, a green pulse ring runs around it
   ========================================================= */
#hs-chat-launcher {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 990;                         /* below header (1000) and loader */
    display: inline-flex;
    align-items: center;
    gap: 12px;
    max-width: 64px;
    height: 64px;
    margin: 0;
    padding: 0 26px 0 8px;
    border: 0;
    border-radius: 50px;
    background: var(--hsc-navy);
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    line-height: 1;
    letter-spacing: .2px;
    white-space: nowrap;
    overflow: hidden;
    cursor: pointer;
    box-shadow: 0 14px 34px rgba(5, 21, 50, .35);
    animation: hsc-label 14s ease-in-out infinite, hsc-pulse 2.6s ease-out infinite;
    transition: background .25s ease, transform .25s ease;
}
#hs-chat-launcher::before {               /* round green icon */
    content: "\f4ad";                     /* Font Awesome: comment-dots */
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    flex: 0 0 48px;
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--hsc-green);
    color: var(--hsc-navy);
    font-size: 21px;
}
/* hover, keyboard focus, or chat open: label stays visible, pulse stops */
#hs-chat-launcher:hover,
#hs-chat-launcher:focus-visible,
#hs-chat-launcher:has(+ #hs-chat-panel.hs-open) {
    animation: none;
    max-width: 260px;
    background: #0a2150;
}
#hs-chat-launcher:hover { transform: translateY(-3px); }

@keyframes hsc-label {
    0%, 10%   { max-width: 64px; }
    16%, 58%  { max-width: 250px; }
    66%, 100% { max-width: 64px; }
}
@keyframes hsc-pulse {
    0%        { box-shadow: 0 14px 34px rgba(5, 21, 50, .35), 0 0 0 0 rgba(15, 218, 144, .6); }
    70%, 100% { box-shadow: 0 14px 34px rgba(5, 21, 50, .35), 0 0 0 20px rgba(15, 218, 144, 0); }
}


/* =========================================================
   PANEL
   ========================================================= */
#hs-chat-panel {
    position: fixed;
    right: 24px;
    bottom: 104px;
    z-index: 990;
    display: flex;
    flex-direction: column;
    width: 390px;
    max-width: calc(100vw - 32px);
    height: min(640px, calc(100vh - 210px));
    height: min(640px, calc(100dvh - 210px));
    min-height: 380px;
    margin: 0;
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--hsc-line);
    border-radius: 24px;
    background: #fff;
    color: var(--hsc-navy);
    font-size: 14px;
    box-shadow: 0 30px 80px rgba(5, 21, 50, .28);

    /* closed state */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(24px) scale(.94);
    transform-origin: bottom right;
    transition: opacity .3s ease, transform .35s cubic-bezier(.2, .9, .3, 1.15), visibility .3s;
}
#hs-chat-panel.hs-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: none;
}


/* ---------- header ---------- */
#hs-chat-panel .hs-chat-head {
    /* protect against site scripts/CSS that add "fixed/sticky" styles to every <header> on scroll */
    position: static !important;
    top: auto !important; left: auto !important; right: auto !important; bottom: auto !important;
    width: auto !important;
    height: auto !important;
    margin: 0 !important;
    transform: none !important;
    animation: none !important;
    z-index: auto !important;
    float: none !important;

    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px !important;
    border: 0;
    background: var(--hsc-navy) !important;
    color: #fff;
    box-shadow: inset 0 -3px 0 var(--hsc-green) !important;
}
#hs-chat-panel .hs-chat-head > div {
    display: grid;
    grid-template-columns: 46px 1fr;
    column-gap: 12px;
    align-items: center;
}
#hs-chat-panel .hs-chat-head > div::before {      /* assistant avatar */
    content: "\f544";                             /* Font Awesome: robot */
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    grid-row: 1 / span 2;
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--hsc-green);
    color: var(--hsc-navy);
    font-size: 20px;
}
#hs-chat-panel .hs-chat-head strong {
    grid-column: 2;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
    color: #fff;
}
#hs-chat-panel .hs-chat-head small {
    grid-column: 2;
    display: block;
    font-size: 12px;
    line-height: 1.4;
    color: #9fb0cc;
}
#hs-chat-close {
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
    margin: 0;
    padding: 0;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .1);
    color: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    transition: background .25s ease, transform .3s ease;
}
#hs-chat-close:hover { background: rgba(255, 255, 255, .22); transform: rotate(90deg); }


/* ---------- messages ---------- */
#hs-chat-log {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px;
    overflow-y: auto;
    background: var(--hsc-soft);
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: #c4d3e8 transparent;
}
#hs-chat-log::-webkit-scrollbar { width: 6px; }
#hs-chat-log::-webkit-scrollbar-thumb { background: #c4d3e8; border-radius: 6px; }

#hs-chat-panel .hs-bubble {
    max-width: 86%;
    padding: 12px 16px;
    font-size: 14.5px;
    line-height: 1.6;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    animation: hsc-pop .3s ease;
}
#hs-chat-panel .hs-bubble.bot {
    align-self: flex-start;
    border: 1px solid var(--hsc-line);
    border-radius: 18px 18px 18px 4px;
    background: #fff;
    color: var(--hsc-navy);
}
#hs-chat-panel .hs-bubble.user {
    align-self: flex-end;
    border-radius: 18px 18px 4px 18px;
    background: var(--hsc-blue);
    color: #fff;
}
@keyframes hsc-pop {
    from { opacity: 0; transform: translateY(10px) scale(.97); }
    to   { opacity: 1; transform: none; }
}

/* markdown inside bot replies (marked + DOMPurify output) */
#hs-chat-panel .hs-bubble.bot > :first-child { margin-top: 0; }
#hs-chat-panel .hs-bubble.bot > :last-child  { margin-bottom: 0; }
#hs-chat-panel .hs-bubble.bot p { margin: 0 0 8px; }
#hs-chat-panel .hs-bubble.bot ul,
#hs-chat-panel .hs-bubble.bot ol { margin: 6px 0 8px; padding-left: 20px; }
#hs-chat-panel .hs-bubble.bot li { margin: 3px 0; }
#hs-chat-panel .hs-bubble.bot a { color: var(--hsc-blue); font-weight: 600; text-decoration: underline; }
#hs-chat-panel .hs-bubble.bot strong { font-weight: 600; color: var(--hsc-navy); }
#hs-chat-panel .hs-bubble.bot h1,
#hs-chat-panel .hs-bubble.bot h2,
#hs-chat-panel .hs-bubble.bot h3,
#hs-chat-panel .hs-bubble.bot h4 { margin: 10px 0 6px; font-size: 15px; font-weight: 600; line-height: 1.4; color: var(--hsc-navy); }
#hs-chat-panel .hs-bubble.bot code { padding: 2px 6px; border-radius: 6px; background: #eef3fa; font-size: 13px; }
#hs-chat-panel .hs-bubble.bot pre { margin: 8px 0; padding: 10px 12px; overflow-x: auto; border-radius: 10px; background: #eef3fa; }
#hs-chat-panel .hs-bubble.bot pre code { padding: 0; background: none; }
#hs-chat-panel .hs-bubble.bot blockquote { margin: 8px 0; padding: 2px 0 2px 12px; border-left: 3px solid var(--hsc-green); color: #52627d; }
#hs-chat-panel .hs-bubble.bot table { width: 100%; margin: 8px 0; border-collapse: collapse; font-size: 13px; }
#hs-chat-panel .hs-bubble.bot th,
#hs-chat-panel .hs-bubble.bot td { padding: 6px 8px; border: 1px solid var(--hsc-line); text-align: left; }

/* optional typing dots (see the small JS tip) */
#hs-chat-panel .hs-bubble.hs-typing { display: flex; align-items: center; gap: 5px; padding: 16px 18px; }
#hs-chat-panel .hs-typing span {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--hsc-blue);
    animation: hsc-dot 1.2s ease-in-out infinite;
}
#hs-chat-panel .hs-typing span:nth-child(2) { animation-delay: .15s; }
#hs-chat-panel .hs-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes hsc-dot { 0%, 60%, 100% { transform: translateY(0); opacity: .4; } 30% { transform: translateY(-6px); opacity: 1; } }


/* ---------- "Request a quote" toggle ---------- */
#hs-chat-panel .hs-lead-toggle {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    margin: 0;
    padding: 13px 20px;
    border: 0;
    border-top: 1px solid var(--hsc-line);
    border-radius: 0;
    background: #fff;
    color: var(--hsc-blue);
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: background .2s ease;
}
#hs-chat-panel .hs-lead-toggle::before {
    content: "\f0e0";                          /* envelope */
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 14px;
}
#hs-chat-panel .hs-lead-toggle::after {
    content: "\f078";                          /* chevron down */
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    margin-left: auto;
    font-size: 11px;
    transition: transform .3s ease;
}
#hs-chat-panel .hs-lead-toggle:hover { background: #f2f7fd; }
#hs-chat-panel .hs-lead-toggle:has(+ #hs-lead-form.hs-show)::after { transform: rotate(180deg); }


/* ---------- lead form ---------- */
#hs-lead-form {
    display: none;
    flex: 0 0 auto;
    gap: 10px;
    max-height: 270px;
    margin: 0;
    padding: 14px 20px 16px;
    overflow-y: auto;
    border-top: 1px solid var(--hsc-line);
    background: #f9fbfe;
}
#hs-lead-form.hs-show { display: grid; animation: hsc-slide .3s ease; }
@keyframes hsc-slide { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

#hs-lead-form input,
#hs-lead-form select,
#hs-lead-form textarea {
    width: 100%;
    height: 42px;
    margin: 0;
    padding: 0 14px;
    border: 1.5px solid #dbe4f0;
    border-radius: 10px;
    background: #fff;
    color: var(--hsc-navy);
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: border-color .2s ease, box-shadow .2s ease;
}
#hs-lead-form textarea { height: auto; min-height: 64px; padding: 10px 14px; resize: none; }
#hs-lead-form select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 38px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%235b6b86' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 12px;
}
#hs-lead-form ::placeholder { color: #a2afc3; }
#hs-lead-form input:focus,
#hs-lead-form select:focus,
#hs-lead-form textarea:focus { border-color: var(--hsc-blue); box-shadow: 0 0 0 3px rgba(4, 137, 249, .15); }

#hs-lead-form button[type="submit"] {
    height: 44px;
    margin: 0;
    padding: 0 20px;
    border: 0;
    border-radius: 10px;
    background: var(--hsc-blue);
    color: #fff;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background .25s ease;
}
#hs-lead-form button[type="submit"]:hover { background: var(--hsc-navy); }
#hs-lead-status { margin: 0; font-size: 13px; font-weight: 500; text-align: center; color: var(--hsc-navy); }
#hs-lead-status:empty { display: none; }


/* ---------- message input bar ---------- */
#hs-chat-panel .hs-chat-form {
    flex: 0 0 auto;
    display: flex;
    gap: 10px;
    margin: 0;
    padding: 14px 16px;
    border-top: 1px solid var(--hsc-line);
    background: #fff;
}
#hs-chat-message {
    flex: 1;
    min-width: 0;
    height: 46px;
    margin: 0;
    padding: 0 20px;
    border: 1.5px solid transparent;
    border-radius: 50px;
    background: #f1f6fc;
    color: var(--hsc-navy);
    font-family: inherit;
    font-size: 14.5px;
    outline: none;
    transition: border-color .2s ease, background .2s ease, box-shadow .2s ease;
}
#hs-chat-message::placeholder { color: #98a6bd; }
#hs-chat-message:focus { background: #fff; border-color: var(--hsc-blue); box-shadow: 0 0 0 3px rgba(4, 137, 249, .14); }

#hs-chat-send {
    flex: 0 0 auto;
    height: 46px;
    margin: 0;
    padding: 0 24px;
    border: 0;
    border-radius: 50px;
    background: var(--hsc-blue);
    color: #fff;
    font-family: inherit;
    font-size: 14.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background .25s ease, transform .25s ease;
}
#hs-chat-send:hover:not(:disabled) { background: var(--hsc-navy); transform: translateY(-1px); }
#hs-chat-send:disabled { opacity: .55; cursor: not-allowed; }


/* =========================================================
   RESPONSIVE + ACCESSIBILITY
   ========================================================= */
@media (max-width: 575px) {
    #hs-chat-launcher { right: 16px; bottom: 16px; height: 58px; max-width: 58px; padding-right: 22px; }
    #hs-chat-launcher::before { flex-basis: 42px; width: 42px; height: 42px; font-size: 18px; }
    @keyframes hsc-label {
        0%, 10%   { max-width: 58px; }
        16%, 58%  { max-width: 240px; }
        66%, 100% { max-width: 58px; }
    }

    #hs-chat-panel {
        left: 12px;
        right: 12px;
        bottom: 86px;
        width: auto;
        max-width: none;
        height: min(620px, calc(100vh - 170px));
        height: min(620px, calc(100dvh - 170px));
        border-radius: 20px;
    }
    #hs-chat-panel .hs-bubble { max-width: 90%; }
}

@media (prefers-reduced-motion: reduce) {
    #hs-chat-launcher { animation: none; max-width: 260px; }
    #hs-chat-panel { transition: opacity .01s, visibility .01s; transform: none; }
    #hs-chat-panel .hs-bubble, #hs-lead-form.hs-show, #hs-chat-panel .hs-typing span { animation: none; }
}