/* ==========================================================================
   Mikrofon vid alla textfält (public/js/dictate-auto.js, VoiceModule.dictateButton)
   --------------------------------------------------------------------------
   Laddas FÖRE sidans egen stil (styles.css, rc.css), så att sidans regler för
   mikrofonen och raden Lyssnar … Klar går före. Adminsidan har inga egna —
   där gäller de här (samma utseende som tavlans, med INCA:s färger som reserv).
   ========================================================================== */

.wb-dict-wrap { display: flex; align-items: flex-start; gap: 8px; }
.wb-dict-wrap[hidden], .dict-auto[hidden] { display: none; }
.wb-dict {
    display: none;               /* visas först när servern har talet påslaget */
    position: relative;
    flex: 0 0 auto;
    box-sizing: border-box;
    width: 52px; height: 52px;
    place-items: center;
    padding: 0;
    border-radius: 50%;
    border: 2px solid var(--interactive, #015e9f);
    background: var(--bg-card, #ffffff);
    color: var(--interactive, #015e9f);
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
body.voice-on:not(.wb-readonly):not(.sandbox-mode):not(.replay-mode):not(.cinema-mode):not(.rc-no-stt) .wb-dict { display: grid; }
body.voice-on:not(.wb-readonly):not(.sandbox-mode):not(.replay-mode):not(.cinema-mode):not(.rc-no-stt) .wb-dict-wrap { padding-right: 8px; }
.wb-dict svg { width: 24px; height: 24px; }
.wb-dict:active { transform: scale(0.94); }
.wb-dict--live {
    background: var(--accent-fire, #f0833d);
    border-color: var(--accent-fire, #f0833d);
    color: #ffffff;
    animation: dictAutoPulse 1.2s ease-in-out infinite;
}
.wb-dict--busy { color: transparent; }
.wb-dict--busy::after {
    content: '';
    position: absolute; inset: 12px;
    border-radius: 50%;
    border: 3px solid #d8dbe0;
    border-top-color: var(--interactive, #015e9f);
    animation: dictAutoSpin 0.8s linear infinite;
}
.wb-dict-bar {
    display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px;
    box-sizing: border-box;
    margin-top: 8px;
    padding: 6px 6px 6px 12px;
    border: 2px solid var(--accent-fire, #f0833d);
    border-radius: 12px;
    background: #fff4ec;
    color: #000000;
    font-size: 16px; font-weight: 800;
    text-align: left;
}
.wb-dict-bar[hidden] { display: none; }
.wb-dict-status { flex: 0 1 auto; min-width: 0; }
.wb-dict-dot, .wb-dict-meter, .wb-dict-time, .wb-dict-btn { display: none; }
.wb-dict-dot {
    flex: 0 0 auto;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: var(--accent-fire, #f0833d);
    animation: dictAutoBlink 1s ease-in-out infinite;
}
.wb-dict-meter { flex: 1 1 60px; min-width: 40px; height: 28px; color: var(--accent-fire, #f0833d); }
.wb-dict-time { font-variant-numeric: tabular-nums; color: #666666; }
.wb-dict-btn {
    min-height: 48px;
    padding: 0 16px;
    border: 2px solid #9aa3ad;
    border-radius: 10px;
    background: #ffffff;
    color: #000000;
    font: inherit; font-size: 16px; font-weight: 900;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.wb-dict-stop { min-width: 88px; border-color: var(--accent-fire, #f0833d); background: var(--accent-fire, #f0833d); color: #ffffff; }
.wb-dict-undo { margin-left: auto; border-color: var(--interactive, #015e9f); color: var(--interactive, #015e9f); }
.wb-dict-bar[data-state="starting"] .wb-dict-cancel,
.wb-dict-bar[data-state="recording"] .wb-dict-cancel,
.wb-dict-bar[data-state="recording"] .wb-dict-stop,
.wb-dict-bar[data-state="done"] .wb-dict-undo { display: inline-flex; align-items: center; justify-content: center; }
.wb-dict-bar[data-state="starting"] .wb-dict-cancel,
.wb-dict-bar[data-state="recording"] .wb-dict-cancel { margin-left: auto; }
.wb-dict-bar[data-state="recording"] .wb-dict-dot,
.wb-dict-bar[data-state="recording"] .wb-dict-meter { display: block; }
.wb-dict-bar[data-state="recording"] .wb-dict-time { display: inline; }
.wb-dict-bar[data-state="recording"] .wb-dict-status { color: #a84a0c; }
.wb-dict-bar[data-state="transcribing"] { border-color: var(--interactive, #015e9f); background: #eef5fb; min-height: 52px; }
.wb-dict-bar[data-state="transcribing"] .wb-dict-dot {
    display: block;
    width: 18px; height: 18px;
    background: none;
    border: 3px solid #d8dbe0;
    border-top-color: var(--interactive, #015e9f);
    animation: dictAutoSpin 0.8s linear infinite;
}
.wb-dict-bar[data-state="done"] { border-color: var(--interactive, #015e9f); background: #eef5fb; color: var(--interactive, #015e9f); }
.wb-dict-bar[data-state="done"] .wb-dict-status::before { content: '✓ '; }
.wb-dict-bar[data-state="error"] { border-color: #9aa3ad; background: #ffffff; color: #d32f2f; min-height: 52px; }

/* ── Fälten som dictate-auto.js gav en mikrofon ──────────────────────────── */

/* Bredvid (som tavlans): fältet krymper, mikrofonen till höger. */
.dict-auto--beside { align-items: flex-start; min-width: 0; }
.dict-auto--beside > input,
.dict-auto--beside > textarea,
.dict-auto--beside > [data-dictate-wrap] { flex: 1 1 auto; min-width: 0; }
.dict-auto--beside > .wb-dict { align-self: flex-start; }
/* Fältet som lyssnar lyser orange (i kanten räcker den orange mikrofonen). */
.wb-dict-wrap--live:not(.dict-auto--edge) > input,
.wb-dict-wrap--live:not(.dict-auto--edge) > textarea,
.wb-dict-wrap--live:not(.dict-auto--edge) > [data-dictate-wrap] input {
    border-color: var(--accent-fire, #f0833d) !important;
    box-shadow: 0 0 0 3px rgba(240, 131, 61, 0.3);
}

/* I fältets kant (sökfältet, fält i en rad med knappar): fältet behåller sin plats i raden,
   mikrofonen ligger inne i högerkanten och raden Lyssnar … Klar svävar under fältet. */
.dict-auto--edge { position: relative; display: block; min-width: 0; box-sizing: border-box; }
.dict-auto--edge > input,
.dict-auto--edge > textarea { width: 100%; box-sizing: border-box; }
body.voice-on:not(.wb-readonly):not(.sandbox-mode):not(.replay-mode):not(.cinema-mode):not(.rc-no-stt) .dict-auto--edge > input,
body.voice-on:not(.wb-readonly):not(.sandbox-mode):not(.replay-mode):not(.cinema-mode):not(.rc-no-stt) .dict-auto--edge > textarea { padding-right: 48px; }
.dict-auto--edge > .wb-dict {
    position: absolute;
    right: 0; top: 50%;
    width: 44px; height: 44px;
    margin-top: -22px;
    border-color: transparent;
    background: transparent;
}
.dict-auto--edge > .wb-dict--live {
    background: var(--accent-fire, #f0833d);
    border-color: var(--accent-fire, #f0833d);
    color: #ffffff;
}
.dict-auto--edge > .wb-dict--busy::after { inset: 9px; }
.dict-auto--edge > .wb-dict-bar {
    position: absolute;
    top: calc(100% + 6px); left: 0; right: 0;
    margin-top: 0;
    z-index: 60;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
}

@keyframes dictAutoPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(240, 131, 61, 0.55); } 50% { box-shadow: 0 0 0 8px rgba(240, 131, 61, 0); } }
@keyframes dictAutoSpin { to { transform: rotate(360deg); } }
@keyframes dictAutoBlink { 50% { opacity: 0.25; } }
@media (prefers-reduced-motion: reduce) {
    .wb-dict--live, .wb-dict-dot { animation: none; }
}
@media print {
    .wb-dict, .wb-dict-bar { display: none !important; }
}
