/**
 * RVR Pay Gateway - Payment Form CSS
 */

/* Container for the card form */
.rvr-card-container {
    padding: 15px !important;
    border: 1px solid #e0e0e0 !important;
    margin-bottom: 15px !important;
    border-radius: 4px !important;
    background-color: #fff !important;
    position: relative !important;
    display: block !important;
    min-height: 100px !important;
}

/* Form control container - holds the payment element */
.rvr-form-control {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    min-height: 34px;
    transition: border-color 0.2s ease;
    background-color: white;
    box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
    position: relative !important;
    z-index: 2 !important;
    overflow: visible !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

.rvr-form-control:hover {
    border-color: #b3b3b3;
}

/* Remove any pointer-events restrictions */
.rvr-form-control * {
    pointer-events: auto !important;
}

/* Style for iframes created by payment provider */
.rvr-form-control iframe,
.rvr-card-inner-container iframe,
iframe[src*="basistheory"] {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    z-index: 2 !important;
    height: 40px !important;
    min-height: 40px !important;
    max-height: 40px !important;
    width: 100% !important;
}

/* Enhanced styles for BasisTheory iframe - OPTIMIZED HEIGHT */
#rvr-card-element iframe {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    z-index: 2 !important;
    height: auto !important;
    min-height: 70px !important;
    max-height: none !important;
    width: 100% !important;
    border: none !important;
    background-color: rgba(255,255,255,0.95) !important;
    pointer-events: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
}

/* Make the card element container interactive - OPTIMIZED HEIGHT */
#rvr-card-element {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    min-height: 100px !important;
    height: auto !important;
    cursor: text !important;
    position: relative !important;
    z-index: 2 !important;
    background-color: #fff !important;
    padding: 15px !important;
    border: 1px solid #ced4da !important;
    border-radius: 4px !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05) !important;
    margin: 10px 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow: visible !important;
}

#rvr-card-element:hover {
    border-color: #b3b3b3 !important;
}

/* Force visibility of hidden elements */
#rvr-card-element > div,
#rvr-card-element > span,
#rvr-card-element > iframe {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.rvr-card-inner-container {
    position: relative !important;
    display: block !important;
    width: 100% !important;
    min-height: 34px !important;
    z-index: 2 !important;
    overflow: visible !important;
    padding: 0 !important;
    box-sizing: border-box !important;
}

/* Style focused state for better user feedback */
.rvr-form-control.focused {
    border-color: #6c757d;
    outline: 0;
    box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(108,117,125,.6);
}

/* Style for error state */
.rvr-form-control.has-error {
    border-color: #dc3545;
    box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(220,53,69,.6);
}

/* Error message styles */
#rvr-errors {
    color: #dc3545;
    margin: 10px 0;
    padding: 5px 0;
    display: none; /* Hide error container until needed */
}

#rvr-errors:not(:empty) {
    display: block;
}

#rvr-errors .woocommerce-error {
    margin: 0 0 10px;
    padding: 8px 12px;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    color: #721c24;
    font-size: 14px;
    line-height: 1.5;
}

/* Test mode notice */
.rvr-test-mode-notice {
    margin-top: 10px;
    font-size: 0.85em;
    color: #856404;
    background-color: #fff3cd;
    border: 1px solid #ffeeba;
    padding: 5px 10px;
    border-radius: 3px;
}

/* Error state */
.rvr-error {
    color: #dc3545;
    font-size: 0.85em;
    margin-top: 0.5em;
    display: none; /* Hide until needed */
}

.rvr-error:not(:empty) {
    display: block;
}

.form-row {
    margin-bottom: 1em;
}

/* Basic WooCommerce compatibility */
@media (max-width: 768px) {
    .form-row-first,
    .form-row-last {
        width: 100% !important;
        float: none !important;
    }
}

/* WooCommerce compatibility */
#payment .payment_methods li .payment_box {
    padding: 1em !important;
    background-color: #f8f9fa !important;
}

#payment .payment_methods li img {
    float: right !important;
    max-height: 30px !important;
}

