/* ============================================================
   Floating Panel — 右下角悬浮操作面板
   品牌色来自 global-tokens.css 的 --brand-* 变量。
   ============================================================ */

/* ---- Container (fixed bottom-right) ---- */
.fp-wrapper {
  position: fixed;
  bottom: 32px;
  right: 32px;
  z-index: 9999;
  display: flex;
  flex-direction: row-reverse;
  align-items: flex-end;
  gap: 16px;
}

/* ---- Button stack ---- */
.fp-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.fp-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border: 0;
  border-radius: 50%;
  background: var(--brand-red);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(1, 120, 218, 0.35);
  transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
  text-decoration: none;
}

.fp-btn:hover,
.fp-btn:focus-visible {
  background: var(--brand-red-dark);
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(1, 120, 218, 0.45);
}

.fp-btn svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

/* ---- Tooltip label ---- */
.fp-btn-label {
  position: absolute;
  right: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--brand-dark-1);
  color: #fff;
  font: 13px/1.4 "Open Sans", sans-serif;
  padding: 4px 10px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.fp-btn-label::after {
  content: "";
  position: absolute;
  right: -5px;
  top: 50%;
  transform: translateY(-50%);
  border: 5px solid transparent;
  border-left-color: var(--brand-dark-1);
}

.fp-btn:hover .fp-btn-label {
  opacity: 1;
}

/* ---- Back to top: hidden until scrolled ---- */
.fp-btn--top {
  opacity: 0;
  transform: scale(0.8);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease, background 0.2s ease;
}

.fp-btn--top.is-visible {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

/* ============================================================
   Popover Panel (right side, adjacent to buttons)
   ============================================================ */

.fp-panel {
  display: none;
  width: 380px;
  max-height: 80vh;
  overflow-y: auto;
}

.fp-panel.is-open {
  display: block;
  animation: fp-slide-in 0.25s ease forwards;
}

@keyframes fp-slide-in {
  from {
    opacity: 0;
    transform: translateX(16px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.fp-panel-inner {
  position: relative;
  background: var(--brand-paper);
  border-radius: 12px;
  padding: 28px 24px 24px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

/* ---- Close button ---- */
.fp-panel-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--brand-muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.fp-panel-close:hover {
  background: var(--brand-soft);
  color: var(--brand-ink);
}

/* ---- Form title ---- */
.fp-form-title {
  font: 700 18px/1.3 "Open Sans", sans-serif;
  color: var(--brand-ink);
  margin: 0 0 20px;
  padding-right: 28px;
}

/* ---- Notifications ---- */
.fp-notice {
  padding: 10px 14px;
  border-radius: 8px;
  font: 14px/1.5 "Open Sans", sans-serif;
  margin-bottom: 16px;
}

.fp-notice--success {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.fp-notice--error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

/* ---- Form grid ---- */
.fp-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.fp-row {
  display: grid;
  gap: 14px;
}

.fp-row--2 {
  grid-template-columns: 1fr 1fr;
}

/* ---- Field ---- */
.fp-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.fp-field label {
  font: 600 13px/1.4 "Open Sans", sans-serif;
  color: var(--brand-text);
}

.fp-field label span {
  color: var(--brand-red);
}

.fp-field input,
.fp-field textarea {
  width: 100%;
  padding: 10px 12px;
  font: 14px/1.5 "Open Sans", sans-serif;
  color: var(--brand-ink);
  background: var(--brand-paper);
  border: 1px solid var(--brand-line);
  border-radius: 8px;
  outline: 0;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  box-sizing: border-box;
}

.fp-field input:focus,
.fp-field textarea:focus {
  border-color: var(--brand-red);
  box-shadow: 0 0 0 3px rgba(1, 120, 218, 0.12);
}

.fp-field input::placeholder,
.fp-field textarea::placeholder {
  color: var(--brand-muted);
}

/* ---- Submit button ---- */
.fp-btn-submit {
  width: 100%;
  padding: 12px 20px;
  font: 600 15px/1.4 "Open Sans", sans-serif;
  color: #fff;
  background: var(--brand-red);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease;
  margin-top: 4px;
}

.fp-btn-submit:hover {
  background: var(--brand-red-dark);
}

/* ============================================================
   Responsive
   ============================================================ */

/* ---- ≤ 768px: bottom sheet ---- */
@media (max-width: 768px) {
  .fp-wrapper {
    right: 0;
    bottom: 0;
    left: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    pointer-events: none;
  }

  .fp-panel {
    width: 100%;
    max-height: 85vh;
    pointer-events: auto;
  }

  .fp-panel.is-open {
    animation: fp-slide-up 0.3s ease forwards;
  }

  @keyframes fp-slide-up {
    from {
      opacity: 0;
      transform: translateY(24px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .fp-panel-inner {
    border-radius: 16px 16px 0 0;
    padding: 24px 20px 20px;
    max-height: 85vh;
    overflow-y: auto;
  }

  .fp-buttons {
    flex-direction: row;
    justify-content: flex-end;
    gap: 10px;
    padding: 12px 16px 16px;
    pointer-events: auto;
  }

  .fp-btn {
    width: 48px;
    height: 48px;
  }

  .fp-btn svg {
    width: 22px;
    height: 22px;
  }

  /* Move tooltip above on mobile */
  .fp-btn-label {
    right: auto;
    left: 50%;
    top: auto;
    bottom: calc(100% + 8px);
    transform: translateX(-50%);
  }

  .fp-btn-label::after {
    right: auto;
    left: 50%;
    top: 100%;
    transform: translateX(-50%);
    border-top-color: var(--brand-dark-1);
    border-left-color: transparent;
  }
}

/* ---- ≤ 480px ---- */
@media (max-width: 480px) {
  .fp-buttons {
    gap: 8px;
    padding: 8px 12px 12px;
  }

  .fp-btn {
    width: 44px;
    height: 44px;
  }

  .fp-btn svg {
    width: 20px;
    height: 20px;
  }
}


/* On mobile, keep the floating contact actions in a vertical stack. */
@media (max-width: 768px) {
  .fp-wrapper { right: 16px; bottom: 16px; left: auto; align-items: flex-end; }
  .fp-buttons { flex-direction: column; padding: 0; }
}
