/* ==========================================
   SETTINGS + FEEDBACK POPUPS, and the "Finish setup" card
   The same frosted glass as the sign-in popup (auth_modal.css provides the
   --fc-* colors and the .fc-btn / .fc-field / .fc-tabs pieces), but floating:
   no dimmed backdrop, the page stays visible and usable around it.
   Markup: views/includes/settings-panel.ejs, feedback-panel.ejs, setup-reminder.ejs
   ========================================== */

.fc-pop {
  position: fixed;
  top: 92px;
  right: 40px;
  z-index: 2400; /* above the nav and toast, below the sign-in / setup popups */
  width: 400px;
  max-height: calc(100vh - 116px);
  max-height: calc(100dvh - 116px);
  display: flex;
  flex-direction: column;
  background: var(--fc-glass);
  backdrop-filter: blur(28px) saturate(160%);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
  border: 1px solid var(--fc-glass-edge);
  border-radius: 20px;
  box-shadow:
    0 24px 70px rgba(0, 0, 0, 0.18),
    0 2px 8px rgba(0, 0, 0, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
  color: var(--fc-ink);
  font-family: 'Inter', sans-serif;
  text-align: left;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px) scale(0.98);
  transform-origin: top right;
  transition:
    opacity 0.25s ease,
    transform 0.35s cubic-bezier(0.16, 1, 0.3, 1),
    visibility 0.25s;
}
.fc-pop.open {
  opacity: 1;
  visibility: visible;
  transform: none;
}
/* The menu is pinned open: sit beside it instead of on top of it */
@media (min-width: 900px) {
  .fc-pop.beside-nav {
    right: 260px;
  }
}

/* --- Header --- */
.fc-pop-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 14px;
}
.fc-pop-avatar {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(var(--fc-blue), 0.95), rgba(var(--fc-blue), 0.55));
  color: #fff;
  font-size: 17px;
  font-weight: 800;
  box-shadow: 0 4px 14px rgba(var(--fc-blue), 0.3);
}
.fc-pop-who {
  flex: 1;
  min-width: 0;
}
.fc-pop-who h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.2px;
  color: var(--fc-ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fc-pop-who > span {
  display: block;
  font-size: 12px;
  color: var(--fc-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fc-pop-close {
  align-self: flex-start;
  margin: -4px -6px 0 0;
  padding: 0 6px;
  background: none;
  border: none;
  color: var(--fc-muted);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.2s;
}
.fc-pop-close:hover {
  color: var(--fc-ink);
}

.fc-plan-badge {
  flex-shrink: 0;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  background: rgba(var(--fc-blue), 0.12);
  color: rgb(var(--fc-blue));
}
.fc-plan-badge[hidden] {
  display: none;
}
.fc-plan-badge.is-good {
  background: rgba(16, 185, 129, 0.14);
  color: #059669;
}
.fc-plan-badge.is-warn {
  background: rgba(245, 158, 11, 0.16);
  color: #b45309;
}
.fc-plan-badge.is-off {
  background: var(--fc-line);
  color: var(--fc-muted);
}
body.dark-mode .fc-plan-badge.is-good {
  color: #6ee7b7;
}
body.dark-mode .fc-plan-badge.is-warn {
  color: #fcd34d;
}

/* --- Tabs + body --- */
.fc-pop-tabs {
  margin: 0 20px 4px;
}
.fc-pop .fc-tabs {
  margin-bottom: 0;
}
.fc-pop-body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.fc-pop-body [data-settings-pane] {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.fc-pop-body [data-settings-pane][hidden] {
  display: none;
}
.fc-pop-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 20px 14px;
  border-top: 1px dashed var(--fc-line);
  font-size: 12px;
  color: var(--fc-muted);
}
.fc-pop-foot a,
.fc-pop-foot button {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--fc-muted);
  text-decoration: none;
  cursor: pointer;
}
.fc-pop-foot a:hover,
.fc-pop-foot button:hover {
  color: var(--fc-ink);
}

/* --- Pieces --- */
.fc-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
}
.fc-micro {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--fc-muted);
}
.fc-hint {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--fc-muted);
}
.fc-inline {
  display: flex;
  gap: 8px;
}
.fc-inline input {
  flex: 1;
  min-width: 0;
}
.fc-static {
  padding: 12px 14px;
  border: 1px dashed var(--fc-line);
  border-radius: 10px;
  font-size: 14px;
  color: var(--fc-muted);
  overflow: hidden;
  text-overflow: ellipsis;
}
.fc-field textarea {
  padding: 12px 14px;
  border: 1px solid var(--fc-line);
  border-radius: 10px;
  background: var(--fc-field);
  color: var(--fc-ink);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  resize: vertical;
  min-height: 110px;
  outline: none;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}
