:root {
  --mk-onetime-primary: #314641;
  --mk-onetime-accent: #005bbb;
  --mk-onetime-bg: #fff;
  --mk-onetime-secondary: #f8f3e7;
  --mk-onetime-success: #ffd500;
  --mk-onetime-error: #f44336;
  --mk-onetime-text: #333;
  --mk-onetime-text-light: #666;
  --mk-onetime-border: #e0e0e0;
  --mk-onetime-shadow: 0 4px 20px rgba(49, 70, 65, 0.15);
  --mk-onetime-ukraine-blue: #005bbb;
  --mk-onetime-ukraine-yellow: #ffd500;
  --mk-onetime-background: #ffffff;
  --mk-onetime-background-secondary: #f9f9f9;
}

/* Shortcode button styles for one-time donations - Ukrainian Yellow theme */
.mk-onetime-trigger-btn,
.mk-onetime-btn-normal,
.mk-onetime-btn-large {
  background: var(--mk-onetime-ukraine-yellow);
  color: #333;
  border: none;
  border-radius: 30px;
  padding: 12px 24px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 16px rgba(255, 213, 0, 0.3);
  position: relative;
  overflow: hidden;
  display: inline-block;
  text-decoration: none;
  text-align: center;
  cursor: pointer;
  font-size: 14px;
  line-height: 1.4;
  min-width: 120px;
  white-space: nowrap;
}

.mk-onetime-btn-large {
  padding: 16px 32px;
  font-size: 16px;
  min-width: 150px;
}

.mk-onetime-trigger-btn:hover,
.mk-onetime-btn-normal:hover,
.mk-onetime-btn-large:hover {
  background: #f0c000;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 213, 0, 0.4);
  color: #222;
  cursor: pointer;
}

/* Width modifier classes for custom button widths */
/* Usage in shortcodes: width="small|medium|large|xl|full|auto" */
/* Examples: 
   [mk_onetime_button width="full" text="Donate Once"] - Full width button
   [mk_onetime_trigger width="small" text="Donate"] - Small width button
*/
.mk-onetime-btn-full-width {
  width: 100%;
  display: block;
}

.mk-onetime-btn-auto-width {
  width: auto;
  min-width: 0;
}

.mk-onetime-btn-small-width {
  min-width: 80px;
  padding: 8px 16px;
  font-size: 12px;
}

.mk-onetime-btn-medium-width {
  min-width: 120px;
}

.mk-onetime-btn-large-width {
  min-width: 200px;
}

.mk-onetime-btn-xl-width {
  min-width: 300px;
}

/* Modal styles */
.mk-onetime-modal {
  display: none;
  position: fixed;
  z-index: 999999;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  animation: fadeIn 0.3s ease;
  pointer-events: auto;
}

.mk-onetime-modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  flex-direction: column;
}

.mk-onetime-modal-content {
  background: var(--mk-onetime-background);
  border-radius: 16px;
  width: 100%;
  max-width: 600px;
  padding: 0;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 400px;
}

.mk-onetime-close {
  position: absolute;
  right: 20px;
  top: 20px;
  background: none;
  border: none;
  font-size: 28px;
  cursor: pointer;
  color: var(--mk-onetime-text-light);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  z-index: 10;
}

.mk-onetime-close:hover {
  background: var(--mk-onetime-ukraine-yellow);
  color: var(--mk-onetime-text);
  transform: scale(1.1);
}

/* Step styles */
.mk-onetime-step {
  display: none;
  padding: 24px 24px 16px;
  max-height: 90vh;
  overflow-y: auto;
}

.mk-onetime-step.active {
  display: block;
  animation: slideIn 0.3s ease;
}

.mk-onetime-step-header {
  margin-bottom: 24px;
  text-align: center;
}

.mk-onetime-step-header h2 {
  margin: 0 0 8px 0;
  font-size: 24px;
  font-weight: 700;
  color: var(--mk-onetime-primary);
  line-height: 1.3;
}

.mk-onetime-step-header p {
  margin: 0;
  color: var(--mk-onetime-text-light);
  font-size: 16px;
  line-height: 1.5;
}

