/**
 * Stripe Dev Gateway - Block & Classic UI Styling
 * Modern Light Theme Design matching WooCommerce and modern themes
 */

/* General Payment Form */
body .custom-design h3.form-section-title {
  font-family: inherit;
  color: #111827 !important;
  font-size: 14px !important;
  font-weight: 500 !important;
  margin-bottom: 8px !important;
}

.block-ui-payment-form {
  background-color: #ffffff;
  color: #111827;
  padding: 16px 18px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  max-width: 100%;
  margin: 8px 0;
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  box-sizing: border-box;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
}

/* Ensure the payment method is visible */
.wc-block-components-radio-control__option .wc-block-components-radio-control__input[value="stripe_dev"] {
  opacity: 1 !important;
}

/* Make sure our payment content is visible */
.wc-block-components-payment-method-icons + div[aria-hidden="true"] {
  display: block !important;
  height: auto !important;
  visibility: visible !important;
  opacity: 1 !important;
}

/* Section Title */
.form-section-title {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 8px;
  color: #111827;
}

/* Card Input Container */
.card-input-container {
  position: relative;
  margin-bottom: 0;
}

/* Card Number Input */
.card-number-input {
  width: 100%;
  background-color: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 6px 6px 0 0;
  padding: 13px 80px 13px 14px;
  color: #111827;
  font-size: 15px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  letter-spacing: 0.05em;
  box-sizing: border-box;
  outline: none;
  transition: border 0.2s, box-shadow 0.2s;
}

.card-number-input::placeholder {
  color: #9ca3af;
  opacity: 1;
}

/* Card Icons */
.card-icons {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  gap: 6px;
  align-items: center;
  z-index: 2;
}

