/* Vatsal AI Assistant v1.3.0.7 — assistant chat.
   Design tokens: 4px spacing grid (4/8/12/16/20/24), 15px body, 24px line-height,
   plain assistant replies (no bubble), solid user bubble, one focus ring, 40-44px touch targets. */

.ai-expertise {
    --ai-brand: #1d4ed8;
    --ai-brand-deep: #1e3a8a;
    --ai-ink: #0f172a;
    --ai-text: #1e293b;
    --ai-muted: #64748b;
    --ai-faint: #94a3b8;
    --ai-line: #e5e7eb;
    --ai-wa: #128c7e;
    --ai-radius: 20px;
    --ai-gutter: 20px;
    position: fixed;
    z-index: 99980;
    right: max(16px, env(safe-area-inset-right, 0px));
    bottom: max(148px, calc(env(safe-area-inset-bottom, 0px) + 132px));
    pointer-events: none;
    font-family: inherit;
}

.ai-expertise *,
.ai-expertise *::before,
.ai-expertise *::after {
    box-sizing: border-box;
}

/* ---------------------------------------------------------------- Launcher */
.ai-expertise__launcher {
    pointer-events: auto;
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 56px;
    height: 56px;
    padding: 0;
    border: 2px solid rgba(255, 255, 255, 0.9);
    border-radius: 999px;
    background: linear-gradient(135deg, var(--ai-brand-deep), var(--ai-brand));
    color: #fff;
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    box-shadow: 0 12px 28px -8px rgba(29, 78, 216, 0.55);
    cursor: pointer;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease, box-shadow 0.2s ease;
    touch-action: manipulation;
}

.ai-expertise__launcher::before {
    content: "AI";
    position: absolute;
    top: -6px;
    right: -4px;
    z-index: 1;
    padding: 2px 6px;
    border-radius: 999px;
    background: #fff;
    color: var(--ai-brand);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.04em;
    line-height: 1.2;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.25);
}

.ai-expertise__launcher::after {
    content: "";
    position: absolute;
    inset: -5px;
    border-radius: inherit;
    border: 2px solid rgba(29, 78, 216, 0.35);
    opacity: 0;
    animation: ai-expertise-ping 3.2s ease-out 1.2s 3;
    pointer-events: none;
}

@keyframes ai-expertise-ping {
    0% { opacity: 0.7; transform: scale(0.96); }
    70%, 100% { opacity: 0; transform: scale(1.22); }
}

.ai-expertise__launcher:hover {
    transform: translateY(-2px);
    box-shadow: 0 18px 36px -10px rgba(29, 78, 216, 0.7);
}

.ai-expertise__launcher:focus-visible {
    outline: 2px solid var(--ai-brand);
    outline-offset: 3px;
}

.ai-expertise__launcher-icon { display: inline-flex; }
.ai-expertise__launcher-text { display: none; }

.ai-expertise.is-open .ai-expertise__launcher {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: scale(0.92);
}

body.cookie-banner-visible .ai-expertise {
    bottom: max(228px, calc(env(safe-area-inset-bottom, 0px) + 212px));
}

.ai-expertise__overlay {
    position: fixed;
    inset: 0;
    z-index: 99981;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    pointer-events: auto;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.28s ease, visibility 0.28s ease;
}

.ai-expertise.is-open .ai-expertise__overlay {
    opacity: 1;
    visibility: visible;
}

/* ------------------------------------------------------------------- Panel */
.ai-expertise__panel {
    position: fixed;
    z-index: 99982;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    background: #fff;
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: 0 32px 80px -20px rgba(15, 23, 42, 0.45), 0 2px 8px rgba(15, 23, 42, 0.06);
    color: var(--ai-text);
    pointer-events: auto;
    visibility: hidden;
    opacity: 0;
    transform: translateY(14px) scale(0.985);
    transition: opacity 0.26s ease, transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.26s ease;
}

