/* Custom Animations */
@keyframes fade-in-up {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-5px);
  }

  75% {
    transform: translateX(5px);
  }
}

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

.animate-fade-in-up {
  animation: fade-in-up 0.5s ease-out forwards;
}

.animate-shake {
  animation: shake 0.3s ease-in-out;
}

.animate-spin {
  animation: spin 1s linear infinite;
}

/* Utility to hide elements */
.hidden {
  display: none !important;
}

/* --- BP Auth Phone Verify Variables --- */
:root {
  --bp-color-indigo-600: #4f46e5;
  --bp-color-indigo-700: #4338ca;
  --bp-color-indigo-100: #e0e7ff;
  --bp-color-slate-50: #f8fafc;
  --bp-color-slate-100: #f1f5f9;
  --bp-color-slate-200: #e2e8f0;
  --bp-color-slate-300: #cbd5e1;
  --bp-color-slate-400: #94a3b8;
  --bp-color-slate-500: #64748b;
  --bp-color-slate-600: #475569;
  --bp-color-slate-800: #1e293b;
  --bp-color-white: #ffffff;
  --bp-color-emerald-50: #ecfdf5;
  --bp-color-emerald-100: #d1fae5;
  --bp-color-emerald-200: #a7f3d0;
  --bp-color-emerald-500: #10b981;
  --bp-color-emerald-600: #059669;
  --bp-color-emerald-700: #047857;
  --bp-color-emerald-900: #064e3b;
  --bp-color-red-500: #ef4444;

  --bp-shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --bp-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --bp-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --bp-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);

  --bp-radius-xl: 0.75rem;
  /* 12px */
  --bp-radius-2xl: 1rem;
  /* 16px */
  --bp-radius-3xl: 1.5rem;
  /* 24px */
}

/* --- Component Styles --- */

.bp-verify-wrapper {
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--bp-color-slate-800);
  box-sizing: border-box;
}

.bp-verify-wrapper * {
  box-sizing: border-box;
}

/* Inline Card */
.bp-inline-card {
  width: 100%;
  max-width: 28rem;
  /* max-w-md */
  background-color: var(--bp-color-white);
  border-radius: var(--bp-radius-3xl);
  box-shadow: var(--bp-shadow-xl);
  overflow: hidden;
  border: 1px solid var(--bp-color-slate-100);
  position: relative;
  margin: 0 auto;
}

/* Modal Container */
#bp-phone-modal {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: var(--bp-color-white);
  border-top-left-radius: var(--bp-radius-3xl);
  border-top-right-radius: var(--bp-radius-3xl);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.2);
  z-index: 2147483647;
  /* High z-index to stay above site footer/header overlays */
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  max-height: 90vh;
  overflow-y: auto;
}

#bp-phone-modal.open {
  transform: translateY(0);
}

/* Login Modal Container (bp_tc_login fallback) */
#bp-login-modal {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: var(--bp-color-white);
  border-top-left-radius: var(--bp-radius-3xl);
  border-top-right-radius: var(--bp-radius-3xl);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.2);
  z-index: 2147483647;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  max-height: 90vh;
  overflow-y: auto;
}

#bp-login-modal.open {
  transform: translateY(0);
}

/* Backdrop */
#bp-modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 2147483646;
  /* Base z-index */
  transition: opacity 0.3s ease;
  opacity: 0;
  pointer-events: none;
}

#bp-modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

/* Login Backdrop */
#bp-login-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 2147483646;
  transition: opacity 0.3s ease;
  opacity: 0;
  pointer-events: none;
}

#bp-login-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

#bp-login-modal,
#bp-phone-modal {
  left: 0;
  right: 0;
  width: 100vw;
  max-width: 100%;
  z-index: 2147483647;
}

#bp-login-backdrop,
#bp-modal-backdrop {
  z-index: 2147483646;
}

/* Header (Modal) */
.bp-modal-header {
  background-color: #c55c39;
  padding: 0.5rem;
  color: var(--bp-color-white);
  text-align: center;
  position: relative;
  overflow: hidden;
  border-top-left-radius: var(--bp-radius-3xl);
  border-top-right-radius: var(--bp-radius-3xl);
}

