/* Floating Feedback Widget Styles */
.pf-feedback-widget {
  position: fixed;
  bottom: 20px;
  right: 0;
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
}

/* Feedback Button */
.pf-feedback-btn {
  position: relative;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px 0 0 8px;
  padding: 12px 20px;
  font-weight: 600;
  font-size: 14px;
  color: #0f172a;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 100px;
}

.pf-feedback-btn:hover {
  background: #f8fafc;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transform: translateX(-2px);
}

.pf-feedback-btn:active {
  transform: translateX(0);
}

.pf-feedback-btn.pf-feedback-btn-hold {
  opacity: 0;
  pointer-events: none;
}

.pf-feedback-btn-text {
  display: block;
}

/* Teal accent bar */
.pf-feedback-btn::after {
  content: '';
  position: absolute;
  right: -4px;
  top: 0;
  bottom: 0;
  width: 4px;
  background: #0ea5a4;
  border-radius: 0 8px 8px 0;
}

/* Feedback Panel */
.pf-feedback-panel {
  position: absolute;
  bottom: 100%;
  right: 0;
  width: 380px;
  max-width: calc(100vw - 40px);
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px 12px 0 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  margin-bottom: 8px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: all 0.3s ease;
}

.pf-feedback-panel[aria-hidden="false"] {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.pf-feedback-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
  border-radius: 12px 12px 0 0;
}

.pf-feedback-panel-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #0f172a;
}

.pf-feedback-close {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.pf-feedback-close:hover {
  background: #e2e8f0;
  color: #0f172a;
}

/* Feedback Form */
.pf-feedback-form {
  padding: 20px;
}

.pf-feedback-message {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
  line-height: 1.5;
}

.pf-feedback-message.success {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #6ee7b7;
}

.pf-feedback-message.error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

.pf-feedback-field {
  margin-bottom: 16px;
}

.pf-feedback-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: #0f172a;
  margin-bottom: 6px;
}

.pf-feedback-required {
  color: #ef4444;
}

.pf-feedback-optional {
  font-weight: 400;
  color: #64748b;
  font-size: 12px;
}

.pf-feedback-input,
.pf-feedback-select,
.pf-feedback-textarea {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-family: inherit;
  transition: all 0.2s ease;
  background: #ffffff;
  color: #0f172a;
}

.pf-feedback-input:focus,
.pf-feedback-select:focus,
.pf-feedback-textarea:focus {
  outline: none;
  border-color: #0ea5a4;
  box-shadow: 0 0 0 3px rgba(14, 165, 164, 0.1);
}

.pf-feedback-textarea {
  resize: vertical;
  min-height: 100px;
}

.pf-feedback-char-count {
  text-align: right;
  font-size: 12px;
  color: #64748b;
  margin-top: 4px;
}

.pf-feedback-submit {
  width: 100%;
  padding: 12px 20px;
  background: #0ea5a4;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.pf-feedback-submit:hover:not(:disabled) {
  background: #0b7f7e;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(14, 165, 164, 0.3);
}

.pf-feedback-submit:active:not(:disabled) {
  transform: translateY(0);
}

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

.pf-feedback-submit-spinner {
  display: inline-block;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Mobile Responsive */
@media (max-width: 640px) {
  .pf-feedback-panel {
    width: calc(100vw - 20px);
    max-width: 100%;
    right: 10px;
  }

  .pf-feedback-btn {
    padding: 10px 16px;
    font-size: 13px;
    min-width: 90px;
  }

  .pf-feedback-form {
    padding: 16px;
  }
}

/* ============================
   Feedback widget: responsive fix
   (mobile centered + safe margins)
   ============================ */

.pf-feedback-panel{
  max-width: calc(100vw - 32px);
}

/* Mobile: center modal-like panel with breathing room */
@media (max-width: 520px){
  .pf-feedback-panel{
    left: 50% !important;
    right: auto !important;
    top: 50% !important;
    bottom: auto !important;
    transform: translate(-50%, -50%) !important;

    width: min(440px, calc(100vw - 32px)) !important;
    max-height: calc(100vh - 32px) !important; /* top+bottom margin */
    overflow: auto !important;

    border-radius: 18px;
  }

  /* keep the button reachable and not stuck to edges */
  .pf-feedback-btn{
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
  }
}

.pf-feedback-backdrop{
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.45);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
  z-index: 9998;
}

/* stacking order: backdrop < button < panel (closed) */
.pf-feedback-backdrop{ z-index: 9998; }
.pf-feedback-btn{ z-index: 9997; }      /* <-- BELOW backdrop so it can't overlap modal */
.pf-feedback-panel{ z-index: 10000; }

.pf-feedback-backdrop.is-open{
  opacity: 1;
  pointer-events: auto;
}

/* Mobile: force center EVEN when panel is open (open-state rules were overriding transform) */
@media (max-width: 520px){
  .pf-feedback-panel,
  .pf-feedback-panel[aria-hidden="false"]{
    left: 50% !important;
    top: 50% !important;
    right: auto !important;
    bottom: auto !important;
    transform: translate(-50%, -50%) !important;
  }
}

/* Mobile: bulletproof centering using flex wrapper when open */
@media (max-width: 640px){
  .pf-feedback-widget.is-open{
    position: fixed;
    inset: 0;
    padding: 16px;                 /* top/bottom margin */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;                /* wrapper above page */
  }

  .pf-feedback-widget.is-open .pf-feedback-backdrop{
    position: absolute;
    inset: 0;
    z-index: 0;
  }

  .pf-feedback-widget.is-open .pf-feedback-panel{
    position: relative !important; /* stop fixed right/bottom logic */
    z-index: 1;

    width: min(440px, calc(100vw - 32px)) !important;
    max-height: calc(100vh - 32px) !important;
    overflow: auto !important;

    left: auto !important;
    right: auto !important;
    top: auto !important;
    bottom: auto !important;
    transform: none !important;
  }
}

/* Mobile: when open, treat panel as a normal flex item (no offsets) + hide the toggle */
@media (max-width: 640px){
  .pf-feedback-widget.is-open .pf-feedback-btn{
    display: none !important;     /* stronger than opacity */
  }

  .pf-feedback-widget.is-open .pf-feedback-panel{
    position: relative !important;
    inset: auto !important;       /* kills left/top/right/bottom:0 from any prior rule */
    left: auto !important;
    right: auto !important;
    top: auto !important;
    bottom: auto !important;
    transform: none !important;
  }
}

/* Mobile: when open, ONLY show the panel (button must disappear or it will push panel off-center) */
@media (max-width: 640px){
  #pf-feedback-widget.is-open{
    position: fixed !important;
    inset: 0 !important;
    padding: 16px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  #pf-feedback-widget.is-open #pf-feedback-btn{
    display: none !important;
  }

  #pf-feedback-widget.is-open #pf-feedback-panel{
    position: relative !important;
    inset: auto !important;   /* kills any 0px offsets */
    margin: 0 auto !important;
  }
}

/* Prevent 1-frame button/shadow flash after close */
.pf-feedback-btn.pf-feedback-btn-hold{
  opacity: 0 !important;
  pointer-events: none !important;
}

/* While closing: keep layout stable but don't block clicks behind it */
#pf-feedback-widget.is-closing{
  pointer-events: none !important;
}

#pf-feedback-widget.is-closing #pf-feedback-panel,
#pf-feedback-widget.is-closing #pf-feedback-backdrop{
  pointer-events: none !important;
}
