/* Sidebar Popup Widget v2.3 */
:root {
    --spw-tab-bg:   #1a3c6e;
    --spw-tab-col:  #ffffff;
    --spw-btn-bg:   #1a3c6e;
    --spw-btn-col:  #ffffff;
    --spw-radius:   10px;
    --spw-shadow:   0 8px 40px rgba(0,0,0,.28);
    --spw-panel-w:  360px;
    --spw-font:     -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --spw-dur:      .32s;
}

/* ── Overlay — body-level, NOT inside wrapper ── */
#spw-overlay {
    position: fixed;
    inset: 0;
    z-index: 99990;
    background: rgba(0,0,0,.42);
    /* NO backdrop-filter — it caused blur bleeding into the panel */
}
#spw-overlay[hidden] { display: none !important; }

/* ── Wrapper ── */
#spw-wrapper {
    position: fixed;
    /* Span full height so the panel can be positioned freely */
    top: 0;
    bottom: 0;
    z-index: 99995;
    display: flex;
    align-items: center;  /* vertically center the tab + panel */
    pointer-events: none; /* wrapper itself is invisible to clicks */
}
#spw-wrapper > * { pointer-events: auto; }

.spw-pos-right { right: 0; flex-direction: row-reverse; }
.spw-pos-left  { left:  0; flex-direction: row; }

/* ── Tab button ── */
.spw-tab {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    background: var(--spw-tab-bg);
    color: var(--spw-tab-col);
    border: none;
    cursor: pointer;
    padding: 22px 14px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .08em;
    box-shadow: var(--spw-shadow);
    transition: filter var(--spw-dur);
    user-select: none;
    line-height: 1.3;
    flex-shrink: 0;
    align-self: center;
}
.spw-pos-right .spw-tab { border-radius: var(--spw-radius) 0 0 var(--spw-radius); transform: rotate(180deg); }
.spw-pos-left  .spw-tab { border-radius: 0 var(--spw-radius) var(--spw-radius) 0; }
.spw-tab:hover { filter: brightness(1.15); }
.spw-tab[aria-expanded="true"] { filter: brightness(.82); }

/* ── Panel ── */
.spw-panel {
    width: var(--spw-panel-w);
    /* Use most of the viewport height */
    height: calc(100vh - 40px);
    max-height: 800px;
    background: #fff;
    box-shadow: var(--spw-shadow);
    border-radius: var(--spw-radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform var(--spw-dur) cubic-bezier(.4,0,.2,1), opacity var(--spw-dur);
    will-change: transform, opacity;
    align-self: center;
}

/* Slide off-screen when hidden */
.spw-panel[hidden] {
    display: flex !important;       /* keep in layout for transition */
    pointer-events: none !important;
    opacity: 0;
    transform: translateX(calc(var(--spw-panel-w) + 20px));
    visibility: hidden;
}
.spw-pos-left .spw-panel[hidden] {
    transform: translateX(calc(-1 * var(--spw-panel-w) - 20px));
}
.spw-panel:not([hidden]) {
    opacity: 1;
    transform: translateX(0);
    visibility: visible;
}

/* ── Panel header ── */
.spw-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--spw-tab-bg);
    color: var(--spw-tab-col);
    padding: 14px 16px;
    flex-shrink: 0;
    z-index: 1;
}
.spw-panel-title {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: inherit;
    font-family: var(--spw-font);
}
.spw-close {
    background: rgba(255,255,255,.2);
    border: none;
    color: inherit;
    width: 30px; height: 30px;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s;
    flex-shrink: 0;
    line-height: 1;
    font-family: var(--spw-font);
}
.spw-close:hover { background: rgba(255,255,255,.38); }

/* ── Panel body — fills remaining space, scrolls ── */
.spw-panel-body {
    flex: 1 1 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 14px 14px 20px;
    -webkit-overflow-scrolling: touch;
    /* Ensure it always has a visible height */
    min-height: 0;
}
.spw-panel-body::-webkit-scrollbar { width: 4px; }
.spw-panel-body::-webkit-scrollbar-track { background: transparent; }
.spw-panel-body::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }

/* ── HubSpot form styles ── */
#spw-hs-form-target {
    min-height: 80px;
    /* Make sure it fills the body */
    width: 100%;
}

/* Loading spinner */
.spw-hs-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 40px 0;
    color: #999;
    font-size: 13px;
    font-family: var(--spw-font);
}

