/* ═══════════════════════════════════════════════════════════
   Обратная связь (feedback.js): окно заявки администраторам,
   «Мои заявки» с перепиской и редактор снимка экрана.

   Окно одно на все страницы, поэтому стили свои и ни от чего не
   зависят: светлое на старых страницах и в светлой теме, тёмное —
   в тёмной теме нового оформления (класс .is-dark).
   ═══════════════════════════════════════════════════════════ */

.fb-ov {
    --fb-bg: #ffffff;
    --fb-sf: #f5f6fa;
    --fb-sf2: #eceef4;
    --fb-line: #e3e6ee;
    --fb-tx: #161a25;
    --fb-tx2: #434a5c;
    --fb-mut: #737b8f;
    --fb-ac: #3346c9;
    --fb-ac-tx: #ffffff;
    --fb-ac-soft: #edf0ff;
    --fb-ac-ink: #2a3aa8;
    --fb-me: #3346c9;
    --fb-me-tx: #ffffff;
    --fb-them: #f1f3f8;
    --fb-note: #fff6db;
    --fb-note-line: #f0dc9a;
    --fb-red: #d92d20;
    --fb-sh: 0 30px 80px -20px rgba(16, 22, 40, .45), 0 4px 14px rgba(16, 22, 40, .10);
    --fb-back: rgba(14, 18, 30, .46);

    position: fixed;
    inset: 0;
    z-index: 2147482000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--fb-back);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    color: var(--fb-tx);
    font-family: inherit;
    font-size: 14.5px;
    line-height: 1.45;
    opacity: 0;
    transition: opacity .18s ease-out;
}
.fb-ov.show { opacity: 1; }
/* hidden должен побеждать display:flex — иначе закрытое окно, прозрачное,
   остаётся поверх страницы и съедает все нажатия */
.fb-ov[hidden], .fb-ov [hidden] { display: none !important; }
.fb-ov.is-dark {
    --fb-bg: #181c28;
    --fb-sf: #1f2432;
    --fb-sf2: #272d3d;
    --fb-line: rgba(255, 255, 255, .08);
    --fb-tx: #e9ebf3;
    --fb-tx2: #b9bfce;
    --fb-mut: #8a92a7;
    --fb-ac: #7086ff;
    --fb-ac-tx: #0d1020;
    --fb-ac-soft: rgba(112, 134, 255, .15);
    --fb-ac-ink: #c3ccff;
    --fb-me: #4459e6;
    --fb-me-tx: #ffffff;
    --fb-them: #242a39;
    --fb-note: rgba(245, 184, 46, .12);
    --fb-note-line: rgba(245, 184, 46, .35);
    --fb-red: #ff6b61;
    --fb-sh: 0 30px 80px -20px rgba(0, 0, 0, .8), 0 4px 14px rgba(0, 0, 0, .4);
    --fb-back: rgba(4, 6, 12, .62);
}

.fb-ov *, .fb-ov *::before, .fb-ov *::after { box-sizing: border-box; }
.fb-ov button { font: inherit; color: inherit; }
.fb-ov :focus-visible { outline: 2px solid var(--fb-ac); outline-offset: 2px; }

.fb {
    position: relative;
    display: flex;
    flex-direction: column;
    width: min(600px, 100%);
    height: min(760px, 100%);
    background: var(--fb-bg);
    border-radius: 20px;
    box-shadow: var(--fb-sh);
    overflow: hidden;
    transform: translateY(12px) scale(.985);
    transition: transform .22s cubic-bezier(.2, .8, .2, 1);
}
.fb-ov.show .fb { transform: none; }

/* ─── шапка ─── */

.fb-hd {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 18px 0 22px;
}
.fb-hd h2 {
    flex: 1;
    min-width: 0;
    margin: 0;
    font-size: 19px;
    font-weight: 700;
    letter-spacing: -.01em;
}
.fb-x {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    flex: none;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--fb-mut) !important;
    cursor: pointer;
}
.fb-x:hover { background: var(--fb-sf); color: var(--fb-tx) !important; }

