/* Shared TapStickyAuth widget — drop-in styles for the email + WhatsApp login
 * widget mounted by public/js/shared/wa-login.js. Uses CSS variables from the
 * host page so it inherits the product's theme. Falls back to safe defaults if
 * the host page does not define them.
 */

.ts-auth {
  --ts-auth-bg: var(--bg-elevated, #1F1F1F);
  --ts-auth-bg-input: var(--bg-secondary, #141414);
  --ts-auth-text: var(--text-primary, #FAFAFA);
  --ts-auth-text-muted: var(--text-secondary, #A0A0A0);
  --ts-auth-text-faint: var(--text-tertiary, #6B6B6B);
  --ts-auth-border: var(--border-subtle, #262626);
  --ts-auth-border-strong: var(--border-medium, #333333);
  /* Defaults match tapsticky.in; a host page can still override via --accent-*. */
  /* #d33f30, not the exact #e74c3c: this token fills buttons that carry white
     text, and #e74c3c is only 3.82:1 against white. */
  --ts-auth-accent: var(--accent-primary, #d33f30);
  --ts-auth-accent-hover: var(--accent-hover, #b03225);
  --ts-auth-error: var(--accent-error, #EF4444);
  --ts-auth-success: var(--accent-success, #10B981);
  --ts-auth-radius: 12px;
  --ts-auth-radius-lg: 16px;
  display: block;
  color: var(--ts-auth-text);
  font-family: var(--font-family, system-ui, sans-serif);
}

.ts-auth * {
  box-sizing: border-box;
}

/* The widget toggles visibility via the [hidden] attribute. CSS rules like
 * `.ts-auth-panel { display: flex }` override that, so explicitly enforce
 * display:none for any [hidden] element inside the widget. */
.ts-auth [hidden] {
  display: none !important;
}

/* Re-auth banner shown when editing a claimed card: tells the owner whose card
 * this is and which identity to verify with. */
.ts-auth-reauth {
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid var(--ts-auth-border-strong);
  border-radius: var(--ts-auth-radius);
  background: var(--ts-auth-bg-input);
  color: var(--ts-auth-text-muted);
  font-size: 13px;
  line-height: 1.4;
  text-align: center;
}

.ts-auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  background: var(--ts-auth-bg-input);
  border: 1px solid var(--ts-auth-border);
  border-radius: var(--ts-auth-radius);
  padding: 4px;
  margin-bottom: 16px;
}

.ts-auth-tab {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--ts-auth-text-muted);
  font: inherit;
  font-weight: 600;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background-color .15s ease, color .15s ease;
}

.ts-auth-tab.is-active {
  background: var(--ts-auth-bg);
  color: var(--ts-auth-text);
  box-shadow: 0 1px 2px rgba(0,0,0,.2);
}

.ts-auth-tab-icon {
  font-size: 1.05em;
  line-height: 1;
}

.ts-auth-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ts-auth-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ts-auth-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--ts-auth-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ts-auth-input-wrap {
  display: flex;
  align-items: center;
  background: var(--ts-auth-bg-input);
  border: 1.5px solid var(--ts-auth-border);
  border-radius: var(--ts-auth-radius);
  overflow: hidden;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.ts-auth-input-wrap:focus-within {
  border-color: var(--ts-auth-accent);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.18);
}

.ts-auth-prefix {
  padding: 0 12px;
  color: var(--ts-auth-text-muted);
  font-weight: 500;
  white-space: nowrap;
}

.ts-auth-phone .ts-auth-prefix {
  border-right: 1px solid var(--ts-auth-border);
  height: 100%;
  display: inline-flex;
  align-items: center;
}

.ts-auth-input-wrap input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--ts-auth-text);
  font: inherit;
  font-size: 16px; /* >=16px: anything smaller makes iOS Safari zoom the viewport on focus and never zoom back */;
  padding: 12px 12px 12px 8px;
  min-width: 0;
}

.ts-auth-input-wrap input::placeholder {
  color: var(--ts-auth-text-faint);
}

.ts-auth-hint {
  font-size: 12px;
  color: var(--ts-auth-text-faint);
}

.ts-auth-error {
  font-size: 12px;
  color: var(--ts-auth-error);
  min-height: 1em;
}

.ts-auth-submit {
  appearance: none;
  border: none;
  width: 100%;
  padding: 13px 16px;
  /* Pill, matching every button on tapsticky.in. */
  border-radius: 999px;
  background: var(--ts-auth-accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  transition: background-color .15s ease, transform .05s ease, opacity .15s ease;
}

.ts-auth-submit:hover:not(:disabled) {
  background: var(--ts-auth-accent-hover);
}

.ts-auth-submit:active:not(:disabled) {
  transform: translateY(1px);
}

.ts-auth-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.ts-auth-otp {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--ts-auth-border);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ts-auth-otp-target {
  font-size: 13px;
  color: var(--ts-auth-text-muted);
  margin: 0;
}

.ts-auth-otp-target strong {
  color: var(--ts-auth-text);
  font-weight: 600;
}

.ts-auth-otp-target a {
  color: var(--ts-auth-accent);
  text-decoration: none;
}

.ts-auth-otp-target a:hover {
  text-decoration: underline;
}

.ts-otp-row {
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.ts-otp-cell {
  width: 44px;
  height: 52px;
  border-radius: 12px;
  border: 1.5px solid var(--ts-auth-border);
  background: var(--ts-auth-bg-input);
  color: var(--ts-auth-text);
  text-align: center;
  font: inherit;
  font-size: 22px;
  font-weight: 600;
  outline: none;
  transition: border-color .12s ease, box-shadow .12s ease;
}

.ts-otp-cell:focus {
  border-color: var(--ts-auth-accent);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.18);
}

.ts-auth-resend {
  font-size: 12px;
  color: var(--ts-auth-text-faint);
  text-align: center;
}

.ts-auth-resend a {
  color: var(--ts-auth-accent);
  text-decoration: none;
  font-weight: 500;
}

.ts-auth-resend a:hover {
  text-decoration: underline;
}

.ts-auth-otp-error {
  font-size: 12px;
  color: var(--ts-auth-error);
  margin: 0;
  min-height: 1em;
}

/* Dev-mode banner showing the OTP returned from the emulator response.
 * Only ever rendered when the backend included a devOtp/verificationCode
 * (i.e. local Firebase emulator), so this surface is invisible in prod. */
.ts-auth-dev-banner {
  background: #fef3c7;
  border: 1px solid #fcd34d;
  color: #78350f;
  border-radius: var(--ts-auth-radius);
  padding: 8px 12px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ts-auth-dev-banner strong {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 15px;
  letter-spacing: 0.06em;
  color: #78350f;
}

.ts-auth-dev-banner a {
  color: var(--ts-auth-accent);
  text-decoration: none;
  font-weight: 600;
  margin-left: auto;
}

.ts-auth-dev-banner a:hover {
  text-decoration: underline;
}

.ts-auth-dev-tag {
  background: #f59e0b;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 2px 6px;
  border-radius: 999px;
}

.ts-auth-busy {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  margin-top: 12px;
  color: var(--ts-auth-text-muted);
  font-size: 13px;
}

.ts-auth-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--ts-auth-border);
  border-top-color: var(--ts-auth-accent);
  border-radius: 50%;
  animation: ts-auth-spin .6s linear infinite;
}

@keyframes ts-auth-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-color-scheme: light) {
  .ts-auth:not([data-force-dark]) {
    --ts-auth-bg: #ffffff;
    --ts-auth-bg-input: #ffffff;
    --ts-auth-text: #1f1f1f;
    --ts-auth-text-muted: #475569;
    --ts-auth-text-faint: #6b6b6c;
    --ts-auth-border: #e5e5e5;
    --ts-auth-border-strong: #cfcfd0;
  }
}
