/* ============ آراء العملاء: الزر العائم والاستبيان والتقرير ============ */

/* الزر العائم «قيّم هذه الميزة» – أسفل الصفحة جهة نهاية السطر (الإشعارات في جهة البداية) */
.fb-widget { position: fixed; bottom: 20px; inset-inline-end: 20px; z-index: 90; }
body.logged-out .fb-widget, .record-mode .fb-widget, body.sv-open .fb-widget { display: none !important; }
.fb-pill {
  display: inline-flex; align-items: center; gap: 7px; height: 42px; padding-inline: 14px 16px; border-radius: 21px; cursor: pointer;
  border: 1px solid color-mix(in srgb, var(--primary) 35%, var(--border)); background: var(--surface); color: var(--primary);
  font-weight: 700; font-size: 13px; white-space: nowrap; box-shadow: var(--shadow-lg); transition: transform .15s, background .15s, color .15s;
}
.fb-pill:hover { transform: translateY(-2px); }
.fb-pill:focus-visible { outline: 0; box-shadow: 0 0 0 3px var(--primary-soft), var(--shadow-lg); }
.fb-pill .ic { width: 18px; height: 18px; }
.fb-widget.open .fb-pill { background: var(--primary); color: var(--primary-ink); border-color: transparent; }

.fb-pop {
  position: absolute; bottom: calc(100% + 10px); inset-inline-end: 0; width: 340px; max-width: calc(100vw - 32px); max-height: calc(100vh - 110px); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg);
  padding: 14px; display: flex; flex-direction: column; gap: 12px; animation: pop .18s ease;
}
.fb-pop-head { display: flex; align-items: center; gap: 10px; }
.fb-pop-head b { font-size: 14px; }
.fb-x { width: 30px; height: 30px; flex: none; }
.fb-choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.fb-choice {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 86px; padding: 10px 6px;
  border-radius: 12px; border: 1.5px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer;
  font-weight: 700; font-size: 12.5px; line-height: 1.35; text-align: center; transition: border-color .15s, background .15s, transform .1s;
}
.fb-choice:hover { border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); }
.fb-choice:active { transform: scale(.97); }
.fb-emo { font-size: 24px; line-height: 1; }
.fb-choice.on.r3 { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
.fb-choice.on.r2 { border-color: var(--info); background: var(--info-soft); color: var(--info); }
.fb-choice.on.r1 { border-color: var(--muted); background: var(--surface); color: var(--text); }
.fb-pop textarea.input { resize: vertical; min-height: 58px; }
.fb-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.fb-foot .btn:disabled { opacity: .5; cursor: not-allowed; }
.fb-foot .link-btn { display: inline-flex; align-items: center; gap: 5px; }
.fb-foot .link-btn .ic { width: 15px; height: 15px; }
.fb-meta { font-size: 11.5px; color: var(--muted); }
.fb-pop.saved { overflow: hidden; }
.fb-done { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 190px; text-align: center; animation: fade .2s ease; }

/* علامة الحفظ المتحركة */
.fb-chk { width: 64px; height: 64px; }
.fb-chk.big { width: 96px; height: 96px; }
.fb-chk circle { fill: var(--ok-soft); stroke: var(--ok); stroke-width: 3; stroke-dasharray: 145; stroke-dashoffset: 145; animation: fbDraw .5s ease forwards; }
.fb-chk path { fill: none; stroke: var(--ok); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 40; stroke-dashoffset: 40; animation: fbDraw .35s .4s ease forwards; }
@keyframes fbDraw { to { stroke-dashoffset: 0; } }

/* أثناء العرض التقديمي يرتفع الزر فوق مشغّل العرض في الشاشات الضيقة */
@media (max-width: 1180px) { body.demo-on .fb-widget { bottom: 240px; } }

/* ============ التقرير ============ */
.fb-stack { display: flex; height: 8px; border-radius: 6px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--border); }
.fb-stack i { display: block; height: 100%; }
.fb-stack .r3 { background: var(--ok); }
.fb-stack .r2 { background: var(--info); }
.fb-stack .r1 { background: var(--faint); }
.fb-counts { display: flex; gap: 10px; margin-top: 5px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.bar.fb-later > i { background: var(--faint); }
.fb-kpi-txt { font-size: 17px; font-weight: 700; line-height: 1.4; display: inline-block; }
.fb-unrated { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 12px 18px 16px; border-top: 1px solid var(--border); font-size: 12.5px; }
.fb-cmt { align-items: flex-start; }
.fb-emo-ic { font-size: 17px; }
.fb-cmt-t { line-height: 1.7; font-size: 13.5px; }
.fb-cmt .li-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 4px; }
.fb-pro { width: 100%; border: 0; border-bottom: 1px solid var(--border); background: none; text-align: start; cursor: pointer; border-radius: 10px; padding-inline: 8px; align-items: flex-start; color: inherit; }
.fb-pro:hover { background: var(--surface-2); }
.fb-pro.on { background: var(--primary-soft); }
.fb-pro .split { flex-wrap: wrap; }
.fb-pro .li-title { white-space: normal; }
.mt-xs { margin-top: 6px; }
.fb-g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 1200px) { .fb-g2 { grid-template-columns: minmax(0, 1fr); } }
.fb-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }

