/* WP AgentBot Widget — themable via CSS custom properties.
 *
 * Variables fall into three groups:
 *   1. Brand        — overridden per persona by the renderer (--wpab-primary, --wpab-font, etc.)
 *   2. Surface      — overridden by the [data-theme] attribute (bg, text, borders)
 *   3. Structure    — radii, shadow, z-index (rarely overridden)
 *
 * Theme is set as a data attribute on the root: data-theme="light" | "dark".
 */

.wpab-root {
    /* --- Brand (persona) --- */
    --wpab-primary: #4F7FF2;
    --wpab-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

    /* --- Light surface (default) --- */
    --wpab-bg:               #FFFFFF;
    --wpab-bg-soft:          #F5F7FA;
    --wpab-text:             #101828;
    --wpab-text-muted:       #667085;
    --wpab-border:           #E2E6EB;
    --wpab-header-bg:        #101828;
    --wpab-header-text:      #FFFFFF;
    --wpab-assistant-bg:     #FFFFFF;
    --wpab-assistant-text:   #101828;
    --wpab-input-bg:         #FFFFFF;
    --wpab-input-border:     #D0D5DD;
    --wpab-chip-bg:          #FFFFFF;
    --wpab-chip-border:      #D0D5DD;
    --wpab-chip-hover-bg:    #F5F7FA;

    /* --- Structure --- */
    --wpab-radius: 16px;
    --wpab-shadow: 0 18px 48px rgba(16, 24, 40, 0.18);
    --wpab-z: 99999;

    font-family: var(--wpab-font);
    color: var(--wpab-text);
    box-sizing: border-box;
}

/* --- Dark theme overrides --- */
.wpab-root[data-theme="dark"] {
    --wpab-bg:               #1A1F2E;
    --wpab-bg-soft:          #14182A;
    --wpab-text:             #ECEDEE;
    --wpab-text-muted:       #98A2B3;
    --wpab-border:           #2C3344;
    --wpab-header-bg:        #0C1020;
    --wpab-header-text:      #FFFFFF;
    --wpab-assistant-bg:     #232838;
    --wpab-assistant-text:   #ECEDEE;
    --wpab-input-bg:         #232838;
    --wpab-input-border:     #2C3344;
    --wpab-chip-bg:          #232838;
    --wpab-chip-border:      #2C3344;
    --wpab-chip-hover-bg:    #2C3344;
    --wpab-shadow:           0 18px 48px rgba(0, 0, 0, 0.5);
}

.wpab-root *, .wpab-root *::before, .wpab-root *::after { box-sizing: border-box; }

/* --- Floating mode --- */
.wpab-floating {
    position: fixed;
    z-index: var(--wpab-z);
}
.wpab-floating[data-placement="bottom-right"] { right: 24px; bottom: 24px; }
.wpab-floating[data-placement="bottom-left"]  { left:  24px; bottom: 24px; }

/* --- Launcher (button + hover tooltip) --- */
.wpab-launcher { position: relative; display: inline-block; }

.wpab-toggle {
    width: 56px; height: 56px;
    border-radius: 50%;
    background: var(--wpab-primary);
    color: #FFFFFF;
    border: none;
    cursor: pointer;
    box-shadow: var(--wpab-shadow);
    display: flex; align-items: center; justify-content: center;
    transition: transform .15s ease;
    overflow: hidden;   /* clip custom/avatar launcher images to the circle */
    padding: 0;
}
.wpab-toggle:hover { transform: translateY(-2px); }
.wpab-toggle svg { width: 26px; height: 26px; }
.wpab-launcher-img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Hover tooltip beside the launcher */
.wpab-tooltip {
    position: absolute;
    top: 50%;
    right: calc(100% + 12px);
    transform: translateY(-50%) translateX(8px);
    background: var(--wpab-header-bg);
    color: var(--wpab-header-text);
    padding: 9px 13px;
    border-radius: 12px;
    font-size: 13px; line-height: 1.35;
    width: max-content; max-width: 230px;
    box-shadow: var(--wpab-shadow);
    opacity: 0; visibility: hidden;
    transition: opacity .18s ease, transform .18s ease;
    pointer-events: none;
}
.wpab-launcher:hover .wpab-tooltip,
.wpab-root.wpab-tip-show .wpab-tooltip {
    opacity: 1; visibility: visible;
    transform: translateY(-50%) translateX(0);
}
/* bottom-left placement: tooltip sits to the right of the button */
.wpab-floating[data-placement="bottom-left"] .wpab-tooltip {
    right: auto; left: calc(100% + 12px);
    transform: translateY(-50%) translateX(-8px);
}
.wpab-floating[data-placement="bottom-left"] .wpab-launcher:hover .wpab-tooltip,
.wpab-floating[data-placement="bottom-left"].wpab-tip-show .wpab-tooltip {
    transform: translateY(-50%) translateX(0);
}
/* hide the tooltip while the panel is open */
.wpab-root.wpab-open .wpab-tooltip { display: none; }

