/* === Facilitators AI Chatbot === */

/* Colours follow the theme (sass/vars/_vars.scss): black buttons,
   $faci-blue accents, $faci-beige surfaces. */
:root {
    --fontsize-messages: 16px;
    --fontsize-suggestions: 14px;
    --pc-primary: #000;
    --pc-primary-hover: #000;
    --pc-navy: #000;
    --pc-navy-light: #7191C7;
    --pc-lavender: #7191C7;
    --pc-lavender-light: #D6D6D6;
    --pc-accent-bg: #EFE9DF;
    --pc-white: #fff;
    --pc-bg: #f9fafb;
    --pc-text: #111827;
    --pc-text-secondary: #374151;
    --pc-text-muted: #6b7280;
    --pc-text-dots: #9ca3af;
    --pc-border: #e5e7eb;
    --pc-border-input: #D0C3EF;
    --pc-disabled: #d1d1db;
    --pc-danger: #dc2626;
    --pc-tag-location-bg: #eff6ff;
    --pc-tag-location: #1d4ed8;
    --pc-tag-type-bg: #fef3c7;
    --pc-tag-type: #92400e;
    --pc-tag-funding-bg: #ede9fe;
    --pc-tag-funding: #6d28d9;
    --pc-retry-bg: #f3f4f6;
    --pc-retry-bg-hover: #e5e7eb;
}

.facilitators-chatbot-container {
    font-family: inherit;
}

.facilitators-chatbot-container.is-floating {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 100004;
}

/* Inline module: part of the page flow (facilitator map page). */
.facilitators-chatbot-container.is-inline {
    position: relative;
    width: 100%;
    max-width: 760px;
    margin: 0 auto 2rem;
}

/* Safari SVG sizing guard.
   The theme ships a global `svg { width: 100%; height: 100%; }` rule. Chromium
   and Safari 26 resolve those percentages against a shrink-to-fit button and
   fall back to the SVG's intrinsic size, but Safari <= 18 blows the icons up to
   fill the button instead. Pinning explicit sizes here keeps every icon in the
   widget at its intended size regardless of ambient theme CSS. */
#facilitators-chatbot-widget svg {
    width: auto;
    height: auto;
}

/* Toggle button */
.chat-toggle-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--pc-primary);
    color: var(--pc-white);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-size: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    position: relative;
}
.chat-toggle-btn:active {
    top: 1px;
}

