/**
 * GiveWP Donation Form Enhancements
 * Error modal, card validation icons, card brand icons, DAF seamless modes
 */

/* =============================================
   ERROR MODAL
   ============================================= */

#give-error-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 999999;
    display: none;
    align-items: center;
    justify-content: center;
}

#give-error-modal-overlay.visible {
    display: flex;
}

#give-error-modal {
    background: #fff;
    border-radius: 16px;
    padding: 32px 28px 28px;
    max-width: 380px;
    width: 88%;
    text-align: center;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.25);
    animation: giveModalSlideIn 0.3s ease-out;
    position: relative;
}

@keyframes giveModalSlideIn {
    from {
        transform: translateY(-24px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.give-error-modal-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    border-radius: 50%;
    background: #FEE2E2;
    display: flex;
    align-items: center;
    justify-content: center;
}

.give-error-modal-icon svg {
    width: 28px;
    height: 28px;
}

.give-error-modal-title {
    font-size: 19px;
    font-weight: 700;
    color: #1D2B3A;
    margin-bottom: 8px;
    font-family: 'Montserrat', sans-serif;
}

.give-error-modal-message {
    font-size: 14px;
    color: #64748B;
    margin-bottom: 24px;
    line-height: 1.6;
    font-family: 'Montserrat', sans-serif;
}

#give-error-modal-close {
    background: #65c9bb;
    color: #fff;
    border: none;
    padding: 13px 44px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
    font-family: 'Montserrat', sans-serif;
    letter-spacing: 0.3px;
}

#give-error-modal-close:hover {
    background: #52b8a9;
}

/* =============================================
   CARD BRAND ICONS
   ============================================= */

.give-card-brand-icons {
    display: flex;
    gap: 6px;
    padding: 4px 0 8px;
    align-items: center;
}

.give-card-brand-icon {
    width: 40px;
    height: 26px;
    object-fit: contain;
    opacity: 0.45;
    transition: all 0.25s ease;
    border-radius: 4px;
    flex-shrink: 0;
}

.give-card-brand-icon.active {
    opacity: 1;
    transform: scale(1.12);
}

.give-card-brand-icon.dimmed {
    opacity: 0.18;
    filter: grayscale(100%);
}

/* =============================================
   CARD VALIDATION ICONS
   ============================================= */

.give-card-field-wrap {
    position: relative;
}

.give-card-validation-icon {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
    font-weight: 700;
    pointer-events: none;
    line-height: 1;
}

.give-card-validation-icon.valid {
    color: #28C77F;
}

.give-card-validation-icon.invalid {
    color: #EF4444;
}

input.card-number.give-enhanced {
    padding-right: 36px;
}

/* =============================================
   REARRANGED CARD FIELD LAYOUT (CSS flex + order)
   ============================================= */

.give-cc-flex-layout {
    display: flex !important;
    flex-wrap: wrap !important;
}

.give-cc-flex-layout > legend {
    order: -1 !important;
    flex-basis: 100% !important;
    width: 100% !important;
}

.give-cc-flex-layout > .give-card-brand-icons {
    order: 0 !important;
    flex-basis: 100% !important;
    width: 100% !important;
}

.give-field-card-number {
    order: 1 !important;
    width: 100% !important;
    flex-basis: 100% !important;
    float: none !important;
}

.give-field-card-expiry {
    order: 2 !important;
    width: calc(50% - 4px) !important;
    flex-basis: calc(50% - 4px) !important;
    float: none !important;
    margin-left: 0 !important;
    margin-right: 4px !important;
}

.give-field-card-cvc {
    order: 3 !important;
    width: calc(50% - 4px) !important;
    flex-basis: calc(50% - 4px) !important;
    float: none !important;
    margin-left: 4px !important;
    margin-right: 0 !important;
}

.give-field-card-name {
    order: 4 !important;
    width: 100% !important;
    flex-basis: 100% !important;
    float: none !important;
}

/* DAF selector sits between card number and expiry/CVC */
.give-cc-flex-layout > .give-daf-selector {
    order: 1 !important;
    flex-basis: 100% !important;
    width: 100% !important;
}

/* Push card number above selector */
.give-cc-flex-layout > .give-field-card-number {
    order: 1 !important;
}

.give-cc-flex-layout > .give-daf-selector {
    order: 2 !important;
}

.give-cc-flex-layout > .give-field-card-expiry {
    order: 3 !important;
}

.give-cc-flex-layout > .give-field-card-cvc {
    order: 4 !important;
}

.give-cc-flex-layout > .give-field-card-name {
    order: 5 !important;
}

/* Hide the inline SSL text div */
.give-cc-flex-layout > div:not(.give-card-brand-icons):not(.give-daf-selector) {
    order: 99 !important;
    display: none !important;
}

/* =============================================
   THEME COLOR OVERRIDES
   ============================================= */

.give-donation-level-btn {
    background-color: #65c9bb !important;
    border-color: #65c9bb !important;
}

