/* JAY AI Chat Plugin — Inline Widget + Modal (no FAB) */

/* ── Floating chat bar ───────────────────────────────────────────────── */
@keyframes jaySlideUp {
    from { transform: translateX(-50%) translateY(100%); opacity: 0; }
    to   { transform: translateX(-50%) translateY(0);    opacity: 1; }
}

.jay-ai-inline-wrap {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    margin: 0;
    z-index: 99999;
    padding: 12px 20px 16px;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: none;
    border-top: none;
    border-radius: 16px 16px 0 0;
    animation: jaySlideUp 0.4s cubic-bezier(0.34,1.56,0.64,1) both;
}

@media (max-width: 520px) {
    @keyframes jaySlideUp {
        from { transform: translateY(100%); opacity: 0; }
        to   { transform: translateY(0);    opacity: 1; }
    }
    .jay-ai-inline-wrap {
        left: 0;
        transform: none;
        max-width: 100%;
        border-radius: 0;
        padding: 10px 16px max(env(safe-area-inset-bottom, 0px), 16px);
    }
}

.jay-ai-inline-glow {
    position: absolute;
    inset: -2px;
    background: linear-gradient(90deg, #1B96FE, #8B5CF6);
    border-radius: 18px;
    filter: blur(6px);
    opacity: 0.2;
    transition: opacity 0.3s;
    pointer-events: none;
    display: none;
}

.jay-ai-inline-wrap:hover .jay-ai-inline-glow,
.jay-ai-inline-wrap:focus-within .jay-ai-inline-glow {
    opacity: 0;
}

.jay-ai-inline-bar {
    position: relative;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    z-index: 1;
}

.jay-ai-inline-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.jay-ai-pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1B96FE, #8B5CF6);
    animation: jayPulse 2s ease-in-out infinite;
}

@keyframes jayPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(0.85); }
}

.jay-ai-label {
    font-size: 11px;
    font-weight: 700;
    color: #1B96FE;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

@media (max-width: 480px) {
    .jay-ai-label { display: none; }
}

.jay-ai-inline-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    font-size: 14px;
    color: #1f2937;
    font-family: inherit;
    min-width: 0;
}

.jay-ai-inline-input::placeholder { color: #9ca3af; }

.jay-ai-inline-btn {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, #1B96FE, #8B5CF6);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.2s, transform 0.2s;
    box-shadow: 0 2px 8px rgba(27,150,254,0.35);
}

.jay-ai-inline-btn:hover {
    opacity: 0.9;
    transform: scale(1.05);
}

/* ── Modal overlay ───────────────────────────────────────────────── */
.jay-ai-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.jay-ai-hidden { display: none !important; }

.jay-ai-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.jay-ai-modal-box {
    position: relative;
    width: 100%;
    max-width: 480px;
    height: 580px;
    max-height: 90vh;
    background: rgba(255,255,255,0.97);
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    border: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 1;
    animation: jayModalIn 0.25s cubic-bezier(0.34,1.56,0.64,1) both;
}

@keyframes jayModalIn {
    from { opacity: 0; transform: scale(0.92) translateY(20px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── Modal header ────────────────────────────────────────────────── */
.jay-ai-modal-header {
    background: linear-gradient(135deg, #EEF6FF, #F5F0FF);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.jay-ai-modal-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.jay-ai-modal-avatar {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: rgba(27,150,254,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.jay-ai-modal-name {
    font-size: 14px;
    font-weight: 700;
    color: #1f2937;
    margin: 0;
    font-family: 'Lexend', 'Nunito', sans-serif;
}

.jay-ai-modal-sub {
    font-size: 12px;
    color: #9ca3af;
    margin: 2px 0 0;
}

.jay-ai-modal-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #f3f4f6;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.jay-ai-modal-close:hover { background: #e5e7eb; }

/* ── Messages area ───────────────────────────────────────────────── */
.jay-ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: rgba(255,255,255,0.6);
}

.jay-ai-messages::-webkit-scrollbar { width: 4px; }
.jay-ai-messages::-webkit-scrollbar-track { background: transparent; }
.jay-ai-messages::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }

.jay-ai-msg-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.jay-ai-msg-user {
    flex-direction: row-reverse;
}

.jay-ai-msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #EEF6FF;
    border: 1px solid #DBEAFE;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.jay-ai-msg-user .jay-ai-msg-avatar {
    background: #f3f4f6;
    border-color: #e5e7eb;
}

.jay-ai-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 13.5px;
    line-height: 1.55;
    max-width: 78%;
}

.jay-ai-bubble-bot {
    background: rgba(219,234,254,0.5);
    border: 1px solid rgba(147,197,253,0.4);
    border-top-left-radius: 4px;
    color: #374151;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.jay-ai-bubble-user {
    background: rgba(27,150,254,0.08);
    border: 1px solid rgba(27,150,254,0.18);
    border-top-right-radius: 4px;
    color: #1f2937;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.jay-ai-welcome-bold {
    font-weight: 600;
    color: #374151;
    margin: 0;
}

/* ── Typing indicator ────────────────────────────────────────────── */
.jay-ai-typing {
    display: flex;
    gap: 4px;
    padding: 6px 2px;
    align-items: center;
}

.jay-ai-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(27,150,254,0.45);
    animation: jayBounce 1s infinite;
}

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

@keyframes jayBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

/* ── Input area ──────────────────────────────────────────────────── */
.jay-ai-input-wrap {
    padding: 12px 16px;
    background: #ffffff;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

.jay-ai-chat-input {
    flex: 1;
    background: #f9fafb;
    border: 1px solid #d1d5db;
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 13.5px;
    color: #1f2937;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.jay-ai-chat-input:focus {
    border-color: rgba(27,150,254,0.5);
    box-shadow: 0 0 0 3px rgba(27,150,254,0.1);
}

.jay-ai-chat-input::placeholder { color: #9ca3af; }

.jay-ai-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: rgba(27,150,254,0.08);
    border: 1px solid rgba(27,150,254,0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.15s;
    flex-shrink: 0;
}

.jay-ai-send-btn:hover {
    background: rgba(27,150,254,0.15);
    transform: scale(1.05);
}

/* ── Markdown rendering inside bubbles ───────────────────────────── */
.jay-ai-bubble a {
    color: #1B96FE;
    text-decoration: underline;
}

.jay-ai-bubble a:hover { opacity: 0.8; }

.jay-ai-bubble strong { color: #111827; }

.jay-ai-bubble code {
    background: rgba(27,150,254,0.1);
    color: #1e40af;
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 12px;
    font-family: monospace;
}

.jay-ai-bubble ul {
    margin: 4px 0;
    padding: 0;
    list-style: none;
}

.jay-ai-bubble li::before {
    content: '• ';
    color: #1B96FE;
}

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 520px) {
    .jay-ai-modal-box {
        height: 85vh;
        max-height: 85vh;
        border-radius: 20px 20px 0 0;
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
    }

    .jay-ai-modal-overlay {
        padding: 0;
        align-items: flex-end;
    }
}