.bp-header-circle-1 {
  position: absolute;
  top: 0;
  left: 0;
  width: 8rem;
  height: 8rem;
  background-color: var(--bp-color-white);
  opacity: 0.1;
  border-radius: 9999px;
  transform: translate(-2.5rem, -2.5rem);
}

.bp-header-circle-2 {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 6rem;
  height: 6rem;
  background-color: var(--bp-color-white);
  opacity: 0.1;
  border-radius: 9999px;
  transform: translate(2rem, 2rem);
}

.bp-header-content {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.bp-header-icon-box {
  width: 4rem;
  height: 4rem;
  background-color: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(12px);
  border-radius: var(--bp-radius-2xl);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0;
  box-shadow: inset 0 2px 4px 0 rgba(0, 0, 0, 0.06);
}

.bp-header-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.025em;
  margin-bottom: 0;
}

.bp-header-subtitle {
  color: var(--bp-color-indigo-100);
  font-size: 0.875rem;
  margin-top: 0.25rem;
  margin-bottom: 0;
}

/* Content Area */
.bp-content-p {
  padding: 0.5rem;
}

.bp-modal-content-p {
  padding: 0.5rem;
  padding-bottom: 2.5rem;
  max-width: 28rem;
  margin: 0 auto;
}

/* Typography & Layout Helpers */
.bp-text-center {
  text-align: center;
}

.bp-flex {
  display: flex;
}

.bp-flex-col {
  display: flex;
  flex-direction: column;
}

.bp-items-center {
  align-items: center;
}

.bp-justify-center {
  justify-content: center;
}

.bp-justify-between {
  justify-content: space-between;
}

.bp-gap-2 {
  gap: 0.5rem;
}

.bp-gap-3 {
  gap: 0.75rem;
}

.bp-gap-4 {
  gap: 1rem;
}

.bp-mb-2 {
  margin-bottom: 0.5rem;
}

.bp-mb-4 {
  margin-bottom: 1rem;
}

.bp-mb-6 {
  margin-bottom: 0.5rem;
}

.bp-mt-1 {
  margin-top: 0.25rem;
}

.bp-mt-2 {
  margin-top: 0.5rem;
}

.bp-mt-3 {
  margin-top: 0.75rem;
}

.bp-mt-6 {
  margin-top: 1.5rem;
}

.bp-mt-8 {
  margin-top: 0.5rem;
}

.bp-w-full {
  width: 100%;
}

.bp-text-xs {
  font-size: 0.75rem;
}

.bp-text-sm {
  font-size: 0.875rem;
}

.bp-text-lg {
  font-size: 1.125rem;
}

.bp-text-xl {
  font-size: 1.25rem;
}

.bp-text-2xl {
  font-size: 1.5rem;
}

.bp-font-bold {
  font-weight: 700;
}

.bp-font-medium {
  font-weight: 500;
}

.bp-font-normal {
  font-weight: 400;
}

.bp-uppercase {
  text-transform: uppercase;
}

.bp-tracking-widest {
  letter-spacing: 0.1em;
}

.bp-tracking-wide {
  letter-spacing: 0.025em;
}

.bp-text-slate-400 {
  color: var(--bp-color-slate-400);
}

.bp-text-slate-500 {
  color: var(--bp-color-slate-500);
}

.bp-text-slate-800 {
  color: var(--bp-color-slate-800);
}

.bp-text-indigo-600 {
  color: var(--bp-color-indigo-600);
}

.bp-text-emerald-500 {
  color: var(--bp-color-emerald-500);
}

.bp-text-emerald-600 {
  color: var(--bp-color-emerald-600);
}

.bp-text-emerald-700 {
  color: var(--bp-color-emerald-700);
}

.bp-text-emerald-900 {
  color: var(--bp-color-emerald-900);
}

.bp-text-red-500 {
  color: var(--bp-color-red-500);
}

.bp-text-white {
  color: var(--bp-color-white);
}

/* Buttons */
.bp-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-radius: var(--bp-radius-xl);
  font-weight: 700;
  transition: all 0.2s;
  cursor: pointer;
  border: none;
  font-size: 1rem;
}

.bp-btn-primary {
  background-color: #c55c39;
  color: var(--bp-color-white);
  box-shadow: var(--bp-shadow-md);
}

.bp-btn-primary:hover {
  background-color: var(--bp-color-indigo-700);
}

