/* ================================================================
   ADDED (round 3) — investor-facing AI assistant widget.
   Additive only: styles the FAB + chat panel mounted by
   js/assistant.js into #wp-assistant-root. Uses the site's own
   design tokens (--ink/--muted/--soft/--line/--card/--blue/--teal,
   --shadow/--shadow-soft) so the existing [data-theme="dark"]
   variable overlay applies automatically; a few explicit dark
   overrides mirror the conventions in style.css.
   ================================================================ */

.wpa-root {
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* ---------- floating action button ---------- */

.wpa-fab {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 1500;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 52px;
    padding: 12px 20px 12px 14px;
    border: 1px solid rgba(15, 23, 42, 0.18);
    border-radius: 999px;
    background: linear-gradient(135deg, var(--blue), var(--teal));
    color: #ffffff;
    font: inherit;
    font-size: 0.95rem;
    font-weight: 750;
    letter-spacing: 0.01em;
    cursor: pointer;
    box-shadow:
        0 20px 44px -18px rgba(37, 99, 235, 0.55),
        0 8px 20px -10px rgba(15, 23, 42, 0.35);
}

.wpa-fab .wpa-fab-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.18);
}

.wpa-fab .wpa-fab-icon svg {
    width: 66%;
    height: 66%;
    display: block;
    color: currentColor;
}

.wpa-fab:hover {
    filter: brightness(1.06);
}

.wpa-root.wpa-open .wpa-fab {
    display: none;
}

/* ---------- panel ---------- */

.wpa-panel {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 1500;
    display: flex;
    flex-direction: column;
    padding: 0; /* neutralize the site-wide `section { padding: 88px 0 }` */
    width: min(400px, calc(100vw - 40px));
    height: min(640px, calc(100dvh - 104px));
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--card);
    box-shadow:
        var(--shadow),
        0 4px 14px rgba(15, 23, 42, 0.10);
}

.wpa-panel[hidden] {
    display: none;
}

.wpa-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, var(--soft), var(--card));
}

.wpa-avatar {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 11px;
    background: linear-gradient(135deg, var(--blue), var(--teal));
    color: #ffffff;
    font-size: 1rem;
    font-weight: 900;
    letter-spacing: -0.02em;
    box-shadow: var(--shadow-soft);
}

.wpa-heading {
    min-width: 0;
    flex: 1 1 auto;
}

.wpa-title {
    margin: 0;
    color: var(--ink);
    font-size: 0.98rem;
    font-weight: 800;
    line-height: 1.25;
}

.wpa-subtitle {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 0.74rem;
    line-height: 1.35;
}

.wpa-close {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--card);
    color: var(--muted);
    font: inherit;
    cursor: pointer;
}

.wpa-close:hover {
    color: var(--ink);
    border-color: var(--blue);
}

.wpa-close svg {
    width: 16px;
    height: 16px;
    display: block;
}

/* ---------- message log ---------- */

.wpa-log {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overscroll-behavior: contain;
}

.wpa-msg {
    max-width: 88%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.9rem;
    line-height: 1.55;
    overflow-wrap: break-word;
}

.wpa-msg-user {
    align-self: flex-end;
    border-bottom-right-radius: 5px;
    background: var(--blue);
    color: #ffffff;
    white-space: pre-wrap;
}

.wpa-msg-assistant {
    align-self: flex-start;
    border: 1px solid var(--line);
    border-bottom-left-radius: 5px;
    background: var(--soft);
    color: var(--ink);
}

.wpa-msg-assistant p {
    margin: 0 0 8px;
}

.wpa-msg-assistant p:last-child,
.wpa-msg-assistant ul:last-child,
.wpa-msg-assistant ol:last-child {
    margin-bottom: 0;
}

.wpa-msg-assistant ul,
.wpa-msg-assistant ol {
    margin: 0 0 8px;
    padding-left: 20px;
}

.wpa-msg-assistant li {
    margin: 2px 0;
}

.wpa-msg-assistant a {
    color: var(--blue);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.wpa-msg-assistant code {
    padding: 1px 5px;
    border-radius: 5px;
    background: rgba(15, 23, 42, 0.07);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.82em;
}

.wpa-msg-error {
    align-self: flex-start;
    max-width: 88%;
    padding: 10px 14px;
    border: 1px solid rgba(190, 18, 60, 0.35);
    border-radius: 14px;
    background: rgba(190, 18, 60, 0.06);
    color: var(--rose);
    font-size: 0.85rem;
    line-height: 1.5;
}

.wpa-retry {
    display: inline-flex;
    margin-top: 8px;
    padding: 6px 12px;
    border: 1px solid rgba(190, 18, 60, 0.4);
    border-radius: 8px;
    background: var(--card);
    color: var(--rose);
    font: inherit;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
}

.wpa-retry:hover {
    background: rgba(190, 18, 60, 0.08);
}

/* typing indicator */

.wpa-typing {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 12px 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    border-bottom-left-radius: 5px;
    background: var(--soft);
}

.wpa-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--muted);
    opacity: 0.5;
}