/* Amount buttons */
.mk-onetime-amounts {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.mk-onetime-amount-btn {
  background: var(--mk-onetime-background);
  border: 2px solid var(--mk-onetime-border);
  color: var(--mk-onetime-primary);
  padding: 16px 8px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
  font-size: 16px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mk-onetime-custom-amount-btn {
  background: var(--mk-onetime-background-secondary);
  font-weight: 600;
  font-size: 14px;
  color: var(--mk-onetime-text);
}

/* Custom amount container for button/input transformation - always full width */
.mk-onetime-custom-amount-container {
  grid-column: 1 / -1;
  display: flex;
  width: 100%;
  margin-top: 10px;
}

.mk-onetime-custom-amount-container .mk-onetime-custom-amount-btn {
  width: 100%;
  flex: 1;
}

.mk-onetime-custom-amount-input {
  width: 100%;
  padding: 16px 20px;
  border: 2px solid var(--mk-onetime-border);
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  transition: all 0.3s ease;
  background: var(--mk-onetime-background);
  color: var(--mk-onetime-text);
}

.mk-onetime-custom-amount-input:focus {
  outline: none;
  border-color: var(--mk-onetime-ukraine-blue);
  box-shadow: 0 0 0 4px rgba(0, 91, 187, 0.1);
}

.mk-onetime-custom-amount-input::placeholder {
  color: var(--mk-onetime-text-light);
  opacity: 0.7;
}

.mk-onetime-amount-btn:hover {
  border-color: var(--mk-onetime-ukraine-blue);
  background: var(--mk-onetime-background);
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0, 91, 187, 0.15);
}

.mk-onetime-amount-btn.selected {
  background: var(--mk-onetime-ukraine-yellow);
  color: var(--mk-onetime-text);
  border-color: var(--mk-onetime-ukraine-yellow);
  transform: scale(1.05);
  box-shadow: 0 8px 25px rgba(255, 213, 0, 0.35);
}

/* Form styles */
.mk-onetime-form-group {
  margin-bottom: 24px;
}

.mk-onetime-form-group label {
  display: block;
  margin-bottom: 8px;
  color: var(--mk-onetime-text);
  font-weight: 600;
  font-size: 15px;
  line-height: 1.4;
}

.mk-onetime-form-group input,
.mk-onetime-form-group select {
  width: 100%;
  padding: 16px 20px;
  border: 2px solid var(--mk-onetime-border);
  border-radius: 10px;
  font-size: 16px;
  transition: all 0.3s ease;
  background: var(--mk-onetime-background);
  box-sizing: border-box;
  font-weight: 400;
}

.mk-onetime-form-group input:focus,
.mk-onetime-form-group select:focus {
  outline: none;
  border-color: var(--mk-onetime-ukraine-blue);
  box-shadow: 0 0 0 4px rgba(0, 91, 187, 0.1);
  background: white;
}

.mk-onetime-form-group input::placeholder {
  color: var(--mk-onetime-text-light);
  opacity: 0.7;
}

/* Inline, compact consent checkbox */
/* Increase specificity to override generic label styles */
.mk-onetime-form-group > label.mk-onetime-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 0; /* keep tight */
  color: var(--mk-onetime-text-light);
  font-weight: 400;
  font-size: 13px;
  line-height: 1.4;
  white-space: normal;
}
.mk-onetime-form-group > label.mk-onetime-checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--mk-onetime-ukraine-yellow);
}
.mk-onetime-form-group > label.mk-onetime-checkbox span {
  font-size: 12px;
}

/* Reduce spacing for consent form group specifically */
.mk-onetime-form-group:has(label.mk-onetime-checkbox) {
  margin-top: -12px;
  margin-bottom: 16px;
}

/* Fallback for browsers without :has() support */
.mk-onetime-form-group.mk-onetime-consent-group {
  margin-top: -12px;
  margin-bottom: 16px;
}

.mk-terms-note {
  display: inline-block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--mk-onetime-text-light);
}

/* Beneficiary section styling */
.mk-beneficiary {
  font-size: 12px;
  color: var(--mk-onetime-text-light);
  line-height: 1.4;
  margin-bottom: 16px;
}

.mk-beneficiary strong {
  color: var(--mk-onetime-text);
  font-weight: 600;
}

/* Payment provider logo */
.mk-payment-provider {
  margin-top: 12px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.mk-payment-provider-text {
  font-size: 10px;
  color: var(--mk-onetime-text-light);
  opacity: 0.8;
  font-weight: 400;
  white-space: nowrap;
  line-height: 1.2;
}

.mk-payment-provider-logo {
  max-width: 55px;
  max-height: 18px;
  width: 55px;
  height: auto;
  object-fit: contain;
  opacity: 0.5;
  transition: opacity 0.3s ease;
  flex-shrink: 0;
}

.mk-payment-provider-logo:hover {
  opacity: 0.7;
}

/* Button styles */
.mk-btn {
  padding: 18px 28px;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: none;
  font-size: 16px;
  position: relative;
  overflow: hidden;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.mk-btn-primary {
  background: var(--mk-onetime-primary);
  color: white;
  width: 100%;
  box-shadow: 0 4px 16px rgba(49, 70, 65, 0.2);
  border: 2px solid var(--mk-onetime-primary);
}

.mk-btn-primary:hover:not(:disabled) {
  background: var(--mk-onetime-accent);
  border-color: var(--mk-onetime-accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(49, 70, 65, 0.3);
}

.mk-btn-primary:disabled {
  background: #cccccc !important;
  color: #666666 !important;
  border-color: #cccccc !important;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  opacity: 0.6;
}

/* Pay button (Step 1) – Ukrainian yellow with white uppercase text */
#mkOnetimePayBtn.mk-btn-primary {
  background: var(--mk-onetime-ukraine-yellow);
  color: #ffffff;
  border-color: var(--mk-onetime-ukraine-yellow);
  text-transform: uppercase;
}

#mkOnetimePayBtn.mk-btn-primary:hover:not(:disabled) {
  background: #e6c000;
  border-color: #e6c000;
}

#mkOnetimePayBtn.mk-btn-primary:disabled {
  background: #cccccc !important;
  color: #666666 !important;
  border-color: #cccccc !important;
}