.chat-toggle-btn:hover {
    background: var(--pc-primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.chat-toggle-btn svg {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    animation: pulse-icon 1.75s linear infinite;
}

@keyframes pulse-icon {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

.chat-toggle-btn span {
    white-space: nowrap;
}

/* Notification badge — small red circle with white "1" on the toggle button.
   Acts as a lightweight engagement nudge; hidden permanently per browser
   once the user opens the chat (see chatbot.js localStorage flag). */
.chat-toggle-btn::after {
    content: "1";
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    box-sizing: border-box;
    border-radius: 10px;
    background: #e53935;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
    box-shadow: 0 0 0 2px var(--pc-white, #fff);
    pointer-events: none;
    transform-origin: center;
    animation: pc-badge-pop 0.4s ease-out 0.2s both, pc-badge-pulse 2s ease-in-out 1s infinite;
}

.chat-toggle-btn.notification-dismissed::after {
    display: none;
}

@keyframes pc-badge-pop {
    0%   { transform: scale(0); }
    70%  { transform: scale(1.2); }
    100% { transform: scale(1); }
}

@keyframes pc-badge-pulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.15); }
}

/* Chat window */
.chat-window {
    background: var(--pc-white);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.is-floating .chat-window {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 400px;
    height: 550px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

.is-inline .chat-window {
    position: relative;
    width: 100%;
    height: 520px;
    border: 1px solid var(--pc-lavender-light);
}

.chat-header {
    padding: 14px 16px;
    background: var(--pc-primary);
    color: var(--pc-white);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.chat-header h3 {
    margin: 0;
    font-size: 24px;
}

#facilitators-chat-input {
    border: 1px solid var(--pc-lavender-light);
    font-size: var(--fontsize-messages);
    padding: 0 6px 0 12px;
}

#facilitators-chat-input::placeholder {
    font-size: var(--fontsize-messages);
}

.chat-close-btn {
    background: none;
    border: none;
    color: var(--pc-white);
    font-size: 22px;
    cursor: pointer;
    padding: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
    line-height: 1;
}

.chat-close-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Minimize icon; ID selector outranks the Safari guard on widget SVGs. */
#facilitators-chatbot-widget .chat-close-btn svg {
    display: block;
    width: 20px;
    height: 20px;
}

/* Messages area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--pc-bg);
}

.chat-messages::-webkit-scrollbar {
    width: 4px;
    background-color: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    border-radius: 0px;
    background-color: var(--pc-primary);
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background-color: var(--pc-primary);
}

.chat-messages::-webkit-scrollbar-track {
    border-radius: 0px;
    background-color: transparent;
}

.chat-message {
    margin-bottom: 10px;
    display: flex;
}

.bot-message {
    justify-content: flex-start;
}

.user-message {
    justify-content: flex-end;
}

.message-content {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: var(--fontsize-messages);
    line-height: 1.25;
    white-space: normal;
    word-wrap: break-word;
}

.chat-link {
    color: var(--pc-navy);
    font-weight: 600;
    text-decoration: none !important;
    background-color: white;
    padding: 1px 7px;
    display: inline-block;
    border-radius: 15px;
    border: 1px solid var(--pc-lavender-light);
    transition: all 0.2s;
    line-height: 1.1;
}

.chat-link:hover {
    background-color: var(--pc-lavender);
    border: 1px solid var(--pc-lavender);
}

.bot-message .message-content {
    background: var(--pc-white);
    color: var(--pc-text);
    border: 1px solid var(--pc-border);
}

.user-message .message-content {
    background: var(--pc-lavender);
    color: var(--pc-primary);
}

/* Cards container */
.cards-container {
    max-width: 100%;
    padding: 2px;
    border: none;
    background: transparent;
}

/* Initiative cards */
.initiative-card,
.opportunity-card {
    background: var(--pc-white);
    border: 1px solid var(--pc-lavender-light);
    border-radius: 8px;
    padding: 10px;
    margin: 6px;
    transition: box-shadow 0.2s;
}

.initiative-card:hover,
.opportunity-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Horizontal row: thumb left, content right */
.card-row {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.initiative-thumb {
    width: 62px;
    height: 62px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
}

.card-body {
    flex: 1;
    min-width: 0;
}

.initiative-card h4,
.opportunity-card h4 {
    margin: 6px 0 0 0;
    color: var(--pc-navy);
    font-size: 16px;
    line-height: 1.2;
}

/* Program / event ("offering") cards — reuse the .initiative-card layout */
.offering-badge {
    /* block (not inline-block) so the badge isn't placed inside a ~20px text
       line box — inline leading was pushing the small 9px badge down from the
       card-body top. block + fit-content keeps the pill shape, top-flush. */
    display: block;
    width: fit-content;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 1px 6px;
    border-radius: 999px;
    background: var(--pc-tag-funding-bg);
    color: var(--pc-tag-funding);
}
.offering-event .offering-badge {
    background: var(--pc-tag-type-bg);
    color: var(--pc-tag-type);
}
.offering-from {
    display: block;
    font-size: 11px;
    color: var(--pc-text-muted);
    line-height: 1.25;
    margin-top: 2px;
}

.card-location {
    font-size: 11px;
    color: var(--pc-text-muted);
    line-height: 1.25;
    display: inline-block;
}

.card-location .pin {
    font-size: 10px;
}

.initiative-summary,
.opp-description {
    margin: 6px 0 0 0;
    font-size: 11px;
    color: var(--pc-text-secondary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-footer {
    text-align: right;
    margin-top: 4px;
}

.opp-logo {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
}

.opp-org {
    margin: 0 0 6px 0;
    font-size: 11px;
    color: var(--pc-text-muted);
    line-height: 1.2;
    text-align: right;
}

.opp-deadline {
    margin: 4px 0;
    font-size: 11px;
    color: var(--pc-danger);
    font-weight: 500;
}

/* Opportunity card meta tags */
.card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 12px 0;
}

.card-meta span {
    display: inline-block;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
}

.card-meta .card-location {
    background: var(--pc-tag-location-bg);
    color: var(--pc-tag-location);
    font-size: 10px;
    /* The location tag holds a full country list — unlike the short
       type/funding pills it must wrap instead of overflowing the card. */
    white-space: normal;
    line-height: 1.5;
}

.opp-type {
    background: var(--pc-tag-type-bg);
    color: var(--pc-tag-type);
}

.opp-funding {
    background: var(--pc-tag-funding-bg);
    color: var(--pc-tag-funding);
}

/* Card links */
.card-link {
    display: inline-block;
    color: var(--pc-navy);
    text-decoration: none;
    font-size: 11px;
    font-weight: bold;
    transition: color 0.2s;
}

.card-link:hover {
    color: var(--pc-navy);
    text-decoration: underline;
}

.card-link-apply {
    background: var(--pc-navy);
    color: var(--pc-white);
    padding: 4px 12px;
    border-radius: 16px;
    text-decoration: none;
    margin-top: 8px;
    position: relative;
    display: block;
    width: fit-content;
    margin-left: 0;
}

.card-link-apply:hover {
    background: var(--pc-navy);
    color: var(--pc-white);
    text-decoration: none;
}
.card-link-apply:active {
    top: 1px;
}

/* Facilitator cards */

/* The theme ships Bootstrap 5, whose .card-body / .card-footer rules (padding,
   background, border) and link colours leak into the widget's same-named classes. */
#facilitators-chatbot-widget .card-body,
#facilitators-chatbot-widget .card-footer {
    padding: 0;
    background: transparent;
    border: 0;
}

/* !important only because the theme forces `a { color: inherit !important }`. */
#facilitators-chatbot-widget .card-link-apply,
#facilitators-chatbot-widget .card-link-apply:hover {
    color: var(--pc-white) !important;
}

#facilitators-chatbot-widget .card-link-map {
    color: var(--pc-navy);
}
.card-pronouns {
    font-weight: normal;
    font-size: 13px;
    color: var(--pc-text-muted);
}