/* --- Panel --- */
.wpab-panel {
    width: 380px; height: 540px;
    background: var(--wpab-bg);
    border-radius: var(--wpab-radius);
    box-shadow: var(--wpab-shadow);
    overflow: hidden;
    display: none;
    flex-direction: column;
    transition: width .2s ease, height .2s ease;
}
.wpab-floating .wpab-panel { position: absolute; right: 0; bottom: 72px; }
.wpab-floating[data-placement="bottom-left"] .wpab-panel { left: 0; right: auto; }
.wpab-inline .wpab-panel { display: flex; position: relative; width: 100%; max-width: 720px; height: 600px; }

/* --- Standalone (full-page) mode — ChatGPT/Claude-style ---
 *
 * Lands as a clean, minimal full-page chat experience:
 *  - Slim header (just persona name + clear-conversation menu)
 *  - Empty state: large centered greeting, suggested-question CARDS, prominent input
 *  - Conversation state: centered max-width column, big rounded input pinned at bottom
 *
 * The `wpab-empty` class on the root is toggled by JS based on whether the
 * user has sent any messages — that's the switch between the two states.
 */
/* The root becomes a 2-column layout: sidebar (previous chats) + main panel.
 * In v1.1 standalone is fully seamless — no panel chrome, no shadow, no border.
 * The sidebar is the only visible chrome, and even it blends into the page. */
.wpab-standalone {
    display: grid;
    grid-template-columns: 260px 1fr;
    width: 100%;
    margin: 0;
    min-height: 80vh;
    min-height: 80dvh;
    background: var(--wpab-bg);
    position: relative;
}
.wpab-standalone .wpab-panel {
    display: flex;
    position: relative;
    width: 100%;
    max-width: 100%;
    height: 80vh;
    height: 80dvh;
    min-height: 540px;
    background: transparent;
    border-radius: 0;
    box-shadow: none;
    overflow: hidden;
}

/* No header at all in standalone — like ChatGPT/Claude. Identity is established
 * by the welcome greeting in the empty state. The sidebar "New chat" button
 * replaces the 3-dot menu so users can start a fresh conversation directly. */
.wpab-standalone .wpab-header,
.wpab-standalone .wpab-menu { display: none !important; }

/* Legacy in-panel "New chat" button — superseded by the sidebar button. */
.wpab-new-chat { display: none !important; }

/* Messages column — centered, larger type, more breathing room. */
.wpab-standalone .wpab-messages {
    background: transparent;
    padding: 32px 24px 20px;
    gap: 18px;
}
.wpab-standalone .wpab-msg-wrap { max-width: min(800px, 92%); width: 100%; margin: 0 auto; }
.wpab-standalone .wpab-msg {
    font-size: 15.5px;
    line-height: 1.65;
    max-width: 100%;
    padding: 14px 18px;
}
.wpab-standalone .wpab-msg.wpab-user {
    align-self: flex-end;
    max-width: min(680px, 80%);
    margin-right: max(0px, calc((100% - 800px) / 2));
}
/* Assistant bubbles render flat on the page background — no card. */
.wpab-standalone .wpab-msg.wpab-assistant {
    margin-left: max(0px, calc((100% - 800px) / 2));
    background: transparent;
    box-shadow: none;
    padding: 6px 0;
    border-radius: 0;
}

