/* ========================================
   QuranRoots — Feedback Widget
   Floating button + modal overlay

   Uses widget-scoped CSS variables (--fb-*)
   so the widget adapts to every theme.
   ======================================== */

/* ── Widget theme tokens ───────────────── */

:root {
  --fb-btn-bg:       var(--teal);           /* FAB + submit background */
  --fb-btn-hover:    #1f7f6a;
  --fb-btn-shadow:   rgba(26, 107, 90, 0.38);
  --fb-active-bg:    var(--teal-light);     /* selected type / hover tint */
  --fb-active-color: var(--teal);           /* selected type text / icon */
  --fb-overlay:      rgba(30, 23, 16, 0.48);
  --fb-focus-ring:   rgba(26, 107, 90, 0.15);
}

[data-theme="dark"] {
  --fb-btn-bg:       #2e9e7e;
  --fb-btn-hover:    #38b890;
  --fb-btn-shadow:   rgba(46, 158, 126, 0.45);
  --fb-active-bg:    rgba(46, 158, 126, 0.12);
  --fb-active-color: #5ec9ab;
  --fb-overlay:      rgba(0, 0, 0, 0.62);
  --fb-focus-ring:   rgba(46, 158, 126, 0.2);
}

[data-theme="sepia"] {
  --fb-btn-bg:       #6a7a2e;
  --fb-btn-hover:    #596826;
  --fb-btn-shadow:   rgba(106, 122, 46, 0.35);
  --fb-active-bg:    rgba(106, 122, 46, 0.1);
  --fb-active-color: #6a7a2e;
  --fb-focus-ring:   rgba(106, 122, 46, 0.15);
}

[data-theme="high-contrast"] {
  --fb-btn-bg:       #ffcc00;
  --fb-btn-hover:    #e6b800;
  --fb-btn-shadow:   rgba(255, 204, 0, 0.5);
  --fb-active-bg:    rgba(255, 204, 0, 0.15);
  --fb-active-color: #ffcc00;
  --fb-overlay:      rgba(0, 0, 0, 0.78);
  --fb-focus-ring:   rgba(255, 204, 0, 0.3);
}

[data-theme="manuscript"] {
  --fb-btn-bg:       #2aa198;
  --fb-btn-hover:    #248f87;
  --fb-btn-shadow:   rgba(42, 161, 152, 0.35);
  --fb-active-bg:    rgba(42, 161, 152, 0.1);
  --fb-active-color: #2aa198;
  --fb-focus-ring:   rgba(42, 161, 152, 0.15);
}

[data-theme="olive"] {
  --fb-btn-bg:       #6B8E23;
  --fb-btn-hover:    #5a781d;
  --fb-btn-shadow:   rgba(107, 142, 35, 0.38);
  --fb-active-bg:    rgba(107, 142, 35, 0.1);
  --fb-active-color: #6B8E23;
  --fb-focus-ring:   rgba(107, 142, 35, 0.15);
}

[data-theme="night"] {
  --fb-btn-bg:       #00BFA5;
  --fb-btn-hover:    #00a68e;
  --fb-btn-shadow:   rgba(0, 191, 165, 0.42);
  --fb-active-bg:    rgba(0, 191, 165, 0.1);
  --fb-active-color: #00BFA5;
  --fb-overlay:      rgba(0, 0, 0, 0.72);
  --fb-focus-ring:   rgba(0, 191, 165, 0.2);
}

[data-theme="academic"] {
  --fb-btn-bg:       #1A73E8;
  --fb-btn-hover:    #1557c0;
  --fb-btn-shadow:   rgba(26, 115, 232, 0.35);
  --fb-active-bg:    rgba(26, 115, 232, 0.08);
  --fb-active-color: #1A73E8;
  --fb-focus-ring:   rgba(26, 115, 232, 0.15);
}

/* High-contrast: FAB and submit text must be black (not white) for WCAG */
[data-theme="high-contrast"] .fb-fab,
[data-theme="high-contrast"] .fb-submit,
[data-theme="high-contrast"] .fb-type-btn--active {
  color: #000;
}

/* Night theme: FAB text should be dark since accent is light turquoise */
[data-theme="night"] .fb-fab,
[data-theme="night"] .fb-submit {
  color: #0c0c0c;
  font-weight: 700;
}

/* ── Floating button ──────────────────── */

.fb-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 400;
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--fb-btn-bg);
  color: #fff;
  border: none;
  border-radius: 99px;
  padding: 11px 18px 11px 14px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 18px var(--fb-btn-shadow);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.2s ease,
              background 0.15s ease;
  letter-spacing: 0.01em;
}

.fb-fab:hover {
  background: var(--fb-btn-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px var(--fb-btn-shadow);
}

.fb-fab:active {
  transform: translateY(0);
}

.fb-fab svg {
  flex-shrink: 0;
  opacity: 0.9;
}

/* Pulse dot */
.fb-fab__pulse {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 11px;
  height: 11px;
  background: var(--accent);
  border-radius: 50%;
  border: 2px solid var(--bg-primary);
}

/* ── Modal overlay ────────────────────── */

.fb-overlay {
  position: fixed;
  inset: 0;
  background: var(--fb-overlay);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 500;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

.fb-overlay.fb-overlay--open {
  opacity: 1;
  pointer-events: all;
}

/* ── Modal box ────────────────────────── */

.fb-modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 400px;
  max-width: calc(100vw - 32px);
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateY(16px) scale(0.97);
  transition: transform 0.28s cubic-bezier(0.34, 1.15, 0.64, 1);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.fb-overlay--open .fb-modal {
  transform: translateY(0) scale(1);
}

/* ── Modal header ─────────────────────── */

.fb-modal__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 22px 0;
}

.fb-modal__brand {
  font-size: 13px;
  font-weight: 600;
  color: var(--fb-active-color);
  letter-spacing: 0.04em;
}

.fb-modal__close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  transition: color 0.15s;
}