.ai-expertise.is-open .ai-expertise__panel {
    visibility: visible;
    opacity: 1;
    transform: none;
}

.ai-expertise__handle {
    display: none;
    flex-shrink: 0;
    width: 36px;
    height: 4px;
    margin: 8px auto 0;
    border-radius: 999px;
    background: #d1d5db;
}

/* ------------------------------------------------------------------ Header */
.ai-expertise__head {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    height: 64px;
    padding: 0 12px 0 var(--ai-gutter);
    background: #fff;
    border-bottom: 1px solid var(--ai-line);
}

.ai-expertise__avatar {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--ai-brand-deep), var(--ai-brand));
    color: #fff;
    font-family: var(--ff-head, Sora, system-ui, sans-serif);
    font-size: 15px;
    font-weight: 800;
    line-height: 1;
}

.ai-expertise__avatar--sm { width: 28px; height: 28px; font-size: 12px; }
.ai-expertise__avatar--lg { width: 48px; height: 48px; font-size: 21px; }

.ai-expertise__id { flex: 1; min-width: 0; }

.ai-expertise__title {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    line-height: 20px;
    letter-spacing: -0.005em;
    color: var(--ai-ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-expertise__status {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 2px 0 0;
    font-size: 12px;
    line-height: 16px;
    color: var(--ai-muted);
}

.ai-expertise__dot {
    flex-shrink: 0;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #22c55e;
}

.ai-expertise__actions {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 2px;
}

.ai-expertise__icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--ai-muted);
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.ai-expertise__icon-btn:hover,
.ai-expertise__icon-btn:focus-visible {
    background: #f1f5f9;
    color: var(--ai-ink);
    outline: none;
}

.ai-expertise__icon-btn:focus-visible { box-shadow: 0 0 0 2px var(--ai-brand); }

.ai-expertise__icon-btn--wa { color: var(--ai-wa); }

.ai-expertise__icon-btn--wa:hover,
.ai-expertise__icon-btn--wa:focus-visible {
    background: rgba(18, 140, 126, 0.1);
    color: var(--ai-wa);
}

/* ------------------------------------------------------------------ Scroll */
.ai-expertise__scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #d1d5db transparent;
}

/* ------------------------------------------------------------- Empty state */
.ai-expertise__intro {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px var(--ai-gutter) 12px;
    text-align: center;
}

.ai-expertise__hello {
    margin: 12px 0 4px;
    font-size: 20px;
    font-weight: 700;
    line-height: 28px;
    letter-spacing: -0.015em;
    color: var(--ai-ink);
}

.ai-expertise__lead {
    margin: 0;
    max-width: 300px;
    font-size: 14px;
    line-height: 21px;
    color: var(--ai-muted);
}

.ai-expertise__chips {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 4px var(--ai-gutter) 20px;
}

.ai-expertise__chips-label {
    margin: 0 0 4px 2px;
    font-size: 12px;
    font-weight: 600;
    line-height: 16px;
    letter-spacing: 0.02em;
    color: var(--ai-faint);
}

.ai-expertise.is-chatting .ai-expertise__intro,
.ai-expertise.is-chatting .ai-expertise__chips { display: none; }

/* Suggestion rows (intro + follow-ups) */
.ai-expertise__suggest {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    min-height: 44px;
    padding: 10px 14px;
    border: 1px solid var(--ai-line);
    border-radius: 12px;
    background: #fff;
    color: var(--ai-text);
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    line-height: 20px;
    text-align: left;
    cursor: pointer;
    touch-action: manipulation;
    transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.ai-expertise__suggest svg {
    flex-shrink: 0;
    color: var(--ai-faint);
    transition: transform 0.15s ease, color 0.15s ease;
}

.ai-expertise__suggest:hover,
.ai-expertise__suggest:focus-visible {
    border-color: #bfdbfe;
    background: #f5f9ff;
    color: var(--ai-brand);
    outline: none;
}

.ai-expertise__suggest:hover svg,
.ai-expertise__suggest:focus-visible svg {
    color: var(--ai-brand);
    transform: translateX(2px);
}

.ai-expertise__suggest:focus-visible { box-shadow: 0 0 0 2px var(--ai-brand); }

/* ------------------------------------------------------------ Conversation */
.ai-expertise__log {
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 20px var(--ai-gutter) 24px;
}

.ai-expertise__row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    animation: ai-expertise-rise 0.26s ease both;
}

