/* Gift Checkout Styles */

/* CSS Custom Properties */
:root {
  --gift-dark-gray: #6D6D6D;
  --gift-light-gray: #E6E6E6;

}

/* Badge Button */
.gift-badge-btn {
  position: fixed;
  top: 300px;
  right: 40px;
  z-index: 999;
  width: 189px;
  height: 189px;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.gift-badge-btn:hover {
  transform: scale(1.06);
}

.gift-badge-btn:active {
  transform: scale(0.98);
}

.gift-badge-btn:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 4px;
  border-radius: 50%;
}

.gift-badge-img {
  width: 100%;
  height: 100%;
  transition: filter 0.2s ease;
}

.gift-badge-btn:hover .gift-badge-img {
  filter: brightness(0.97);
}

/* Badge Responsive */
@media (min-width: 1400px) {
  .gift-badge-btn {
    top: 400px;
    right: 80px;
  }
}

@media (min-width: 1600px) {
  .gift-badge-btn {
    top: 400px;
    right: 200px;
  }
}

@media (min-width: 1920px) {
  .gift-badge-btn {
    top: 400px;
    right: 300px;
  }
}

@media (max-width: 1200px) {
  .gift-badge-btn {
    width: 160px;
    height: 160px;
    right: 20px;
    top: 300px;
  }
}

@media (max-width: 991px) {
  .gift-badge-btn {
    width: 140px;
    height: 140px;
    top: auto;
    bottom: 100px;
    right: 20px;
  }
}

@media (max-width: 767px) {
  .gift-badge-btn {
    width: 120px;
    height: 120px;
    bottom: 80px;
    right: 16px;
  }
}

/* Modal Dialog */
dialog.gift-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  margin: 0;
  padding: 20px;
  border: none;
  background: transparent;
  z-index: 10000;
  overflow-y: auto;
  display: none;
}

/* Manual backdrop since we're not using showModal() */
/* This allows reCAPTCHA to appear above the modal with higher z-index */
dialog.gift-modal-overlay.is-open::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: -1;
}

dialog.gift-modal-overlay[open],
dialog.gift-modal-overlay.is-open {
  display: flex;
  align-items: center;
  justify-content: center;
  animation: giftFadeIn 0.3s ease;
}

/* Keep ::backdrop for browsers that may still use it */
dialog.gift-modal-overlay::backdrop {
  background: rgba(0, 0, 0, 0.5);
}

@keyframes giftFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Modal Container */
.gift-modal-container {
  background: #FFFFFF;
  border-radius: 20px;
  box-shadow: 0px 4px 32px rgba(0, 0, 0, 0.15);
  max-width: 780px;
  width: 100%;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  animation: giftSlideUp 0.3s ease;
}

@keyframes giftSlideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Steps */
.gift-modal-step {
  display: none;
}

.gift-modal-step.active {
  display: block;
}

/* Close/Back Buttons */
.gift-modal-close-row {
  display: flex;
  justify-content: flex-end;
  padding: 40px 50px 0;
}

.gift-modal-close-row--with-back {
  justify-content: space-between;
  align-items: center;
}

.gift-modal-close-btn,
.gift-modal-back-btn {
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #000000;
  padding: 0;
  transition: opacity 0.2s ease;
}

.gift-modal-close-btn:hover,
.gift-modal-back-btn:hover {
  opacity: 0.6;
}