/* Chips — laid out as a 2-column grid of cards (Claude/ChatGPT prompt cards). */
.wpab-standalone .wpab-chips {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    padding: 0 24px 12px;
    max-width: min(800px, 100%);
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}
.wpab-standalone .wpab-chip {
    padding: 14px 16px;
    font-size: 13.5px;
    line-height: 1.4;
    text-align: left;
    border-radius: 14px;
    white-space: normal;
    background: var(--wpab-chip-bg);
    border: 1px solid var(--wpab-chip-border);
    transition: background .12s ease, border-color .12s ease, transform .08s ease;
}
.wpab-standalone .wpab-chip:hover { background: var(--wpab-chip-hover-bg); transform: translateY(-1px); }
@media (max-width: 600px) {
    .wpab-standalone .wpab-chips { grid-template-columns: 1fr; }
}

/* Input — a centered, rounded pill (ChatGPT-style). The form itself IS the
 * pill; textarea is borderless inside, and send button is a round icon. */
.wpab-standalone .wpab-input {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--wpab-input-bg);
    border: 1.5px solid var(--wpab-input-border);
    border-top: 1.5px solid var(--wpab-input-border); /* override default border-top rule */
    border-radius: 28px;
    padding: 6px 6px 6px 18px;
    /* Match the assistant message column width (min(800px, 92%)). */
    max-width: min(800px, 92%);
    margin: 12px auto 28px;
    width: 100%;
    box-shadow: 0 4px 16px rgba(16, 24, 40, 0.05);
    transition: border-color .15s ease, box-shadow .15s ease;
}
.wpab-standalone .wpab-input:focus-within {
    border-color: var(--wpab-primary);
    box-shadow: 0 6px 22px rgba(16, 24, 40, 0.08);
}
.wpab-standalone .wpab-input textarea {
    border: none;
    background: transparent;
    padding: 10px 0;
    min-height: 32px;
    max-height: 180px;
    font-size: 16px;
    line-height: 1.5;
    flex: 1;
}
.wpab-standalone .wpab-input textarea:focus {
    outline: none;
    border: none;
    box-shadow: none;
}
.wpab-standalone .wpab-input button {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
}
.wpab-standalone .wpab-input button svg { width: 16px; height: 16px; }

/* --- Empty-state brand mark (logo above the greeting) ---
 * Hidden in non-empty / non-standalone modes; rendered as a centered logo
 * above the welcome greeting in the standalone empty state.
 */