.ai-expertise__row--user { justify-content: flex-end; }

.ai-expertise__row--bot > .ai-expertise__avatar { margin-top: 1px; }

.ai-expertise__col {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

@keyframes ai-expertise-rise {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

.ai-expertise__msg {
    max-width: 100%;
    font-size: 15px;
    line-height: 24px;
    overflow-wrap: anywhere;
}

.ai-expertise__msg--user {
    max-width: 85%;
    padding: 10px 16px;
    border-radius: 18px 18px 4px 18px;
    background: var(--ai-brand);
    color: #fff;
}

.ai-expertise__msg--bot {
    padding: 2px 0 0;
    background: none;
    border: 0;
    color: var(--ai-text);
}

.ai-expertise__msg-text > :first-child { margin-top: 0; }
.ai-expertise__msg-text > :last-child { margin-bottom: 0; }

.ai-expertise__msg-text p { margin: 0 0 12px; }

.ai-expertise__msg-text ul {
    margin: 0 0 12px;
    padding-left: 20px;
}

.ai-expertise__msg-text li {
    margin: 0 0 6px;
    padding-left: 2px;
}

.ai-expertise__msg-text li::marker { color: var(--ai-faint); }

.ai-expertise__msg-text strong { font-weight: 650; color: var(--ai-ink); }

.ai-expertise__msg-text a {
    color: var(--ai-brand);
    font-weight: 500;
    text-decoration: underline;
    text-decoration-color: rgba(29, 78, 216, 0.35);
    text-underline-offset: 3px;
}

.ai-expertise__msg-text a:hover { text-decoration-color: currentColor; }

.ai-expertise__msg-text.is-streaming::after {
    content: "";
    display: inline-block;
    width: 2px;
    height: 1.05em;
    margin-left: 2px;
    vertical-align: text-bottom;
    background: var(--ai-brand);
    animation: ai-expertise-caret 1s steps(1) infinite;
}

@keyframes ai-expertise-caret { 50% { opacity: 0; } }

/* Boundary / guardrail replies keep a quiet callout so they read as notices */
.ai-expertise__msg--boundary,
.ai-expertise__msg--guardrail {
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid;
    font-size: 14px;
    line-height: 22px;
}

.ai-expertise__msg--boundary { background: #fffbeb; border-color: #fde68a; color: #78350f; }
.ai-expertise__msg--guardrail { background: #fef2f2; border-color: #fecaca; color: #7f1d1d; }

/* Extras appear after the stream ends */
.ai-expertise__extras,
.ai-expertise__meta {
    display: flex;
    flex-direction: column;
    gap: 12px;
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transition: opacity 0.25s ease;
}

.ai-expertise__extras:empty { display: none; }

.ai-expertise__row.is-done .ai-expertise__extras,
.ai-expertise__row.is-done .ai-expertise__meta {
    opacity: 1;
    max-height: 1200px;
    overflow: visible;
}

.ai-expertise__msg-foot { display: flex; }

.ai-expertise__source {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    padding: 6px 12px;
    border: 1px solid var(--ai-line);
    border-radius: 999px;
    color: var(--ai-brand);
    font-size: 13px;
    font-weight: 500;
    line-height: 20px;
    text-decoration: none;
}

.ai-expertise__source::before { content: "↗"; font-weight: 700; }

.ai-expertise__source:hover,
.ai-expertise__source:focus-visible {
    border-color: #bfdbfe;
    background: #f5f9ff;
    outline: none;
}

/* Action row under each answer */
.ai-expertise__meta { flex-direction: row; align-items: center; margin-top: -4px; }

.ai-expertise__tools { display: flex; gap: 2px; margin-left: -6px; }

.ai-expertise__tool {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--ai-faint);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.ai-expertise__tool:hover,
.ai-expertise__tool:focus-visible {
    background: #f1f5f9;
    color: var(--ai-ink);
    outline: none;
}

.ai-expertise__tool:focus-visible { box-shadow: 0 0 0 2px var(--ai-brand); }
.ai-expertise__tool.is-picked,
.ai-expertise__tool.is-done { color: var(--ai-brand); }

/* Typing indicator */
.ai-expertise__typing {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 28px;
    padding: 0;
}

.ai-expertise__typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--ai-faint);
    animation: ai-expertise-dot 1.2s ease-in-out infinite;
}

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

@keyframes ai-expertise-dot {
    0%, 80%, 100% { opacity: 0.35; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-3px); }
}

/* -------------------------------------------------------- CTAs, form, chips */
.ai-expertise__ctas {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
}

.ai-expertise__calendly,
.ai-expertise__wa {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 16px;
    border-radius: 12px;
    color: #fff !important;
    font-size: 14px;
    font-weight: 600;
    line-height: 20px;
    text-align: center;
    white-space: nowrap;
    text-decoration: none !important;
    touch-action: manipulation;
    transition: filter 0.15s ease, transform 0.15s ease;
}

.ai-expertise__calendly { background: var(--ai-brand); }
.ai-expertise__wa { background: var(--ai-wa); }

.ai-expertise__calendly:hover,
.ai-expertise__wa:hover,
.ai-expertise__calendly:focus-visible,
.ai-expertise__wa:focus-visible {
    filter: brightness(1.08);
    transform: translateY(-1px);
    outline: none;
}

.ai-expertise__calendly:focus-visible,
.ai-expertise__wa:focus-visible { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--ai-brand); }

