/* ============================================================
   Ask AI-Jason Widget — ask-ai-jason.css
   Living Lights Publishing © 2025
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600&family=Source+Serif+4:ital,wght@0,300;0,400;0,600;1,300&display=swap');

:root {
    --aaj-primary:      #8B4513;
    --aaj-primary-dark: #6b3410;
    --aaj-primary-lt:   #f5ede6;
    --aaj-bg:           #fffdf9;
    --aaj-card:         #ffffff;
    --aaj-border:       #e8ddd4;
    --aaj-text:         #2c1f17;
    --aaj-muted:        #7a6860;
    --aaj-ai-bg:        #f8f1eb;
    --aaj-user-bg:      var(--aaj-primary);
    --aaj-radius:       14px;
    --aaj-shadow:       0 4px 24px rgba(139,69,19,0.12), 0 1px 4px rgba(0,0,0,0.06);
    --aaj-font-head:    'Playfair Display', Georgia, serif;
    --aaj-font-body:    'Source Serif 4', Georgia, serif;
}

/* ── Container ── */
.aaj-widget {
    font-family: var(--aaj-font-body);
    font-size: 15px;
    color: var(--aaj-text);
    background: var(--aaj-card);
    border: 1px solid var(--aaj-border);
    border-radius: var(--aaj-radius);
    box-shadow: var(--aaj-shadow);
    overflow: hidden;
    max-width: 680px;
    margin: 2rem auto;
    display: flex;
    flex-direction: column;
}

/* ── Header ── */
.aaj-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: linear-gradient(135deg, var(--aaj-primary) 0%, var(--aaj-primary-dark) 100%);
    color: white;
}

.aaj-avatar {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.4);
    overflow: hidden;
}

.aaj-avatar svg {
    width: 100%;
    height: 100%;
    display: block;
}

.aaj-header-text {
    flex: 1;
}

.aaj-header-text h3 {
    margin: 0;
    font-family: var(--aaj-font-head);
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    letter-spacing: 0.01em;
}

.aaj-subtitle {
    font-size: 0.72rem;
    opacity: 0.78;
    font-style: italic;
    font-weight: 300;
}

.aaj-status {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.72rem;
    opacity: 0.85;
}

.aaj-dot {
    width: 7px;
    height: 7px;
    background: #4ade80;
    border-radius: 50%;
    animation: aaj-pulse 2s infinite;
}

@keyframes aaj-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ── Conversation ── */
.aaj-conversation {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-height: 140px;
    max-height: 440px;
    overflow-y: auto;
    background: var(--aaj-bg);
    scroll-behavior: smooth;
}

.aaj-conversation::-webkit-scrollbar      { width: 4px; }
.aaj-conversation::-webkit-scrollbar-track { background: transparent; }
.aaj-conversation::-webkit-scrollbar-thumb { background: var(--aaj-border); border-radius: 2px; }

/* ── Messages ── */
.aaj-message {
    display: flex;
    gap: 10px;
    animation: aaj-fadein 0.3s ease;
}

