/* === Possibilists AI Chatbot v3 === */

:root {
    --fontsize-messages: 16px;
    --fontsize-suggestions: 13px;
    --pc-primary: #020244;
    --pc-primary-hover: #020244;
    --pc-navy: #020244;
    --pc-navy-light: #4122ff;
    --pc-lavender: #BA9DFF;
    --pc-lavender-light: #D0C3EF;
    --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;
}

.possibilists-chatbot-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 100004;
    /*font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;*/
}

/* 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 {
    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;
}

/* Chat window */
.chat-window {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 400px;
    height: 550px;
    background: var(--pc-white);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.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;
}

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

#possibilists-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 {

}

/* 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.3;
    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: 3px 0 0 0;
    color: var(--pc-navy);
    font-size: 16px;
    line-height: 1.2;
}

.card-location {
    font-size: 11px;
    color: var(--pc-text-muted);
    line-height: 1.3;
    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: 62px;
    height: 62px;
    object-fit: cover;
    border-radius: 6px;
}

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

.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: 6px 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;
}

.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: 6px;
    text-decoration: none;
    margin-top: 5px;
    position: relative;
}

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

/* 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 {
    padding: 5px 12px 7px 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;
}
.send-btn svg {
    padding: 5px;
}

/* 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;
    }

    .possibilists-chatbot-widget {
        bottom: 0;
        right: 0;
    }

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

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

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