/* ── JPD Site Assistant Widget ───────────────────────── */

/* Toggle button — bottom-right */
#jpd-bot-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: #1a1a1a;
    border: 2px solid #d97706;
    cursor: pointer;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    animation: jpd-bot-pulse 2.5s ease-in-out infinite;
}

#jpd-bot-toggle img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    border-radius: 50%;
    padding: 6px;
    box-sizing: border-box;
    display: block;
}

#jpd-bot-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 0 18px rgba(217, 119, 6, 0.7);
}

#jpd-bot-toggle.jpd-bot-open {
    animation: none;
    box-shadow: 0 0 14px rgba(217, 119, 6, 0.5);
}

@keyframes jpd-bot-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(217, 119, 6, 0.6); }
    50%       { box-shadow: 0 0 0 10px rgba(217, 119, 6, 0); }
}

/* Chat window — opens above the toggle, on the right */
#jpd-bot-window {
    position: fixed;
    bottom: 88px;
    right: 24px;
    width: 360px;
    height: 520px;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 10px;
    display: none;
    flex-direction: column;
    z-index: 9998;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    overflow: hidden;
    animation: jpd-bot-slidein 0.22s ease;
    min-width: 280px;
    min-height: 320px;
}

#jpd-bot-window.jpd-bot-visible {
    display: flex;
}

@keyframes jpd-bot-slidein {
    from { opacity: 0; transform: translateY(18px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Header */
#jpd-bot-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: #111;
    border-bottom: 1px solid #333;
    cursor: default;
    user-select: none;
    flex-shrink: 0;
}

#jpd-bot-header img {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: contain;
    flex-shrink: 0;
}

.jpd-bot-header-text {
    flex: 1;
    min-width: 0;
}

.jpd-bot-header-title {
    font-size: 13px;
    font-weight: 600;
    color: #e5e7eb;
    line-height: 1.2;
    font-family: 'Montserrat', sans-serif;
}

.jpd-bot-header-subtitle {
    font-size: 10px;
    color: #888;
    line-height: 1.2;
}

.jpd-bot-header-btns {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.jpd-bot-header-btns button {
    background: none;
    border: none;
    color: #888;
    font-size: 14px;
    cursor: pointer;
    padding: 2px 5px;
    border-radius: 4px;
    line-height: 1;
    transition: color 0.15s, background 0.15s;
}

.jpd-bot-header-btns button:hover {
    color: #d97706;
    background: rgba(217, 119, 6, 0.1);
}

/* Messages area */
#jpd-bot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

#jpd-bot-messages::-webkit-scrollbar {
    width: 5px;
}
#jpd-bot-messages::-webkit-scrollbar-track {
    background: #111;
}
#jpd-bot-messages::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 3px;
}

/* Message bubbles */
.jpd-bot-msg {
    max-width: 90%;
    padding: 8px 11px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.5;
    word-break: break-word;
}

.jpd-bot-msg-user {
    align-self: flex-end;
    background: #d97706;
    color: #fff;
    border-bottom-right-radius: 2px;
}

.jpd-bot-msg-assistant {
    align-self: flex-start;
    background: #2a2a2a;
    color: #e5e7eb;
    border-bottom-left-radius: 2px;
    border: 1px solid #3a3a3a;
}

/* Markdown rendering */
.jpd-bot-msg strong {
    font-weight: 700;
    color: #f9fafb;
}

.jpd-bot-msg a {
    color: #d97706;
    text-decoration: underline;
}

.jpd-bot-msg a:hover {
    color: #f59e0b;
}

.jpd-bot-msg ul, .jpd-bot-msg ol {
    margin: 4px 0;
    padding-left: 18px;
}

.jpd-bot-msg li {
    margin: 2px 0;
}

/* Typing indicator */
.jpd-bot-typing {
    align-self: flex-start;
    background: #2a2a2a;
    color: #888;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 18px;
    letter-spacing: 3px;
    border: 1px solid #3a3a3a;
}

.jpd-bot-typing span {
    display: inline-block;
    animation: jpd-bot-bounce 1.2s infinite;
}

.jpd-bot-typing span:nth-child(2) { animation-delay: 0.2s; }
.jpd-bot-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes jpd-bot-bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
    40%            { transform: translateY(-4px); opacity: 1; }
}

/* Input area */
#jpd-bot-input-area {
    padding: 10px 12px;
    border-top: 1px solid #333;
    background: #111;
    flex-shrink: 0;
}

#jpd-bot-input-row {
    display: flex;
    gap: 7px;
    align-items: flex-end;
}

#jpd-bot-input {
    flex: 1;
    background: #222;
    border: 1px solid #444;
    color: #e5e7eb;
    font-size: 13px;
    padding: 8px 10px;
    border-radius: 6px;
    resize: none;
    max-height: 100px;
    overflow-y: auto;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
    line-height: 1.4;
}

#jpd-bot-input:focus {
    border-color: #d97706;
}

#jpd-bot-input::placeholder {
    color: #555;
}

#jpd-bot-send {
    background: #d97706;
    border: none;
    color: #fff;
    font-size: 15px;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

#jpd-bot-send:hover {
    background: #b45309;
}

#jpd-bot-send:disabled {
    background: #444;
    cursor: not-allowed;
}

/* Powered-by footer */
#jpd-bot-footer {
    text-align: center;
    font-size: 10px;
    color: #555;
    padding: 4px 0 6px;
    background: #111;
    flex-shrink: 0;
}

/* Mobile */
@media (max-width: 480px) {
    #jpd-bot-window {
        width: 100vw !important;
        right: 0 !important;
        bottom: 0 !important;
        border-radius: 10px 10px 0 0;
        height: 70vh !important;
    }

    #jpd-bot-toggle {
        bottom: 16px;
        right: 16px;
    }
}