.wpab-empty-logo { display: none; }
.wpab-standalone.wpab-empty .wpab-empty-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    margin: 0 auto 18px;
    color: var(--wpab-primary);
    order: 0;
}
.wpab-standalone.wpab-empty .wpab-empty-logo svg { width: 100%; height: 100%; }
.wpab-standalone.wpab-empty .wpab-empty-logo img {
    width: 100%; height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

/* --- Empty state (no user messages yet) ---
 * The whole panel content collapses to a centered "landing":
 *  - Brand mark (logo/avatar) centered above the greeting.
 *  - The first assistant message becomes a large centered greeting.
 *  - Input sits below the greeting (visually anchored to the group).
 *  - Suggested-question chips become a horizontal row of pills BELOW the
 *    input — like Claude's "Write / Create / Code" action chips.
 */
.wpab-standalone.wpab-empty .wpab-panel { justify-content: center; }
.wpab-standalone.wpab-empty .wpab-messages {
    flex: 0 0 auto;
    overflow: visible;
    padding-bottom: 4px;
    order: 1;
}
.wpab-standalone.wpab-empty .wpab-msg-wrap:first-child { align-self: center; max-width: min(720px, 100%); }
.wpab-standalone.wpab-empty .wpab-msg-wrap:first-child .wpab-msg.wpab-assistant {
    background: transparent;
    box-shadow: none;
    border: none;
    text-align: center;
    font-size: clamp(22px, 3.4vw, 30px);
    line-height: 1.32;
    font-weight: 500;
    padding: 4px 16px;
    color: var(--wpab-text);
}
/* Hide the copy button on the centered greeting — feels out of place there. */
.wpab-standalone.wpab-empty .wpab-msg-wrap:first-child .wpab-copy { display: none; }

.wpab-standalone.wpab-empty .wpab-input {
    order: 2;
    margin-top: 8px;
    margin-bottom: 16px;
}

/* Chips below the input, as a single centered horizontal row of compact pills. */
.wpab-standalone.wpab-empty .wpab-chips {
    order: 3;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    max-width: min(720px, calc(100% - 48px));
    margin: 0 auto 28px;
    padding: 0;
}
.wpab-standalone.wpab-empty .wpab-chip {
    flex: 0 0 auto;
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 13px;
    line-height: 1.2;
    text-align: center;
    white-space: nowrap;
    max-width: 100%;
}
@media (max-width: 600px) {
    .wpab-standalone.wpab-empty .wpab-chip { white-space: normal; }
}

.wpab-root.wpab-open .wpab-panel { display: flex; }
.wpab-root.wpab-expanded .wpab-panel { width: 680px; height: calc(100vh - 80px); }

/* --- Sidebar (standalone mode only) ---
 *
 * Left rail with a "New chat" button and the list of previous conversations.
 * Hidden in floating/inline modes — those modes never render the sidebar at all,
 * but we belt-and-brace it with display:none anyway.
 *
 * On desktop the sidebar is a permanent 260px column. On mobile it slides in
 * from the left as an overlay, triggered by the hamburger button.
 */
.wpab-sidebar,
.wpab-sidebar-toggle,
.wpab-sidebar-scrim { display: none; }

.wpab-standalone .wpab-sidebar {
    display: flex;
    flex-direction: column;
    height: 80vh;
    height: 80dvh;
    min-height: 540px;
    border-right: 1px solid var(--wpab-border);
    background: var(--wpab-bg-soft);
    overflow: hidden;
}
/* Brand bar — persona avatar + name at the very top of the sidebar.
 * Mirrors the ChatGPT "logo + product name" rail header. */
.wpab-standalone .wpab-sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 14px;
    border-bottom: 1px solid var(--wpab-border);
}
.wpab-standalone .wpab-sidebar-brand .wpab-avatar {
    width: 28px;
    height: 28px;
    font-size: 12px;
}
.wpab-standalone .wpab-sidebar-brand-name {
    font-size: 18px;
    font-weight: 600;
    line-height: 1;
    color: var(--wpab-text);
    letter-spacing: -0.01em;
}

.wpab-standalone .wpab-sidebar-header {
    padding: 12px 12px 10px;
}
.wpab-standalone .wpab-sidebar-new {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 12px;
    background: var(--wpab-bg);
    border: 1px solid var(--wpab-border);
    border-radius: 10px;
    color: var(--wpab-text);
    font-size: 13.5px;
    font-family: inherit;
    cursor: pointer;
    transition: background .12s ease, border-color .12s ease;
}
.wpab-standalone .wpab-sidebar-new:hover {
    background: var(--wpab-chip-hover-bg);
    border-color: var(--wpab-text-muted);
}
.wpab-standalone .wpab-sidebar-new svg { width: 14px; height: 14px; flex-shrink: 0; }

