/* ==========================================================================
   JIMS EduTech Chatbot — v2 Floating Widget Styles
   ========================================================================== */

#jims-chatbot-root {
    --jims-primary: #1e3a8a;
    --jims-primary-hover: color-mix(in srgb, var(--jims-primary) 88%, black);
    --jims-accent: #f59e0b;
    --jims-bg: #ffffff;
    --jims-bg-soft: #f8fafc;
    --jims-border: #e2e8f0;
    --jims-text: #0f172a;
    --jims-text-soft: #475569;
    --jims-user-bubble: var(--jims-primary);
    --jims-bot-bubble: #f1f5f9;
    --jims-shadow: 0 10px 40px rgba(15, 23, 42, 0.15);
    --jims-radius: 16px;

    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--jims-text);
    box-sizing: border-box;
}

#jims-chatbot-root *,
#jims-chatbot-root *::before,
#jims-chatbot-root *::after {
    box-sizing: border-box;
}

/* ----- Floating bubble ----- */
#jims-chatbot-bubble {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--jims-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--jims-shadow);
    z-index: 999998;
    transition: transform 0.2s ease, background 0.2s ease;
    padding: 0;
}

#jims-chatbot-bubble:hover {
    background: var(--jims-primary-hover);
    transform: scale(1.05);
}

#jims-chatbot-bubble:active { transform: scale(0.95); }

#jims-chatbot-bubble-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: var(--jims-accent);
    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;
}

#jims-chatbot-root.is-open #jims-chatbot-bubble {
    transform: scale(0.9);
    opacity: 0;
    pointer-events: none;
}

/* ----- Chat window ----- */
#jims-chatbot-window {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 580px;
    max-height: calc(100vh - 48px);
    background: var(--jims-bg);
    border-radius: var(--jims-radius);
    box-shadow: var(--jims-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 999999;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

#jims-chatbot-root.is-open #jims-chatbot-window {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ----- Header ----- */
#jims-chatbot-header {
    background: linear-gradient(135deg, var(--jims-primary) 0%, color-mix(in srgb, var(--jims-primary) 70%, #2563eb) 100%);
    color: #fff;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.jims-chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.jims-chatbot-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
}

.jims-chatbot-title { font-size: 15px; font-weight: 600; line-height: 1.2; }

.jims-chatbot-subtitle {
    font-size: 12px;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}

.jims-chatbot-status-dot {
    width: 8px;
    height: 8px;
    background: #34d399;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 0 2px rgba(52, 211, 153, 0.3);
}

#jims-chatbot-close {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    padding: 0;
}

#jims-chatbot-close:hover { background: rgba(255, 255, 255, 0.25); }

/* ----- Messages ----- */
#jims-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px;
    background: var(--jims-bg-soft);
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

#jims-chatbot-messages::-webkit-scrollbar { width: 6px; }
#jims-chatbot-messages::-webkit-scrollbar-track { background: transparent; }
#jims-chatbot-messages::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

.jims-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: jimsMsgIn 0.3s ease;
}

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

.jims-msg-bot {
    background: var(--jims-bot-bubble);
    color: var(--jims-text);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.jims-msg-user {
    background: var(--jims-user-bubble);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

/* Rich content inside bot answers */
.jims-msg-bot strong { font-weight: 600; }
.jims-msg-bot em { font-style: italic; }
.jims-msg-bot a { color: var(--jims-primary); text-decoration: underline; }
.jims-msg-bot a:hover { opacity: 0.8; }
.jims-msg-bot p { margin: 0 0 8px; }
.jims-msg-bot p:last-child { margin-bottom: 0; }
.jims-msg-bot ul, .jims-msg-bot ol {
    margin: 6px 0;
    padding-left: 22px;
}
.jims-msg-bot li { margin-bottom: 4px; }
.jims-msg-bot code {
    background: rgba(0,0,0,0.08);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 13px;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.jims-msg-bot h1, .jims-msg-bot h2, .jims-msg-bot h3, .jims-msg-bot h4 {
    margin: 8px 0 4px;
    font-weight: 600;
    font-size: 14px;
}
.jims-msg-bot blockquote {
    margin: 6px 0;
    padding-left: 10px;
    border-left: 3px solid var(--jims-border);
    color: var(--jims-text-soft);
}

/* ----- Category chips ----- */
.jims-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.jims-chip {
    background: #fff;
    border: 1px solid var(--jims-border);
    color: var(--jims-text);
    padding: 7px 12px;
    border-radius: 999px;
    font-size: 12.5px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.jims-chip:hover {
    background: var(--jims-primary);
    color: #fff;
    border-color: var(--jims-primary);
    transform: translateY(-1px);
}

.jims-chip-icon { font-size: 14px; }

/* ----- Question list ----- */
.jims-question-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
}

.jims-question-item {
    background: #fff;
    border: 1px solid var(--jims-border);
    border-left: 3px solid var(--jims-primary);
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    color: var(--jims-text);
    transition: all 0.15s ease;
    line-height: 1.4;
}

.jims-question-item:hover {
    background: var(--jims-bg-soft);
    border-left-color: var(--jims-accent);
    transform: translateX(2px);
}

/* ----- Action buttons ----- */
.jims-action-btn {
    background: transparent;
    border: 1px dashed var(--jims-border);
    color: var(--jims-text-soft);
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12px;
    cursor: pointer;
    font-family: inherit;
    margin-top: 8px;
    align-self: flex-start;
    transition: all 0.15s ease;
}

.jims-action-btn:hover {
    color: var(--jims-primary);
    border-color: var(--jims-primary);
    border-style: solid;
}

/* ----- Typing indicator ----- */
.jims-typing {
    display: flex;
    gap: 4px;
    padding: 12px 14px;
    background: var(--jims-bot-bubble);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    width: fit-content;
}

.jims-typing span {
    width: 7px;
    height: 7px;
    background: #94a3b8;
    border-radius: 50%;
    animation: jimsTyping 1.2s infinite ease-in-out;
}

.jims-typing span:nth-child(2) { animation-delay: 0.15s; }
.jims-typing span:nth-child(3) { animation-delay: 0.3s; }

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

/* ----- Input area ----- */
#jims-chatbot-input-area {
    display: flex;
    gap: 8px;
    padding: 12px 14px;
    background: #fff;
    border-top: 1px solid var(--jims-border);
    flex-shrink: 0;
}

#jims-chatbot-input {
    flex: 1;
    border: 1px solid var(--jims-border);
    border-radius: 999px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    font-family: inherit;
    color: var(--jims-text);
    background: var(--jims-bg-soft);
    transition: border-color 0.15s ease, background 0.15s ease;
}

#jims-chatbot-input:focus {
    border-color: var(--jims-primary);
    background: #fff;
}

#jims-chatbot-send {
    background: var(--jims-primary);
    color: #fff;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s ease, transform 0.15s ease;
    padding: 0;
}

#jims-chatbot-send:hover {
    background: var(--jims-primary-hover);
    transform: scale(1.05);
}

#jims-chatbot-send:active { transform: scale(0.95); }

/* ----- Footer ----- */
#jims-chatbot-footer {
    text-align: center;
    font-size: 11px;
    color: var(--jims-text-soft);
    padding: 6px;
    background: #fff;
    border-top: 1px solid var(--jims-border);
    flex-shrink: 0;
}

/* ----- Mobile responsive ----- */
@media (max-width: 480px) {
    #jims-chatbot-window {
        bottom: 0;
        right: 0;
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
    #jims-chatbot-bubble {
        bottom: 16px;
        right: 16px;
    }
}
