/* Contact Tracker Pro — Frontend v3.0 — Bubble FAB */

:root {
  --ctp-z:      9990;
  --ctp-side:   24px;
  --ctp-bottom: 30px;
  --ctp-gap:    14px;
  --ctp-size:   60px;
}

/* ── Widget shell ─────────────────────────────────────────────────────────── */
.ctp-widget {
  position: fixed;
  bottom: var(--ctp-bottom);
  /* iOS: keep buttons above the home indicator / Safari toolbar */
  bottom: calc(var(--ctp-bottom) + env(safe-area-inset-bottom, 0px));
  z-index: var(--ctp-z);
  display: flex;
  flex-direction: column;
  gap: var(--ctp-gap);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  /* pointer-events NOT set to none — iOS Safari < 15.4 has a bug where
     children with pointer-events:auto still miss touch events when any
     ancestor has pointer-events:none. Non-interactive children opt out below. */
}
.ctp-pos-right { right: var(--ctp-side); align-items: flex-end; }
.ctp-pos-left  { left:  var(--ctp-side); align-items: flex-start; }

/* ── Bubble wrapper ───────────────────────────────────────────────────────── */
.ctp-bub {
  position: relative;
  display: flex;
  align-items: center;
  width: var(--ctp-size);
  height: var(--ctp-size);
  pointer-events: auto;
}

/* Staggered spring entry */
.ctp-bub { animation: ctp-pop-in .52s cubic-bezier(.34, 1.56, .64, 1) both; }
.ctp-bub:nth-child(1) { animation-delay: .06s; }
.ctp-bub:nth-child(2) { animation-delay: .16s; }
.ctp-bub:nth-child(3) { animation-delay: .26s; }
.ctp-bub:nth-child(4) { animation-delay: .36s; }
.ctp-bub:nth-child(5) { animation-delay: .46s; }