/* Secondary button for CTA */
.mk-btn-secondary {
  background: var(--mk-onetime-background);
  color: var(--mk-onetime-primary);
  border: 2px solid var(--mk-onetime-primary);
}

.mk-btn-secondary:hover:not(:disabled) {
  background: var(--mk-onetime-secondary);
  transform: translateY(-2px);
}

/* Success step close button styling */
#mkOnetimeStep3 .mk-btn-primary {
  background: var(--mk-onetime-ukraine-yellow);
  color: var(--mk-onetime-text);
  border-color: var(--mk-onetime-ukraine-yellow);
  box-shadow: 0 4px 16px rgba(255, 213, 0, 0.3);
  font-weight: 600;
}

#mkOnetimeStep3 .mk-btn-primary:hover:not(:disabled) {
  background: #e6c000;
  border-color: #e6c000;
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(255, 213, 0, 0.4);
}

/* Loading spinner */
.mk-onetime-loading {
  text-align: center;
  padding: 64px 32px;
}

.mk-spinner {
  width: 64px;
  height: 64px;
  border: 4px solid var(--mk-onetime-border);
  border-top: 4px solid var(--mk-onetime-ukraine-blue);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 24px;
  box-shadow: 0 4px 12px rgba(0, 91, 187, 0.2);
}

.mk-onetime-loading p {
  color: var(--mk-onetime-text-light);
  margin: 0;
  font-size: 16px;
  font-weight: 500;
}

/* Success message */
.mk-message {
  max-width: 520px;
  margin: 32px auto;
  padding: 32px;
  border-radius: 20px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.mk-message-icon {
  font-size: 120px;
  margin-bottom: 24px;
  display: block;
}

.mk-message-icon img {
  max-width: 160px;
  max-height: 160px;
  width: auto;
  height: auto;
  object-fit: contain;
  margin: 0 auto;
  display: block;
}

.mk-message h3 {
  margin: 0 0 16px 0;
  font-size: 28px;
  font-weight: 700;
  line-height: 1.3;
}

.mk-message p {
  margin: 12px 0;
  font-size: 16px;
  line-height: 1.5;
}

.mk-message .mk-btn {
  margin-top: 24px;
}

.mk-success {
  background: rgba(255, 213, 0, 0.1);
  color: var(--mk-onetime-text);
  border: 2px solid var(--mk-onetime-ukraine-yellow);
}

.mk-error {
  background: rgba(220, 53, 69, 0.1);
  color: var(--mk-onetime-text);
  border: 2px solid #dc3545;
}

/* Dynamic success text and CTA */
.mk-onetime-success-dynamic {
  margin: 8px 0 0;
}

.mk-onetime-success-text {
  font-size: 16px;
  margin: 8px 0 16px;
}

.mk-onetime-cta-title {
  font-size: 15px;
  color: var(--mk-onetime-text-light);
  margin: 4px 0 8px;
}

.mk-onetime-cta-btn {
  width: 100%;
}

/* Payment method grid */
.mk-onetime-methods {
  display: grid;
  /* Auto-fit grid that adapts to container width - maintains 5 columns on desktop */
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin: 8px 0 20px;
  justify-items: stretch; /* Let items fill the track width to avoid edge overflow */
  max-width: 100%; /* Ensure it doesn't exceed container width */
  box-sizing: border-box;
}

.mk-onetime-method-btn {
  position: relative;
  background: none;
  border: none;
  padding: 0;
  margin: 0; /* Use grid gap for spacing to avoid adding width beyond track */
  display: block; /* Fill the grid cell so images can scale with it */
  width: 100%;
  cursor: pointer;
  transition: all 0.25s ease;
  text-align: center; /* Ensure contained image is centered */
}

.mk-onetime-method-btn img {
  width: 100%; /* Scale down within the grid cell to prevent partial overflow */
  height: auto;
  /* Remove max-width to allow full expansion within grid cells */
  max-height: 60px; /* Taller maximum height to avoid excessive squashing */
  object-fit: contain;
  filter: grayscale(30%) opacity(0.8);
  transition: all 0.25s ease;
  border-radius: 0; /* Remove rounded corners */
  display: block;
  margin: 0 auto; /* Center inside full-width button */
}

.mk-onetime-method-btn .mk-onetime-method-label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -40px;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 6px;
  text-align: center;
  letter-spacing: 0.5px;
  transition: all 0.25s ease;
  pointer-events: none;
}

