/* prototype-feedback widget — scoped with .pf- prefix to avoid host conflicts */

.pf-root,
.pf-root * {
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  line-height: 1.4;
}

/* Floating trigger button — vertical tab pinned to right edge.
   writing-mode: vertical-rl runs the label top-to-bottom (English convention:
   tilt head right to read). Icon renders above the label. */
.pf-launcher {
  position: fixed;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  z-index: 2147483000;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 18px 10px;
  background: #111827;
  color: #ffffff;
  border: 0;
  border-top-left-radius: 12px;
  border-bottom-left-radius: 12px;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: -4px 0 14px rgba(0, 0, 0, 0.25);
  min-height: 140px;
}
.pf-launcher.pf-ready {
  transition: transform 0.15s ease, background 0.15s ease;
}
.pf-launcher .pf-launcher-icon {
  flex-shrink: 0;
}
.pf-launcher:hover {
  background: #1f2937;
  transform: translateY(-50%) translateX(-3px);
}
.pf-launcher:focus-visible {
  outline: 2px solid #60a5fa;
  outline-offset: 2px;
}
.pf-launcher.pf-active {
  background: #dc2626;
}
.pf-launcher-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Select-mode cursor */
.pf-select-mode,
.pf-select-mode * {
  cursor: crosshair !important;
}

/* Hover outline on candidate elements */
.pf-outline {
  outline: 2px dashed #2563eb !important;
  outline-offset: 2px !important;
  background: rgba(37, 99, 235, 0.06) !important;
}

/* Backdrop for popover */
.pf-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2147483100;
  background: rgba(15, 23, 42, 0.12);
}

/* Popover */
.pf-popover {
  position: absolute;
  z-index: 2147483200;
  width: 320px;
  max-width: calc(100vw - 24px);
  background: #ffffff;
  color: #0f172a;
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.25);
  border: 1px solid #e2e8f0;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.pf-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.pf-popover-title {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: #0f172a;
}
.pf-popover-close {
  background: transparent;
  border: 0;
  color: #64748b;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  line-height: 0;
}
.pf-popover-close:hover {
  background: #f1f5f9;
  color: #0f172a;
}
.pf-selector {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  color: #334155;
  background: #f1f5f9;
  padding: 6px 8px;
  border-radius: 6px;
  word-break: break-all;
  max-height: 60px;
  overflow: auto;
}
.pf-textarea {
  width: 100%;
  min-height: 90px;
  resize: vertical;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  color: #0f172a;
  background: #ffffff;
}
.pf-textarea:focus {
  outline: 2px solid #2563eb;
  outline-offset: -1px;
  border-color: #2563eb;
}
.pf-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.pf-hint {
  font-size: 11px;
  color: #64748b;
}
.pf-button-row {
  display: flex;
  gap: 6px;
}
.pf-btn {
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  border: 0;
  cursor: pointer;
  font-family: inherit;
}
.pf-btn-primary {
  background: #111827;
  color: #ffffff;
}
.pf-btn-primary:hover {
  background: #1f2937;
}
.pf-btn-primary:disabled {
  background: #94a3b8;
  cursor: not-allowed;
}
.pf-btn-ghost {
  background: transparent;
  color: #475569;
}
.pf-btn-ghost:hover {
  background: #f1f5f9;
}

/* Toast */
.pf-toast {
  position: fixed;
  bottom: 80px;
  right: 20px;
  z-index: 2147483300;
  background: #16a34a;
  color: #ffffff;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 6px 20px rgba(22, 163, 74, 0.35);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}
.pf-toast.pf-error {
  background: #dc2626;
  box-shadow: 0 6px 20px rgba(220, 38, 38, 0.35);
}
.pf-toast.pf-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Mobile: promote the popover from floating card to a bottom-sheet
   (standard mobile pattern — thumb-reach, doesn't fight small viewports) */
@media (max-width: 640px) {
  .pf-popover {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    bottom: 0 !important;
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    border-radius: 16px 16px 0 0 !important;
    max-height: 82vh;
    overflow-y: auto;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.35);
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    animation: pf-sheet-in 0.22s ease-out;
  }
  @keyframes pf-sheet-in {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }
  /* Larger tap targets in the sheet */
  .pf-popover textarea { min-height: 120px; font-size: 16px; }
  .pf-popover .pf-btn-primary,
  .pf-popover .pf-btn-ghost { min-height: 48px; font-size: 15px; }

  /* Launcher: swap the desktop vertical side-tab for a standard mobile FAB */
  .pf-launcher {
    top: auto;
    right: 16px;
    bottom: 16px;
    transform: none !important;
    writing-mode: horizontal-tb;
    text-orientation: mixed;
    padding: 12px 16px;
    min-height: 0;
    border-radius: 999px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
    letter-spacing: 0.06em;
  }
  .pf-launcher:hover {
    transform: none !important;
  }
  .pf-launcher .pf-launcher-icon {
    transform: none;
  }

  /* Arrows repositioned for the bottom-right FAB */
  .pf-arrow-top {
    top: auto;
    right: 96px;
    bottom: 36px;
  }
  .pf-arrow-bottom {
    top: auto;
    right: 36px;
    bottom: 96px;
    transform: rotate(90deg);
  }
  @keyframes pf-arrow-in-flip {
    from { opacity: 0; transform: rotate(90deg) translateX(-8px); }
    to   { opacity: 1; transform: rotate(90deg) translateX(0); }
  }
  @keyframes pf-arrow-nudge-flip {
    0%, 100% { transform: rotate(90deg) translateX(0); }
    50%      { transform: rotate(90deg) translateX(-6px); }
  }
}