/* Override HubSpot styles to fit panel */
#spw-hs-form-target .hs-form fieldset {
    max-width: 100% !important;
}
#spw-hs-form-target .hs-form .hs-form-field {
    margin-bottom: 10px !important;
    width: 100% !important;
}
#spw-hs-form-target .hs-form label.hs-form-field > label,
#spw-hs-form-target .hs-form label {
    font-size: 12px !important;
    font-weight: 600 !important;
    margin-bottom: 3px !important;
    display: block !important;
    color: #333 !important;
    font-family: var(--spw-font) !important;
}
#spw-hs-form-target .hs-form input[type="text"],
#spw-hs-form-target .hs-form input[type="email"],
#spw-hs-form-target .hs-form input[type="tel"],
#spw-hs-form-target .hs-form input[type="number"],
#spw-hs-form-target .hs-form input[type="date"],
#spw-hs-form-target .hs-form input[type="phone"],
#spw-hs-form-target .hs-form select,
#spw-hs-form-target .hs-form textarea {
    width: 100% !important;
    max-width: 100% !important;
    padding: 8px 10px !important;
    border: 1.5px solid #d0d5dd !important;
    border-radius: 6px !important;
    font-size: 13px !important;
    font-family: var(--spw-font) !important;
    box-sizing: border-box !important;
    color: #333 !important;
    background: #fafafa !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    transition: border-color .2s !important;
    margin: 0 !important;
}
#spw-hs-form-target .hs-form input:focus,
#spw-hs-form-target .hs-form select:focus,
#spw-hs-form-target .hs-form textarea:focus {
    border-color: var(--spw-tab-bg) !important;
    outline: none !important;
    background: #fff !important;
    box-shadow: 0 0 0 3px rgba(26,60,110,.1) !important;
}
#spw-hs-form-target .hs-form .hs-button,
#spw-hs-form-target .hs-form input[type="submit"] {
    width: 100% !important;
    background: var(--spw-tab-bg) !important;
    color: var(--spw-tab-col) !important;
    border: none !important;
    padding: 11px !important;
    border-radius: 7px !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    cursor: pointer !important;
    margin-top: 6px !important;
    transition: filter .2s !important;
    font-family: var(--spw-font) !important;
    box-sizing: border-box !important;
}
#spw-hs-form-target .hs-form .hs-button:hover { filter: brightness(1.12) !important; }
#spw-hs-form-target .hs-error-msgs {
    color: #c00 !important;
    font-size: 11px !important;
    margin: 2px 0 0 !important;
    padding: 0 !important;
    list-style: none !important;
}
#spw-hs-form-target .submitted-message {
    text-align: center;
    padding: 30px 10px;
    font-size: 14px;
    color: #333;
    font-family: var(--spw-font);
}
/* Hide HubSpot branding */
#spw-hs-form-target .hs-richtext p { font-size: 12px !important; }
#spw-hs-form-target .legal-consent-container { font-size: 11px !important; }

/* ── Custom form ── */
.spw-field { margin-bottom: 11px; }
.spw-label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 3px; color: #333; }
.spw-star { color: #c00; margin-left: 2px; }
.spw-input {
    width: 100%; padding: 8px 10px; font-size: 13px;
    border: 1.5px solid #d0d5dd; border-radius: 6px;
    color: #333; background: #fafafa;
    box-sizing: border-box; font-family: var(--spw-font);
    -webkit-appearance: none; appearance: none;
    transition: border-color .2s;
}
.spw-input:focus { outline: none; border-color: var(--spw-tab-bg); background: #fff; box-shadow: 0 0 0 3px rgba(26,60,110,.1); }
select.spw-input { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%23555' d='M4 6l4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 14px; padding-right: 28px; }
textarea.spw-input { resize: vertical; min-height: 68px; }
.spw-submit {
    width: 100%; padding: 11px; margin-top: 4px;
    background: var(--spw-btn-bg); color: var(--spw-btn-col);
    border: none; border-radius: 7px;
    font-size: 14px; font-weight: 700;
    cursor: pointer; font-family: var(--spw-font);
    transition: filter .2s;
}
.spw-submit:hover { filter: brightness(1.1); }
.spw-submit:disabled { opacity: .7; cursor: not-allowed; }
.spw-error { color: #c00; font-size: 12px; margin-top: 8px; text-align: center; font-family: var(--spw-font); }
.spw-success { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; padding: 30px 0; color: #333; font-size: 14px; font-family: var(--spw-font); }

/* ── Mobile ── */
@media (max-width: 520px) {
    :root { --spw-panel-w: calc(100vw - 44px); }
    .spw-panel {
        height: calc(100vh - 80px);
        max-height: none;
    }
    .spw-tab { padding: 16px 11px; font-size: 12px; }
}
