/**
 * Google popup login flow (static/js/google-login-popup.js).
 * The clicked [data-google-login-popup] button carries the feedback in place
 * (waiting spinner -> green check); the page is never dimmed. The original
 * button content stays in the layout but hidden, so the size never shifts.
 * Brand tokens follow Docs/DESIGN_SYSTEM.md (dark #bb86fc / light #E1306C).
 */
[data-google-login-popup][data-oauth-state] {
  position: relative;
  color: transparent !important;
  cursor: progress;
  transform: none !important;
}

[data-google-login-popup][data-oauth-state='success'] {
  cursor: default;
}

[data-google-login-popup][data-oauth-state] > :not(.flu-oauth-btn-status) {
  visibility: hidden;
}

.flu-oauth-btn-status {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  padding: 0 1rem;
  color: var(--flu-oauth-fg, currentColor);
  white-space: nowrap;
  overflow: hidden;
  pointer-events: none;
  animation: flu-oauth-fade-in 0.18s ease-out;
}

.flu-oauth-btn-status__label {
  overflow: hidden;
  text-overflow: ellipsis;
}

.flu-oauth-btn-status__spinner {
  flex: none;
  width: 1.15em;
  height: 1.15em;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  opacity: 0.75;
  animation: flu-oauth-spin 0.8s linear infinite;
}

.flu-oauth-btn-status__check {
  display: none;
  flex: none;
  width: 1.4em;
  height: 1.4em;
}

.flu-oauth-btn-status__check circle {
  fill: #16a34a;
}

.flu-oauth-btn-status__check path {
  fill: none;
  stroke: #ffffff;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 16;
  stroke-dashoffset: 16;
}

[data-oauth-state='success'] .flu-oauth-btn-status__spinner {
  display: none;
}

[data-oauth-state='success'] .flu-oauth-btn-status__check {
  display: block;
  animation: flu-oauth-pop 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
}

[data-oauth-state='success'] .flu-oauth-btn-status__check path {
  animation: flu-oauth-draw 0.28s ease-out 0.12s forwards;
}

@keyframes flu-oauth-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes flu-oauth-fade-in {
  from {
    opacity: 0;
  }
}

@keyframes flu-oauth-pop {
  from {
    transform: scale(0.4);
    opacity: 0;
  }
}

@keyframes flu-oauth-draw {
  to {
    stroke-dashoffset: 0;
  }
}

/* Error feedback: compact non-blocking toast (page stays interactive) */
.flu-google-oauth-toast {
  position: fixed;
  left: 50%;
  bottom: 2rem;
  transform: translate(-50%, 12px);
  z-index: 2100;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  max-width: min(420px, calc(100vw - 2rem));
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px solid rgba(248, 113, 113, 0.35);
  background: #2a1e20;
  color: #f5f5f5;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
  font-family: Nunito, system-ui, sans-serif;
  font-size: 0.95rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease;
}

.flu-google-oauth-toast.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

.flu-google-oauth-toast__icon {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(248, 113, 113, 0.18);
  color: #f87171;
  font-weight: 700;
  font-size: 0.85rem;
}

.flu-google-oauth-toast__text {
  line-height: 1.35;
}

.flu-google-oauth-toast__close {
  flex: none;
  margin-left: auto;
  background: none;
  border: none;
  color: rgba(245, 245, 245, 0.6);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.15rem 0.35rem;
  border-radius: 6px;
}

.flu-google-oauth-toast__close:hover {
  color: #f5f5f5;
  background: rgba(255, 255, 255, 0.08);
}

body.light-mode .flu-google-oauth-toast {
  background: #ffffff;
  color: #7f1d1d;
  border-color: rgba(225, 48, 108, 0.3);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.2);
}

body.light-mode .flu-google-oauth-toast__icon {
  background: rgba(225, 48, 108, 0.12);
  color: #dc2626;
}

body.light-mode .flu-google-oauth-toast__close {
  color: rgba(31, 41, 55, 0.55);
}

body.light-mode .flu-google-oauth-toast__close:hover {
  color: #1f2937;
  background: rgba(15, 23, 42, 0.06);
}

@media (prefers-reduced-motion: reduce) {
  .flu-oauth-btn-status,
  [data-oauth-state='success'] .flu-oauth-btn-status__check {
    animation: none;
  }

  [data-oauth-state='success'] .flu-oauth-btn-status__check path {
    animation: none;
    stroke-dashoffset: 0;
  }

  .flu-oauth-btn-status__spinner {
    animation-duration: 1.6s;
  }

  .flu-google-oauth-toast {
    transition: none;
  }
}
