/* Tyck till (public/js/feedback-module.js): redigeraren med skärmbilden, Ny bild,
   kortet "Rättat: …" och knappen i tavlans toppfält. Laddas av både tavlan
   (index.html) och adminsidan, därför egna färger i stället för styles.css-variabler.
   INCA:s färger: orange #f0833d (Skicka, aktivt), blå #015e9f (toppraden, info). */

.fb-root[hidden], .fb-root [hidden], .fb-cam-wrap [hidden] { display: none !important; }
.fb-root, .fb-root *, .fb-cam-wrap, .fb-cam-wrap *, .fb-toast, .fb-reply, .fb-reply *, .fb-working { box-sizing: border-box; }

/* ── Redigeraren (helskärm, ljus som tavlan) ── */
.fb-root {
    position: fixed;
    inset: 0;
    z-index: 20000;
    display: flex;
    flex-direction: column;
    background: #f0f2f5;
    color: #000;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    -webkit-tap-highlight-color: transparent;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}
.fb-top {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 64px;
    padding: calc(env(safe-area-inset-top, 0px)) 12px 0;
    padding-left: max(12px, env(safe-area-inset-left, 0px));
    padding-right: max(12px, env(safe-area-inset-right, 0px));
    background: #015e9f;
    color: #fff;
}
.fb-title { flex: 1 1 auto; font-size: 19px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fb-iconbtn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    flex: 0 0 auto;
    border-radius: 12px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    cursor: pointer;
}
.fb-send {
    min-height: 48px;
    min-width: 112px;
    padding: 0 22px;
    border: none;
    border-radius: 12px;
    background: #f0833d;
    color: #fff;
    font: inherit;
    font-size: 18px;
    font-weight: 800;
    cursor: pointer;
}
.fb-send:active, .fb-iconbtn:active, .fb-tool:active, .fb-chip:active { transform: scale(0.97); }

.fb-main {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
/* Telefon: texten överst (tangentbordet täcker den inte), bilden, verktygen. */
.fb-side { order: -1; flex: 0 0 auto; display: flex; flex-direction: column; gap: 8px; padding: 10px 12px 6px; }
.fb-stagewrap { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.fb-stage {
    position: relative;
    flex: 1 1 auto;
    min-height: 120px;
    margin: 0 12px;
    border-radius: 12px;
    background: #3a3f47;
    overflow: hidden;
}
.fb-shot, .fb-ink { position: absolute; display: block; }
.fb-shot { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35); }
.fb-ink { touch-action: none; cursor: crosshair; }
.fb-empty, .fb-busy {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    text-align: center;
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.4;
}
.fb-busy { background: rgba(0, 0, 0, 0.55); }
.fb-hint { padding: 6px 14px 0; color: #555; font-size: 13px; font-weight: 600; }
.fb-tools { display: flex; gap: 8px; padding: 8px 12px 10px; }
.fb-tool {
    flex: 1 1 0;
    min-width: 0;
    min-height: 52px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 8px;
    border: 1px solid #d8dbe0;
    border-radius: 12px;
    background: #fff;
    color: #000;
    font: inherit;
    font-size: 15px;
    font-weight: 800;
    cursor: pointer;
}
.fb-tool span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fb-tool:disabled { opacity: 0.4; }
.fb-tool[aria-pressed="true"] { border-color: #f0833d; box-shadow: inset 0 0 0 1px #f0833d; }

.fb-chips { display: flex; gap: 8px; }
.fb-chip {
    min-height: 44px;
    padding: 0 16px;
    border: 2px solid #d8dbe0;
    border-radius: 22px;
    background: #fff;
    color: #000;
    font: inherit;
    font-size: 15px;
    font-weight: 800;
    cursor: pointer;
}
.fb-chip[aria-pressed="true"] { background: #f0833d; border-color: #f0833d; color: #fff; }
.fb-textwrap { display: flex; gap: 8px; align-items: flex-start; }
.fb-text {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 64px;
    padding: 10px 12px;
    border: 2px solid #d8dbe0;
    border-radius: 12px;
    background: #fff;
    color: #000;
    font: inherit;
    font-size: 16px;            /* 16 px: iOS zoomar inte in */
    line-height: 1.35;
    resize: none;
}
.fb-text:focus { outline: none; border-color: #f0833d; }
.fb-mic { background: #015e9f; border-color: #015e9f; }
.fb-mic--on { background: #f0833d; border-color: #f0833d; animation: fb-pulse 1.2s ease-in-out infinite; }
.fb-mic--busy { opacity: 0.6; }
@keyframes fb-pulse { 50% { box-shadow: 0 0 0 6px rgba(240, 131, 61, 0.3); } }
.fb-mask { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 15px; font-weight: 700; cursor: pointer; }
.fb-mask input { width: 22px; height: 22px; accent-color: #f0833d; flex: 0 0 auto; }
.fb-meta { color: #666; font-size: 12px; line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Platta på tvären och dator: bilden till vänster, texten i en spalt till höger.
   (Stående platta som telefonen: texten överst och bilden så stor som möjligt.) */
@media (min-width: 700px) and (orientation: landscape), (min-width: 1100px) {
    .fb-main { flex-direction: row; }
    .fb-side { order: 0; flex: 0 0 340px; padding: 14px 16px; overflow-y: auto; border-left: 1px solid #d8dbe0; background: #fff; }
    .fb-stage { margin: 12px 0 0 12px; }
    .fb-tools { padding: 10px 0 12px 12px; }
    .fb-hint { padding-left: 14px; }
    .fb-text { min-height: 140px; }
    .fb-meta { white-space: normal; }
}
/* Telefon på tvären: låg skärm — texten bredvid bilden. */
@media (max-height: 520px) and (min-width: 560px) {
    .fb-main { flex-direction: row; }
    .fb-side { order: 0; flex: 0 0 300px; overflow-y: auto; }
    .fb-top { min-height: 56px; }
    .fb-hint { display: none; }
    .fb-tool { min-height: 46px; }
}

/* Liten telefon (iPhone SE): verktygens text får plats. */
@media (max-width: 389px) {
    .fb-tools { gap: 6px; }
    .fb-tool { gap: 4px; padding: 0 4px; font-size: 14px; }
    .fb-tool svg { width: 20px; height: 20px; }
}

/* ── Ny bild: kameran ovanpå allt ── */
.fb-cam-wrap {
    position: fixed;
    z-index: 20010;
    left: 12px;
    right: 12px;
    top: calc(env(safe-area-inset-top, 0px) + 10px);
    width: max-content;
    max-width: calc(100vw - 24px);
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px 6px 6px;
    border-radius: 40px;
    background: rgba(0, 0, 0, 0.82);
    color: #fff;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}
.fb-cam {
    flex: 0 0 auto;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 3px solid #fff;
    background: #f0833d;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.fb-cam-label { flex: 1 1 auto; max-width: 320px; font-size: 15px; font-weight: 700; line-height: 1.3; min-width: 0; }
.fb-cam-cancel {
    flex: 0 0 auto;
    min-height: 44px;
    padding: 0 14px;
    border-radius: 22px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    background: transparent;
    color: #fff;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}

/* ── Fångsten: "Tar bild …" och blixten ── */
.fb-working {
    position: fixed;
    z-index: 20020;
    left: 50%;
    top: calc(env(safe-area-inset-top, 0px) + 14px);
    transform: translateX(-50%);
    padding: 10px 18px;
    border-radius: 22px;
    background: #015e9f;
    color: #fff;
    font: 700 15px -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}
.fb-flash { position: fixed; inset: 0; z-index: 20030; background: #fff; pointer-events: none; animation: fb-flash 0.35s ease-out forwards; }
@keyframes fb-flash { from { opacity: 0.85; } to { opacity: 0; } }

/* ── Toast (när sidan inte har en egen) och kortet "Rättat: …" ── */
.fb-toast, .fb-reply {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    width: min(420px, calc(100vw - 32px));
    background: #fff;
    color: #000;
    border: 1px solid #d8dbe0;
    border-left: 4px solid #015e9f;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}
.fb-toast {
    z-index: 20040;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 24px);
    padding: 12px 16px;
    font-size: 15px;
    font-weight: 600;
    transition: opacity 0.4s;
}
.fb-toast--error { border-left-color: #d32f2f; }
.fb-toast--out { opacity: 0; }
.fb-reply {
    z-index: 19990;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 96px);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.fb-reply-title { color: #015e9f; font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; }
.fb-reply-text { font-size: 16px; font-weight: 700; line-height: 1.35; }
.fb-reply-row--fixed .fb-reply-text::before { content: '✓ '; color: #015e9f; }
.fb-reply-answer { margin-top: 2px; color: #333; font-size: 15px; line-height: 1.35; }
.fb-reply-ok {
    align-self: flex-end;
    min-height: 48px;
    min-width: 96px;
    border: none;
    border-radius: 12px;
    background: #f0833d;
    color: #fff;
    font: inherit;
    font-size: 17px;
    font-weight: 800;
    cursor: pointer;
}

/* ── Knappen i tavlans toppfält: ikon + text, bara ikon på telefon ── */
.fb-topbar-btn svg { flex: 0 0 auto; }
@media (max-width: 699px), (max-height: 500px) and (pointer: coarse) {
    .fb-topbar-btn { width: 44px; padding: 0; justify-content: center; }
    .fb-topbar-text { display: none; }
}
/* Sist under ⋯ (draw-module.js), efter ett streck. */
.draw-pop-item.fb-more-item { position: relative; margin-top: 7px; }
.draw-pop-item.fb-more-item::before { content: ''; position: absolute; left: 6px; right: 6px; top: -5px; height: 1px; background: #d8dbe0; }

@media print {
    .fb-root, .fb-cam-wrap, .fb-working, .fb-flash, .fb-toast, .fb-reply, #wb-feedback-btn { display: none !important; }
}

/* Fliken vid skärmkanten (mountFloat): alltid nåbar, över fönster, ark och paneler
   (appens lager slutar under 10000) men under Tyck tills egen redigerare (20000).
   Högerkanten mitt på höjden är fri i kartvyn och på tavlan (texten börjar till vänster);
   i fältläget står ritkapseln där, så fliken går till vänsterkanten. */
.fb-float {
    position: fixed;
    right: 0;
    top: calc(50% - 56px);          /* placeFloat flyttar den till en fri höjd */
    z-index: 19000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 40px;
    min-height: 112px;
    padding: 10px 0;
    border: 0;
    border-radius: 12px 0 0 12px;
    background: #015e9f;
    color: #ffffff;
    box-shadow: -2px 2px 10px rgba(0, 0, 0, 0.25);
    opacity: 0.88;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.fb-float:active { opacity: 1; background: #f0833d; color: #000000; }
.fb-float[hidden] { display: none !important; }
.fb-float svg { width: 20px; height: 20px; flex: none; }
.fb-float-text {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    font: 700 13px/1 system-ui, -apple-system, sans-serif;
    letter-spacing: 0.02em;
    white-space: nowrap;
}
body.field-mode .fb-float { right: auto; left: 0; border-radius: 0 12px 12px 0; box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.25); }
body.fb-open .fb-float, body.replay-mode .fb-float { display: none !important; }
@media print { .fb-float { display: none !important; } }
