/**
 * bug_reporter.css — v4. Single canonical stylesheet for the bug reporter.
 *
 * Loaded on every top-level page that owns the reporter. Embedded iframes
 * never need this file: their reporter is a postMessage proxy with no DOM.
 *
 * All v3 defensive rules (legacy bb-/bbk- ids, [data-audit-dock], CSS-mode
 * gating in css/05-auth.css) are GONE. The JS suppresses the badge inside
 * iframes directly so CSS no longer needs to know about modes.
 *
 * Selectors are scoped under #aifi-bug-* and .br- so they never collide
 * with workflow CSS. The badge attaches to #aifi-floating-root when that
 * portal exists (so X-Ray + Ask AI keep their layout) and falls back to
 * position:fixed on document.body otherwise.
 */

/* ── Floating badge ─────────────────────────────────────────────────── */
#aifi-bug-badge {
    position: absolute;
    bottom: 18px;
    right: 18px;
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px 10px 13px;
    border-radius: 999px;
    background: #f28b3c;
    border: none;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
    font-size: 0.8rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s, transform 0.15s;
    font-family: system-ui, sans-serif;
    text-decoration: none;
    outline: none;
    /* The pipeline editor's tool popup uses z-index 100000-100001 with a
       backdrop-filter: blur(6px). At any z-index below 100001 the bug
       pill renders BEHIND the popup and gets visually blurred to the
       point of being unusable. Use the 32-bit signed-int max so nothing
       in the app — popup, admin drawer, lightbox, future modal — can
       ever stack above the reporter. The overlay sits one above. */
    z-index: 2147483646;
}
/* When the badge attaches to body (no floating root), pin it ourselves. */
body > #aifi-bug-badge { position: fixed; }
#aifi-bug-badge:hover  { background: #e07b2c; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.55); }
#aifi-bug-badge:active { transform: translateY(1px); }
#aifi-bug-badge .br-icon  { font-size: 0.95rem; line-height: 1; }
#aifi-bug-badge .br-label { white-space: nowrap; }

/* ── Modal overlay ──────────────────────────────────────────────────── */
#aifi-bug-overlay {
    position: absolute;
    inset: 0;
    pointer-events: auto;
    background: rgba(8, 10, 16, 0.55);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    font-family: system-ui, sans-serif;
    /* Outranks every host stacking context (pipeline modals, menu shell,
       admin drawers). Badge sits at 2147483646, overlay one above. The
       badge is hidden behind the overlay anyway when open. */
    z-index: 2147483647;
}
body > #aifi-bug-overlay { position: fixed; }
#aifi-bug-overlay.is-open { display: flex; }

#aifi-bug-panel {
    background: rgba(16, 18, 28, 0.98);
    color: #e2e8f0;
    border: 1px solid rgba(242, 139, 60, 0.3);
    border-radius: 14px;
    padding: 18px 18px 14px;
    width: 100%;
    max-width: 460px;
    max-height: 92vh;
    overflow: auto;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
}

