/* ============================================
   ASK AI JAMES — CHAT WIDGET
   ============================================ */

.chat-launcher {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.9rem 1.4rem;
    border: none;
    border-radius: 999px;
    background: var(--midnight-blue);
    color: var(--white);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transition: var(--transition-smooth);
}

.chat-launcher:hover {
    background: var(--midnight-blue-light);
    transform: translateY(-2px);
}

.chat-launcher:focus-visible {
    outline: 3px solid var(--accent-blue);
    outline-offset: 3px;
}

.chat-launcher svg { width: 20px; height: 20px; flex-shrink: 0; }

.chat-panel {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    width: min(400px, calc(100vw - 3rem));
    height: min(580px, calc(100vh - 3rem));
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    opacity: 0;
    transform: translateY(12px) scale(0.98);
    pointer-events: none;
    transition: var(--transition-smooth);
}

.chat-panel.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ---- header ---- */
.chat-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.1rem 1.25rem;
    background: var(--midnight-blue);
    color: var(--white);
}

.chat-header h3 {
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.3;
}

.chat-header p {
    margin-top: 0.15rem;
    font-size: 0.78rem;
    line-height: 1.4;
    opacity: 0.8;
}

.chat-close {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.14);
    color: var(--white);
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    transition: var(--transition-fast);
}

.chat-close:hover { background: rgba(255, 255, 255, 0.28); }

/* ---- messages ---- */
.chat-log {
    flex: 1;
    padding: 1.25rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    background: var(--off-white);
}

.chat-msg {
    max-width: 85%;
    padding: 0.7rem 1rem;
    border-radius: 14px;
    font-size: 0.92rem;
    line-height: 1.6;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.chat-msg.bot {
    align-self: flex-start;
    background: var(--white);
    color: var(--text-dark);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
}

.chat-msg.user {
    align-self: flex-end;
    background: var(--accent-blue);
    color: var(--white);
    border-bottom-right-radius: 4px;
}

.chat-msg.error {
    align-self: flex-start;
    background: #FFF5F5;
    border: 1px solid #FEB2B2;
    color: #9B2C2C;
    border-bottom-left-radius: 4px;
}

/* typing indicator */
.chat-typing { display: inline-flex; gap: 4px; padding: 0.25rem 0; }

.chat-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-light);
    animation: chat-bounce 1.3s infinite ease-in-out;
}

.chat-typing span:nth-child(2) { animation-delay: 0.16s; }
.chat-typing span:nth-child(3) { animation-delay: 0.32s; }

@keyframes chat-bounce {
    0%, 70%, 100% { transform: translateY(0); opacity: 0.45; }
    35%           { transform: translateY(-5px); opacity: 1; }
}

/* ---- suggested prompts ---- */
.chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    padding: 0 1.25rem 0.9rem;
    background: var(--off-white);
}

.chat-suggestions button {
    padding: 0.45rem 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: var(--white);
    color: var(--text-medium);
    font-family: inherit;
    font-size: 0.78rem;
    cursor: pointer;
    transition: var(--transition-fast);
}

.chat-suggestions button:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

/* ---- composer ---- */
.chat-form {
    display: flex;
    gap: 0.5rem;
    padding: 0.85rem;
    border-top: 1px solid var(--border-color);
    background: var(--white);
}

.chat-form textarea {
    flex: 1;
    resize: none;
    max-height: 110px;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.92rem;
    line-height: 1.5;
    color: var(--text-dark);
}

.chat-form textarea:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.chat-send {
    flex-shrink: 0;
    width: 42px;
    border: none;
    border-radius: 10px;
    background: var(--midnight-blue);
    color: var(--white);
    cursor: pointer;
    transition: var(--transition-fast);
}

.chat-send:hover:not(:disabled) { background: var(--midnight-blue-light); }
.chat-send:disabled { opacity: 0.45; cursor: not-allowed; }
.chat-send svg { width: 18px; height: 18px; }

.chat-disclaimer {
    padding: 0 0.85rem 0.7rem;
    background: var(--white);
    color: var(--text-light);
    font-size: 0.68rem;
    text-align: center;
    line-height: 1.4;
}

@media (max-width: 600px) {
    .chat-panel {
        bottom: 0;
        right: 0;
        width: 100vw;
        height: 100dvh;
        border-radius: 0;
        border: none;
    }
    .chat-launcher { bottom: 1rem; right: 1rem; padding: 0.8rem 1.2rem; }
}

@media (prefers-reduced-motion: reduce) {
    .chat-launcher, .chat-panel, .chat-send, .chat-suggestions button { transition: none; }
    .chat-typing span { animation: none; }
}
