/* ═══════════════════════════════════════════════════════════════
   Manual Assistant — Embedded Card Theme
   Matches the site's existing layout (container + section-padding)
   ═══════════════════════════════════════════════════════════════ */

/* ── Variables ──────────────────────────────────────────────────── */
:root {
    --ai-accent: #2563eb;
    --ai-accent-light: #3b82f6;
    --ai-accent-glow: rgba(37, 99, 235, 0.18);
    --ai-accent-gradient: linear-gradient(135deg, #1a6dff 0%, #3b82f6 50%, #60a5fa 100%);
    --ai-bg-card: #ffffff;
    --ai-bg-messages: #fdfdfd;
    --ai-bg-input: #f3f4f6;
    --ai-bg-welcome-btn: #f8faff;
    --ai-border: #f1f5f9;
    --ai-border-focus: rgba(37, 99, 235, 0.4);
    --ai-text-dark: #0f172a;
    --ai-text-main: #1e293b;
    --ai-text-secondary: #475569;
    --ai-text-muted: #94a3b8;
    --ai-text-caption: #9ca3af;
    --text-primary: #1e293b;
    --ai-radius-sm: 10px;
    --ai-radius-md: 14px;
    --ai-radius-lg: 24px;
    --ai-shadow-card: 0 20px 60px -15px rgba(0, 0, 0, 0.10);
    --ai-shadow-blue: 0 4px 12px rgba(37, 99, 235, 0.22);
    --ai-font: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --ai-card-height: 700px;
}

/* ── Wrapper — sits inside .container.section-padding ──────────── */
.app {
    display: flex;
    flex-direction: column;
    height: auto;                        /* shrinks to content */
    max-height: var(--ai-card-height);   /* caps at 700px when full */
    background: var(--ai-bg-card);
    border-radius: var(--ai-radius-lg);
    box-shadow: var(--ai-shadow-card);
    border: 1px solid var(--ai-border);
    overflow: hidden;
    font-family: var(--ai-font);
    font-size: 14px;
    color: var(--ai-text-main);
    -webkit-font-smoothing: antialiased;
}

/* ── Header ─────────────────────────────────────────────────────── */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    background: var(--ai-bg-card);
    border-bottom: 1px solid var(--ai-border);
    flex-shrink: 0;
}

.header__left {
    display: flex;
    align-items: center;
    gap: 14px;
}

/* "UP" badge — mirrors original blue square */
    .header__left::before {
        content: "AI ";
        display: flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        background: var(--ai-accent);
        border-radius: var(--ai-radius-sm);
        color: #fff;
        font-weight: 900;
        font-size: 14px;
        letter-spacing: 0.02em;
        box-shadow: var(--ai-shadow-blue);
        flex-shrink: 0;
    }

.header__title {
    font-size: 15px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--ai-text-dark);
    margin: 0;
    line-height: 1.2;
}

.header__subtitle {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ai-text-secondary);
    opacity: 0.7;
    margin: 2px 0 0;
}

.header__right {
    display: flex;
    align-items: center;
}

/* New Chat button */
.btn-new-chat {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    font-size: 12px;
    font-family: var(--ai-font);
    font-weight: 700;
    color: #fff;
    background: var(--ai-accent-gradient);
    border: none;
    border-radius: var(--ai-radius-sm);
    cursor: pointer;
    box-shadow: var(--ai-shadow-blue);
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
    letter-spacing: 0.02em;
}

.btn-new-chat:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.32);
    filter: brightness(1.06);
}

.btn-new-chat:active {
    transform: translateY(0);
}

/* ── Chat / Messages area ───────────────────────────────────────── */
.chat-area {
    overflow-y: auto;
    max-height: 520px;           /* scrolls after this height */
    padding: 24px;
    background: var(--ai-bg-messages);
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

.chat-area::-webkit-scrollbar        { width: 5px; }
.chat-area::-webkit-scrollbar-track  { background: transparent; }
.chat-area::-webkit-scrollbar-thumb  { background: rgba(148,163,184,0.35); border-radius: 3px; }
.chat-area::-webkit-scrollbar-thumb:hover { background: rgba(148,163,184,0.55); }

/* ── Welcome screen ─────────────────────────────────────────────── */
.welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    flex: 1;
    gap: 20px;
    animation: aiChatFadeIn 0.6s ease;
}

.welcome__title {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--ai-text-dark);
    margin: 0;
    background: linear-gradient(135deg, #0f172a 20%, #2563eb 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome__text {
    font-size: 14px;
    color: var(--ai-text-secondary);
    line-height: 1.8;
    max-width: 480px;
    margin: 0;
}

.welcome__text strong {
    color: var(--ai-accent);
    font-weight: 700;
}

.welcome__examples {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    width: 100%;
    max-width: 560px;
}

