/* Floating feedback widget for the Product Builder pages.
   Markup: application/views/inc/inc_producttemplatefeedback.php
   Behaviour: javascript/producttemplatefeedback-raw.js

   z-index sits at 1030 on purpose — Bootstrap's fixed-element level. Above the
   page, but below the modal backdrop (1050) and the toast container (1090), so
   the bubble never floats over an open dialog in the builder.
   See docs/PRODUCT_TEMPLATE_CONFIGURATOR.md */

.ptfb {
  --ptfb-accent: #0d6efd;
  --ptfb-accent-dark: #0b5ed7;
  --ptfb-border: #e3e6ea;
  --ptfb-ink: #1f2937;
  --ptfb-muted: #6b7280;
  --ptfb-z: 1030;
}

/* ── Launcher ─────────────────────────────────────────────────────────────── */

.ptfb-toggle {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: var(--ptfb-z);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.125rem;
  border: none;
  border-radius: 2rem;
  background: var(--ptfb-accent);
  color: #fff;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(13, 110, 253, 0.35);
  transition: transform 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.ptfb-toggle:hover {
  background: var(--ptfb-accent-dark);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(13, 110, 253, 0.45);
  color: #fff;
}

.ptfb-toggle:focus-visible {
  outline: 3px solid rgba(13, 110, 253, 0.4);
  outline-offset: 2px;
}

.ptfb-toggle i {
  font-size: 1rem;
}

/* Panel open: the launcher becomes a plain circle so the label does not sit
   under the panel it opened. */
.ptfb-toggle.ptfb-toggle-open .ptfb-toggle-label {
  display: none;
}

.ptfb-toggle.ptfb-toggle-open {
  padding: 0.75rem;
  border-radius: 50%;
}

/* ── Panel ────────────────────────────────────────────────────────────────── */

.ptfb-panel {
  position: fixed;
  bottom: 5rem;
  right: 1.25rem;
  z-index: var(--ptfb-z);
  width: 22.5rem;
  max-width: calc(100vw - 2.5rem);
  max-height: calc(100vh - 7rem);
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid var(--ptfb-border);
  border-radius: 0.75rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  color: var(--ptfb-ink);
  overflow: hidden;
  /* Entrance: the panel is unhidden first, then .ptfb-panel-in is added on the
     next frame so the transition has two states to move between. */
  opacity: 0;
  transform: translateY(0.75rem);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

/* [hidden] alone loses to the display:flex above */
.ptfb-panel[hidden] {
  display: none;
}

.ptfb-panel.ptfb-panel-in {
  opacity: 1;
  transform: translateY(0);
}

.ptfb-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--ptfb-border);
  background: #f8fafc;
}

.ptfb-title {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 700;
}

.ptfb-sub {
  margin: 0.125rem 0 0;
  font-size: 0.75rem;
  color: var(--ptfb-muted);
  line-height: 1.4;
}

.ptfb-close {
  flex: 0 0 auto;
  border: none;
  background: transparent;
  color: var(--ptfb-muted);
  font-size: 1rem;
  line-height: 1;
  padding: 0.25rem;
  cursor: pointer;
  border-radius: 0.25rem;
}

.ptfb-close:hover {
  color: var(--ptfb-ink);
  background: #eef2f7;
}

.ptfb-body {
  padding: 1rem;
  overflow-y: auto;
}

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

.ptfb-field {
  margin-bottom: 0.875rem;
}

.ptfb-label {
  display: block;
  margin-bottom: 0.3125rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ptfb-muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.ptfb-input {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 0.5rem;
  padding: 0.5rem 0.625rem;
  font-size: 0.875rem;
  color: var(--ptfb-ink);
  background: #fff;
}

.ptfb-input:focus {
  border-color: var(--ptfb-accent);
  outline: none;
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15);
}

.ptfb-textarea {
  resize: vertical;
  min-height: 5.5rem;
  line-height: 1.45;
}

.ptfb-hint {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.6875rem;
  color: var(--ptfb-muted);
}

.ptfb-error {
  margin: 0 0 0.75rem;
  padding: 0.5rem 0.625rem;
  border: 1px solid #fca5a5;
  border-radius: 0.5rem;
  background: #fef2f2;
  color: #b91c1c;
  font-size: 0.78125rem;
}

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

/* Mood row — an optional one-tap signal, so a report can be useful even when
   the artist types only a sentence. */
.ptfb-mood {
  display: flex;
  gap: 0.375rem;
}

.ptfb-mood-btn {
  flex: 1 1 0;
  border: 1px solid #cbd5e1;
  border-radius: 0.5rem;
  background: #fff;
  color: var(--ptfb-muted);
  font-size: 1.25rem;
  line-height: 1;
  padding: 0.4375rem 0;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

.ptfb-mood-btn:hover {
  border-color: var(--ptfb-accent);
  color: var(--ptfb-accent);
}

.ptfb-mood-btn.ptfb-mood-on {
  border-color: var(--ptfb-accent);
  background: #eff6ff;
  color: var(--ptfb-accent);
}

.ptfb-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.625rem;
  margin-top: 0.25rem;
}

.ptfb-hint-page {
  margin-top: 0;
  flex: 1 1 auto;
}

.ptfb-send {
  flex: 0 0 auto;
  border: none;
  border-radius: 0.5rem;
  background: var(--ptfb-accent);
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0.5rem 0.9375rem;
  cursor: pointer;
}

.ptfb-send:hover:not(:disabled) {
  background: var(--ptfb-accent-dark);
  color: #fff;
}

.ptfb-send:disabled {
  opacity: 0.6;
  cursor: default;
}

.ptfb-send-ghost {
  background: #fff;
  border: 1px solid #cbd5e1;
  color: var(--ptfb-muted);
}

.ptfb-send-ghost:hover:not(:disabled) {
  background: #f1f5f9;
  color: var(--ptfb-ink);
}

/* ── Confirmation ─────────────────────────────────────────────────────────── */

.ptfb-done {
  text-align: center;
  padding: 0.75rem 0.25rem 0.5rem;
}

.ptfb-done[hidden] {
  display: none;
}

.ptfb-done-icon {
  font-size: 2.25rem;
  color: #16a34a;
}

.ptfb-done-title {
  margin: 0.625rem 0 0.25rem;
  font-size: 0.9375rem;
  font-weight: 700;
}

.ptfb-done-text {
  margin: 0 0 0.875rem;
  font-size: 0.8125rem;
  color: var(--ptfb-muted);
  line-height: 1.5;
}

/* ── Small screens ────────────────────────────────────────────────────────── */

/* At 320px a 22.5rem panel would not fit, so it becomes a bottom sheet that
   spans the viewport with the launcher tucked in beside it. */
@media (max-width: 575.98px) {
  .ptfb-toggle {
    bottom: 0.875rem;
    right: 0.875rem;
    padding: 0.75rem;
    border-radius: 50%;
  }

  .ptfb-toggle-label {
    display: none;
  }

  .ptfb-panel {
    left: 0.625rem;
    right: 0.625rem;
    bottom: 0.625rem;
    width: auto;
    max-width: none;
    max-height: calc(100vh - 1.25rem);
  }

  /* The launcher would sit on top of a full-width sheet */
  .ptfb-toggle.ptfb-toggle-open {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ptfb-toggle,
  .ptfb-panel {
    transition: none;
  }

  .ptfb-toggle:hover {
    transform: none;
  }
}
