/* ================================================================
 * Josh AI (Roger-9) — floating chat bubble
 * ================================================================ */

#josh-ai-root {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: 14px;
    color: #1a1a1a;
}

/* ── Toggle button ─────────────────────────────────────────────── */

.josh-ai-toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.35), 0 2px 6px rgba(0, 0, 0, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    padding: 0;
}

.josh-ai-toggle:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 10px 28px rgba(37, 99, 235, 0.45), 0 3px 8px rgba(0, 0, 0, 0.15);
}

.josh-ai-toggle:focus-visible {
    outline: 3px solid #93c5fd;
    outline-offset: 3px;
}

.josh-ai-toggle svg {
    width: 26px;
    height: 26px;
    transition: opacity 0.15s ease, transform 0.2s ease;
}

.josh-ai-toggle .josh-ai-icon-close {
    display: none;
}

.josh-ai-toggle.josh-ai-open .josh-ai-icon-chat {
    display: none;
}

.josh-ai-toggle.josh-ai-open .josh-ai-icon-close {
    display: block;
}

/* ── Panel ─────────────────────────────────────────────────────── */

.josh-ai-panel {
    position: absolute;
    bottom: 72px;
    right: 0;
    width: 360px;
    max-width: calc(100vw - 40px);
    height: 540px;
    max-height: calc(100vh - 120px);
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.18), 0 6px 18px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    animation: joshAiPanelIn 0.22s ease-out;
}

@keyframes joshAiPanelIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.josh-ai-panel[hidden] {
    display: none;
}

/* ── Header ────────────────────────────────────────────────────── */

.josh-ai-header {
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.josh-ai-header-text {
    line-height: 1.2;
}

.josh-ai-title {
    font-weight: 700;
    font-size: 16px;
    letter-spacing: 0.3px;
}

.josh-ai-subtitle {
    font-size: 12px;
    opacity: 0.85;
    margin-top: 2px;
}

.josh-ai-header-close {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    padding: 0 6px;
    opacity: 0.85;
    transition: opacity 0.15s ease;
}

.josh-ai-header-close:hover {
    opacity: 1;
}

/* ── Messages ──────────────────────────────────────────────────── */

.josh-ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

.josh-ai-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    line-height: 1.45;
    word-wrap: break-word;
    animation: joshAiMsgIn 0.22s ease-out;
}

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

.josh-ai-msg-bot {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    color: #1f2937;
}

.josh-ai-msg-user {
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.josh-ai-msg a {
    color: inherit;
    text-decoration: underline;
    font-weight: 500;
}

.josh-ai-msg-user a {
    color: #dbeafe;
}

.josh-ai-msg-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    align-self: flex-start;
}

/* Typing indicator */
.josh-ai-typing {
    display: inline-flex;
    gap: 4px;
    padding: 4px 0;
}

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

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

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

/* ── Suggestions ──────────────────────────────────────────────── */

.josh-ai-suggestions {
    padding: 0 16px 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    background: #f8fafc;
    flex-shrink: 0;
}

.josh-ai-suggestions:empty {
    display: none;
}

.josh-ai-chip {
    background: #fff;
    border: 1px solid #cbd5e1;
    color: #334155;
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
}

.josh-ai-chip:hover {
    background: #eff6ff;
    border-color: #2563eb;
    color: #1e40af;
}

/* ── Input form ───────────────────────────────────────────────── */

.josh-ai-form {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid #e5e7eb;
    background: #fff;
    flex-shrink: 0;
}

.josh-ai-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: 22px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    color: #1f2937;
    background: #fff;
}

.josh-ai-input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.josh-ai-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.josh-ai-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, opacity 0.15s ease;
    flex-shrink: 0;
}

.josh-ai-send:hover:not(:disabled) {
    transform: scale(1.05);
}

.josh-ai-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.josh-ai-send svg {
    width: 18px;
    height: 18px;
}

.josh-ai-footer {
    text-align: center;
    font-size: 11px;
    color: #94a3b8;
    padding: 6px 12px 10px;
    background: #fff;
    flex-shrink: 0;
}

/* ── Mobile ───────────────────────────────────────────────────── */

@media (max-width: 480px) {
    #josh-ai-root {
        bottom: 16px;
        right: 16px;
    }

    .josh-ai-panel {
        width: calc(100vw - 32px);
        height: calc(100vh - 120px);
        bottom: 72px;
        right: 0;
    }
}