.ai-expertise__lead-form { display: grid; gap: 8px; }

.ai-expertise__lead-form input {
    min-height: 44px;
    padding: 0 14px;
    border: 1px solid #d1d5db;
    border-radius: 12px;
    background: #fff;
    font: inherit;
    font-size: 16px;
    color: var(--ai-ink);
}

.ai-expertise__lead-form input:focus { border-color: var(--ai-brand); outline: none; box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.12); }

.ai-expertise__lead-form button {
    min-height: 44px;
    border: 0;
    border-radius: 12px;
    background: var(--ai-ink);
    color: #fff;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    touch-action: manipulation;
}

.ai-expertise__lead-ok { margin: 0; font-size: 14px; font-weight: 500; color: #047857; }

.ai-expertise__suggestions { display: flex; flex-wrap: wrap; gap: 8px; }
.ai-expertise__suggest--inline {
    width: auto;
    max-width: 100%;
    min-height: 36px;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 13px;
    line-height: 20px;
}
.ai-expertise__suggest--inline svg { display: none; }

/* ---------------------------------------------------------------- Composer */
.ai-expertise__composer {
    flex-shrink: 0;
    padding: 12px var(--ai-gutter) max(16px, env(safe-area-inset-bottom, 0px));
    background: #fff;
    border-top: 1px solid var(--ai-line);
}

.ai-expertise__field {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 6px 6px 6px 16px;
    border: 1px solid #d1d5db;
    border-radius: 16px;
    background: #fff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ai-expertise__field:focus-within {
    border-color: var(--ai-brand);
    box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.1);
}

.ai-expertise .ai-expertise__input,
.ai-expertise .ai-expertise__input:focus,
.ai-expertise .ai-expertise__input:focus-visible {
    flex: 1;
    min-width: 0;
    min-height: 36px;
    max-height: 120px;
    margin: 0;
    padding: 8px 0;
    border: 0 !important;
    outline: none !important;
    box-shadow: none !important;
    background: transparent !important;
    font: inherit;
    font-size: 16px;
    line-height: 20px;
    color: var(--ai-ink);
    resize: none;
}