@keyframes ctp-pop-in {
  from { opacity: 0; transform: scale(.3) translateY(24px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── Pulsing glow ring ────────────────────────────────────────────────────── */
.ctp-bub-ring {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0; /* longhand — inset: 0 unsupported in Safari < 14.1 */
  border-radius: 50%;
  background: var(--fab-glow, rgba(0, 0, 0, .2));
  animation: ctp-ring-pulse 2.8s ease-out infinite;
  pointer-events: none;
  z-index: 0;
}
@keyframes ctp-ring-pulse {
  0%   { transform: scale(1);    opacity: .7; }
  60%  { transform: scale(1.75); opacity: 0; }
  100% { transform: scale(1.75); opacity: 0; }
}

/* ── FAB circle button ────────────────────────────────────────────────────── */
.ctp-bub-btn {
  position: relative;
  z-index: 2; /* above ring (z-index:0) */
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation; /* removes 300 ms tap delay on mobile */
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
  width: var(--ctp-size);
  height: var(--ctp-size);
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: var(--fab-bg, #0073aa);
  color: #fff;
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow:
    0 6px 26px var(--fab-glow, rgba(0, 0, 0, .28)),
    0 2px 8px rgba(0, 0, 0, .14),
    inset 0 1px 0 rgba(255, 255, 255, .28);
  -webkit-transition:
    -webkit-transform .32s cubic-bezier(.34, 1.56, .64, 1),
    box-shadow .25s ease;
  transition:
    transform .32s cubic-bezier(.34, 1.56, .64, 1),
    box-shadow .25s ease;
  outline: none;
  overflow: hidden;
}

/* Glossy inner sheen */
.ctp-bub-btn::before {
  content: '';
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  border-radius: 50%;
  background: linear-gradient(145deg, rgba(255, 255, 255, .3) 0%, transparent 52%);
  pointer-events: none;
}
.ctp-bub-btn svg {
  position: relative;
  z-index: 1;
  display: block;
  width: 27px;
  height: 27px;
}

/* Hover lift — desktop */
@media (hover: hover) {
  .ctp-bub:hover .ctp-bub-btn {
    transform: scale(1.15) translateY(-3px);
    box-shadow:
      0 12px 38px var(--fab-glow, rgba(0, 0, 0, .35)),
      0 4px 14px rgba(0, 0, 0, .18),
      inset 0 1px 0 rgba(255, 255, 255, .28);
  }
}
.ctp-bub-btn:active { transform: scale(.91) !important; transition-duration: .1s; }
.ctp-bub-btn:focus-visible {
  outline: 3px solid rgba(255, 255, 255, .9);
  outline-offset: 3px;
}

/* ── Hover tooltip label ──────────────────────────────────────────────────── */
.ctp-bub-tip {
  position: absolute;
  top: 50%;
  transform: translateY(-50%) translateX(10px);
  background: rgba(255, 255, 255, .97);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: #1e293b;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .01em;
  padding: 7px 14px;
  border-radius: 100px;
  white-space: nowrap;
  box-shadow: 0 4px 20px rgba(0, 0, 0, .13), 0 1px 4px rgba(0, 0, 0, .08);
  pointer-events: none;
  opacity: 0;
  transition: opacity .22s ease .06s, transform .28s cubic-bezier(.34, 1.56, .64, 1) .06s;
}
.ctp-pos-right .ctp-bub-tip {
  right: calc(var(--ctp-size) + 10px);
  left: auto;
}
.ctp-pos-left .ctp-bub-tip {
  left: calc(var(--ctp-size) + 10px);
  right: auto;
  transform: translateY(-50%) translateX(-10px);
}

@media (hover: hover) {
  .ctp-bub:hover .ctp-bub-tip {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
    transition-delay: 0s;
  }
}

/* Hide labels on touch-only screens */
@media (hover: none) {
  .ctp-bub-tip { display: none; }
}

/* ── Mobile sizing ────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  :root {
    --ctp-side:   14px;
    --ctp-bottom: 22px;
    --ctp-gap:    12px;
    --ctp-size:   54px;
  }
  .ctp-bub-btn svg { width: 24px; height: 24px; }
}

/* ══════════════════════════════════════════════════════════════════════════
   Modals
   ══════════════════════════════════════════════════════════════════════════ */
.ctp-modal {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  z-index: calc(var(--ctp-z) + 10);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.ctp-modal[hidden] { display: none; }

.ctp-modal-overlay {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  background: rgba(15, 23, 42, .55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  cursor: pointer;
}
.ctp-modal-box {
  position: relative;
  background: #fff;
  border-radius: 18px;
  width: 100%;
  max-width: 440px;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0, 0, 0, .28);
  animation: ctp-modal-in .28s cubic-bezier(.34, 1.56, .64, 1) both;
}
@keyframes ctp-modal-in {
  from { opacity: 0; transform: scale(.88) translateY(20px); }
  to   { opacity: 1; transform: scale(1)   translateY(0); }
}
.ctp-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-radius: 18px 18px 0 0;
  position: sticky;
  top: 0;
  z-index: 1;
}
.ctp-modal-head h2 { margin: 0; color: #fff; font-size: .95rem; font-weight: 700; }
.ctp-modal-x {
  background: rgba(255, 255, 255, .2);
  border: none;
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: .82rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s;
  flex-shrink: 0;
}
.ctp-modal-x:hover { background: rgba(255, 255, 255, .38); }

.ctp-modal-body  { padding: 20px 22px 24px; }
.ctp-modal-intro { color: #475569; font-size: .85rem; margin: 0 0 18px; line-height: 1.6; }

/* Form fields */
.ctp-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.ctp-fg {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
}
.ctp-fg:last-child { margin-bottom: 0; }
.ctp-fg label { font-size: .79rem; font-weight: 700; color: #374151; }
.ctp-req { color: #ef4444; margin-left: 1px; }
.ctp-fg input,
.ctp-fg textarea {
  border: 1.5px solid #e5e7eb;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: .875rem;
  font-family: inherit;
  color: #111827;
  background: #f9fafb;
  width: 100%;
  box-sizing: border-box;
  transition: border-color .15s, box-shadow .15s, background .15s;
  outline: none;
}
.ctp-fg input::placeholder,
.ctp-fg textarea::placeholder { color: #9ca3af; }
.ctp-fg input:focus,
.ctp-fg textarea:focus {
  border-color: #0073aa;
  box-shadow: 0 0 0 3px rgba(0, 115, 170, .1);
  background: #fff;
}
.ctp-fg input.ctp-invalid,
.ctp-fg textarea.ctp-invalid {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, .1);
}
.ctp-err {
  color: #dc2626;
  font-size: .73rem;
  font-weight: 600;
  min-height: 15px;
}

/* Submit button */
.ctp-submit {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px;
  margin-top: 6px;
  border: none;
  border-radius: 9px;
  color: #fff;
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .2s, transform .15s;
  letter-spacing: .02em;
}
.ctp-submit:hover   { opacity: .9; }
.ctp-submit:active  { transform: scale(.98); }
.ctp-submit:disabled { opacity: .6; cursor: not-allowed; }
.ctp-submit.ctp-loading::before {
  content: '';
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, .4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: ctp-spin .65s linear infinite;
  display: inline-block;
  vertical-align: middle;
}
@keyframes ctp-spin { to { transform: rotate(360deg); } }

/* Success message */
.ctp-success-msg {
  background: #f0fdf4;
  color: #166534;
  border: 1.5px solid #86efac;
  border-radius: 10px;
  padding: 14px 16px;
  font-size: .88rem;
  font-weight: 600;
  text-align: center;
  margin-bottom: 12px;
  animation: ctp-modal-in .3s ease both;
}

/* Mobile modal */
@media (max-width: 480px) {
  .ctp-form-row  { grid-template-columns: 1fr; }
  .ctp-modal-box { border-radius: 14px; }
}