.br-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}
.br-title {
    font-size: 0.92rem;
    font-weight: 800;
    color: #f28b3c;
}
.br-slug-pill {
    font-size: 0.65rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.55);
    background: rgba(255, 255, 255, 0.06);
    padding: 3px 8px;
    border-radius: 999px;
    margin-left: 8px;
}
.br-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}
.br-close:hover { color: #fff; }

/* ── Guest banner (shown when current_user is anonymous) ─────────────── */
.br-guest-banner {
    background: rgba(242, 139, 60, 0.12);
    border: 1px solid rgba(242, 139, 60, 0.35);
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 12px;
    font-size: 0.78rem;
    color: #fde9d4;
}
.br-guest-link {
    color: #f28b3c;
    font-weight: 700;
    text-decoration: underline;
}
.br-guest-link:hover { color: #fff; }

/* ── Category picker ────────────────────────────────────────────────── */
.br-categories {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 14px;
}
.br-cat-btn {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 12px 12px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    border: 1.5px solid rgba(255, 255, 255, 0.08);
    color: #e2e8f0;
    cursor: pointer;
    transition: all 0.15s;
    text-align: left;
    font-family: inherit;
}
.br-cat-btn:hover { background: rgba(255, 255, 255, 0.07); border-color: rgba(242, 139, 60, 0.4); }
.br-cat-btn.is-on { border-color: #f28b3c; background: rgba(242, 139, 60, 0.12); }
.br-cat-btn.br-cat-pass {
    grid-column: 1 / -1;
    border-color: rgba(34, 197, 94, 0.45);
    background: rgba(34, 197, 94, 0.08);
}
.br-cat-btn.br-cat-pass:hover  { border-color: #22c55e; background: rgba(34, 197, 94, 0.18); }
.br-cat-btn.br-cat-pass.is-on  { border-color: #22c55e; background: rgba(34, 197, 94, 0.22); }
.br-cat-emoji { font-size: 1.4rem; flex-shrink: 0; }
.br-cat-label { font-size: 0.76rem; font-weight: 600; line-height: 1.2; }

/* ── Notes & screenshot ─────────────────────────────────────────────── */
.br-section-label {
    display: block;
    font-size: 0.64rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(255, 255, 255, 0.45);
    margin: 10px 0 5px;
}
.br-notes {
    width: 100%;
    box-sizing: border-box;
    min-height: 70px;
    resize: vertical;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #e2e8f0;
    padding: 8px 10px;
    font-size: 0.8rem;
    font-family: inherit;
}
.br-notes:focus { outline: none; border-color: rgba(242, 139, 60, 0.5); }

.br-shot-row { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.br-shot-zone {
    flex: 1;
    min-height: 56px;
    border: 1.5px dashed rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: border-color 0.15s, background 0.15s;
}
.br-shot-zone:hover { border-color: rgba(242, 139, 60, 0.5); background: rgba(242, 139, 60, 0.04); }
.br-shot-zone.is-dragover { border-color: #f28b3c; background: rgba(242, 139, 60, 0.12); }
.br-shot-zone.has-image   { padding: 4px; }
.br-shot-hint { font-size: 0.68rem; color: rgba(255, 255, 255, 0.45); text-align: center; padding: 6px; }
.br-shot-img  { display: none; max-width: 100%; max-height: 110px; border-radius: 4px; }
.br-shot-zone.has-image .br-shot-img  { display: block; }
.br-shot-zone.has-image .br-shot-hint { display: none; }
.br-shot-actions { display: flex; flex-direction: column; gap: 5px; flex-shrink: 0; }
.br-shot-snap {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid rgba(242, 139, 60, 0.4);
    background: rgba(242, 139, 60, 0.08);
    color: #f28b3c;
    font-weight: 700;
    font-size: 0.72rem;
    cursor: pointer;
    white-space: nowrap;
}
.br-shot-snap:hover { background: rgba(242, 139, 60, 0.18); }
.br-shot-upload {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.04);
    color: rgba(255, 255, 255, 0.6);
    font-weight: 700;
    font-size: 0.72rem;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, border-color 0.15s;
}
.br-shot-upload:hover { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.3); color: #fff; }
@media (max-width: 720px) {
    .br-shot-snap--desktop { display: none; }
    .br-shot-actions { flex-direction: row; flex-wrap: wrap; }
    .br-shot-upload { border-color: rgba(255, 255, 255, 0.2); }
}

/* ── Advanced (admin/tester only) ───────────────────────────────────── */
.br-advanced-toggle {
    font-size: 0.68rem;
    color: rgba(255, 255, 255, 0.4);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    margin-top: 6px;
    text-decoration: underline;
}
.br-advanced-toggle:hover { color: #f28b3c; }
.br-advanced { display: none; margin-top: 8px; padding-top: 10px; border-top: 1px dashed rgba(255, 255, 255, 0.1); }
.br-advanced.is-open { display: block; }
.br-adv-row { display: flex; gap: 8px; margin-bottom: 6px; }
.br-adv-row select,
.br-adv-row input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: #e2e8f0;
    padding: 6px 8px;
    font-size: 0.75rem;
}
.br-adv-context {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 6px;
    padding: 8px;
    font-family: Menlo, Consolas, monospace;
    font-size: 0.67rem;
    color: rgba(255, 255, 255, 0.55);
    max-height: 120px;
    overflow: auto;
    white-space: pre-wrap;
}

/* ── Footer / submit ────────────────────────────────────────────────── */
.br-foot {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 14px;
}
.br-submit {
    flex: 1;
    padding: 10px;
    border-radius: 8px;
    border: none;
    background: #f28b3c;
    color: #fff;
    font-weight: 800;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s;
}
.br-submit:hover    { background: #e07b2c; }
.br-submit:disabled { opacity: 0.5; cursor: not-allowed; }
.br-msg {
    font-size: 0.72rem;
    color: #22c55e;
    min-height: 16px;
    margin-top: 4px;
    text-align: center;
}
.br-msg.is-error { color: #ef4444; }