.gift-modal-close-btn:focus-visible,
.gift-modal-back-btn:focus-visible {
  outline: 2px solid var(--primary, #BE5937);
  outline-offset: 2px;
}

.gift-modal-close-btn svg,
.gift-modal-back-btn svg {
  stroke-width: 2;
}

/* Modal Body */
.gift-modal-body {
  padding: 40px 50px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Header Section */
.gift-header-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.gift-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.gift-header-row .gift-modal-close-btn {
  flex-shrink: 0;
  margin-top: 4px;
}

.gift-modal-title {
  font-family: 'Outfit', sans-serif;
  font-weight: 500;
  font-size: 28px;
  line-height: 1.26;
  color: #0F0F0F;
  margin: 0;
}

.gift-modal-title--centered {
  text-align: center;
  flex: 1;
}

.gift-modal-description-container {
  width: 100%;
}

.gift-modal-description {
  font-family: 'Outfit', sans-serif;
  font-weight: 300;
  font-size: 18px;
  line-height: 1.26;
  color: #0F0F0F;
  margin: 0;
}

.gift-modal-description strong {
  font-weight: 500;
}

.gift-modal-subtitle {
  font-family: 'Outfit', sans-serif;
  font-weight: 300;
  font-size: 13px;
  line-height: 1.26;
  color: #0F0F0F;
  margin: 0;
}

/* Divider */
.gift-divider {
  height: 1px;
  background-color: #E6E6E6;
  width: 100%;
}

/* Form Sections */
.gift-form-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.gift-section-header {
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  font-size: 16px;
  line-height: 1.26;
  letter-spacing: 0.065em;
  text-transform: uppercase;
  color: #6D6D6D;
}

/* Form Fields */
.gift-inline-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 13px;
}

.gift-inline-field {
  display: flex;
  align-items: center;
  gap: 13px;
  flex: 1;
  min-width: 0;
}

.gift-inline-field label,
.gift-email-row > label {
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  font-size: 15px;
  line-height: 1.26;
  letter-spacing: 0.065em;
  text-transform: uppercase;
  color: #909090;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 100px;
}

.gift-inline-field input[type="text"],
.gift-inline-field input[type="email"] {
  flex: 1;
  min-width: 0;
  padding: 9px 13px;
  border: 1.24px solid #F1F1F1;
  border-radius: 3px;
  font-family: 'Outfit', sans-serif;
  font-weight: 400;
  font-size: 16px;
  line-height: 0.94;
  letter-spacing: 0.03125em;
  color: #0F0F0F;
  background: var(--text--background-text);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.gift-email-row {
  display: flex;
  align-items: center;
  gap: 13px;
}

.gift-email-row input[type="email"] {
  flex: 1;
  padding: 9px 13px;
  border: 1.24px solid #F1F1F1;
  border-radius: 3px;
  font-family: 'Outfit', sans-serif;
  font-weight: 400;
  font-size: 16px;
  line-height: 0.94;
  letter-spacing: 0.03125em;
  color: #0F0F0F;
  background: var(--text--background-text);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.gift-inline-field input::placeholder,
.gift-email-row input::placeholder {
  color: #AAAAAA;
}

.gift-inline-field input:focus,
.gift-email-row input:focus {
  outline: none;
  border-color: var(--primary, #BE5937);
  box-shadow: 0 0 0 2px rgba(190, 89, 55, 0.15);
}

.gift-helper-text {
  font-family: 'Outfit', sans-serif;
  font-weight: 400;
  font-size: 14px;
  line-height: 1.2;
  letter-spacing: -0.03em;
  color: #AEAEAE;
  margin: -7px 0 0;
}

/* Checkbox */
.gift-checkbox-wrapper {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.gift-checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
}

.gift-checkbox-row input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.gift-checkbox-box {
  width: 16px;
  height: 16px;
  min-width: 16px;
  background: #F3F3F5;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 4px;
  box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.05);
  position: relative;
  transition: all 0.2s ease;
  margin-top: 2px;
}

.gift-checkbox-row input[type="checkbox"]:checked + .gift-checkbox-box {
  background: #0F0F0F;
  border-color: #0F0F0F;
}

.gift-checkbox-row input[type="checkbox"]:checked + .gift-checkbox-box::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 10px;
  font-weight: bold;
}

.gift-checkbox-row input[type="checkbox"]:focus-visible + .gift-checkbox-box {
  outline: 2px solid var(--primary, #BE5937);
  outline-offset: 2px;
}

.gift-checkbox-text {
  font-family: 'Outfit', sans-serif;
  font-weight: 400;
  font-size: 16px;
  line-height: 1.2;
  letter-spacing: -0.03em;
  color: #8F8F8F;
}

/* Footer Row */
.gift-footer-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 0 1px;
}

.gift-recaptcha-wrapper {
  flex-shrink: 0;
}

.gift-recaptcha-wrapper .g-recaptcha {
  transform-origin: left center;
}

/* Ensure reCAPTCHA challenge popup appears above modal */
/* The challenge is rendered in an iframe outside the modal */
body > div[style*="z-index"]:has(iframe[src*="recaptcha"]),
body > div[style*="z-index"]:has(iframe[title*="recaptcha" i]) {
  z-index: 10001 !important;
}

/* Fallback for browsers that don't support :has() */
/* Google reCAPTCHA challenge container */
.grecaptcha-badge {
  z-index: 10001 !important;
}

/* reCAPTCHA challenge overlay iframe container */
body > div > div > iframe[src*="google.com/recaptcha"] {
  z-index: 10001 !important;
}

/* Continue Button */
.gift-continue-btn {
  width: 161px;
  height: 44px;
  padding: 9px 21px;
  background-color: #0F0F0F;
  color: #F9F9F9;
  border: none;
  border-radius: 0;
  font-family: 'Outfit', sans-serif;
  font-weight: 500;
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: 0.105em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-shrink: 0;
}

.gift-continue-btn:hover:not(:disabled) {
  background-color: #333;
}

.gift-continue-btn:focus-visible {
  outline: 2px solid var(--primary, #BE5937);
  outline-offset: 2px;
}

.gift-continue-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.gift-continue-btn--full {
  width: 100%;
}

/* Modal Footer (Step 2) */
.gift-modal-footer {
  padding: 20px 50px 40px;
}

/* Stripe Payment Element */
#gift-payment-element {
  margin: 20px 0;
}

/* Price Display */
.gift-price-display {
  text-align: right;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid #E6E6E6;
}

.gift-price-amount {
  font-family: 'Outfit', sans-serif;
  font-size: 42px;
  font-weight: 700;
  color: #0F0F0F;
}

.gift-price-currency {
  font-family: 'Outfit', sans-serif;
  font-size: 18px;
  font-weight: 600;
  color: #6D6D6D;
  margin-left: 4px;
}

/* Stripe Badge */
.gift-stripe-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 20px;
  font-family: 'Outfit', sans-serif;
  font-size: 12px;
  color: #AEAEAE;
}

.gift-stripe-badge svg {
  height: 16px;
}

/* Loading Spinner */
.gift-loading-spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: gift-spin 0.6s linear infinite;
}