.bp-btn-primary:active {
  transform: scale(0.95);
}

.bp-btn-disabled {
  background-color: #fdbba5;
  color: var(--bp-color-white);
  cursor: not-allowed;
  box-shadow: none;
}

.bp-btn-icon-only {
  padding: 0.75rem;
  background-color: var(--bp-color-slate-100);
  color: var(--bp-color-slate-600);
}

.bp-btn-icon-only:hover {
  background-color: var(--bp-color-slate-200);
}

.bp-btn-close {
  padding: 0.5rem;
  background-color: var(--bp-color-slate-100);
  color: var(--bp-color-slate-400);
  border-radius: 9999px;
}

.bp-btn-close:hover {
  color: var(--bp-color-slate-600);
}

.bp-btn-back {
  font-size: 0.875rem;
  color: var(--bp-color-slate-400);
  background: none;
  padding: 0;
  justify-content: flex-start;
}

.bp-btn-back:hover {
  color: var(--bp-color-indigo-600);
}

/* Inputs */
.bp-input-group {
  position: relative;
  display: flex;
  align-items: center;
  background-color: var(--bp-color-slate-50);
  border: 2px solid var(--bp-color-slate-100);
  border-radius: var(--bp-radius-xl);
  transition: all 0.2s;
}

.bp-input-group:focus-within {
  border-color: var(--bp-color-indigo-600);
  box-shadow: 0 0 0 4px var(--bp-color-indigo-100);
}

/* Country Wrapper */
.bp-wa-country-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  padding-left: 1rem;
  padding-right: 0.5rem;
  border-right: 1px solid var(--bp-color-slate-200);
  min-width: 100px;
}

.bp-wa-flag-img {
  width: 1.5rem;
  height: auto;
  border-radius: 2px;
  margin-right: 0.5rem;
}

.bp-wa-country-select {
  appearance: none;
  background: transparent;
  border: none;
  font-size: 1rem;
  font-weight: 600;
  color: var(--bp-color-slate-500);
  padding-right: 1.25rem;
  /* space for arrow */
  cursor: pointer;
  outline: none;
  width: 100%;
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  opacity: 0;
  /* Hide select but keep clickable */
  z-index: 2;
}

/* Visible value comes from a pseudo-element or JS, but here we use the select's text if possible, 
   or just overlay the text. Actually, simpler approach: make select visible but styled. */
.bp-wa-country-select {
  position: static;
  opacity: 1;
  width: auto;
  padding: 0.5rem;
  padding-right: 1.5rem;
}

.bp-wa-arrow {
  position: absolute;
  right: 0.5rem;
  pointer-events: none;
  font-size: 0.6rem;
  color: var(--bp-color-slate-400);
}

.bp-input {
  display: block;
  width: 100%;
  padding: 1rem;
  background-color: transparent;
  border: none;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--bp-color-slate-800);
  outline: none;
}

.bp-input::placeholder {
  color: var(--bp-color-slate-300);
  font-weight: 500;
}

.bp-otp-input {
  text-align: center;
  font-size: 2.25rem;
  letter-spacing: 0.5em;
  padding: 1rem 0;
  border-bottom: 2px solid var(--bp-color-slate-200);
  border-radius: 0;
}

.bp-otp-input:focus {
  border-color: var(--bp-color-emerald-500);
  box-shadow: none;
}

/* Method Button */
.bp-method-btn {
  width: 100%;
  background-color: var(--bp-color-emerald-50);
  border: 2px solid var(--bp-color-emerald-100);
  padding: 1rem;
  border-radius: var(--bp-radius-2xl);
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: all 0.2s;
  cursor: pointer;
  text-align: left;
}

.bp-method-btn:hover {
  background-color: var(--bp-color-emerald-100);
  border-color: var(--bp-color-emerald-200);
}

.bp-method-btn:active {
  transform: scale(0.98);
}

.bp-method-icon {
  width: 3rem;
  height: 3rem;
  background-color: var(--bp-color-emerald-500);
  color: var(--bp-color-white);
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--bp-shadow-lg);
}

/* Verified Badge */
.bp-verified-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.75rem;
  background-color: var(--bp-color-emerald-50);
  color: var(--bp-color-emerald-700);
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 9999px;
  border: 1px solid var(--bp-color-emerald-100);
}