.give-donation-level-btn:hover {
    background-color: #52b8a9 !important;
    border-color: #52b8a9 !important;
}

.give-donation-level-btn.give-btn-level-custom,
.give-donation-level-btn[aria-pressed="true"],
.give-donation-level-btn.give-default-level {
    background-color: #fff !important;
    color: #364f75 !important;
    border-color: #364f75 !important;
}

.advance-btn {
    background-color: #65c9bb !important;
    border-color: #65c9bb !important;
}

.advance-btn:hover {
    background-color: #52b8a9 !important;
    border-color: #52b8a9 !important;
}

.give-submit,
.give-btn {
    background-color: #65c9bb !important;
    border-color: #65c9bb !important;
}

.give-submit:hover,
.give-btn:hover {
    background-color: #52b8a9 !important;
    border-color: #52b8a9 !important;
}

.give-form-navigator .back-btn:hover {
    color: #364f75 !important;
}

input[type="radio"]:checked {
    accent-color: #65c9bb !important;
}

.give-input:focus,
input:focus {
    border-color: #65c9bb !important;
    box-shadow: 0 0 0 1px #65c9bb !important;
}

/* =============================================
   OJC SEAMLESS MODE
   Hide CVC and Cardholder Name when OJC card detected.
   Expiry goes full-width.
   ============================================= */

.give-ojc-mode .give-field-card-cvc {
    display: none !important;
}

.give-ojc-mode .give-field-card-name {
    display: none !important;
}

.give-ojc-mode .give-field-card-expiry {
    width: 100% !important;
    flex-basis: 100% !important;
    margin-right: 0 !important;
}

/* =============================================
   DONORS FUND SEAMLESS MODE
   Hide expiry and cardholder name.
   CVC (renamed to Security Pin) goes full-width.
   ============================================= */

.give-daf-mode-dfd .give-field-card-expiry {
    display: none !important;
}

.give-daf-mode-dfd .give-field-card-name {
    display: none !important;
}

.give-daf-mode-dfd .give-field-card-cvc {
    width: 100% !important;
    flex-basis: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

/* =============================================
   PLEDGER SEAMLESS MODE
   Hide cardholder name only. Keep expiry + CVC.
   ============================================= */

.give-daf-mode-pledger .give-field-card-name {
    display: none !important;
}

/* =============================================
   DAF CARD TYPE SELECTOR
   Appears when 6599 prefix detected — user picks
   Donors Fund or Pledger.
   ============================================= */

.give-daf-selector {
    display: block !important;
    padding: 12px 0;
    width: 100%;
}

.give-daf-selector-label {
    font-size: 13px;
    font-weight: 600;
    color: #364f75;
    margin-bottom: 10px;
    font-family: 'Montserrat', sans-serif;
    text-align: center;
}

.give-daf-selector-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.give-daf-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Montserrat', sans-serif;
    font-size: 13px;
    font-weight: 600;
    color: #475569;
}

.give-daf-btn svg {
    width: 36px;
    height: 24px;
    border-radius: 3px;
    flex-shrink: 0;
}

.give-daf-btn:hover {
    border-color: #65c9bb;
    background: #f0fdfb;
}

.give-daf-btn.active {
    border-color: #65c9bb;
    background: #f0fdfb;
    box-shadow: 0 0 0 1px #65c9bb;
    color: #1D2B3A;
}

/* =============================================
   SUPPORTED GATEWAYS NOTICE
   ============================================= */

.give-supported-gateways {
    text-align: center;
    padding: 16px 12px 8px;
    margin-top: 8px;
}

.give-supported-gateways-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #94a3b8;
    margin-bottom: 10px;
    font-family: 'Montserrat', sans-serif;
}

.give-supported-gateways-icons {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.give-gateway-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.give-gateway-badge svg {
    width: 42px;
    height: 28px;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.give-gateway-badge-name {
    font-size: 9px;
    color: #94a3b8;
    font-family: 'Montserrat', sans-serif;
    font-weight: 500;
}

/* =============================================
   LEGACY TEMPLATE OVERRIDES
   The legacy GiveWP form (/donations/donate/) has
   .single-give_forms .give-form { background: #65c9bb }
   so teal buttons are invisible. Override for contrast.
   ============================================= */

.single-give_forms .give-form .give-donation-level-btn {
    background-color: rgba(255, 255, 255, 0.15) !important;
    border: 2px solid #fff !important;
    color: #fff !important;
}

.single-give_forms .give-form .give-donation-level-btn:hover {
    background-color: rgba(255, 255, 255, 0.3) !important;
    border-color: #fff !important;
}

.single-give_forms .give-form .give-donation-level-btn[aria-pressed="true"],
.single-give_forms .give-form .give-donation-level-btn.give-default-level,
.single-give_forms .give-form .give-donation-level-btn.give-btn-level-custom {
    background-color: #fff !important;
    color: #364f75 !important;
    border-color: #fff !important;
}