.wpab-standalone .wpab-conv-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 8px 16px;
}
.wpab-standalone .wpab-conv-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    line-height: 1.3;
    color: var(--wpab-text);
    transition: background .1s ease;
}
.wpab-standalone .wpab-conv-item:hover { background: var(--wpab-bg); }
.wpab-standalone .wpab-conv-item.wpab-active {
    background: var(--wpab-bg);
}
.wpab-standalone .wpab-conv-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.wpab-standalone .wpab-conv-delete {
    background: transparent;
    border: none;
    padding: 4px;
    color: var(--wpab-text-muted);
    cursor: pointer;
    border-radius: 4px;
    opacity: 0;
    transition: opacity .1s ease, background .1s ease, color .1s ease;
}
.wpab-standalone .wpab-conv-delete svg { width: 14px; height: 14px; display: block; }
.wpab-standalone .wpab-conv-item:hover .wpab-conv-delete,
.wpab-standalone.wpab-touch .wpab-conv-delete { opacity: .8; }
.wpab-standalone .wpab-conv-delete:hover { opacity: 1; color: #DC2626; background: rgba(220, 38, 38, .08); }

/* --- Mobile sidebar (overlay + hamburger) --- */
@media (max-width: 900px) {
    .wpab-standalone {
        grid-template-columns: 1fr;
        position: relative;
    }
    .wpab-standalone .wpab-sidebar {
        position: absolute;
        top: 0;
        left: 0;
        width: min(280px, 82vw);
        height: 100%;
        z-index: 20;
        transform: translateX(-100%);
        transition: transform .22s ease;
        box-shadow: 4px 0 24px rgba(16, 24, 40, .12);
    }
    .wpab-standalone.wpab-sidebar-open .wpab-sidebar { transform: translateX(0); }
    .wpab-standalone .wpab-sidebar-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        position: absolute;
        top: 14px;
        left: 14px;
        z-index: 15;
        width: 36px;
        height: 36px;
        border: 1px solid var(--wpab-border);
        background: var(--wpab-bg);
        color: var(--wpab-text);
        border-radius: 8px;
        cursor: pointer;
    }
    .wpab-standalone .wpab-sidebar-toggle svg { width: 18px; height: 18px; }
    .wpab-standalone .wpab-sidebar-scrim {
        display: block;
        position: absolute;
        inset: 0;
        background: rgba(16, 24, 40, .35);
        opacity: 0;
        visibility: hidden;
        transition: opacity .18s ease, visibility .18s ease;
        z-index: 18;
    }
    .wpab-standalone.wpab-sidebar-open .wpab-sidebar-scrim {
        opacity: 1;
        visibility: visible;
    }
    /* The empty-state landing nudges down so the hamburger doesn't overlap. */
    .wpab-standalone.wpab-empty .wpab-panel { padding-top: 40px; }
}

/* --- Header --- */
.wpab-header {
    background: var(--wpab-header-bg);
    color: var(--wpab-header-text);
    padding: 14px 16px;
    display: flex; align-items: center; gap: 12px;
}
.wpab-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--wpab-primary);
    overflow: hidden;
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    color: #FFFFFF; font-weight: 600; font-size: 14px;
}
.wpab-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.wpab-header .wpab-title { font-weight: 600; font-size: 15px; line-height: 1.1; }
.wpab-header .wpab-tagline { font-size: 12px; opacity: .7; line-height: 1.2; margin-top: 2px; }
.wpab-header-spacer { flex: 1; }
.wpab-icon-btn {
    background: transparent; border: none; color: inherit; opacity: .7; cursor: pointer;
    padding: 4px; border-radius: 4px;
}
.wpab-icon-btn:hover { opacity: 1; background: rgba(255,255,255,.08); }
.wpab-icon-btn svg { width: 18px; height: 18px; }

/* --- Messages --- */
.wpab-messages {
    flex: 1; overflow-y: auto; padding: 16px;
    display: flex; flex-direction: column; gap: 10px;
    background: var(--wpab-bg-soft);
}
.wpab-msg { max-width: 85%; padding: 10px 14px; border-radius: 14px; font-size: 14px; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; }
.wpab-msg.wpab-user      { align-self: flex-end; background: var(--wpab-primary); color: #FFFFFF; border-bottom-right-radius: 4px; }
.wpab-msg.wpab-assistant { align-self: flex-start; background: var(--wpab-assistant-bg); color: var(--wpab-assistant-text); border-bottom-left-radius: 4px; box-shadow: 0 1px 2px rgba(16,24,40,.06); }
.wpab-msg.wpab-assistant p:first-child { margin-top: 0; }
.wpab-msg.wpab-assistant p:last-child  { margin-bottom: 0; }
.wpab-msg.wpab-assistant strong { font-weight: 600; }
.wpab-msg.wpab-assistant ul, .wpab-msg.wpab-assistant ol { margin: .25em 0 .25em 1.25em; padding: 0; }
.wpab-msg.wpab-assistant li { margin: .1em 0; }
.wpab-msg.wpab-assistant h3, .wpab-msg.wpab-assistant h4, .wpab-msg.wpab-assistant h5 { margin: .6em 0 .3em; }

/* Streaming cursor */
.wpab-msg.wpab-streaming::after {
    content: '▍';
    display: inline-block;
    margin-left: 2px;
    color: var(--wpab-primary);
    animation: wpab-blink 1s steps(2, start) infinite;
}
@keyframes wpab-blink { to { visibility: hidden; } }

/* Copy button under assistant messages */
.wpab-msg-wrap { position: relative; align-self: flex-start; max-width: 85%; }
.wpab-msg-wrap .wpab-copy {
    position: absolute; right: -8px; bottom: -24px;
    background: var(--wpab-bg); border: 1px solid var(--wpab-border); color: var(--wpab-text-muted);
    font-size: 11px; padding: 2px 8px; border-radius: 999px; cursor: pointer;
    opacity: 0; transition: opacity .15s ease;
}
.wpab-msg-wrap:hover .wpab-copy, .wpab-touch .wpab-copy { opacity: 1; }

/* Typing indicator */
.wpab-typing { display: inline-flex; gap: 4px; padding: 12px 14px; background: var(--wpab-assistant-bg); border-radius: 14px; box-shadow: 0 1px 2px rgba(16,24,40,.06); align-self: flex-start; }
.wpab-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--wpab-text-muted); animation: wpab-bounce 1.2s infinite; }
.wpab-typing span:nth-child(2) { animation-delay: .15s; }
.wpab-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes wpab-bounce { 0%, 80%, 100% { transform: translateY(0); opacity: .4; } 40% { transform: translateY(-4px); opacity: 1; } }