.card-languages {
    display: block;
    font-size: 12px;
    color: var(--pc-text-secondary);
    margin-top: 2px;
}

.card-badge {
    display: inline-block;
    margin-top: 4px;
    padding: 1px 8px;
    border-radius: 10px;
    background: var(--pc-accent-bg);
    font-size: 11px;
    color: var(--pc-text);
}

.card-reason {
    margin: 8px 0 0;
    font-size: 14px;
    line-height: 1.4;
    color: var(--pc-text);
}

.facilitator-card .card-footer {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 8px;
}

/* Spacing comes from the footer (margin-top + gap). Bootstrap's
   `.card-link + .card-link { margin-left: 1.25rem }` would otherwise add
   extra space before "View profile". */
#facilitators-chatbot-widget .facilitator-card .card-footer .card-link {
    margin: 0;
}

.card-link-map {
    margin-top: 8px;
    padding: 4px 12px;
    border: 1px solid var(--pc-navy);
    border-radius: 16px;
    background: transparent;
    cursor: pointer;
    line-height: inherit;
}

/* AI Disclaimer / Consent gate */
.disclaimer-message .message-content {
    background: var(--pc-lavender-light);
    border: 1px solid var(--pc-lavender);
    color: var(--pc-text);
    font-size: 13px;
    line-height: 1.4;
}

.disclaimer-message .message-content a {
    color: var(--pc-navy);
    font-weight: 600;
    text-decoration: underline;
}

