/* Shared "add words from image / text" modal.
 *
 * Used by the admin words-manager (public/javascripts/edit-words.js) and the
 * user popup on the Quests / Practice pages, all via window.BulkWordAdd
 * (public/javascripts/bulk-word-add.js). Fully self-contained under the .bwa-*
 * namespace so it can drop onto any page without depending on that page's CSS.
 *
 * Visuals mirror the brutalist word-manager modal in
 * public/stylesheets/pages/edit-words.css (.wfill-* / .wbulk-* / .wa-btn*).
 */

.bwa-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.bwa-box {
    background-color: #fff;
    border: 2px solid var(--as-black);
    box-shadow: 6px 6px 0 var(--as-black);
    padding: 20px;
    width: 660px;
    max-width: 100%;
    max-height: 92vh;
    overflow: auto;
}

/* The modal mounts on <body>, outside any page wrapper, so it misses page-level
   box-sizing resets and the Inter font, and bare span/input/textarea/button
   rules elsewhere force Roboto/monospace here. Re-establish both for the
   subtree. */
.bwa-box,
.bwa-box * {
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

.bwa-title {
    font-size: 13px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 14px;
}

.bwa-help {
    font-size: 12px;
    color: var(--as-grey);
    line-height: 1.45;
    margin-bottom: 12px;
}

/* ── Image upload ─────────────────────────────────────────────────────── */

.bwa-upload {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    border: 2px dashed var(--as-black);
    background-color: #fafafa;
    padding: 12px;
    margin-bottom: 12px;
}

.bwa-file-input { display: none; }

.bwa-upload-btn {
    border: 2px solid var(--as-black);
    background-color: var(--as-black);
    color: #fff;
    padding: 10px 16px;
    font-size: 10px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease;
}

.bwa-upload-btn:hover { background-color: var(--as-yellow); color: var(--as-black); }
.bwa-upload-btn:disabled { opacity: 0.5; cursor: default; }

.bwa-upload-hint {
    font-size: 11px;
    color: var(--as-grey);
    line-height: 1.4;
    flex: 1 1 180px;
}

.bwa-upload-status {
    flex: 1 1 100%;
    font-size: 10px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #2a7d2a;
}

.bwa-spinner {
    display: inline-block;
    width: 9px;
    height: 9px;
    margin-right: 6px;
    vertical-align: -1px;
    background-color: var(--as-black);
    animation: bwa-spin 0.9s linear infinite;
}

@keyframes bwa-spin {
    to { transform: rotate(360deg); }
}

.bwa-upload-status.bwa-error { color: var(--as-red); }

/* ── Free-text input ──────────────────────────────────────────────────── */

.bwa-input {
    width: 100%;
    border: 2px solid var(--as-black);
    padding: 10px;
    font-size: 13px;
    resize: vertical;
    margin-bottom: 12px;
}

/* ── Review stage ─────────────────────────────────────────────────────── */

.bwa-stage { max-height: 46vh; overflow: auto; }
.bwa-list { display: flex; flex-direction: column; gap: 8px; }

.bwa-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    border: 1px solid #e0e0e0;
    padding: 6px 8px;
}

.bwa-tag {
    flex: 0 0 auto;
    width: 30px;
    text-align: center;
    font-size: 9px;
    font-weight: 900;
    border: 1px solid var(--as-black);
    padding: 3px 0;
}

