/* ═══════════════════════════════════════════════════════════════════════════
   ScholarshipsLists AI Chatbot — chatbot.css
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── CSS custom properties (overridden per widget by JS) ─────────────────── */
#sl-chatbot-widget {
    --sl-primary:   #1a73e8;
    --sl-secondary: #ffffff;
    --sl-bg:        #f8f9fa;
    --sl-msg-bot:   #ffffff;
    --sl-msg-user:  var(--sl-primary);
    --sl-shadow:    0 8px 32px rgba(0,0,0,0.18);
    --sl-radius:    18px;
    --sl-radius-sm: 10px;
    --sl-font:      -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --sl-transition:all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Widget wrapper ─────────────────────────────────────────────────────── */
#sl-chatbot-widget {
    position: fixed;
    bottom:   24px;
    right:    24px;
    z-index:  999999;
    font-family: var(--sl-font);
    font-size: 14px;
    line-height: 1.5;
}

/* ── Bubble ─────────────────────────────────────────────────────────────── */
#sl-chat-bubble {
    width:  58px;
    height: 58px;
    background: var(--sl-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--sl-shadow);
    position: relative;
    transition: var(--sl-transition);
    margin-left: auto;
}

#sl-chat-bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 12px 36px rgba(0,0,0,0.25);
}

#sl-chat-bubble svg {
    width: 28px;
    height: 28px;
    fill: #ffffff;
}

#sl-unread-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #ea4335;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    animation: sl-pulse 1.5s infinite;
}

@keyframes sl-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(234,67,53,0.5); }
    70%  { box-shadow: 0 0 0 8px rgba(234,67,53,0); }
    100% { box-shadow: 0 0 0 0 rgba(234,67,53,0); }
}

/* ── Chat window ────────────────────────────────────────────────────────── */
#sl-chat-window {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 360px;
    max-height: 580px;
    background: var(--sl-bg);
    border-radius: var(--sl-radius);
    box-shadow: var(--sl-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    transform: scale(0.85) translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: var(--sl-transition);
}

#sl-chat-window.sl-open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
#sl-chat-header {
    background: var(--sl-primary);
    color: var(--sl-secondary);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

#sl-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

#sl-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.25);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

#sl-bot-name {
    font-weight: 700;
    font-size: 15px;
    color: var(--sl-secondary);
}

#sl-bot-status {
    font-size: 11px;
    opacity: 0.85;
    color: var(--sl-secondary);
}

#sl-chat-close {
    background: none;
    border: none;
    color: var(--sl-secondary);
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    opacity: 0.85;
    transition: opacity 0.2s;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#sl-chat-close:hover { opacity: 1; background: rgba(255,255,255,0.15); }

/* ── Messages area ──────────────────────────────────────────────────────── */
#sl-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

#sl-chat-messages::-webkit-scrollbar { width: 4px; }
#sl-chat-messages::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }

/* ── Messages ───────────────────────────────────────────────────────────── */
.sl-msg {
    display: flex;
    max-width: 88%;
    animation: sl-slide-in 0.25s ease;
}

@keyframes sl-slide-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.sl-bot-msg {
    align-self: flex-start;
}

.sl-user-msg {
    align-self: flex-end;
}

.sl-bot-msg > span {
    background: var(--sl-msg-bot);
    color: #333;
    padding: 10px 14px;
    border-radius: 4px 14px 14px 14px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    font-size: 13.5px;
    line-height: 1.55;
}

.sl-user-msg > span {
    background: var(--sl-msg-user);
    color: #ffffff;
    padding: 10px 14px;
    border-radius: 14px 4px 14px 14px;
    font-size: 13.5px;
    line-height: 1.55;
}

/* ── Typing indicator ───────────────────────────────────────────────────── */
#sl-typing-indicator {
    align-self: flex-start;
    background: #ffffff;
    padding: 10px 16px;
    border-radius: 4px 14px 14px 14px;
    display: flex;
    gap: 4px;
    margin: 0 16px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    width: fit-content;
}

#sl-typing-indicator span {
    width: 7px;
    height: 7px;
    background: #aaa;
    border-radius: 50%;
    animation: sl-bounce 1.2s infinite;
}

#sl-typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
#sl-typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes sl-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30%            { transform: translateY(-6px); }
}

/* ── Quick replies ──────────────────────────────────────────────────────── */
#sl-quick-replies {
    padding: 8px 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    background: var(--sl-bg);
    border-top: 1px solid #eee;
    flex-shrink: 0;
    max-height: 140px;
    overflow-y: auto;
}