.mk-onetime-method-btn:hover img,
.mk-onetime-method-btn:focus img {
  filter: grayscale(0%) opacity(1);
  transform: scale(1.05);
}

.mk-onetime-method-btn.selected img {
  filter: grayscale(0%) opacity(1);
  box-shadow: 0 0 15px rgba(255, 213, 0, 0.9), 0 0 30px rgba(255, 213, 0, 0.45);
}

.mk-onetime-method-btn:hover,
.mk-onetime-method-btn:focus {
  transform: translateY(-2px);
}

/* Check icon for selected state */
.mk-onetime-method-btn.selected::after {
  content: "✓";
  position: absolute;
  top: 2px; /* Keep inside the cell to prevent overflow at edges */
  right: 2px;
  background: var(--mk-onetime-ukraine-yellow);
  color: var(--mk-onetime-text);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  z-index: 10;
}

/* Disabled state for payment methods that exceed max_amount */
.mk-onetime-method-btn.mk-disabled {
  cursor: not-allowed;
  pointer-events: none;
}

.mk-onetime-method-btn.mk-disabled img {
  filter: grayscale(100%) opacity(0.3);
  transform: none;
}

.mk-onetime-method-btn.mk-disabled:hover img,
.mk-onetime-method-btn.mk-disabled:focus img {
  filter: grayscale(100%) opacity(0.3);
  transform: none;
}

.mk-onetime-method-btn.mk-disabled:hover,
.mk-onetime-method-btn.mk-disabled:focus {
  transform: none;
}

/* X icon for disabled payment methods */
.mk-onetime-method-btn.mk-disabled::before {
  content: "✕";
  position: absolute;
  top: 2px;
  left: 2px;
  background: #f44336;
  color: white;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  z-index: 10;
}

/* Add overlay icon for disabled state */
.mk-onetime-method-btn.mk-disabled::before {
  content: "✕";
  position: absolute;
  top: 2px;
  left: 2px;
  background: var(--mk-onetime-error);
  color: white;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  z-index: 10;
}

.mk-onetime-method-hint {
  font-size: 12px;
  color: var(--mk-onetime-text-light);
  margin-top: -10px;
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* 
 * Responsive breakpoints for payment methods:
 * Desktop (>768px): 5 columns
 * Tablet (768px-521px): 4 columns 
 * Medium Mobile (520px-401px): 3 columns
 * Small Mobile (<400px): 2 columns
 */

/* Mobile responsive */
@media (max-width: 768px) {
  .mk-onetime-modal-content {
    max-width: 90vw;
    margin: 20px;
  }

  .mk-onetime-step {
    padding: 16px 16px 12px; /* Reduced padding for mobile */
  }

  .mk-onetime-step-header h2 {
    font-size: 20px;
  }

  .mk-onetime-methods {
    /* Always 4 columns for tablet */
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
  }

  .mk-onetime-method-btn img {
    max-height: 50px;
  }
}

@media (max-width: 520px) {
  .mk-onetime-amount-btn {
    font-size: 14px;
    padding: 12px 6px;
  }

  .mk-onetime-step {
    padding: 12px 12px 8px; /* Even smaller padding for small screens */
  }

  .mk-onetime-step-header h2 {
    font-size: 18px;
  }

  .mk-onetime-methods {
    /* Always 3 columns for medium mobile */
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
  }

  .mk-onetime-method-btn img {
    max-height: 55px;
  }
}

/* Add specific breakpoint for 430px screen size */
@media (max-width: 450px) and (min-width: 401px) {
  .mk-onetime-methods {
    /* Force 3 columns for this specific range */
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
  }
}

@media (max-width: 400px) {
  .mk-onetime-step {
    padding: 10px 10px 6px; /* Minimal padding for very small screens */
  }

  .mk-onetime-methods {
    /* Always 2 columns for smallest screens */
    grid-template-columns: repeat(2, 1fr);
    gap: 3px;
  }

  .mk-onetime-method-btn img {
    max-height: 60px;
  }
}