.fb-tabs {
    display: flex;
    gap: 4px;
    margin: 14px 22px 0;
    padding: 4px;
    border-radius: 13px;
    background: var(--fb-sf);
}
.fb-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 38px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--fb-mut) !important;
    font-weight: 600 !important;
    cursor: pointer;
}
.fb-tab.is-on { background: var(--fb-bg); color: var(--fb-tx) !important; box-shadow: 0 1px 3px rgba(16, 22, 40, .12); }
.fb-ov.is-dark .fb-tab.is-on { background: var(--fb-sf2); box-shadow: none; }
.fb-dot {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--fb-red);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
}

.fb-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 18px 22px 22px; }
.fb-foot {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 22px calc(16px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--fb-line);
    background: var(--fb-bg);
}

/* ─── новая заявка ─── */

.fb-lbl { display: block; margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--fb-tx2); }
.fb-types { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 18px; }
.fb-type {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 12px 12px 11px;
    border: 1.5px solid var(--fb-line);
    border-radius: 14px;
    background: transparent;
    text-align: left;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
.fb-type:hover { border-color: color-mix(in srgb, var(--tc) 45%, var(--fb-line)); }
.fb-type.is-on { border-color: var(--tc); background: color-mix(in srgb, var(--tc) 9%, transparent); }
.fb-type-ic {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 9px;
    background: color-mix(in srgb, var(--tc) 16%, transparent);
    color: var(--tc);
}
.fb-type b { font-size: 13.5px; font-weight: 600; line-height: 1.2; }
.fb-type small { display: block; margin-top: 2px; font-size: 11.5px; color: var(--fb-mut); line-height: 1.3; }

.fb-in, .fb-ta {
    display: block;
    width: 100%;
    padding: 11px 13px;
    border: 1.5px solid var(--fb-line);
    border-radius: 12px;
    background: var(--fb-bg);
    color: var(--fb-tx);
    font: inherit;
    font-size: 15px;
    transition: border-color .15s;
}
.fb-in::placeholder, .fb-ta::placeholder { color: var(--fb-mut); opacity: .85; }
.fb-in:focus, .fb-ta:focus { outline: none; border-color: var(--fb-ac); }
.fb-ta { min-height: 128px; resize: vertical; line-height: 1.5; }
.fb-field { margin-bottom: 16px; }

.fb-attach { display: flex; flex-wrap: wrap; gap: 8px; }
.fb-btn2 {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 38px;
    padding: 0 13px;
    border: 1.5px solid var(--fb-line);
    border-radius: 11px;
    background: transparent;
    color: var(--fb-tx) !important;
    font-size: 13.5px !important;
    font-weight: 600 !important;
    cursor: pointer;
}
.fb-btn2:hover { background: var(--fb-sf); }
.fb-btn2 svg { color: var(--fb-mut); }
.fb-btn2:disabled { opacity: .5; cursor: default; }
.fb-hint { margin-top: 8px; font-size: 12px; color: var(--fb-mut); }

.fb-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; margin-top: 12px; }
.fb-thumbs:empty { display: none; }
.fb-th {
    position: relative;
    aspect-ratio: 1;
    border-radius: 12px;
    overflow: hidden;
    background: var(--fb-sf);
}
.fb-th img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fb-th-acts { position: absolute; top: 5px; right: 5px; display: flex; gap: 4px; }
.fb-th-b {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 9px;
    background: rgba(12, 15, 24, .66);
    color: #fff !important;
    cursor: pointer;
    backdrop-filter: blur(4px);
}
.fb-th-b:hover { background: rgba(12, 15, 24, .85); }
.fb-th-tag {
    position: absolute;
    left: 5px;
    bottom: 5px;
    padding: 1px 7px;
    border-radius: 6px;
    background: rgba(12, 15, 24, .66);
    color: #fff;
    font-size: 10.5px;
    font-weight: 600;
}