.bwa-tag--cz { background-color: var(--as-yellow); }
.bwa-tag--en { background-color: #cffafe; }

.bwa-field {
    flex: 1 1 160px;
    min-width: 140px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Fallback for browsers without flexbox `gap` support (older Safari, some
   in-app/webview browsers): without it, the CZ/EN tag and the type <select>
   sit flush against their neighboring input with zero space, which reads as
   the tag/dropdown overlapping the input to its left. */
@supports not (gap: 1px) {
    .bwa-row > * + * { margin-left: 8px; }
    .bwa-field > * + * { margin-left: 8px; }
}

/* Beats the global `input[type="text"] { min-width: 200px; }` desktop rule
   (public/stylesheets/style.css) on specificity alone — a bare `.bwa-cz`
   class selector loses to that attribute selector, which otherwise forces
   these inputs wider than their flex box and makes them overflow into the
   next field/column. */
.bwa-box .bwa-cz,
.bwa-box .bwa-en {
    flex: 1 1 auto;
    min-width: 0;
    border: 1px solid var(--as-black);
    padding: 6px 8px;
    font-size: 12px;
    /* Global mobile rules (public/stylesheets/style.css, max-width: 1000px)
       set a bare `input { align-self: flex-end }` that isn't overridden by
       anything else here — without this, inputs sink to the bottom of the
       flex row instead of sitting centered with their tag. */
    align-self: center;
}

/* A required English field left blank when the learner tries to add. */
.bwa-en.bwa-invalid {
    border-color: var(--as-red);
    background-color: #fff5f5;
}

/* A word with no Czech translation: shown for context but not addable. */
.bwa-row--no-cz { opacity: 0.72; }
.bwa-cz:disabled,
.bwa-en:disabled {
    background-color: #f2f2f2;
    color: var(--as-grey, #888);
    cursor: not-allowed;
}
.bwa-cz:disabled { font-size: 10.5px; }
.bwa-cz:disabled::placeholder {
    color: var(--as-red, #c0392b);
    opacity: 1;
    font-style: italic;
}

.bwa-type {
    flex: 0 0 auto;
    border: 1px solid var(--as-black);
    padding: 6px 8px;
    font-size: 11px;
    font-weight: 700;
    background-color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    cursor: pointer;
}

.bwa-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    flex: 0 0 auto;
    border: none;
    background: none;
    padding: 0;
    cursor: pointer;
}

.bwa-icon {
    display: block;
    width: 16px;
    height: 16px;
    background-color: var(--as-black);
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-position: center;
    mask-position: center;
    -webkit-mask-image: url(/images/icons8-delete-48.png);
    mask-image: url(/images/icons8-delete-48.png);
    transition: background-color .15s ease;
}

.bwa-remove:hover .bwa-icon { background-color: var(--as-red); }

.bwa-cands {
    flex: 1 1 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding-left: 46px;
}

.bwa-cand {
    font-size: 11px;
    padding: 2px 8px;
    border: 1px solid var(--as-black);
    background-color: #fff;
    color: var(--as-black);
    cursor: pointer;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.bwa-cand:hover { background-color: #fef9c3; }

/* ── Actions / status ─────────────────────────────────────────────────── */

.bwa-actions { display: flex; align-items: center; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

.bwa-btn {
    appearance: none;
    -webkit-appearance: none;
    border: 1px solid var(--as-black);
    background-color: #fff;
    color: var(--as-black);
    padding: 4px 10px;
    cursor: pointer;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.bwa-btn:hover:not(:disabled) { background-color: #fef9c3; }
.bwa-btn:disabled {
    opacity: 1;
    cursor: default;
    background-color: #e5e5e5;
    border-color: #e5e5e5;
    color: var(--as-grey);
    padding: 4px 10px;
    text-decoration: none;
}

.bwa-btn--add {
    background-color: var(--as-yellow);
    border-color: transparent;
    box-shadow: none;
    color: var(--as-black);
}

.bwa-btn--add:hover:not(:disabled) {
    background-color: var(--as-black);
    color: var(--as-yellow);
}

/* Look up again + Close read as underlined links (see login .forgot-password-link). */
.bwa-btn--link {
    border: none;
    background: none;
    padding: 0;
    font-family: var(--font-base);
    font-weight: 500;
    font-size: 11px;
    letter-spacing: 1px;
    color: var(--as-grey);
    text-decoration: underline;
    text-decoration-color: var(--as-yellow);
    text-decoration-thickness: 1px;
    text-underline-offset: 4px;
}

.bwa-btn--link:hover:not(:disabled) { background: none; color: var(--as-yellow); }
.bwa-btn--link:disabled { text-decoration: none; }

.bwa-status {
    margin-top: 10px;
    font-size: 10px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #2a7d2a;
    min-height: 12px;
}

.bwa-status.bwa-error { color: var(--as-red); }

/* ── "Create quest from these words" checkbox ─────────────────────────── */

.bwa-quest-check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 700;
    color: var(--as-black);
    cursor: pointer;
}

.bwa-quest-check-input { cursor: pointer; }
.bwa-quest-check-input:disabled { cursor: default; }

/* A disabled <label> doesn't stop clicks/hover on its own — the checkbox
   itself is disabled, but the tooltip lives on the label so it still shows
   on hover even though the label isn't a form control. */
.bwa-quest-check:has(.bwa-quest-check-input:disabled) { color: var(--as-grey); cursor: default; }

/* ── Quest-creation failure (shown under the button row when the
   "Create quest" checkbox's auto-create fails) ───────────────────────── */

.bwa-quest-error {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 8px;
    border: none;
    background: none;
    padding: 0;
    cursor: help;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--as-red);
}

.bwa-quest-error-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border: 1px solid var(--as-red);
    border-radius: 50%;
    font-size: 10px;
    font-weight: 900;
    text-transform: none;
}

/* This tooltip explains a failure, so it gets a red drop-shadow instead of
   the site-wide yellow one (components/tooltips.css) — beats that rule's
   !important on specificity (three class/attribute selectors vs its two). */
.bwa-box [aria-label].bwa-quest-error:after {
    box-shadow: 4px 4px 0 var(--as-red) !important;
}

.bwa-results { display: flex; flex-direction: column; gap: 4px; }
.bwa-result { font-size: 12px; line-height: 1.4; }
.bwa-result--ok { color: #2a7d2a; }
.bwa-result--upd { color: #1d6fa5; }
.bwa-result--err { color: var(--as-red); }

/* ── Quest shortcut (shown once enough words are added in one session) ──── */

.bwa-quest-shortcut {
    margin-top: 14px;
    padding: 12px;
    border: 2px solid var(--as-black);
    background-color: var(--as-yellow);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.bwa-quest-shortcut-text {
    font-size: 12px;
    font-weight: 800;
    margin: 0;
}

.bwa-quest-shortcut-btn { flex: 0 0 auto; }