.sl-qr-btn {
    background: #ffffff;
    border: 1.5px solid var(--sl-primary);
    color: var(--sl-primary);
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 12.5px;
    cursor: pointer;
    transition: var(--sl-transition);
    font-family: var(--sl-font);
    font-weight: 500;
    line-height: 1.3;
}

.sl-qr-btn:hover {
    background: var(--sl-primary);
    color: #ffffff;
    transform: translateY(-1px);
}

/* ── Input area ─────────────────────────────────────────────────────────── */
#sl-chat-input-area {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 12px;
    background: #ffffff;
    border-top: 1px solid #eee;
    flex-shrink: 0;
}

#sl-chat-input {
    flex: 1;
    border: 1.5px solid #e0e0e0;
    border-radius: 24px;
    padding: 9px 14px;
    font-size: 13.5px;
    font-family: var(--sl-font);
    outline: none;
    transition: border-color 0.2s;
    background: var(--sl-bg);
    color: #333;
}

#sl-chat-input:focus { border-color: var(--sl-primary); }

#sl-chat-send {
    width: 38px;
    height: 38px;
    background: var(--sl-primary);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: var(--sl-transition);
}

#sl-chat-send:hover { opacity: 0.85; transform: scale(1.05); }

#sl-chat-send svg {
    width: 18px;
    height: 18px;
    fill: #ffffff;
}

/* ── Footer ─────────────────────────────────────────────────────────────── */
#sl-chat-footer {
    text-align: center;
    padding: 6px;
    font-size: 11px;
    color: #999;
    background: #ffffff;
    flex-shrink: 0;
}

#sl-chat-footer a { color: #999; text-decoration: none; }
#sl-chat-footer a:hover { color: var(--sl-primary); }

/* ── Lead form card ─────────────────────────────────────────────────────── */
.sl-form-card {
    background: #ffffff;
    border-radius: var(--sl-radius-sm);
    padding: 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0 0 4px;
    animation: sl-slide-in 0.25s ease;
}

.sl-form-group { display: flex; flex-direction: column; }

.sl-input {
    border: 1.5px solid #e0e0e0;
    border-radius: var(--sl-radius-sm);
    padding: 9px 12px;
    font-size: 13.5px;
    font-family: var(--sl-font);
    outline: none;
    transition: border-color 0.2s;
    color: #333;
    background: var(--sl-bg);
}

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

.sl-gdpr {
    font-size: 11.5px;
    color: #666;
}

.sl-gdpr label {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    cursor: pointer;
}

.sl-gdpr input[type="checkbox"] { margin-top: 2px; flex-shrink: 0; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.sl-btn {
    border: none;
    border-radius: 24px;
    padding: 10px 18px;
    font-size: 13.5px;
    font-family: var(--sl-font);
    font-weight: 600;
    cursor: pointer;
    transition: var(--sl-transition);
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.sl-btn-primary {
    background: var(--sl-primary);
    color: #ffffff;
}

.sl-btn-primary:hover {
    opacity: 0.88;
    transform: translateY(-1px);
    color: #ffffff;
    text-decoration: none;
}

/* ── Post list ──────────────────────────────────────────────────────────── */
.sl-post-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
}

.sl-post-item {
    background: #ffffff;
    border: 1.5px solid #e8f0fe;
    border-radius: var(--sl-radius-sm);
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    text-decoration: none;
    color: inherit;
    transition: var(--sl-transition);
    cursor: pointer;
}

.sl-post-item:hover {
    border-color: var(--sl-primary);
    transform: translateX(3px);
    box-shadow: 0 2px 8px rgba(26,115,232,0.12);
    text-decoration: none;
}

.sl-post-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--sl-primary);
    line-height: 1.35;
}

.sl-post-excerpt {
    font-size: 11.5px;
    color: #666;
    line-height: 1.4;
}

/* ── Shake animation ────────────────────────────────────────────────────── */
@keyframes sl-shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-5px); }
    40%, 80% { transform: translateX(5px); }
}

.sl-shake { animation: sl-shake 0.5s ease; border-color: #ea4335 !important; }

/* ── Mobile responsive ──────────────────────────────────────────────────── */
@media (max-width: 480px) {
    #sl-chatbot-widget {
        bottom: 12px;
        right:  12px;
    }

    #sl-chat-window {
        width:  calc(100vw - 24px);
        right:  -12px;
        bottom: 68px;
        max-height: 70vh;
    }
}