/* Suggested-question chips */
.wpab-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 4px 4px; }
.wpab-chip {
    background: var(--wpab-chip-bg);
    color: var(--wpab-text);
    border: 1px solid var(--wpab-chip-border);
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
    font-family: inherit;
    transition: background .12s ease;
    line-height: 1.2;
}
.wpab-chip:hover { background: var(--wpab-chip-hover-bg); }

/* --- Input --- */
.wpab-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--wpab-border); background: var(--wpab-bg); }
.wpab-input textarea {
    flex: 1; resize: none; border: 1px solid var(--wpab-input-border); border-radius: 10px;
    padding: 10px 12px; font-size: 14px; font-family: inherit; max-height: 120px;
    color: var(--wpab-text); background: var(--wpab-input-bg);
}
.wpab-input textarea::placeholder { color: var(--wpab-text-muted); }
.wpab-input textarea:focus { outline: none; border-color: var(--wpab-primary); }
.wpab-input button {
    background: var(--wpab-primary); color: #FFFFFF; border: none;
    width: 40px; height: 40px; border-radius: 10px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.wpab-input button:disabled { opacity: .5; cursor: not-allowed; }
.wpab-input button svg { width: 18px; height: 18px; }

/* Clear-conversation menu */
.wpab-menu { position: relative; }
.wpab-menu-dropdown {
    position: absolute; right: 0; top: 100%; margin-top: 4px;
    background: var(--wpab-bg); color: var(--wpab-text);
    border: 1px solid var(--wpab-border); border-radius: 8px;
    box-shadow: var(--wpab-shadow);
    min-width: 180px; padding: 4px 0; display: none; z-index: 10;
}
.wpab-menu-dropdown.wpab-show { display: block; }
.wpab-menu-dropdown button {
    display: block; width: 100%; text-align: left; padding: 8px 12px;
    background: transparent; border: none; cursor: pointer; font-size: 13px;
    color: inherit; font-family: inherit;
}
.wpab-menu-dropdown button:hover { background: var(--wpab-bg-soft); }

/* Mobile */
/* --- Mobile (large phones included) ---
 * Pin the panel to the viewport with BOTH side edges so it can never bleed
 * off-screen, regardless of theme viewport quirks or the launcher offset.
 */
@media (max-width: 600px) {
    .wpab-floating .wpab-panel,
    .wpab-root.wpab-expanded .wpab-panel {
        position: fixed;
        left: 10px;
        right: 10px;
        bottom: 86px;
        top: auto;
        width: auto;
        height: auto;
        max-height: calc(100vh - 104px);
        max-height: calc(100dvh - 104px); /* account for mobile browser chrome */
    }
    /* Keep the launcher and its tooltip on-screen */
    .wpab-floating[data-placement="bottom-right"],
    .wpab-floating[data-placement="bottom-left"] {
        right: 16px; left: auto; bottom: 16px;
    }
    .wpab-floating[data-placement="bottom-left"] { left: 16px; right: auto; }
    .wpab-tooltip { max-width: 60vw; font-size: 12px; }
}