.example-btn {
    padding: 14px 18px;
    font-size: 13px;
    font-weight: 500;
    font-family: var(--ai-font);
    color: var(--ai-text-main);
    background: var(--ai-bg-welcome-btn);
    border: 1px solid #e2e8f0;
    border-radius: var(--ai-radius-md);
    cursor: pointer;
    text-align: left;
    line-height: 1.5;
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.example-btn:hover {
    color: #fff;
    background: var(--ai-accent);
    border-color: transparent;
    transform: translateY(-3px);
    box-shadow: var(--ai-shadow-blue);
}

/* ── Message bubbles (injected by JS) ───────────────────────────── */
.message {
    display: flex;
    gap: 12px;
    max-width: 85%;
    animation: aiChatSlideUp 0.35s ease;
}

.message--user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message--bot {
    align-self: flex-start;
}

.message__avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.message--user .message__avatar {
    background: var(--ai-accent-gradient);
    color: #fff;
    box-shadow: var(--ai-shadow-blue);
}

.message--bot .message__avatar {
    background: #f1f5f9;
    color: var(--ai-accent);
    border: 1px solid #e2e8f0;
}

.message__body {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.message__content {
    padding: 12px 12px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.message--user .message__content {
    background: var(--ai-accent);
    color: #fff;
    border-bottom-right-radius: 4px;
    box-shadow: var(--ai-shadow-blue);
}

.message--bot .message__content {
    background: #fff;
    border: 1px solid #eee;
    color: #374151;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

/* Markdown inside bot messages */
.message--bot .message__content strong { color: var(--ai-accent); font-weight: 700; }
.message--bot .message__content ul,
.message--bot .message__content ol    { padding-left: 20px; margin: 8px 0; }
.message--bot .message__content li    { margin: 4px 0; }
.message--bot .message__content code  {
    background: rgba(37, 99, 235, 0.08);
    color: var(--ai-accent);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12.5px;
}

/* ── Typing indicator ───────────────────────────────────────────── */
.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 12px 16px;
    background: #eee;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    width: fit-content;
    align-self: flex-start;
}

.typing-indicator span {
    width: 7px;
    height: 7px;
    background: #9ca3af;
    border-radius: 50%;
    animation: aiTypingDot 1.4s infinite ease-in-out;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

/* ── Source badges ──────────────────────────────────────────────── */
.message__sources { display: flex; flex-wrap: wrap; gap: 6px; }

.source-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    font-size: 11px;
    font-weight: 600;
    color: var(--ai-accent);
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 20px;
    white-space: nowrap;
    transition: background 0.2s ease, transform 0.2s ease;
}

.source-badge:hover {
    background: #dbeafe;
    transform: translateY(-1px);
}

/* ── Input bar ──────────────────────────────────────────────────── */
.input-bar {
    padding: 16px 20px 12px;
    background: var(--ai-bg-card);
    border-top: 1px solid #eee;
    flex-shrink: 0;
}

.input-bar__inner {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: var(--ai-bg-input);
    border-radius: 12px;
    padding: 10px 14px;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
    border: 1.5px solid transparent;
}

.input-bar__inner:focus-within {
    border-color: var(--ai-border-focus);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}

.input-field {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.6;
    resize: none;
    max-height: 160px;
    padding: 8px 6px;
}

.input-field::placeholder {
    color: var(--ai-text-caption);
}

.btn-send {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--ai-accent);
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    flex-shrink: 0;
    box-shadow: 0 3px 8px rgba(37, 99, 235, 0.25);
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.btn-send:hover:not(:disabled) {
    transform: scale(1.1);
    box-shadow: 0 5px 16px rgba(37, 99, 235, 0.35);
}

.btn-send:active:not(:disabled) {
    transform: scale(0.95);
}

.btn-send:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    box-shadow: none;
    background: #94a3b8;
}

.input-bar__disclaimer {
    text-align: center;
    font-size: 9px;
    color: var(--ai-text-caption);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 10px;
    line-height: 1.5;
}

/* ── Animations ─────────────────────────────────────────────────── */
@keyframes aiChatFadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

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

@keyframes aiTypingDot {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.3; }
    30%           { transform: translateY(-6px); opacity: 1; }
}

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 640px) {
    :root { --ai-card-height: 580px; }

    .chat-area { max-height: 400px; }

    .header { padding: 14px 16px; }

    .header__title { font-size: 14px; }
    .header__subtitle { font-size: 8px; }

    .welcome__title { font-size: 18px; }
    .welcome__text  { font-size: 13px; }

    .welcome__examples {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .example-btn { padding: 12px 14px; font-size: 12.5px; }

    .chat-area { padding: 16px; }

    .input-bar { padding: 12px 14px 10px; }
}

/* ── Selection accent ───────────────────────────────────────────── */
::selection {
    background: rgba(37, 99, 235, 0.2);
    color: var(--ai-text-dark);
}