.gift-continue-btn.loading .gift-loading-spinner {
  display: inline-block;
}

.gift-continue-btn.loading #gift-btn-text {
  display: none;
}

/* Payment Message */
.gift-payment-message {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: 4px;
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  display: none;
  line-height: 1.4;
}

.gift-payment-message.error {
  background: #fef0f0;
  color: #c33;
  border: 1px solid #fcc;
  display: block;
}

.gift-payment-message.success {
  background: #f0fef4;
  color: #2a7d3c;
  border: 1px solid #c3e6cb;
  display: block;
}

/* Info Message (Step 1) */
.gift-info-message {
  padding: 12px 16px;
  border-radius: 4px;
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  display: none;
  line-height: 1.4;
}

.gift-info-message.error {
  background: #fef0f0;
  color: #c33;
  border: 1px solid #fcc;
  display: block;
}

/* Success State */
.gift-success-content {
  text-align: center;
  padding: 40px 50px;
}

.gift-success-icon {
  font-size: 64px;
  line-height: 1;
  margin-bottom: 20px;
}

.gift-success-title {
  font-family: 'Outfit', sans-serif;
  font-size: 28px;
  font-weight: 500;
  color: #0F0F0F;
  margin-bottom: 12px;
}

.gift-success-message {
  font-family: 'Outfit', sans-serif;
  font-size: 16px;
  font-weight: 300;
  color: #6D6D6D;
  line-height: 1.5;
  margin-bottom: 28px;
  max-width: 360px;
  margin-left: auto;
  margin-right: auto;
}

