/* Help widget — collapsible pill/card, bottom-right, all site pages.
   Mobile rules per owner: no over-padding, inputs ≥16px (no iOS focus zoom),
   card may grow to near-full dvh with internal scroll, safe-area aware. */

/* Our display rules below would otherwise beat the UA's [hidden] style on
   pages that don't load Bootstrap (which carries its own !important rule). */
#help-widget [hidden] {
    display: none !important;
}

#help-widget {
    position: fixed;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    z-index: 9990; /* below the portal PWA banner (9999) */
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    text-align: left;
}

.hw-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 3px solid var(--green-bright, #cbff07);
    border-radius: 999px;
    background: #006400;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    padding: 10px 16px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.28);
}
.hw-pill:hover { background: #007a00; }

.hw-card {
    width: min(360px, calc(100vw - 24px));
    max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 16px);
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    animation: hw-slide-up 0.25s ease;
}
@keyframes hw-slide-up {
    from { transform: translateY(24px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

.hw-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #006400;
    color: #fff;
    padding: 12px 14px;
    flex-shrink: 0;
}
.hw-title { font-weight: 700; font-size: 15px; }
.hw-collapse {
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}
.hw-collapse:hover { background: rgba(255, 255, 255, 0.28); }

.hw-body {
    padding: 12px 14px;
    overflow-y: auto;
}

.hw-contact {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}
.hw-contact-btn {
    flex: 1 1 auto;
    text-align: center;
    background: #f3f9ee;
    border: 1px solid #cde3c0;
    border-radius: 8px;
    color: #004d00;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    padding: 9px 10px;
    white-space: nowrap;
}
.hw-contact-btn:hover { background: #e6f3db; color: #004d00; }

/* Step-flow elements */
.hw-q {
    font-size: 14px;
    font-weight: 700;
    color: #333;
    margin: 0 0 10px;
}
.hw-step { display: flex; flex-direction: column; gap: 8px; }
.hw-menu-btn {
    display: block;
    width: 100%;
    box-sizing: border-box;
    text-align: left;
    background: #f3f9ee;
    border: 1px solid #cde3c0;
    border-radius: 10px;
    color: #004d00;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    padding: 12px;
    cursor: pointer;
    font-family: inherit;
}
.hw-menu-btn:hover { background: #e6f3db; color: #004d00; }
.hw-row { display: flex; gap: 8px; }
.hw-row input { flex: 1; min-width: 0; }
.hw-mini-btn {
    border: none;
    border-radius: 8px;
    background: #006400;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    padding: 0 16px;
    cursor: pointer;
    flex-shrink: 0;
}
.hw-mini-btn:hover { background: #007a00; }
.hw-link {
    background: none;
    border: none;
    color: #006400;
    font-size: 13px;
    text-align: left;
    text-decoration: underline;
    padding: 2px 0;
    cursor: pointer;
    font-family: inherit;
}
.hw-info {
    background: #fffbe0;
    border: 1px solid #fbd500;
    border-radius: 10px;
    color: #5c4d00;
    font-size: 14px;
    line-height: 1.45;
    padding: 10px 12px;
}
.hw-hint { font-size: 13px; color: #555; }
.hw-step input,
.hw-step select,
.hw-step textarea {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #ccc;
    border-radius: 8px;
    padding: 11px 12px;
    font-size: 16px; /* ≥16px prevents iOS focus zoom */
    font-family: inherit;
    color: #222;
    background: #fff;
}
.hw-step input:focus,
.hw-step select:focus,
.hw-step textarea:focus {
    outline: none;
    border-color: #006400;
    box-shadow: 0 0 0 2px rgba(0, 100, 0, 0.12);
}

#hw-form { display: flex; flex-direction: column; gap: 8px; }
#hw-form input,
#hw-form textarea {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #ccc;
    border-radius: 8px;
    padding: 11px 12px;
    font-size: 16px; /* ≥16px prevents iOS focus zoom */
    font-family: inherit;
    color: #222;
    background: #fff;
}
#hw-form input:focus,
#hw-form textarea:focus {
    outline: none;
    border-color: #006400;
    box-shadow: 0 0 0 2px rgba(0, 100, 0, 0.12);
}
#hw-form textarea { resize: none; overflow: hidden; min-height: 72px; }

/* Honeypot: visually removed but present for bots (never display:none) */
.hw-hp {
    position: absolute;
    left: -9999px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.hw-submit {
    border: none;
    border-radius: 8px;
    background: #fbd500;
    color: #004d00;
    font-size: 15px;
    font-weight: 700;
    padding: 12px;
    cursor: pointer;
}
.hw-submit:hover { background: #e6c400; }
.hw-submit:disabled { opacity: 0.6; cursor: default; }

.hw-error {
    background: #fdecea;
    border-left: 3px solid #d9534f;
    border-radius: 4px;
    color: #a94442;
    font-size: 13px;
    padding: 8px 10px;
}

.hw-success {
    background: #f3f9ee;
    border-left: 4px solid #006400;
    border-radius: 6px;
    color: #2d5016;
    font-size: 14px;
    padding: 12px 14px;
    margin-top: 4px;
}

.hw-privacy {
    font-size: 11px;
    color: #999;
    margin-top: 10px;
    line-height: 1.4;
}
.hw-privacy a { color: #777; text-decoration: underline; }

@media (max-width: 480px) {
    #help-widget { right: 8px; left: 8px; }
    .hw-card { width: auto; margin-left: auto; }
    /* Compact round chat bubble — full pill is too bulky on phones, and a
       full-width bar would clash with the tv/porta floating basebars */
    .hw-pill {
        float: right;
        width: 54px;
        height: 54px;
        padding: 0;
        font-size: 24px;
        border-radius: 50%;
    }
    .hw-pill-label { display: none; }
    .hw-body { padding: 1.25rem 1rem; padding-top: 12px; }
}

/* ── porta.php variant ─────────────────────────────────────────────────────
   The proposal page has a sticky base bar at the bottom, so the pill can't
   live down there. Per owner: use the compact round bubble at every width
   (the page is a checkout — no room for clutter) and float it clear of the
   bar: vertically centred on mobile, lower third on desktop.

   Only the PILL is repositioned, not #help-widget itself. The card therefore
   still opens from its normal bottom-right anchor with its existing sizing,
   scrolling and safe-area handling — and since the JS hides the pill while
   the card is open, the two never appear at once. */
.porta-page .hw-pill {
    position: fixed;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    float: none;
    width: 54px;
    height: 54px;
    padding: 0;
    font-size: 24px;
    border-radius: 50%;
    z-index: 9991; /* above the base bar (60) and its own container */
}
.porta-page .hw-pill-label { display: none; }

@media (min-width: 769px) {
    /* lower third, clear of the base bar's ~64px */
    .porta-page .hw-pill {
        top: auto;
        bottom: 28vh;
        transform: none;
    }
}