/* Payment Elements styling */
.rvr-form-control > div {
    height: 100% !important;
    width: 100% !important;
    position: relative !important;
    top: 0 !important;
    left: 0 !important;
    z-index: 2 !important;
    box-sizing: border-box !important;
}

/* Loading animation */
.rvr-processing:after {
    content: '' !important;
    display: block !important;
    width: 20px !important;
    height: 20px !important;
    position: absolute !important;
    top: 50% !important;
    right: 10px !important;
    margin-top: -10px !important;
    border-radius: 50% !important;
    border: 2px solid rgba(0, 0, 0, 0.1) !important;
    border-top-color: #6c757d !important; /* Neutral gray color */
    animation: rvr-spinner .6s linear infinite !important;
    z-index: 3 !important;
}

@keyframes rvr-spinner {
    to {
        transform: rotate(360deg);
    }
}

/* Card brand icon styles */
.card-brand-icon {
    height: 24px !important;
    position: absolute !important;
    right: 10px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    z-index: 3 !important;
}

/* Fix for hidden iframes */
#rvr-card-number, #rvr-card-expiry, #rvr-card-cvc {
    position: relative !important;
    overflow: hidden !important;
    z-index: 2 !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

/* Make sure our container is always visible */
#rvr-card-number {
    background-color: #ffffff;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 15px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    min-height: 40px;
    position: relative;
}

/* Success state for the form */
.rvr-diagnostic.success {
    color: #28a745 !important;
    border-color: #28a745 !important;
    background-color: rgba(40, 167, 69, 0.1) !important;
}

/* Ensure the Basis Theory form is visible */
.rvr-card-inner-container iframe {
    background-color: #fff !important;
    border: none !important;
    border-radius: 4px !important;
    padding: 0 !important;
    box-sizing: border-box !important;
}

/* Ensure the form container is properly sized */
.rvr-card-inner-container {
    background-color: #fff !important;
    border: none !important;
    border-radius: 4px !important;
    padding: 0 !important;
    box-sizing: border-box !important;
}

/* Error state for the card element */
#rvr-card-number.has-error {
    border-color: #dc3545;
}

/* Complete/valid state for the card element */
#rvr-card-number.is-complete {
    border-color: #28a745;
}

/* Make sure iframes are visible */
#rvr-card-number iframe {
    width: 100% !important;
    min-height: 24px !important;
}

/* Fallback form styles */
.rvr-fallback-wrapper {
    background-color: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 15px;
}

/* Form control focus state */
.rvr-form-control:focus {
    border-color: #6c757d; /* Neutral gray color */
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(108,117,125,.25);
}

/* Error message styles */
.rvr-pay-error-message {
    color: #dc3545;
    font-size: 0.9em;
    margin-top: 5px;
    padding: 5px;
    border-radius: 3px;
    background-color: rgba(220, 53, 69, 0.1);
    display: none;
}

.rvr-pay-error-message:not(:empty) {
    display: block;
}

/* Ensure the container and all children allow pointer events */
#rvr-card-element, 
#rvr-card-element *, 
.rvr-form-control, 
.rvr-form-control * {
    pointer-events: auto !important;
}

/* Reset any overriding styles */
body .rvr-card-container,
body .rvr-card-container * {
    max-height: none !important;
    transform: none !important;
    clip: auto !important;
    clip-path: none !important;
    filter: none !important;
    mask: none !important;
}

/* Additional fix for hidden iframes */
iframe[src*="basistheory"],
iframe[allowtransparency="true"],
iframe[frameborder="0"] {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    z-index: 2 !important;
    position: relative !important;
}

/* Fix for scrolling when clicking on card element */
#rvr-card-element,
#rvr-card-element * {
    scroll-margin-top: 50px;
    overflow: visible !important;
}

/* Add consistent styling for BasisTheory elements */
.bt-card-element-base {
    padding: 10px;
    width: 100%;
    height: 40px;
    border: none !important;
    background-color: transparent !important;
    color: #333 !important;
}

.bt-card-element-focus {
    border-color: #6c757d !important; /* Consistent neutral color */
    outline: 0;
    box-shadow: none !important;
}

.bt-card-element-invalid {
    border-color: #dc3545 !important;
}

.bt-card-element-complete {
    border-color: #28a745 !important;
} 