.fc-field textarea:focus {
  border-color: rgba(var(--fc-blue), 0.6);
  box-shadow: 0 0 0 4px rgba(var(--fc-blue), 0.12);
}
.fc-pop .fc-btn-ghost,
.fc-pop .fc-btn-primary {
  margin-top: 0;
}

.fc-chip-btn {
  flex-shrink: 0;
  padding: 0 16px;
  border: 1px solid rgba(var(--fc-blue), 0.35);
  border-radius: 10px;
  background: rgba(var(--fc-blue), 0.08);
  color: rgb(var(--fc-blue));
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}
.fc-chip-btn:hover:not(:disabled) {
  background: rgba(var(--fc-blue), 0.16);
}
.fc-chip-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.fc-btn-danger {
  width: 100%;
  padding: 12px 20px;
  border: 1px solid rgba(239, 68, 68, 0.45);
  border-radius: 20px;
  background: none;
  color: #dc2626;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s;
}
.fc-btn-danger:hover:not(:disabled),
.fc-btn-danger.is-armed {
  background: #dc2626;
  border-color: #dc2626;
  color: #fff;
}
.fc-btn-danger:disabled {
  opacity: 0.6;
  cursor: default;
}
body.dark-mode .fc-btn-danger {
  color: #f87171;
}
body.dark-mode .fc-btn-danger:hover:not(:disabled),
body.dark-mode .fc-btn-danger.is-armed {
  color: #fff;
}

.fc-text-btn {
  align-self: center;
  background: none;
  border: none;
  padding: 4px 8px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--fc-muted);
  cursor: pointer;
}
.fc-text-btn:hover {
  color: var(--fc-ink);
}
.fc-text-btn.is-danger:hover {
  color: #dc2626;
}

/* Folding sections (change password, delete account) */
.fc-fold {
  border: 1px solid var(--fc-line);
  border-radius: 12px;
  padding: 0 14px;
}
.fc-fold summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.fc-fold summary::-webkit-details-marker {
  display: none;
}
.fc-fold summary::after {
  content: '+';
  font-size: 16px;
  font-weight: 500;
  color: var(--fc-muted);
}
.fc-fold[open] summary::after {
  content: '–';
}
.fc-fold-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 14px;
}
.fc-fold-body .fc-link-muted {
  margin-top: 0;
  text-align: center;
}
.fc-fold--danger summary {
  color: #dc2626;
}
body.dark-mode .fc-fold--danger summary {
  color: #f87171;
}

/* Preference rows with a switch */
.fc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 4px 0 14px;
  border-bottom: 1px dashed var(--fc-line);
}
.fc-row > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.fc-row strong {
  font-size: 14px;
  font-weight: 700;
}
.fc-row span {
  font-size: 12px;
  color: var(--fc-muted);
}
.fc-toggle {
  position: relative;
  flex-shrink: 0;
  width: 42px;
  height: 24px;
}
.fc-toggle input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
  z-index: 1;
}
.fc-toggle input:disabled {
  cursor: not-allowed;
}
.fc-toggle span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--fc-line);
  transition: background 0.2s;
}
.fc-toggle span::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.fc-toggle input:checked + span {
  background: rgb(var(--fc-blue));
}
.fc-toggle input:checked + span::after {
  transform: translateX(18px);
}
.fc-toggle input:focus-visible + span {
  box-shadow: 0 0 0 4px rgba(var(--fc-blue), 0.2);
}
.fc-toggle input:disabled + span {
  opacity: 0.5;
}

/* Connected banks */
.fc-bank {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--fc-line);
  font-size: 13px;
}
.fc-bank strong {
  font-weight: 700;
}
.fc-bank span {
  font-size: 12px;
  color: var(--fc-muted);
  white-space: nowrap;
}
.fc-bank .is-warn {
  color: #d97706;
  font-weight: 600;
}