.card-icon {
  opacity: 0.35;
  transition: opacity 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.card-icon.show {
  opacity: 1;
}

.card-icon img {
  width: 32px;
  height: 20px;
  object-fit: contain;
  transition: all 0.3s ease;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  filter: none;
  max-width: 100%;
  height: auto;
  display: block;
}

/* Enhanced Responsive Design for Card Icons */
@media (max-width: 1024px) {
  .card-icons {
    right: 12px;
    gap: 5px;
  }
  .card-icon img {
    width: 30px;
    height: 19px;
  }
}

@media (max-width: 768px) {
  .card-icons {
    right: 10px;
    gap: 4px;
  }
  .card-icon img {
    width: 28px;
    height: 18px;
  }
}

@media (max-width: 600px) {
  .card-icons {
    right: 8px;
    gap: 3px;
  }
  .card-icon img {
    width: 26px;
    height: 16px;
  }
}

@media (max-width: 480px) {
  .card-icons {
    right: 6px;
    gap: 2px;
  }
  .card-icon img {
    width: 24px;
    height: 15px;
  }
}

@media (max-width: 360px) {
  .card-icons {
    right: 4px;
    gap: 1px;
  }
  .card-icon img {
    width: 22px;
    height: 14px;
  }
}

@media (max-width: 320px) {
  .card-icons {
    right: 3px;
    gap: 1px;
  }
  .card-icon img {
    width: 20px;
    height: 13px;
  }
  .card-icon:nth-child(4) {
    display: none;
  }
}

@media (hover: none) and (pointer: coarse) {
  .card-icons {
    min-height: 44px;
    min-width: 44px;
  }
  .card-icon {
    padding: 2px;
  }
}

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .card-icon img {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
}

@media (max-width: 768px) and (orientation: landscape) {
  .card-icons {
    right: 8px;
    gap: 2px;
  }
  .card-icon img {
    width: 24px;
    height: 15px;
  }
}

/* Input Row (Expiry and CVC) */
.input-row {
  display: flex;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

/* Form Input (Expiry and CVC) */
.form-input {
  flex: 1;
  min-width: 120px;
  background-color: #ffffff;
  border: 1px solid #d1d5db;
  padding: 13px 14px;
  color: #111827;
  font-size: 15px;
  box-sizing: border-box;
  outline: none;
  transition: border 0.2s, box-shadow 0.2s;
}

.form-input:first-child {
  border-radius: 0 0 0 6px;
  border-top: none;
  border-right: none;
}

.form-input:last-child {
  border-radius: 0 0 6px 0;
  border-top: none;
}

.form-input::placeholder {
  color: #9ca3af;
  opacity: 1;
}

/* Cardholder Name Input */
.cardholder-name-input {
  width: 100%;
  background-color: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 13px 14px;
  color: #111827;
  font-size: 15px;
  box-sizing: border-box;
  outline: none;
  transition: border 0.2s, box-shadow 0.2s;
}

.cardholder-name-input::placeholder {
  color: #9ca3af;
  opacity: 1;
}

/* Focus States */
.card-number-input:focus,
.form-input:focus,
.cardholder-name-input:focus,
#cardExpiry:focus,
#cardCvc:focus {
  outline: none;
  border-color: #635bff;
  box-shadow: 0 0 0 3px rgba(99, 91, 255, 0.15);
  z-index: 2;
}

/* Footer */
.checkout-footer {
  display: flex;
  gap: 16px;
  font-family: inherit;
  align-items: center;
  font-size: 12px;
  margin-top: 16px;
  color: #6b7280;
}

.checkout-footer .footer-link {
  color: #6b7280;
  text-decoration: none;
  transition: color 0.2s;
}

.checkout-footer .footer-link:hover {
  color: #111827;
  text-decoration: none;
}

.checkout-footer svg {
  vertical-align: middle;
  margin-left: 4px;
}

/* Responsive */
@media (max-width: 480px) {
  .block-ui-payment-form {
    padding: 16px;
  }
}

/* Error state */
.input-error {
  border: 1px solid #ef4444 !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15) !important;
}

/* WooCommerce Blocks Integration Fixes */
.wc-block-components-payment-method-icons {
  display: none !important;
}

.wc-block-components-payment-method-label[for*="stripe_dev"] + div .block-ui-payment-form {
  margin: 0;
  padding: 20px;
}

.wc-block-components-radio-control__input[name="wc-stripe_dev-payment-token"] {
  display: none !important;
}

.wc-block-components-payment-method-label--with-icon[for*="stripe_dev"] + div {
  display: block !important;
}

.wc-block-components-payment-method-label--with-icon[for*="stripe_dev"] + div .block-ui-payment-form {
  background-color: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
}

.wc-block-components-payment-method-label--with-icon[for*="stripe_dev"] {
  display: block;
  margin-bottom: 10px;
}

.stripe-dev-block-checkout .block-ui-exact,
.stripe-dev-block-checkout .PaymentForm-form:not(.custom-design),
.stripe-dev-block-checkout .FormFieldGroup:not(.custom-design) {
  display: none !important;
}

/* Card UI force display */
body .wc-block-checkout .block-ui-payment-form.custom-design {
  display: block !important;
  opacity: 1 !important;
  visibility: visible !important;
}

/* Show credit card fields */
body .wc-block-components-radio-control-accordion-content {
  display: block !important;
  height: auto !important;
  visibility: visible !important;
  opacity: 1 !important;
}

body .wc-block-components-radio-control__option:has(input[value="stripe_dev"]) {
  display: block !important;
  opacity: 1 !important;
}

.wc-block-components-checkout-step--with-step-number .wc-block-components-checkout-step__title[aria-hidden="true"]::before {
  display: none !important;
}

.wc-block-components-checkout-step--with-step-number[aria-hidden="true"] {
  display: none !important;
}

.wc-block-components-checkout-payment-methods {
  min-height: 100px !important;
}

.wc-block-components-checkout-payment-methods:empty::before {
  content: "Loading payment methods..." !important;
  display: block !important;
  padding: 20px !important;
  text-align: center !important;
  background-color: #f9fafb !important;
  border-radius: 4px !important;
  color: #6b7280 !important;
}

.wc-block-components-payment-method-options {
  display: block !important;
}

.wc-block-components-payment-method-options .wc-block-components-radio-control {
  display: block !important;
}

.wc-block-components-payment-method-options {
  display: block !important;
  min-height: 100px !important;
}

.wc-block-components-payment-method-options .wc-block-components-radio-control {
  display: block !important;
  opacity: 1 !important;
  visibility: visible !important;
}

.wc-block-components-radio-control__option:has(input[value="stripe_dev"]) {
  display: block !important;
  opacity: 1 !important;
  visibility: visible !important;
}

/* Remove border-radius from ALL card icons */
#card_icon_detected,
#card_icon_detected_img,
#card_icons_all .card-icon img,
#card_icons_all .card-icon,
.card-icons img,
.card-icon img {
  border-radius: 0 !important;
}

/* CSS force-hide safety net (belt & suspenders)
   When JS adds .brand-detected to .card-input-container,
   these rules enforce visibility with !important */
.card-input-container.brand-detected #card_icons_all {
  display: none !important;
}
.card-input-container.brand-detected #card_icon_detected {
  display: flex !important;
}