/* ============================================
   "Need More Help?" Chat Widget
   Matches site theme: #5e5ce6 (primary), #30d5c8 (accent)
   Load AFTER styles.css
   ============================================ */

.help-chat {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 1100;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 15px;
    /* The container can span the viewport width on mobile, so let clicks
       fall through everywhere except on the launcher and panel themselves. */
    pointer-events: none;
}

.help-chat-launcher,
.help-chat-panel {
    pointer-events: auto;
}

/* ---------- Launcher button ---------- */
.help-chat-launcher {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 22px;
    background: #5e5ce6;
    color: white;
    border: none;
    border-radius: 30px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(94, 92, 230, 0.4);
    transition: all 0.3s ease;
}

.help-chat-launcher:hover {
    background: #4442d4;
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(94, 92, 230, 0.5);
}

.help-chat-launcher:active {
    transform: translateY(-1px);
}

.help-chat-launcher:focus-visible {
    outline: 3px solid rgba(94, 92, 230, 0.4);
    outline-offset: 3px;
}

.help-chat-launcher svg {
    flex-shrink: 0;
}

.help-chat-launcher .help-chat-icon-close {
    display: none;
}

.help-chat.is-open .help-chat-icon-open {
    display: none;
}

.help-chat.is-open .help-chat-icon-close {
    display: block;
}

/* Attention dot, shown until the widget has been opened once */
.help-chat-dot {
    position: absolute;
    top: 7px;
    right: 9px;
    width: 10px;
    height: 10px;
    background: #30d5c8;
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(48, 213, 200, 0.7);
    animation: helpChatPulse 2.2s infinite;
}

.help-chat.is-open .help-chat-dot,
.help-chat.is-seen .help-chat-dot {
    display: none;
}

@keyframes helpChatPulse {
    0%   { box-shadow: 0 0 0 0 rgba(48, 213, 200, 0.7); }
    70%  { box-shadow: 0 0 0 12px rgba(48, 213, 200, 0); }
    100% { box-shadow: 0 0 0 0 rgba(48, 213, 200, 0); }
}

/* ---------- Panel ---------- */
.help-chat-panel {
    width: 360px;
    max-width: calc(100vw - 40px);
    background: white;
    border-radius: 20px;
    border: 1px solid #e5e5ea;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.16);
    overflow: hidden;
    display: none;
    flex-direction: column;
    max-height: calc(100vh - 150px);
}

.help-chat.is-open .help-chat-panel {
    display: flex;
    animation: helpChatOpen 0.28s ease-out;
}

@keyframes helpChatOpen {
    from { opacity: 0; transform: translateY(16px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.help-chat-header {
    background: #5e5ce6;
    color: white;
    padding: 20px 22px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-shrink: 0;
}

.help-chat-header h3 {
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 5px;
    color: white;
}

.help-chat-header p {
    font-size: 13px;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.85);
    margin: 0;
}

.help-chat-close {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s ease;
}

.help-chat-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.help-chat-body {
    padding: 22px;
    overflow-y: auto;
}

/* ---------- Form fields ---------- */
.help-chat-field {
    margin-bottom: 15px;
}

.help-chat-field label {
    display: block;
    color: #1d1d1f;
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 13px;
}

.help-chat-field input,
.help-chat-field select,
.help-chat-field textarea {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid #d2d2d7;
    border-radius: 10px;
    font-size: 15px;
    font-family: inherit;
    color: #1d1d1f;
    background: #fafafa;
    outline: none;
    transition: all 0.3s ease;
}

.help-chat-field select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%2386868b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
    cursor: pointer;
}

.help-chat-field textarea {
    resize: vertical;
    min-height: 90px;
    line-height: 1.5;
}

.help-chat-field input:focus,
.help-chat-field select:focus,
.help-chat-field textarea:focus {
    border-color: #5e5ce6;
    box-shadow: 0 0 0 3px rgba(94, 92, 230, 0.1);
    background: white;
}

.help-chat-field input.error,
.help-chat-field textarea.error {
    border-color: #f44336;
}

/* Honeypot - hidden from real users */
.help-chat-hp {
    position: absolute !important;
    left: -9999px !important;
    opacity: 0;
    height: 0;
    overflow: hidden;
}

.help-chat-submit {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 10px;
    background: #30d5c8;
    color: white;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.3s ease;
}

.help-chat-submit:hover:not(:disabled) {
    background: #2bc4b8;
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(48, 213, 200, 0.3);
}

.help-chat-submit:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.help-chat-note {
    margin-top: 12px;
    margin-bottom: 0;
    font-size: 12px;
    color: #86868b;
    line-height: 1.5;
    text-align: center;
}

.help-chat-note a {
    color: #5e5ce6;
    text-decoration: none;
}

.help-chat-note a:hover {
    text-decoration: underline;
}

.help-chat-alert {
    display: none;
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.6;
    margin-bottom: 15px;
    background: #fdeceb;
    border: 1px solid #f5c6c3;
    color: #c0392b;
}

.help-chat-alert.show {
    display: block;
}

.help-chat-alert a {
    color: inherit;
    font-weight: 600;
}

/* ---------- Success state ---------- */
.help-chat-success {
    display: none;
    padding: 35px 22px 30px;
    text-align: center;
}

.help-chat-success.show {
    display: block;
    animation: helpChatFadeIn 0.4s ease-out;
}

@keyframes helpChatFadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.help-chat-success-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 18px;
    border-radius: 50%;
    background: #e9faf8;
    color: #30d5c8;
    display: flex;
    align-items: center;
    justify-content: center;
}

.help-chat-success h4 {
    color: #1d1d1f;
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 10px;
}

.help-chat-success p {
    color: #86868b;
    font-size: 14px;
    line-height: 1.7;
    margin: 0 0 20px;
}

.help-chat-success button {
    background: #f5f5f7;
    color: #1d1d1f;
    border: 1px solid #d2d2d7;
    border-radius: 10px;
    padding: 11px 22px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s ease;
}

.help-chat-success button:hover {
    background: #e8e8ed;
}

/* ---------- Keep the scroll-to-top button clear of the widget ---------- */
.scroll-top-btn {
    bottom: 100px;
}

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
    .help-chat {
        bottom: 20px;
        right: 20px;
        left: 20px;
    }

    .help-chat-panel {
        width: 100%;
        max-width: 100%;
        max-height: calc(100vh - 130px);
    }

    .help-chat-launcher {
        padding: 13px 18px;
        font-size: 14px;
    }

    .scroll-top-btn {
        bottom: 88px;
        right: 20px;
    }
}

@media (max-width: 360px) {
    .help-chat-launcher-text {
        display: none;
    }

    .help-chat-launcher {
        padding: 15px;
        border-radius: 50%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .help-chat-launcher,
    .help-chat-submit,
    .help-chat-panel,
    .help-chat-dot,
    .help-chat-success.show {
        transition: none;
        animation: none;
    }

    .help-chat-launcher:hover,
    .help-chat-submit:hover:not(:disabled) {
        transform: none;
    }
}