/* --- Plan --- */
.fc-plan-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px;
  border: 1px solid rgba(var(--fc-blue), 0.18);
  border-radius: 14px;
  background: rgba(var(--fc-blue), 0.05);
}
.fc-plan-card.is-warn {
  border-color: rgba(245, 158, 11, 0.35);
  background: rgba(245, 158, 11, 0.07);
}
.fc-plan-card.is-loading {
  animation: fcPulse 1.2s ease-in-out infinite;
}
.fc-plan-name {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--fc-muted);
}
.fc-plan-amount {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.5px;
}
.fc-plan-amount small {
  font-size: 13px;
  font-weight: 600;
  color: var(--fc-muted);
  letter-spacing: 0;
}
.fc-plan-line {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
}
.fc-plan-line.is-muted {
  color: var(--fc-muted);
}
.fc-plan-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Cancel step */
.fc-cancel h3 {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 800;
}
.fc-reasons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.fc-reason {
  padding: 7px 12px;
  border: 1px solid var(--fc-line);
  border-radius: 999px;
  background: var(--fc-field);
  color: var(--fc-ink);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition:
    border-color 0.15s,
    background 0.15s,
    color 0.15s;
}
.fc-reason[aria-pressed='true'] {
  border-color: rgb(var(--fc-blue));
  background: rgba(var(--fc-blue), 0.1);
  color: rgb(var(--fc-blue));
}
.fc-offer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  border: 1px dashed rgba(var(--fc-blue), 0.55);
  border-radius: 14px;
  background:
    radial-gradient(120% 120% at 100% 0%, rgba(var(--fc-blue), 0.14), transparent 60%),
    rgba(var(--fc-blue), 0.04);
}
.fc-offer strong {
  font-size: 15px;
  font-weight: 800;
}

/* --- Feedback attachments --- */
.fc-pop .fc-tabs label {
  display: flex;
  align-items: center;
  justify-content: center;
}
.fc-pop .fc-tabs input[type='radio'] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.fc-attach {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border: 1px dashed var(--fc-line);
  border-radius: 12px;
  transition:
    border-color 0.15s,
    background 0.15s;
}
.fc-attach.is-dragging {
  border-color: rgb(var(--fc-blue));
  background: rgba(var(--fc-blue), 0.06);
}
.fc-attach-btn {
  position: relative;
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--fc-line);
  border-radius: 10px;
  background: var(--fc-field);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.fc-attach-btn:hover {
  border-color: var(--fc-muted);
}
.fc-attach-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.fc-attach-btn.is-full {
  display: none;
}
.fc-thumbs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.fc-thumbs:empty {
  display: none;
}
.fc-thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--fc-line);
  background: var(--fc-field);
}
.fc-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.fc-thumb span {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  font-size: 10px;
  color: var(--fc-muted);
  text-align: center;
  word-break: break-all;
}
.fc-thumb button {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

/* --- "Finish setup" card --- */
.fc-setup-card {
  position: fixed;
  left: 24px;
  bottom: 24px;
  z-index: 2300;
  width: 300px;
  background: var(--fc-glass);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  border: 1px solid var(--fc-glass-edge);
  border-radius: 18px;
  box-shadow:
    0 18px 50px rgba(0, 0, 0, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
  color: var(--fc-ink);
  font-family: 'Inter', sans-serif;
  animation: fcSetupIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes fcSetupIn {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
}
.fc-setup-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: none;
  border: none;
  font-family: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.fc-setup-toggle strong {
  flex: 1;
  font-size: 13px;
  font-weight: 800;
}
.fc-setup-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgb(var(--fc-blue));
  box-shadow: 0 0 0 0 rgba(var(--fc-blue), 0.5);
  animation: fcSetupPing 2s ease-out infinite;
}
.fc-setup-card[data-step='resubscribe'] .fc-setup-dot {
  background: #f59e0b;
  animation: none;
}
@keyframes fcSetupPing {
  70% {
    box-shadow: 0 0 0 8px rgba(var(--fc-blue), 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(var(--fc-blue), 0);
  }
}
.fc-setup-chevron {
  color: var(--fc-muted);
  transition: transform 0.25s;
}
.fc-setup-body {
  padding: 0 16px 16px;
}
.fc-setup-body p {
  margin: 0 0 12px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--fc-muted);
}
.fc-setup-body .fc-btn-primary {
  margin-top: 0;
  padding: 11px 16px;
}
.fc-setup-card.is-collapsed {
  width: auto;
}
.fc-setup-card.is-collapsed .fc-setup-body {
  display: none;
}
.fc-setup-card.is-collapsed .fc-setup-chevron {
  transform: rotate(180deg);
}

/* --- Phones: a floating sheet near the bottom (still no backdrop) --- */
@media (max-width: 520px) {
  .fc-pop {
    top: auto;
    left: 10px;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    width: auto;
    max-height: 84vh;
    max-height: 84dvh;
    transform: translateY(24px);
    transform-origin: bottom center;
  }
  .fc-setup-card {
    left: 10px;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    width: auto;
  }
  .fc-setup-card.is-collapsed {
    right: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .fc-pop,
  .fc-setup-card,
  .fc-setup-dot {
    transition: none;
    animation: none;
  }
}

/* Radio labels used as segmented tabs (feedback type) */
.fc-pop .fc-tabs label {
  position: relative;
}
.fc-pop .fc-tabs label:has(input:focus-visible) {
  box-shadow: 0 0 0 3px rgba(var(--fc-blue), 0.25);
}

/* The plan pane is redrawn by settings_panel.js */
[data-plan-body] {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