.fb-ctx {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-top: 18px;
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--fb-sf);
    color: var(--fb-mut);
    font-size: 12.5px;
    line-height: 1.4;
}
.fb-ctx svg { flex: none; margin-top: 1px; }

.fb-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 46px;
    padding: 0 20px;
    border: 0;
    border-radius: 13px;
    background: var(--fb-ac);
    color: var(--fb-ac-tx) !important;
    font-size: 15px !important;
    font-weight: 700 !important;
    cursor: pointer;
    transition: filter .15s, transform .1s;
}
.fb-btn:hover { filter: brightness(1.08); }
.fb-btn:active { transform: scale(.985); }
.fb-btn:disabled { opacity: .55; cursor: default; filter: none; }
.fb-btn.is-wide { flex: 1; }
.fb-btn.is-ghost { background: var(--fb-sf); color: var(--fb-tx) !important; }
.fb-btn.is-ghost:hover { filter: none; background: var(--fb-sf2); }
.fb-err { flex: 1; min-width: 0; color: var(--fb-red); font-size: 13px; font-weight: 500; }

/* ─── отправлено ─── */

.fb-done { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 48px 12px 24px; }
.fb-done-ic {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: color-mix(in srgb, #12a36b 16%, transparent);
    color: #12a36b;
    margin-bottom: 18px;
}
.fb-done h3 { margin: 0 0 8px; font-size: 22px; font-weight: 700; }
.fb-done p { margin: 0 0 26px; max-width: 380px; color: var(--fb-tx2); }
.fb-done-acts { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* ─── мои заявки ─── */

.fb-list { display: flex; flex-direction: column; gap: 2px; margin: 0 -10px; }
.fb-row {
    position: relative;
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    width: 100%;
    padding: 12px 10px;
    border: 0;
    border-radius: 14px;
    background: transparent;
    text-align: left;
    cursor: pointer;
}
.fb-row:hover { background: var(--fb-sf); }
.fb-row-ic {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 11px;
    background: color-mix(in srgb, var(--tc) 15%, transparent);
    color: var(--tc);
}
.fb-row-t { display: flex; align-items: center; gap: 8px; min-width: 0; }
.fb-row-t b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fb-row-t.is-new b { font-weight: 700; }
.fb-row-m { margin-top: 2px; font-size: 12.5px; color: var(--fb-mut); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fb-row-r { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.fb-row-r time { font-size: 11.5px; color: var(--fb-mut); white-space: nowrap; }
.fb-unread { width: 8px; height: 8px; border-radius: 50%; background: var(--fb-red); flex: none; }
.fb-list-h { margin: 14px 10px 6px; font-size: 12px; font-weight: 600; color: var(--fb-mut); }
.fb-list-h:first-child { margin-top: 0; }

.fb-st {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 9px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--sc) 14%, transparent);
    color: var(--sc);
    font-size: 11.5px;
    font-weight: 700;
    white-space: nowrap;
}
.fb-ov.is-dark .fb-st { color: color-mix(in srgb, var(--sc) 70%, #fff); }

.fb-empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 56px 16px; color: var(--fb-mut); }
.fb-empty b { display: block; margin: 14px 0 4px; font-size: 16px; color: var(--fb-tx); }
.fb-empty .fb-btn { margin-top: 20px; }

/* ─── переписка ─── */

.fb-th-hd { padding: 0 0 14px; border-bottom: 1px solid var(--fb-line); margin-bottom: 14px; }
.fb-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: -4px 0 10px -6px;
    padding: 4px 8px 4px 4px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--fb-mut) !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    cursor: pointer;
}
.fb-back:hover { background: var(--fb-sf); color: var(--fb-tx) !important; }
.fb-th-hd h3 { margin: 0 0 8px; font-size: 18px; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
.fb-th-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 12.5px; color: var(--fb-mut); }

.fb-msgs { display: flex; flex-direction: column; gap: 10px; }
.fb-msg { display: flex; flex-direction: column; max-width: 86%; }
.fb-msg.is-me { align-self: flex-end; align-items: flex-end; }
.fb-msg-who { margin: 0 4px 4px; font-size: 11.5px; font-weight: 600; color: var(--fb-mut); }
.fb-bub {
    padding: 10px 13px;
    border-radius: 16px;
    background: var(--fb-them);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.fb-msg.is-me .fb-bub { background: var(--fb-me); color: var(--fb-me-tx); border-bottom-right-radius: 6px; }
.fb-msg:not(.is-me) .fb-bub { border-bottom-left-radius: 6px; }
.fb-msg-time { margin: 4px 6px 0; font-size: 11px; color: var(--fb-mut); }
.fb-files { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 6px; margin-top: 6px; width: min(340px, calc(70vw / var(--fd-z, 1))); }
.fb-msg.is-me .fb-files { justify-items: end; }
.fb-file { display: block; width: 100%; aspect-ratio: 4 / 3; border: 0; padding: 0; border-radius: 12px; overflow: hidden; background: var(--fb-sf); cursor: zoom-in; }
.fb-file img { width: 100%; height: 100%; object-fit: cover; display: block; }

.fb-sys { align-self: center; max-width: 92%; padding: 5px 12px; border-radius: 999px; background: var(--fb-sf); color: var(--fb-mut); font-size: 12px; text-align: center; }
.fb-sys b { color: var(--fb-tx2); font-weight: 600; }

.fb-banner {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 16px;
    padding: 14px;
    border-radius: 14px;
    background: var(--fb-ac-soft);
    color: var(--fb-ac-ink);
    font-size: 13.5px;
}
.fb-banner b { color: var(--fb-tx); }
.fb-banner-acts { display: flex; gap: 8px; flex-wrap: wrap; }
.fb-banner .fb-btn { min-height: 40px; font-size: 14px !important; padding: 0 16px; }

/* Поле ответа внизу переписки */
.fb-comp { flex-direction: column; align-items: stretch; gap: 8px; }
.fb-comp-row { display: flex; align-items: flex-end; gap: 8px; }
.fb-comp .fb-ta { min-height: 46px; max-height: 180px; resize: none; padding: 11px 13px; }
.fb-ib {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    flex: none;
    border: 0;
    border-radius: 13px;
    background: var(--fb-sf);
    color: var(--fb-tx2) !important;
    cursor: pointer;
}
.fb-ib:hover { background: var(--fb-sf2); }
.fb-ib.is-send { background: var(--fb-ac); color: var(--fb-ac-tx) !important; }
.fb-ib.is-send:hover { filter: brightness(1.08); background: var(--fb-ac); }
.fb-ib:disabled { opacity: .5; cursor: default; }
.fb-comp .fb-thumbs { margin-top: 0; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); }

/* Меню «Приложить» у поля ответа */
.fb-pop {
    position: absolute;
    z-index: 3;
    min-width: 210px;
    padding: 5px;
    border-radius: 13px;
    background: var(--fb-bg);
    border: 1px solid var(--fb-line);
    box-shadow: var(--fb-sh);
}
.fb-pop button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 40px;
    padding: 0 12px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    text-align: left;
    font-weight: 500;
    cursor: pointer;
}
.fb-pop button:hover { background: var(--fb-sf); }
.fb-pop svg { color: var(--fb-mut); }