.ai-expertise__input::placeholder { color: var(--ai-faint); }

.ai-expertise__send {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 12px;
    background: var(--ai-brand);
    color: #fff;
    cursor: pointer;
    touch-action: manipulation;
    transition: background 0.15s ease;
}

.ai-expertise__send:hover:not(:disabled) { background: var(--ai-brand-deep); }
.ai-expertise__send:disabled { background: #e5e7eb; color: #9ca3af; cursor: not-allowed; }
.ai-expertise__send:focus-visible { outline: 2px solid var(--ai-brand); outline-offset: 2px; }

.ai-expertise__note {
    margin: 8px 0 0;
    font-size: 12px;
    line-height: 16px;
    color: var(--ai-faint);
    text-align: center;
}

/* ----------------------------------------------------------------- Desktop */
@media (min-width: 1024px) {
    .ai-expertise {
        bottom: 92px;
        right: max(22px, env(safe-area-inset-right, 0px));
    }

    .ai-expertise__launcher {
        width: auto;
        height: 50px;
        padding: 0 18px 0 14px;
    }

    .ai-expertise__launcher::before { display: none; }
    .ai-expertise__launcher-text { display: inline; }
    .ai-expertise__overlay { display: none; }

    .ai-expertise__panel {
        top: 88px;
        right: 20px;
        bottom: auto;
        left: auto;
        width: min(420px, calc(100vw - 40px));
        height: min(640px, calc(100vh - 190px));
        min-height: 400px;
        border-radius: var(--ai-radius);
    }
}

/* ---------------------------------------------------- Phone / tablet sheet */
@media (max-width: 1023px) {
    .ai-expertise {
        --ai-gutter: 16px;
        right: max(14px, env(safe-area-inset-right, 0px));
        bottom: calc(env(safe-area-inset-bottom, 0px) + 92px);
    }

    .ai-expertise__launcher { width: 54px; height: 54px; box-shadow: 0 10px 24px rgba(15, 23, 42, 0.28); }
    body.cookie-banner-visible .ai-expertise { bottom: calc(env(safe-area-inset-bottom, 0px) + 92px); }

    .ai-expertise__handle { display: block; }

    .ai-expertise__panel {
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        width: 100%;
        height: min(92dvh, 760px);
        max-height: 92dvh;
        border-radius: 24px 24px 0 0;
        border-bottom: 0;
        transform: translateY(100%);
    }

    .ai-expertise.is-open .ai-expertise__panel { transform: none; }

    .ai-expertise__head { height: 60px; }
}

@media (min-width: 768px) and (max-width: 1023px) {
    /* Tablet: centred sheet so line length stays readable */
    .ai-expertise__panel {
        left: 50%;
        right: auto;
        width: min(640px, 100%);
        transform: translate(-50%, 100%);
    }

    .ai-expertise.is-open .ai-expertise__panel { transform: translate(-50%, 0); }
}

@media (max-width: 767px) {
    .ai-expertise { bottom: calc(env(safe-area-inset-bottom, 0px) + 82px); }

    body.cookie-banner-visible .ai-expertise {
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
    }

    .ai-expertise__msg--user { max-width: 88%; }
}

@media (max-width: 440px) {
    .ai-expertise__title-sub { display: none; }
}

@media (max-width: 360px) {
    .ai-expertise__icon-btn { width: 36px; height: 36px; }
}

@media (prefers-reduced-motion: reduce) {
    .ai-expertise__panel,
    .ai-expertise__overlay,
    .ai-expertise__launcher,
    .ai-expertise__row,
    .ai-expertise__extras,
    .ai-expertise__meta,
    .ai-expertise__suggest svg {
        transition: none;
        animation: none;
    }

    .ai-expertise__launcher::after { display: none; }
}
