/* ==========================================================================
   ui-feedback — стили виджета

   Все селекторы под префиксом .uifb, чтобы стили сайта не поехали и наоборот.
   Настройка через переменные ниже — цвет, скругления, слой.
   Позиция кнопки переключается атрибутом data-position="right|left".
   ========================================================================== */

.uifb {
    --uifb-accent:        #48C46F;
    --uifb-accent-hover:  #35B25F;
    --uifb-accent-soft:   #C7E9D3;
    --uifb-text:          #1f2328;
    --uifb-text-muted:    #8a9099;
    --uifb-border:        #dfe3e8;
    --uifb-surface:       #ffffff;
    --uifb-ghost:         #eef0f3;
    --uifb-ghost-hover:   #e3e6ea;
    --uifb-danger:        #B4462F;
    --uifb-radius:        24px;
    --uifb-radius-sm:     12px;
    --uifb-z:             99999;
    --uifb-font:          -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                          "Helvetica Neue", Arial, sans-serif;
}

.uifb *,
.uifb *::before,
.uifb *::after { box-sizing: border-box; }

/* --------------------------------------------------------------- кнопка -- */

.uifb-tab {
    position: fixed;
    top: 50%;
    z-index: var(--uifb-z);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 18px 10px;
    border: 1px solid var(--uifb-border);
    background: var(--uifb-surface);
    color: var(--uifb-text);
    font: 500 14px/1 var(--uifb-font);
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(16, 24, 40, .12);
    transition: box-shadow .18s ease, transform .18s ease;
}

.uifb[data-position="right"] .uifb-tab {
    right: 0;
    transform: translateY(-50%);
    border-right: none;
    border-radius: var(--uifb-radius-sm) 0 0 var(--uifb-radius-sm);
}

.uifb[data-position="left"] .uifb-tab {
    left: 0;
    transform: translateY(-50%);
    border-left: none;
    border-radius: 0 var(--uifb-radius-sm) var(--uifb-radius-sm) 0;
}

.uifb-tab:hover { box-shadow: 0 6px 24px rgba(16, 24, 40, .18); }
.uifb-tab:focus-visible { outline: 2px solid var(--uifb-accent); outline-offset: 2px; }

.uifb-tab__label {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    letter-spacing: .01em;
    white-space: nowrap;
}

.uifb[data-position="left"] .uifb-tab__label { transform: rotate(180deg); }

/* Иконка идёт первой в разметке, а кнопка — колонка,
   поэтому на десктопе она оказывается над текстом. */
.uifb-tab__icon {
    flex: none;
    width: 22px;
    height: 22px;
    color: var(--uifb-accent);
}

/* --------------------------------------------------------------- модалка -- */

.uifb-overlay {
    position: fixed;
    inset: 0;
    z-index: calc(var(--uifb-z) + 1);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    background: rgba(16, 24, 40, .45);
    overflow-y: auto;
    animation: uifb-fade .16s ease;
}

.uifb-overlay[hidden] { display: none; }

.uifb-modal {
    position: relative;
    width: 100%;
    max-width: 560px;
    margin: auto;
    padding: 32px;
    border-radius: var(--uifb-radius);
    background: var(--uifb-surface);
    color: var(--uifb-text);
    font: 400 15px/1.5 var(--uifb-font);
    box-shadow: 0 24px 64px rgba(16, 24, 40, .24);
    animation: uifb-rise .2s cubic-bezier(.2, .8, .3, 1);
}

@keyframes uifb-fade { from { opacity: 0; } }
@keyframes uifb-rise { from { opacity: 0; transform: translateY(12px); } }

@media (prefers-reduced-motion: reduce) {
    .uifb-overlay, .uifb-modal { animation: none; }
    .uifb-tab { transition: none; }
}

.uifb-close {
    position: absolute;
    top: 20px;
    right: 20px;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--uifb-text);
    cursor: pointer;
}

.uifb-close:hover { background: var(--uifb-ghost); }
.uifb-close:focus-visible { outline: 2px solid var(--uifb-accent); outline-offset: 2px; }

.uifb-title {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 40px 28px 0;
    font-size: 26px;
    font-weight: 700;
    line-height: 1.2;
}

.uifb-title__icon { display: flex; color: var(--uifb-text); }

/* ------------------------------------------------------------------ поля -- */

.uifb-field { margin-bottom: 26px; padding: 0; border: none; }

.uifb-label {
    display: block;
    margin-bottom: 12px;
    padding: 0;
    font-size: 16px;
    font-weight: 700;
}

.uifb-label__hint { font-weight: 400; color: var(--uifb-text-muted); }

/* ---------------------------------------------------------------- оценка -- */

.uifb-faces { display: flex; gap: 20px; flex-wrap: wrap; }

.uifb-face {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--uifb-text-muted);
    cursor: pointer;
    transition: color .15s ease, transform .15s ease, background-color .15s ease;
}

.uifb-face:hover { color: var(--uifb-text); transform: scale(1.08); }
.uifb-face:focus-visible { outline: 2px solid var(--uifb-accent); outline-offset: 2px; }

.uifb-face[aria-checked="true"] {
    color: var(--uifb-accent);
    background: color-mix(in srgb, var(--uifb-accent) 12%, transparent);
}