#gift-close-success {
  margin: 0 auto;
}

/* Modal Responsive */
/* Body scroll lock when modal is open */
body.gift-modal-open {
  overflow: hidden;
  touch-action: none;
}

@media (max-width: 768px) {
  dialog.gift-modal-overlay[open] {
    align-items: flex-start;
    padding: 0;
    overflow-y: scroll;
    -webkit-overflow-scrolling: touch;
  }

  .gift-modal-container {
    max-width: 100%;
    width: 100%;
    min-height: 100vh;
    max-height: none;
    border-radius: 0;
    margin: 0;
    overflow: visible;
  }

  .gift-modal-step {
    min-height: 100vh;
    display: none;
    flex-direction: column;
  }

  .gift-modal-step.active {
    display: flex;
  }

  .gift-modal-close-row {
    padding: 30px 30px 0;
    flex-shrink: 0;
  }

  .gift-modal-body {
    padding: 30px;
    flex: 1;
  }

  .gift-modal-footer {
    padding: 20px 30px 30px;
    flex-shrink: 0;
    background: #FFFFFF;
  }

  .gift-modal-title {
    font-size: 22px;
  }

  .gift-modal-description {
    font-size: 16px;
  }

  .gift-inline-row {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
  }

  .gift-inline-field {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    width: 100%;
  }

  .gift-inline-field input[type="text"],
  .gift-inline-field input[type="email"] {
    width: 100%;
  }

  .gift-email-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    width: 100%;
  }

  .gift-email-row input[type="email"] {
    width: 100%;
  }

  .gift-footer-row {
    flex-direction: column;
    gap: 20px;
  }

  /* Center reCAPTCHA properly on mobile */
  .gift-recaptcha-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;
    transform: scale(0.9);
    transform-origin: center center;
  }

  .gift-continue-btn {
    width: 100%;
  }
}

@media (max-width: 400px) {
  .gift-modal-close-row {
    padding: 24px 20px 0;
  }

  .gift-modal-body {
    padding: 24px 20px;
  }

  .gift-modal-footer {
    padding: 16px 20px 24px;
  }

  .gift-section-header {
    font-size: 14px;
  }

  .gift-inline-field label,
  .gift-email-row > label {
    font-size: 13px;
  }

  .gift-recaptcha-wrapper .g-recaptcha {
    transform: scale(0.85);
    transform-origin: center center;
  }
}

/* Payment Loading State */
.gift-payment-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  gap: 16px;
  color: var(--gift-dark-gray);
  font-size: 14px;
}

.gift-payment-loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--gift-light-gray);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: gift-spin 0.8s linear infinite;
}

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

/* Checkout Elements Container */
.gift-checkout-elements {
  display: none;
}

.gift-checkout-elements.visible {
  display: block;
}

/* Billing Address Section */
.gift-billing-section .gift-section-header,
.gift-payment-section .gift-section-header {
  margin-bottom: 16px;
}

#gift-billing-address-element {
  min-height: 100px;
}

/* Payment Section */
.gift-payment-section {
  margin-top: 0;
}

/* Divider spacing in checkout */
.gift-checkout-elements .gift-divider {
  margin: 24px 0;
}

/* Express Checkout Element */
.gift-express-checkout {
  min-height: 44px;
  margin-bottom: 4px;
}

/* Hide express checkout container when empty (no buttons available) */
.gift-express-checkout:empty {
  display: none;
}

/* Hide divider when express checkout is empty */
.gift-express-checkout:empty + .gift-express-divider {
  display: none;
}

.gift-express-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 20px 0;
  color: #AEAEAE;
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.gift-express-divider::before,
.gift-express-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background-color: #E6E6E6;
}

/* Hidden State */
.gift-badge-btn.hidden,
.gift-modal-overlay.hidden {
  display: none !important;
}