@keyframes aaj-fadein {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.aaj-message--user {
    flex-direction: row-reverse;
}

.aaj-bubble {
    max-width: 88%;
    padding: 11px 15px;
    border-radius: var(--aaj-radius);
    line-height: 1.65;
    font-size: 0.92rem;
}

.aaj-message--ai .aaj-bubble {
    background: var(--aaj-ai-bg);
    border: 1px solid var(--aaj-border);
    border-bottom-left-radius: 4px;
    color: var(--aaj-text);
}

.aaj-message--user .aaj-bubble {
    background: var(--aaj-user-bg);
    color: white;
    border-bottom-right-radius: 4px;
}

.aaj-bubble p {
    margin: 0 0 0.6em;
}

.aaj-bubble p:last-child {
    margin-bottom: 0;
}

.aaj-bubble strong {
    font-weight: 600;
    color: var(--aaj-primary);
}

.aaj-message--user .aaj-bubble strong {
    color: rgba(255,255,255,0.9);
}

.aaj-bubble a {
    color: var(--aaj-primary);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.aaj-message--user .aaj-bubble a {
    color: rgba(255,255,255,0.85);
}

/* Deeper dive section inside AI bubble */
.aaj-dig-deeper {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--aaj-border);
    font-size: 0.85rem;
}

.aaj-dig-deeper h4 {
    margin: 0 0 6px;
    font-family: var(--aaj-font-head);
    font-size: 0.82rem;
    color: var(--aaj-primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.aaj-dig-deeper ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.aaj-dig-deeper li {
    margin-bottom: 6px;
    padding-left: 14px;
    position: relative;
}

.aaj-dig-deeper li::before {
    content: '→';
    position: absolute;
    left: 0;
    color: var(--aaj-primary);
}

/* ── Typing indicator ── */
.aaj-typing .aaj-bubble {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 14px 18px;
    min-width: 56px;
}

.aaj-typing .aaj-dot-anim {
    width: 7px;
    height: 7px;
    background: var(--aaj-muted);
    border-radius: 50%;
    animation: aaj-bounce 1.2s infinite;
}

.aaj-typing .aaj-dot-anim:nth-child(2) { animation-delay: 0.2s; }
.aaj-typing .aaj-dot-anim:nth-child(3) { animation-delay: 0.4s; }

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

/* ── Suggestions ── */
.aaj-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    padding: 10px 16px 0;
}

.aaj-chip {
    font-family: var(--aaj-font-body);
    font-size: 0.78rem;
    padding: 5px 12px;
    background: var(--aaj-primary-lt);
    color: var(--aaj-primary-dark);
    border: 1px solid rgba(139,69,19,0.2);
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    white-space: nowrap;
}

.aaj-chip:hover {
    background: rgba(139,69,19,0.15);
    transform: translateY(-1px);
}

/* ── Input row ── */
.aaj-input-area {
    padding: 12px 16px 14px;
    background: var(--aaj-card);
    border-top: 1px solid var(--aaj-border);
}

.aaj-input-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    margin-top: 10px;
}

#aaj-input {
    flex: 1;
    font-family: var(--aaj-font-body);
    font-size: 0.9rem;
    line-height: 1.5;
    padding: 9px 13px;
    border: 1.5px solid var(--aaj-border);
    border-radius: 10px;
    resize: none;
    background: var(--aaj-bg);
    color: var(--aaj-text);
    transition: border-color 0.2s;
    overflow: hidden;
}

#aaj-input:focus {
    outline: none;
    border-color: var(--aaj-primary);
    box-shadow: 0 0 0 3px rgba(139,69,19,0.1);
}

#aaj-input::placeholder { color: var(--aaj-muted); font-style: italic; }

.aaj-send {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border: none;
    border-radius: 10px;
    background: var(--aaj-primary);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, transform 0.1s;
}

.aaj-send:hover  { background: var(--aaj-primary-dark); transform: scale(1.05); }
.aaj-send:active { transform: scale(0.97); }
.aaj-send svg    { width: 16px; height: 16px; }
.aaj-send:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.aaj-footer-note {
    font-size: 0.69rem;
    color: var(--aaj-muted);
    text-align: center;
    margin-top: 8px;
    font-style: italic;
}

.aaj-footer-note a {
    color: var(--aaj-primary);
}

/* ── Error message ── */
.aaj-error .aaj-bubble {
    background: #fff3f3;
    border-color: #f5c0c0;
    color: #b91c1c;
}

/* ── Responsive ── */
@media (max-width: 500px) {
    .aaj-widget { border-radius: 0; margin: 0; }
    .aaj-bubble { max-width: 94%; font-size: 0.88rem; }
    .aaj-suggestions { padding: 8px 12px 0; }
    .aaj-chip { font-size: 0.73rem; }
}

/* ── Source buttons below AI answer ── */
.aaj-sources {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--aaj-border);
}

.aaj-sources-label {
    font-family: var(--aaj-font-head);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--aaj-primary);
    margin-bottom: 8px;
}

.aaj-sources-list {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.aaj-src-btn {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 9px 13px;
    background: var(--aaj-primary-lt);
    border: 1px solid rgba(139,69,19,0.18);
    border-radius: 8px;
    text-decoration: none !important;
    transition: background 0.15s, border-color 0.15s, transform 0.1s, box-shadow 0.15s;
    cursor: pointer;
}

.aaj-src-btn:hover {
    background: rgba(139,69,19,0.13);
    border-color: rgba(139,69,19,0.35);
    transform: translateX(3px);
    box-shadow: 0 2px 8px rgba(139,69,19,0.12);
}

.aaj-src-arrow {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    background: var(--aaj-primary);
    color: white;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.82rem;
    font-weight: 700;
    margin-top: 1px;
}

.aaj-src-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.aaj-src-text strong {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--aaj-primary-dark);
    line-height: 1.3;
}

.aaj-src-note {
    font-size: 0.77rem;
    color: var(--aaj-muted);
    font-style: italic;
    line-height: 1.4;
}

/* ── Body lists inside AI answer ── */
.aaj-bubble p { margin: 0 0 0.7em; }
.aaj-bubble p:last-of-type { margin-bottom: 0; }


