/**
 * KOP Bug Reporter Widget
 * Floating "Report a problem" button + modal. Colors come from css/colors.css.
 */

/* Small feature-scoped bug link, injected into containers tagged with
   data-kop-bug-feature (or via KOPBugReporter.attach). Icon-only at rest;
   the "Report a bug" label slides out on hover/focus. The !important flags
   defend against the theme's global button styling (white text, shadows,
   uppercase), which otherwise wins on hover. */
.kop-bug-report-link,
.kop-bug-report-link:hover,
.kop-bug-report-link:focus,
.kop-bug-report-link:focus-visible,
.kop-bug-report-link:active {
    display: inline-flex;
    align-items: center;
    margin: 6px 0 0;
    padding: 3px 6px;
    background: none;
    border: none !important;
    border-radius: 999px;
    box-shadow: none !important;
    color: var(--kop-navy, #000080) !important;
    font-size: 0.78rem !important;
    font-weight: 600;
    line-height: 1 !important;
    letter-spacing: normal !important;
    text-transform: none !important;
    text-decoration: none;
    cursor: pointer;
    opacity: 0.55;
}

.kop-bug-report-link__icon {
    font-size: 0.95rem;
    line-height: 1;
}

.kop-bug-report-link__text {
    max-width: 0;
    margin-left: 0;
    overflow: hidden;
    white-space: nowrap;
    opacity: 0;
    transition: max-width 0.2s ease, opacity 0.2s ease, margin-left 0.2s ease;
}

.kop-bug-report-link:hover,
.kop-bug-report-link:focus-visible {
    opacity: 1;
    background: var(--kop-soft-pastel-yellow, #FFF5CB);
}

.kop-bug-report-link:hover .kop-bug-report-link__text,
.kop-bug-report-link:focus-visible .kop-bug-report-link__text {
    /* Generous cap — only paces the slide-out; must never clip the label. */
    max-width: 16em;
    margin-left: 5px;
    opacity: 1;
}

/* Small screens / touch: hover can't reveal the label, so show it always
   and give the button a comfortable tap size. */
@media (hover: none), (max-width: 640px) {
    .kop-bug-report-link,
    .kop-bug-report-link:hover,
    .kop-bug-report-link:focus,
    .kop-bug-report-link:focus-visible,
    .kop-bug-report-link:active {
        padding: 7px 12px;
        min-height: 32px;
        opacity: 0.75;
        background: var(--kop-soft-pastel-yellow, #FFF5CB);
        border: 1px solid var(--kop-teal, #33A7B5) !important;
    }

    .kop-bug-report-link__text {
        max-width: none;
        margin-left: 6px;
        opacity: 1;
        transition: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .kop-bug-report-link__text {
        transition: none;
    }
}

/* "Reporting a problem with: <feature>" chip at the top of the modal */
.kop-bug-reporter__feature {
    margin: 0 0 12px;
    padding: 6px 10px;
    background: var(--kop-mint, #B6E3D4);
    border: 1px solid var(--kop-teal, #33A7B5);
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--kop-midnight-blue, #000435);
}

.kop-bug-reporter__feature[hidden] {
    display: none;
}

/* Overlay + panel */
.kop-bug-reporter__overlay {
    position: fixed;
    inset: 0;
    z-index: 99995;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0, 4, 53, 0.55);
}

.kop-bug-reporter__overlay[hidden] {
    display: none;
}

.kop-bug-reporter__panel {
    width: 100%;
    max-width: 520px;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    background: var(--kop-sand, #F2EEDF);
    border: 2px solid var(--kop-midnight-blue, #000435);
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 4, 53, 0.35);
}

.kop-bug-reporter__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: var(--kop-midnight-blue, #000435);
    border-radius: 9px 9px 0 0;
}

.kop-bug-reporter__title {
    margin: 0;
    font-size: 1.1rem;
    color: #fff;
}

.kop-bug-reporter__close {
    border: none;
    background: transparent;
    color: #fff;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
}

.kop-bug-reporter__form {
    padding: 16px 18px 18px;
}

.kop-bug-reporter__label {
    display: block;
    margin: 12px 0 4px;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--kop-midnight-blue, #000435);
}

.kop-bug-reporter__label:first-child {
    margin-top: 0;
}

.kop-bug-reporter__input {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    border: 1px solid var(--kop-navy, #000080);
    border-radius: 6px;
    background: #fff;
    color: var(--kop-midnight-blue, #000435);
    font-size: 0.95rem;
    font-family: inherit;
}

.kop-bug-reporter__input:focus {
    outline: 2px solid var(--kop-teal, #33A7B5);
    outline-offset: 1px;
}

.kop-bug-reporter__textarea {
    resize: vertical;
    min-height: 70px;
}

/* Honeypot: off-screen, not display:none (some bots skip hidden inputs) */
.kop-bug-reporter__hp {
    position: absolute;
    left: -9999px;
    top: -9999px;
    height: 1px;
    width: 1px;
    overflow: hidden;
}

.kop-bug-reporter__tech {
    margin-top: 14px;
    padding: 10px;
    background: var(--kop-soft-pastel-yellow, #FFF5CB);
    border: 1px dashed var(--kop-teal, #33A7B5);
    border-radius: 6px;
    font-size: 0.85rem;
}

.kop-bug-reporter__checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    cursor: pointer;
    color: var(--kop-midnight-blue, #000435);
}

.kop-bug-reporter__checkbox-label input {
    margin-top: 2px;
}

.kop-bug-reporter__tech-preview {
    margin-top: 8px;
}

.kop-bug-reporter__tech-preview summary {
    cursor: pointer;
    color: var(--kop-navy, #000080);
    text-decoration: underline;
}

.kop-bug-reporter__tech-pre {
    margin: 8px 0 0;
    padding: 8px;
    max-height: 160px;
    overflow: auto;
    background: #fff;
    border-radius: 4px;
    font-size: 0.75rem;
    white-space: pre-wrap;
    word-break: break-word;
}

.kop-bug-reporter__status {
    min-height: 1.2em;
    margin: 12px 0 0;
    font-size: 0.9rem;
}

.kop-bug-reporter__status--error {
    color: #b00020;
    font-weight: 600;
}

.kop-bug-reporter__status--success {
    color: var(--kop-navy, #000080);
    font-weight: 600;
}

.kop-bug-reporter__actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 14px;
}

.kop-bug-reporter__btn {
    padding: 9px 18px;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border: 2px solid var(--kop-midnight-blue, #000435);
}

.kop-bug-reporter__btn--primary {
    background: var(--kop-teal, #33A7B5);
    color: #fff;
    border-color: var(--kop-teal, #33A7B5);
}

.kop-bug-reporter__btn--primary:disabled {
    opacity: 0.6;
    cursor: default;
}

.kop-bug-reporter__btn--ghost {
    background: transparent;
    color: var(--kop-midnight-blue, #000435);
}

.kop-bug-reporter--modal-open {
    overflow: hidden;
}

@media (max-width: 640px) {
    .kop-bug-reporter__overlay {
        align-items: flex-end;
        padding: 0;
    }

    .kop-bug-reporter__panel {
        max-width: none;
        max-height: 92vh;
        border-radius: 12px 12px 0 0;
        border-bottom: none;
    }

    .kop-bug-reporter__header {
        border-radius: 9px 9px 0 0;
    }
}