/* ============ شاشة الاستبيان ============ */
body.sv-open { overflow: hidden; }
.sv-screen { position: fixed; inset: 0; z-index: 110; background: var(--bg); display: flex; flex-direction: column; animation: fade .2s ease; }
.sv-top { display: flex; align-items: center; gap: 12px; padding: 12px 20px; background: var(--surface); border-bottom: 1px solid var(--border); }
.sv-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.sv-title b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sv-title span { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sv-count { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.sv-prog { height: 4px; background: var(--surface-2); flex: none; }
.sv-prog i { display: block; height: 100%; background: var(--primary); transition: width .3s ease; }
.sv-dots { display: flex; gap: 6px; padding: 10px 20px; overflow-x: auto; scrollbar-width: none; background: var(--surface); border-bottom: 1px solid var(--border); flex: none; }
.sv-dots::-webkit-scrollbar { display: none; }
.sv-dots button { flex: none; width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 700; cursor: pointer; }
.sv-dots button.past { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.sv-dots button.on { background: var(--primary); color: var(--primary-ink); border-color: transparent; }
.sv-body { flex: 1; overflow-y: auto; padding: 24px 20px 32px; }
.sv-wrap { max-width: 820px; margin-inline: auto; display: flex; flex-direction: column; gap: 14px; }
.sv-intro h2 { font-size: 22px; }
.sv-intro p { line-height: 1.9; margin: 0 0 12px; }
.sv-lead { color: var(--primary); font-weight: 600; margin-top: 4px !important; }
.sv-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.sv-chip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 12px; border-radius: 20px; background: var(--surface); border: 1px solid var(--border); font-size: 12.5px; color: var(--muted); }
.sv-chip .ic { width: 14px; height: 14px; }
.sv-sec-head { display: flex; align-items: center; gap: 12px; }
.sv-sec-head h2 { font-size: 19px; }
.sv-sec-head .kpi-ic { font-weight: 700; flex: none; }
.sv-q { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); transition: border-color .15s; }
.sv-q.done { border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); }
.sv-q-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.sv-num { flex: none; min-width: 28px; height: 28px; padding: 0 6px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--border); font-size: 12px; font-weight: 700; color: var(--muted); }
.sv-q.done .sv-num { background: var(--primary); color: var(--primary-ink); border-color: transparent; }
.sv-q-t { font-weight: 600; font-size: 14.5px; line-height: 1.7; }
.sv-hint { font-size: 12px; color: var(--muted); }
.sv-opts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.sv-opt {
  position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; min-height: 48px; padding: 11px 12px;
  border-radius: 11px; border: 1.5px solid var(--border); background: var(--surface-2); cursor: pointer; transition: border-color .15s, background .15s;
}
.sv-opt:hover { border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); }
.sv-opt > input[type="radio"], .sv-opt > input[type="checkbox"] { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.sv-mark { flex: none; width: 20px; height: 20px; border: 2px solid var(--faint); border-radius: 50%; display: grid; place-items: center; background: var(--surface); transition: background .15s, border-color .15s; }
.sv-opt > input[type="checkbox"] + .sv-mark { border-radius: 6px; }
.sv-opt > input:checked + .sv-mark { border-color: var(--primary); background: var(--primary); box-shadow: inset 0 0 0 3px var(--surface); }
.sv-opt > input[type="checkbox"]:checked + .sv-mark { box-shadow: none; }
.sv-opt > input[type="checkbox"]:checked + .sv-mark::after { content: ''; width: 9px; height: 5px; border: solid var(--primary-ink); border-width: 0 0 2px 2px; transform: translateY(-1px) rotate(-45deg); }
.sv-opt > input:focus-visible + .sv-mark { box-shadow: 0 0 0 3px var(--primary-soft); }
.sv-opt:has(> input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.sv-txt { flex: 1; min-width: 0; font-size: 13.5px; line-height: 1.6; }
.sv-other { display: none; flex-basis: 100%; width: 100%; background: var(--surface); }
.sv-opt > input:checked ~ .sv-other { display: block; }
.sv-q textarea.input { resize: vertical; min-height: 84px; line-height: 1.8; }
.sv-scale { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.sv-sc { position: relative; cursor: pointer; }
.sv-sc input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.sv-sc span { display: grid; place-items: center; height: 48px; border-radius: 11px; border: 1.5px solid var(--border); background: var(--surface-2); font-weight: 700; font-size: 16px; transition: background .15s; }
.sv-sc input:checked + span { background: var(--primary); color: var(--primary-ink); border-color: transparent; }
.sv-sc input:focus-visible + span { box-shadow: 0 0 0 3px var(--primary-soft); }
.sv-scale-l { display: flex; justify-content: space-between; gap: 10px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.sv-foot { background: var(--surface); border-top: 1px solid var(--border); padding: 12px 20px; flex: none; }
.sv-foot-in { max-width: 820px; margin-inline: auto; display: flex; align-items: center; gap: 10px; }
.sv-foot .btn { min-height: 42px; padding-inline: 18px; }
.sv-foot .btn:disabled { opacity: .45; cursor: default; }
.sv-answered { flex: 1; text-align: center; font-size: 12.5px; color: var(--muted); }
.sv-thanks { align-items: center; text-align: center; padding: 48px 0; }
.sv-thanks h2 { font-size: 22px; }
.sv-thanks p { margin: 0 0 8px; }

/* عرض الرد للقراءة فقط */
.sv-meta { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 16px; font-size: 13px; padding-bottom: 6px; }
.sv-meta > div { min-width: 0; overflow-wrap: anywhere; }
.sv-meta .muted { display: block; font-size: 12px; }
.sv-ro-sec h4 { font-size: 14px; color: var(--primary); margin: 18px 0 4px; }
.sv-ro-q { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.sv-ro-q:last-child { border-bottom: 0; }
.sv-ro-q.na { opacity: .6; }
.sv-ro-t { line-height: 1.7; }
.sv-ro-a { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 4px; }
.sv-ans { display: inline-block; padding: 1px 8px; border-radius: 6px; background: var(--primary-soft); color: var(--primary); font-size: 12.5px; font-weight: 600; line-height: 1.7; }
.sv-ans small { color: var(--text); font-weight: 400; font-size: 12.5px; }
.sv-ans-txt { line-height: 1.8; white-space: pre-wrap; }

/* ============ الشاشات الصغيرة ============ */
@media (max-width: 640px) {
  .fb-widget { bottom: 16px; inset-inline-end: 16px; }
  .fb-pill { width: 46px; height: 46px; padding: 0; justify-content: center; border-radius: 50%; }
  .fb-pill span { display: none; }
  .fb-pop { position: fixed; inset-inline: 12px; bottom: 72px; width: auto; max-width: none; max-height: calc(100vh - 96px); }
  body:not(.logged-out) .view { padding-bottom: 80px; }
  body:not(.demo-on):not(.logged-out) .toasts { bottom: 72px; }
  body.demo-on .fb-widget { bottom: 270px; }
  .sv-opts, .sv-meta, .sv-ro-q { grid-template-columns: minmax(0, 1fr); }
  .sv-ro-q { gap: 4px; }
  .sv-top, .sv-dots, .sv-foot { padding-inline: 14px; }
  .sv-body { padding: 16px 14px 24px; }
  .sv-q { padding: 14px; }
  .sv-foot .btn { padding-inline: 14px; }
  .sv-intro h2 { font-size: 19px; }
  .sv-sec-head h2 { font-size: 17px; }
}