/* -------------------------------------------------------------- текстарея -- */

.uifb-textarea-wrap { position: relative; }

.uifb-textarea {
    display: block;
    width: 100%;
    min-height: 140px;
    padding: 16px 16px 34px;
    border: 1px solid var(--uifb-border);
    border-radius: var(--uifb-radius-sm);
    background: var(--uifb-surface);
    color: var(--uifb-text);
    font: inherit;
    resize: vertical;
}

.uifb-textarea::placeholder { color: var(--uifb-text-muted); }
.uifb-textarea:focus { outline: none; border-color: var(--uifb-accent); }

.uifb-counter {
    position: absolute;
    right: 14px;
    bottom: 12px;
    color: var(--uifb-text-muted);
    font-size: 13px;
    pointer-events: none;
}

/* -------------------------------------------------------------- дропзона -- */

.uifb-drop {
    padding: 22px 16px;
    border: 1px dashed var(--uifb-border);
    border-radius: var(--uifb-radius-sm);
    text-align: center;
    cursor: pointer;
    transition: border-color .15s ease, background-color .15s ease;
}

.uifb-drop:hover,
.uifb-drop:focus-visible { border-color: var(--uifb-accent); outline: none; }

.uifb-drop.is-dragover { border-color: var(--uifb-accent); background: color-mix(in srgb, var(--uifb-accent) 8%, transparent); }

.uifb-drop__text { margin: 0 0 4px; color: var(--uifb-text-muted); }
.uifb-drop__link { color: var(--uifb-accent); text-decoration: underline; }
.uifb-drop__meta { margin: 0; color: var(--uifb-text-muted); font-size: 14px; }

.uifb-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--uifb-border);
    border-radius: var(--uifb-radius-sm);
}

.uifb-preview[hidden] { display: none; }

.uifb-preview__img {
    width: 56px;
    height: 56px;
    border-radius: 8px;
    object-fit: cover;
    background: var(--uifb-ghost);
}

.uifb-preview__info { display: flex; min-width: 0; flex-direction: column; flex: 1; }

.uifb-preview__name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.uifb-preview__size { color: var(--uifb-text-muted); font-size: 13px; }

.uifb-preview__remove {
    flex: none;
    padding: 6px 12px;
    border: none;
    border-radius: 999px;
    background: var(--uifb-ghost);
    color: var(--uifb-text);
    font: inherit;
    font-size: 14px;
    cursor: pointer;
}

.uifb-preview__remove:hover { background: var(--uifb-ghost-hover); }

/* ------------------------------------------------------------- служебное -- */

.uifb-trap {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.uifb-captcha__box { min-height: 78px; }

.uifb-error {
    margin: 0 0 16px;
    padding: 12px 14px;
    border-radius: var(--uifb-radius-sm);
    background: color-mix(in srgb, var(--uifb-danger) 10%, transparent);
    color: var(--uifb-danger);
    font-size: 14px;
}

.uifb-error[hidden] { display: none; }

/* --------------------------------------------------------------- кнопки -- */

.uifb-actions { display: flex; gap: 12px; justify-content: flex-end; }

.uifb-btn {
    min-width: 132px;
    padding: 13px 26px;
    border: none;
    border-radius: 999px;
    font: 600 16px/1 var(--uifb-font);
    cursor: pointer;
    transition: background-color .15s ease;
}

.uifb-btn:focus-visible { outline: 2px solid var(--uifb-accent); outline-offset: 2px; }

.uifb-btn--ghost { background: var(--uifb-ghost); color: var(--uifb-text); }
.uifb-btn--ghost:hover { background: var(--uifb-ghost-hover); }

.uifb-btn--primary { background: var(--uifb-accent); color: #fff; }
.uifb-btn--primary:hover:not(:disabled) { background: var(--uifb-accent-hover); }

.uifb-btn:disabled { background: var(--uifb-accent-soft); color: #fff; cursor: default; }
.uifb-btn.is-loading { pointer-events: none; opacity: .8; }

/* --------------------------------------------------------------- финал -- */

.uifb-done { padding: 20px 0 4px; text-align: center; }
.uifb-done[hidden] { display: none; }
.uifb-done__icon { display: flex; justify-content: center; margin-bottom: 16px; color: var(--uifb-accent); }
.uifb-done__title { margin: 0 0 8px; font-size: 22px; font-weight: 700; }
.uifb-done__text { margin: 0 0 24px; color: var(--uifb-text-muted); }

/* --------------------------------------------------------------- мобилка -- */

@media (max-width: 600px) {
    .uifb-modal { padding: 24px 20px; border-radius: 20px; }
    .uifb-title { margin-bottom: 22px; font-size: 22px; }
    .uifb-faces { gap: 8px; justify-content: space-between; }
    .uifb-actions { flex-direction: column-reverse; }
    .uifb-btn { width: 100%; }

    /* На мобильных остаётся только иконка: кнопка занимает минимум места
       у края экрана, но сохраняет комфортную зону нажатия 44 × 44. */
    .uifb-tab { gap: 0; padding: 11px; }
    .uifb-tab__label { display: none; }
    .uifb-tab__icon { width: 24px; height: 24px; }
}