.fb-modal__close:hover {
  color: var(--text-primary);
}

.fb-modal__title {
  font-size: 20px;
  font-weight: 400;
  color: var(--text-primary);
  padding: 10px 22px 2px;
}

.fb-modal__subtitle {
  font-size: 13px;
  color: var(--text-muted);
  padding: 0 22px 18px;
  font-style: italic;
}

/* ── Type selector ────────────────────── */

.fb-type-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 0 22px 18px;
}

.fb-type-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 13px 8px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-primary);
  cursor: pointer;
  font-family: var(--font-body);
  color: var(--text-secondary);
  transition: all 0.18s;
}

.fb-type-btn:hover {
  border-color: var(--fb-active-color);
  background: var(--fb-active-bg);
}

.fb-type-btn--active {
  border-color: var(--fb-active-color);
  background: var(--fb-active-bg);
  color: var(--fb-active-color);
}

.fb-type-btn__label {
  font-size: 13px;
  font-weight: 600;
}

.fb-type-btn__desc {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.4;
}

.fb-type-btn--active .fb-type-btn__desc {
  color: var(--fb-active-color);
  opacity: 0.8;
}

/* ── Form panels ──────────────────────── */

.fb-form {
  padding: 0 22px 22px;
}

.fb-panel {
  display: none;
}

.fb-panel--active {
  display: block;
}

/* ── Form elements ────────────────────── */

.fb-field {
  margin-bottom: 14px;
}

.fb-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.fb-input,
.fb-textarea {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.fb-input:focus,
.fb-textarea:focus {
  border-color: var(--fb-active-color);
  box-shadow: 0 0 0 3px var(--fb-focus-ring);
}

.fb-textarea {
  resize: vertical;
  min-height: 88px;
}

/* ── Star rating (CSS-only) ───────────── */

.fb-stars {
  display: flex;
  flex-direction: row-reverse;
  justify-content: flex-end;
  gap: 2px;
}

.fb-stars input[type='radio'] {
  display: none;
}

.fb-stars label {
  font-size: 30px;
  color: var(--border);
  cursor: pointer;
  line-height: 1;
  transition: color 0.1s;
}

.fb-stars input:checked ~ label,
.fb-stars label:hover,
.fb-stars label:hover ~ label {
  color: var(--accent);
}

/* ── Sub-type toggle ──────────────────── */

.fb-subtype {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.fb-subtype-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-primary);
  font-family: var(--font-body);
  font-size: 13px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.15s;
}

.fb-subtype-btn--active {
  border-color: var(--fb-active-color);
  background: var(--fb-active-bg);
  color: var(--fb-active-color);
  font-weight: 600;
}

/* Bug sub-type keeps a distinct red regardless of theme */
.fb-subtype-btn--bug.fb-subtype-btn--active {
  border-color: var(--btn-again, #a83232);
  background: rgba(168, 50, 50, 0.08);
  color: var(--btn-again, #a83232);
}

/* ── Submit button ────────────────────── */

.fb-submit {
  width: 100%;
  padding: 12px;
  background: var(--fb-btn-bg);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  margin-top: 6px;
  letter-spacing: 0.01em;
}

.fb-submit:hover {
  background: var(--fb-btn-hover);
}

.fb-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ── Error message ────────────────────── */

.fb-error {
  display: none;
  font-size: 13px;
  color: var(--btn-again, #a83232);
  background: rgba(168, 50, 50, 0.06);
  border: 1px solid rgba(168, 50, 50, 0.25);
  border-radius: var(--radius);
  padding: 8px 12px;
  margin-bottom: 12px;
}

.fb-error--show {
  display: block;
}

/* ── Success state ────────────────────── */

.fb-success {
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 44px 28px 48px;
}

.fb-success--show {
  display: flex;
}

.fb-success__icon {
  width: 56px;
  height: 56px;
  background: var(--fb-active-bg);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
  font-size: 24px;
  color: var(--fb-active-color);
}

.fb-success__title {
  font-size: 21px;
  font-weight: 400;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.fb-success__msg {
  font-size: 14px;
  color: var(--text-muted);
  font-style: italic;
  line-height: 1.65;
  margin-bottom: 14px;
}

.fb-success__arabic {
  font-family: var(--arabic-font);
  font-size: 24px;
  color: var(--fb-active-color);
  direction: rtl;
}

/* ── Responsive ───────────────────────── */

@media (max-width: 480px) {
  .fb-overlay {
    align-items: flex-end;
    justify-content: center;
    padding: 0;
  }

  .fb-modal {
    width: 100%;
    max-width: 100%;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    max-height: 92vh;
  }

  .fb-fab {
    bottom: 16px;
    right: 16px;
    padding: 10px 14px 10px 12px;
    font-size: 13px;
  }
}