.fb-loading { padding: 60px 0; text-align: center; color: var(--fb-mut); }

/* Просмотр фото на весь экран */
.fb-lb {
    position: fixed;
    inset: 0;
    z-index: 2147482600;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(6, 8, 14, .9);
    cursor: zoom-out;
}
.fb-lb img { max-width: 100%; max-height: 100%; border-radius: 10px; box-shadow: 0 20px 60px rgba(0, 0, 0, .6); }

/* ─── редактор снимка ─── */

.fb-ed {
    position: fixed;
    inset: 0;
    z-index: 2147482500;
    display: flex;
    flex-direction: column;
    background: #0c0f17;
    color: #eef0f6;
    font-family: inherit;
}
.fb-ed *, .fb-ed *::before, .fb-ed *::after { box-sizing: border-box; }
.fb-ed button { font: inherit; }
.fb-ed-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    padding-top: calc(10px + env(safe-area-inset-top));
    background: #141925;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.fb-ed-t { flex: 1; min-width: 0; text-align: center; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fb-ed-tools {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 12px 0;
}
.fb-ed-grp { display: flex; gap: 4px; padding: 3px; border-radius: 12px; background: rgba(255, 255, 255, .06); }
.fb-ed-b {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 40px;
    min-width: 40px;
    padding: 0 11px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: #c9cedb;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}
.fb-ed-b:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.fb-ed-b.is-on { background: #fff; color: #10131c; }
.fb-ed-b:disabled { opacity: .4; cursor: default; }
.fb-ed-tools > .fb-ed-b, .fb-ed-colb { background: rgba(255, 255, 255, .06); border-radius: 12px; height: 46px; min-width: 46px; }
.fb-ed-sw { display: block; width: 24px; height: 24px; padding: 0; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .85); cursor: pointer; }
/* цвет — одна кнопка; по нажатию над ней всплывают три кружка */
.fb-ed-col { position: relative; }
.fb-ed-pal {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 14px;
    background: #1c2232;
    border: 1px solid rgba(255, 255, 255, .1);
    box-shadow: 0 14px 34px rgba(0, 0, 0, .55);
}
.fb-ed-pal[hidden] { display: none; }
.fb-ed-pal .fb-ed-sw { width: 32px; height: 32px; border-color: transparent; }
.fb-ed-pal .fb-ed-sw.is-on { border-color: #fff; box-shadow: 0 0 0 2px #1c2232 inset; }
.fb-ed-ok { background: #7086ff; color: #0c0f17; }
.fb-ed-ok:hover { background: #8497ff; color: #0c0f17; }
.fb-ed-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 16px; overflow: hidden; }
.fb-ed-stage canvas { max-width: 100%; max-height: 100%; border-radius: 6px; box-shadow: 0 18px 50px rgba(0, 0, 0, .55); touch-action: none; cursor: crosshair; }
.fb-ed-tip { padding: 8px 12px calc(10px + env(safe-area-inset-bottom)); text-align: center; font-size: 12.5px; color: #8f97aa; }

/* Пока снимаем экран — короткая вспышка, чтобы было видно, что снимок сделан */
.fb-flash { position: fixed; inset: 0; z-index: 2147482400; background: #fff; pointer-events: none; animation: fbFlash .35s ease-out forwards; }
@keyframes fbFlash { from { opacity: .55; } to { opacity: 0; } }

/* Пункт «Обратная связь» в меню нового оформления: красная точка, если есть непрочитанный ответ */
html[data-fb-unread] [data-fn="openFeedback"] { position: relative; }
html[data-fb-unread] [data-fn="openFeedback"]::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 12px;
    width: 8px;
    height: 8px;
    margin-top: -4px;
    border-radius: 50%;
    background: #ef4444;
}

/* ─── телефон: окно — лист на весь экран ─── */
@media (max-width: 640px) {
    .fb-ov { padding: 0; align-items: stretch; }
    .fb { width: 100%; height: 100%; border-radius: 0; transform: translateY(24px); }
    .fb-hd { padding: calc(12px + env(safe-area-inset-top)) 12px 0 16px; }
    .fb-tabs { margin: 12px 16px 0; }
    .fb-body { padding: 16px; }
    .fb-foot { padding-left: 16px; padding-right: 16px; }
    .fb-types { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .fb-msg { max-width: 92%; }
    .fb-ed-t { font-size: 14px; }
    .fb-ed-tools .fb-ed-b > span:not(.fb-ed-sw) { display: none; }
    .fb-ed-stage { padding: 10px; }
    .fb-ed-tip { font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
    .fb-ov, .fb, .fb-type, .fb-btn { transition: none; }
    .fb-flash { animation: none; opacity: 0; }
}
