/* Виджет «Написать обращение» (feedback, этап 3, ТЗ 6).
   Рабочая копия — в репозитории сайта; копия для истории — feedback/integrations/hostcms.
   Стили самодостаточны и не зависят от style.css: виджет работает и на страницах
   из статкэша со старой разметкой. Префикс fbw- во избежание конфликтов. */

/* ---------- оверлей и контейнер ---------- */

.fbw-overlay {
	position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 999990;
	background: rgba(17, 24, 32, 0.55);
	display: flex; align-items: center; justify-content: center;
	padding: 16px;
	-webkit-tap-highlight-color: transparent;
}

.fbw-modal {
	font-family: "Muller", -apple-system, "Segoe UI", Roboto, sans-serif;
	font-size: 14px; line-height: 1.35; color: #333;
	background: #fff; border-radius: 14px;
	width: 560px; max-width: 100%;
	max-height: 86vh;
	display: flex; flex-direction: column;
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
	animation: fbw-pop 0.18s ease-out;
	overflow: hidden;
}

@keyframes fbw-pop { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fbw-up  { from { transform: translateY(100%); } to { transform: none; } }

/* мобильная «шторка» снизу (ТЗ 6.3) */
@media (max-width: 640px) {
	.fbw-overlay { padding: 0; align-items: flex-end; }
	.fbw-modal {
		width: 100%; max-height: 92vh;
		border-radius: 16px 16px 0 0;
		animation: fbw-up 0.22s ease-out;
	}
	/* 16px в полях ввода — iOS не приближает страницу при фокусе */
	.fbw-modal input, .fbw-modal select, .fbw-modal textarea { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
	.fbw-modal { animation: none; }
}

/* ---------- шапка ---------- */

.fbw-head {
	display: flex; align-items: flex-start; gap: 12px;
	padding: 18px 20px 0;
}
.fbw-title { margin: 0; font-size: 19px; font-weight: 500; flex: 1 1 auto; }
.fbw-close {
	flex: 0 0 auto; border: 0; background: none; cursor: pointer;
	width: 32px; height: 32px; margin: -6px -8px 0 0; padding: 0;
	font-size: 22px; line-height: 32px; color: #9aa0a6; border-radius: 8px;
}
.fbw-close:hover { color: #333; background: #f1f3f5; }
.fbw-context { padding: 4px 20px 0; color: #8a9097; font-size: 12.5px; }

/* ---------- тело ---------- */

.fbw-body { padding: 14px 20px 4px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.fbw-label { display: block; font-weight: 500; margin: 14px 0 8px; }
.fbw-label:first-child { margin-top: 0; }
.fbw-optional { color: #9aa0a6; font-weight: 400; }

.fbw-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.fbw-chip {
	border: 1px solid #d6d9de; background: #fff; color: #333;
	border-radius: 999px; padding: 7px 14px; font: inherit; cursor: pointer;
	transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.fbw-chip:hover { border-color: #36cad1; }
.fbw-chip[aria-pressed="true"] {
	background: #36cad1; border-color: #36cad1; color: #fff; font-weight: 500;
}
.fbw-hint { margin: 8px 0 0; color: #8a9097; font-size: 12.5px; }

.fbw-field { margin-top: 10px; }
.fbw-input, .fbw-select, .fbw-textarea {
	width: 100%; box-sizing: border-box;
	border: 1px solid #d6d9de; border-radius: 8px; background: #fff;
	padding: 10px 12px; font: inherit; color: #333;
	-webkit-appearance: none; appearance: none;
}
.fbw-select {
	background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238a9097' stroke-width='1.5'/%3E%3C/svg%3E");
	background-repeat: no-repeat; background-position: right 12px center;
	padding-right: 30px;
}
.fbw-input:focus, .fbw-select:focus, .fbw-textarea:focus { border-color: #36cad1; outline: none; }
.fbw-input.fbw-invalid, .fbw-textarea.fbw-invalid { border-color: #e05252; }
.fbw-textarea { resize: none; min-height: 74px; max-height: 40vh; overflow-y: auto; display: block; }
.fbw-counter { text-align: right; color: #b5bac0; font-size: 11.5px; margin-top: 3px; }
.fbw-counter.fbw-over { color: #e05252; }

/* сетка мини-полей «Нет моего учебника» */
.fbw-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.fbw-grid .fbw-colspan { grid-column: 1 / -1; }
@media (max-width: 400px) { .fbw-grid { grid-template-columns: 1fr; } }

/* звёзды (категория «Предложение / качество») */
.fbw-stars { display: flex; gap: 2px; margin-top: 4px; }
.fbw-star {
	border: 0; background: none; cursor: pointer; padding: 2px;
	font-size: 26px; line-height: 1; color: #d8dbe0;
}
.fbw-star.fbw-lit { color: #f5b301; }

/* чекбокс */
.fbw-check { display: flex; align-items: flex-start; gap: 8px; margin-top: 10px; cursor: pointer; }
.fbw-check input { width: 16px; height: 16px; margin: 1px 0 0; accent-color: #36cad1; }

/* контакт */
.fbw-contact-toggle {
	background: none; border: 0; padding: 0; margin: 12px 0 0; cursor: pointer;
	color: #0f9ba1; font: inherit; text-decoration: underline; text-underline-offset: 2px;
}
.fbw-consent { margin: 8px 0 0; color: #9aa0a6; font-size: 11.5px; }

/* honeypot: визуально скрыт, но «заполняемый» для ботов */
.fbw-hp { position: absolute !important; left: -9999px; top: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- подвал ---------- */

.fbw-foot { padding: 12px 20px 18px; }
.fbw-error { color: #e05252; font-size: 12.5px; margin: 0 0 8px; }
.fbw-submit {
	width: 100%; height: 44px; border: 0; border-radius: 8px; cursor: pointer;
	background: #36cad1; color: #fff; font: inherit; font-size: 15px; font-weight: 500;
	display: flex; align-items: center; justify-content: center; gap: 10px;
	transition: filter 0.15s;
}
.fbw-submit:hover { filter: brightness(0.95); }
.fbw-submit[disabled] { opacity: 0.6; cursor: default; }
.fbw-spin {
	width: 16px; height: 16px; border-radius: 50%;
	border: 2px solid rgba(255, 255, 255, 0.4); border-top-color: #fff;
	animation: fbw-rot 0.7s linear infinite;
}
@keyframes fbw-rot { to { transform: rotate(360deg); } }

/* ---------- экран «Спасибо» ---------- */

.fbw-success { text-align: center; padding: 30px 24px 8px; }
.fbw-success-icon {
	width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 50%;
	background: #e6f8f4; color: #17b890; font-size: 26px; line-height: 52px;
}
.fbw-success-title { font-size: 17px; font-weight: 500; margin: 0 0 6px; }
.fbw-success-id { color: #b5bac0; font-size: 11.5px; margin-top: 10px; word-break: break-all; }

/* ---------- точки входа на страницах ---------- */

/* плитка «Нет вашего учебника?» в списках книг — видна, только когда виджет работает */
.fb-missing-tile { display: none; }
body.fbw-ready .fb-missing-tile {
	display: flex; flex-direction: column; align-items: center; justify-content: center;
	gap: 8px; box-sizing: border-box; min-height: 150px; margin: 20px 14px 20px 0;
	border: 1.5px dashed #c9ced6; border-radius: 10px; padding: 16px;
	text-align: center; text-decoration: none; color: #333;
	transition: border-color 0.15s, background 0.15s;
}
body.fbw-ready .fb-missing-tile:hover { border-color: #36cad1; background: #fbfefe; }
.fb-missing-tile__plus {
	width: 34px; height: 34px; border-radius: 50%; background: #e7f8f9;
	color: #0f9ba1; font-size: 22px; line-height: 34px; font-weight: 500;
}
.fb-missing-tile__text b { display: block; font-weight: 500; }
.fb-missing-tile__text i { display: block; font-style: normal; color: #8a9097; font-size: 12px; margin-top: 4px; }
/* внутри сетки .books плитка занимает колонку (float-вёрстка сетки книг) */
.books .fb-missing-tile { float: left; width: calc(50% - 14px); }
@media (max-width: 700px) { .books .fb-missing-tile { float: none; width: auto; } }

/* ссылка в подвале */
.footer-feedback { margin-top: 8px; }
.footer-feedback a { color: #0f9ba1; text-decoration: underline; text-underline-offset: 2px; }

/* фолбэк в #errorModal (открывается fancybox'ом, только если сам виджет не загрузился) */
.fb-fallback { margin: 20px 0; line-height: 1.5; }