.disclaimer-message .message-content a:hover {
    color: var(--pc-navy-light);
}

.consent-gate {
    display: flex;
    justify-content: flex-end;
    margin: 4px 0 12px 0;
}

.consent-button {
    padding: 10px 22px;
    background: var(--pc-primary);
    color: var(--pc-white);
    border: none;
    border-radius: 8px;
    font-size: var(--fontsize-messages);
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    transition: transform 0.15s, box-shadow 0.2s, background 0.2s;
    position: relative;
}

.consent-button:hover {
    background: var(--pc-navy-light);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
}

.consent-button:active {
    top: 1px;
}

.chat-input-container.is-locked {
    opacity: 0.55;
    pointer-events: none;
}

.chat-input-container.is-locked .chat-input,
.chat-input-container.is-locked .send-btn {
    cursor: not-allowed;
}

/* Suggestion chips */
.suggested-questions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px 0;
    margin: 4px 0 8px 0;
}

.suggestion-chip {
    display: inline-block;
    padding: 6px 12px;
    background: var(--pc-white);
    color: var(--pc-navy);
    border: 1px solid var(--pc-lavender);
    border-radius: 16px;
    font-size: var(--fontsize-suggestions);
    cursor: pointer;
    transition: all 0.2s;
    white-space: normal;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    position: relative;
    text-align: left;
    line-height: 1.1;
}

.suggestion-chip:hover {
    background: var(--pc-lavender);
    color: var(--pc-primary);
    border-color: var(--pc-lavender);
}
.suggestion-chip:active {
    top: 1px;
}

/* Retry button */
.retry-container {
    text-align: center;
    margin: 8px 0;
}

.retry-btn {
    padding: 6px 16px;
    background: var(--pc-retry-bg);
    color: var(--pc-text-secondary);
    border: 1px solid var(--pc-border-input);
    border-radius: 8px;
    font-size: var(--fontsize-messages);
    cursor: pointer;
    transition: all 0.2s;
}

.retry-btn:hover {
    background: var(--pc-retry-bg-hover);
}

/* Input area */
.chat-input-container {
    padding: 10px 12px;
    background: var(--pc-white);
    border-top: 1px solid var(--pc-border);
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.chat-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--pc-border-input);
    border-radius: 8px;
    font-size: var(--fontsize-messages);
    outline: none;
    transition: border-color 0.2s;
}

.chat-input:focus {
    border-color: var(--pc-primary);
}

.send-btn {
    /* The input row stretches the button to its height; flex keeps the
       icon centred in whatever height that is. */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
    background: var(--pc-primary);
    color: var(--pc-white);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
    position: relative;
}

.send-btn:active {
    top: 1px;
}
.send-btn:hover {
    background: var(--pc-primary);
}

.send-btn:disabled {
    background: var(--pc-disabled);
    cursor: not-allowed;
}
/* ID selector: must outrank the Safari guard `#facilitators-chatbot-widget svg`. */
#facilitators-chatbot-widget .send-btn svg {
    display: block;
    width: 20px;
    height: 20px;
}

/* Typing indicator */
.typing-indicator {
    display: inline-flex;
    align-items: center;
    padding: 10px 14px;
    background: var(--pc-white);
    border: 1px solid var(--pc-border);
    border-radius: 12px;
}

.typing-indicator span {
    height: 7px;
    width: 7px;
    background: var(--pc-text-dots);
    border-radius: 50%;
    display: inline-block;
    margin: 0 2px;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* Responsive */
@media (max-width: 600px) {

    .chat-toggle-btn span {
        display: none;
    }

    .is-floating .chat-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 30vh);
        right: -10px;
        bottom: -10px;
    }

    .is-inline .chat-window {
        height: 70vh;
    }

    .message-content {
        max-width: 90%;
    }

    .suggestion-chip {
        font-size: var(--fontsize-suggestions);
        padding: 5px 10px;
    }
}