/* ---------- starter chips ---------- */

.wpa-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 2px 0 4px;
}

.wpa-chip {
    padding: 8px 13px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--card);
    color: var(--ink);
    font: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.3;
    cursor: pointer;
    text-align: left;
}

.wpa-chip:hover {
    border-color: var(--blue);
    color: var(--blue);
}

/* ---------- composer ---------- */

.wpa-form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 14px 8px;
    border-top: 1px solid var(--line);
    background: var(--card);
}

.wpa-input {
    flex: 1 1 auto;
    min-height: 42px;
    max-height: 120px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: var(--card);
    color: var(--ink);
    font: inherit;
    font-size: 0.9rem;
    line-height: 1.45;
    resize: none;
}

.wpa-input::placeholder {
    color: var(--muted);
}

.wpa-input:focus-visible {
    outline: 3px solid rgba(37, 99, 235, 0.34);
    outline-offset: 1px;
}

.wpa-send {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border: 1px solid var(--blue);
    border-radius: 11px;
    background: var(--blue);
    color: #ffffff;
    font: inherit;
    cursor: pointer;
}

.wpa-send:hover:not(:disabled) {
    filter: brightness(1.08);
}

.wpa-send:disabled {
    opacity: 0.45;
    cursor: default;
}

.wpa-send svg {
    width: 18px;
    height: 18px;
    display: block;
}

.wpa-note {
    margin: 0;
    padding: 0 16px 10px;
    color: var(--muted);
    font-size: 0.68rem;
    line-height: 1.4;
    text-align: center;
    background: var(--card);
}

.wpa-note a {
    color: inherit;
}

/* ---------- motion (opt-in only) ---------- */

@media (prefers-reduced-motion: no-preference) {
    .wpa-fab {
        transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
    }

    .wpa-fab:hover {
        transform: translateY(-2px);
    }

    .wpa-panel {
        animation: wpa-pop 0.22s ease-out;
    }

    .wpa-typing span {
        animation: wpa-blink 1.1s infinite ease-in-out;
    }

    .wpa-typing span:nth-child(2) {
        animation-delay: 0.18s;
    }

    .wpa-typing span:nth-child(3) {
        animation-delay: 0.36s;
    }

    @keyframes wpa-pop {
        from {
            opacity: 0;
            transform: translateY(14px) scale(0.98);
        }

        to {
            opacity: 1;
            transform: none;
        }
    }

    @keyframes wpa-blink {

        0%,
        80%,
        100% {
            opacity: 0.35;
        }

        40% {
            opacity: 1;
        }
    }
}

/* ---------- mobile: full-width bottom sheet ---------- */

@media (max-width: 640px) {
    .wpa-panel {
        right: 0;
        bottom: 0;
        left: 0;
        width: 100%;
        height: min(86dvh, 640px);
        border-radius: 16px 16px 0 0;
        border-right: 0;
        border-bottom: 0;
        border-left: 0;
    }

    .wpa-fab {
        right: 16px;
        bottom: 16px;
    }

    .wpa-form {
        padding-bottom: max(8px, env(safe-area-inset-bottom));
    }
}

/* ---------- dark mode (token overlay + explicit tweaks) ---------- */

:root[data-theme="dark"] .wpa-fab {
    border-color: rgba(147, 197, 253, 0.28);
    box-shadow:
        0 20px 44px -18px rgba(0, 0, 0, 0.65),
        0 8px 20px -10px rgba(37, 99, 235, 0.35);
}

:root[data-theme="dark"] .wpa-panel {
    background: linear-gradient(180deg, #111f34 0%, #0e1a2d 100%);
}

:root[data-theme="dark"] .wpa-header {
    background: linear-gradient(180deg, #14213a, rgba(16, 29, 49, 0));
}

:root[data-theme="dark"] .wpa-close,
:root[data-theme="dark"] .wpa-chip {
    background: #14213a;
}

:root[data-theme="dark"] .wpa-chip:hover {
    border-color: #3b5b86;
    color: #93c5fd;
}

:root[data-theme="dark"] .wpa-msg-assistant,
:root[data-theme="dark"] .wpa-typing {
    background: #0f1b2e;
}

:root[data-theme="dark"] .wpa-msg-assistant a {
    color: #93c5fd;
}

:root[data-theme="dark"] .wpa-msg-assistant code {
    background: rgba(148, 163, 184, 0.16);
}

:root[data-theme="dark"] .wpa-msg-error {
    border-color: rgba(251, 113, 133, 0.4);
    background: rgba(190, 18, 60, 0.16);
    color: #fda4af;
}

:root[data-theme="dark"] .wpa-retry {
    background: #14213a;
    border-color: rgba(251, 113, 133, 0.45);
    color: #fda4af;
}

:root[data-theme="dark"] .wpa-input,
:root[data-theme="dark"] .wpa-form,
:root[data-theme="dark"] .wpa-note {
    background: transparent;
}

:root[data-theme="dark"] .wpa-input {
    background: #0f1b2e;
}