.bp-verified-wrapper {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.bp-verified-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0.25rem;
}

.bp-verified-number {
  display: flex;
  align-items: center;
  gap: unset;
}

@media (max-width: 480px) {
  .bp-verified-row {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .bp-verified-badge {
    align-self: center;
  }
}

/* Empty State Icon */
.bp-empty-icon {
  width: 3rem;
  height: 3rem;
  background-color: var(--bp-color-indigo-100);
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--bp-color-slate-200);
  color: var(--bp-color-indigo-600);
}

/* Footer */
.bp-footer {
  background-color: var(--bp-color-slate-50);
  padding: 1rem;
  border-top: 1px solid var(--bp-color-slate-100);
  text-align: center;
  display: none;
}

.bp-footer-text {
  font-size: 0.625rem;
  color: var(--bp-color-slate-400);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

/* Loading Overlay */
.bp-loading-overlay {
  position: absolute;
  inset: 0;
  background-color: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(4px);
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  text-align: center;
}

/* Drag Handle */
.bp-drag-handle {
  width: 3rem;
  height: 0.375rem;
  background-color: var(--bp-color-slate-200);
  border-radius: 9999px;
  margin: 0 auto 0.5rem auto;
}

.bp-text-left p:nth-of-type(1) {
  margin-bottom: 2px;
}

.bp-text-left p:nth-of-type(2) {
  margin-bottom: 2px;
}

/* Inline Flow Styles (Refactored to Classes) */
.bp-wa-inline-wrapper {
  margin-top: 1rem;
  border-top: 1px solid var(--bp-color-slate-200);
  padding-top: 1rem;
}

.bp-wa-inline-wrapper.is-hidden {
  display: none;
}

.bp-wa-inline-content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.bp-wa-input-group {
  display: flex;
  gap: 0.5rem;
}

.bp-wa-phone-row {
  display: flex;
  gap: 0.5rem;
}

.bp-wa-country-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  background: white;
  border: 1px solid var(--bp-color-slate-300);
  border-radius: 10px;
  padding: 0 0.5rem;
  width: 100px;
  flex-shrink: 0;
}

.bp-wa-flag-img {
  width: 24px;
  height: 16px;
  object-fit: cover;
  border-radius: 2px;
  margin-right: 4px;
}

.bp-wa-country-select {
  appearance: none;
  background: transparent;
  border: none;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--bp-color-slate-800);
  width: 100%;
  padding: 0.75rem 0;
  cursor: pointer;
  outline: none;
  z-index: 1;
}

.bp-wa-arrow {
  font-size: 0.6rem;
  color: var(--bp-color-slate-400);
  margin-left: auto;
  pointer-events: none;
}

.bp-wa-phone-input,
.bp-wa-otp-input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 1px solid var(--bp-color-slate-300);
  border-radius: var(--bp-radius-lg);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.bp-wa-phone-input:focus,
.bp-wa-otp-input:focus {
  border-color: var(--bp-color-indigo-600);
  box-shadow: 0 0 0 3px var(--bp-color-indigo-100);
}

.bp-wa-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.bp-wa-send-btn,
.bp-wa-verify-btn {
  width: 100%;
  padding: 0.75rem;
  background-color: var(--bp-color-indigo-600);
  color: white;
  border: none;
  border-radius: var(--bp-radius-lg);
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s;
}

.bp-wa-send-btn:hover,
.bp-wa-verify-btn:hover {
  background-color: var(--bp-color-indigo-700);
}

.bp-wa-send-btn:disabled,
.bp-wa-verify-btn:disabled {
  background-color: var(--bp-color-slate-300);
  cursor: not-allowed;
}

.bp-wa-back-btn {
  width: 100%;
  padding: 0.5rem;
  background: transparent;
  color: var(--bp-color-slate-500);
  border: none;
  font-size: 0.875rem;
  cursor: pointer;
}

.bp-wa-back-btn:hover {
  color: var(--bp-color-slate-800);
  text-decoration: underline;
}

#bp-tc-login-btn {
  cursor: pointer;
}

#view-saved .bp-mb-6 p {
  margin-bottom: 1px;
  text-align: center;
}

#step-input #phone-input{ border-radius: 0 10px 10px 0;}