/**
 * RVR Pay Gateway - Payment Form CSS
 * Version 3.17.52 - Consolidated Styling (Single Source of Truth)
 * 
 * ARCHITECTURE:
 * - SDK styles (inside iframe): Defined in payment-form.js cardElementOptions
 * - Container styles: Defined HERE in CSS (no JS overrides)
 * - This prevents collisions between JS and CSS
 */

/* ==========================================================================
   PAYMENT BOX - WooCommerce Integration
   ========================================================================== */

.payment_box.payment_method_rvr_payment {
    position: relative;
    clear: both;
    min-height: 120px;
}

/* ==========================================================================
   CARD CONTAINER - Main wrapper for payment form
   ========================================================================== */

.rvr-card-container {
    padding: 0;
    border: none;
    margin-bottom: 16px;
    background-color: transparent;
    position: relative;
    display: block;
    min-height: 60px;
    clear: both;
}

.rvr-card-container label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    line-height: 1.5;
}

.rvr-card-container label .required {
    color: #dc2626;
    text-decoration: none;
}

/* ==========================================================================
   CARD ELEMENT - The BasisTheory iframe container
   SINGLE SOURCE OF TRUTH for container sizing
   ========================================================================== */

#rvr-card-element {
    display: block;
    visibility: visible;
    opacity: 1;
    min-height: 56px;
    height: auto;
    cursor: text;
    position: relative;
    z-index: 2;
    background-color: #fff;
    padding: 12px 16px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    margin: 8px 0 16px 0;
    width: 100%;
    max-width: 100%;
    overflow: visible;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    box-sizing: border-box;
}

#rvr-card-element:hover {
    border-color: #9ca3af;
}

#rvr-card-element:focus-within {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    outline: none;
}

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

/* ==========================================================================
   IFRAME STYLES - BasisTheory card element iframe
   Targets tokenization iframes only, NOT 3DS modals
   ========================================================================== */

#rvr-card-element iframe {
    display: block;
    visibility: visible;
    opacity: 1;
    position: relative;
    z-index: 2;
    height: auto;
    min-height: 32px;
    width: 100%;
    border: none;
    background-color: transparent;
    pointer-events: auto;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Generic iframe selector for fallback (tokenization only, NOT 3DS) */
.rvr-form-control iframe:not([src*="3ds"]),
.rvr-card-inner-container iframe:not([src*="3ds"]) {
    display: block;
    visibility: visible;
    opacity: 1;
    position: relative;
    z-index: 2;
    min-height: 32px;
    width: 100%;
}

/* ==========================================================================
   FORM CONTROL - Legacy support for older markup
   ========================================================================== */

.rvr-form-control {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    min-height: 40px;
    transition: border-color 0.15s ease;
    background-color: white;
    position: relative;
    z-index: 2;
    overflow: visible;
    width: 100%;
    box-sizing: border-box;
}

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

.rvr-form-control:focus-within {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    outline: none;
}

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

/* ==========================================================================
   ERROR STATES
   ========================================================================== */

#rvr-errors {
    color: #dc2626;
    margin: 10px 0;
    padding: 0;
    display: none;
}

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

#rvr-errors .woocommerce-error {
    margin: 0 0 10px;
    padding: 12px 16px;
    background-color: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    color: #dc2626;
    font-size: 14px;
    line-height: 1.5;
}

.rvr-form-control.has-error,
#rvr-card-element.has-error {
    border-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

.rvr-error,
.rvr-pay-error-message {
    color: #dc2626;
    font-size: 13px;
    margin-top: 6px;
    display: none;
}

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

/* ==========================================================================
   SUCCESS/COMPLETE STATES
   ========================================================================== */

.rvr-form-control.is-complete,
#rvr-card-element.is-complete,
#rvr-card-number.is-complete {
    border-color: #059669;
}

.rvr-diagnostic.success {
    color: #059669;
    border-color: #059669;
    background-color: rgba(5, 150, 105, 0.1);
}

/* ==========================================================================
   TEST MODE NOTICE
   ========================================================================== */

.rvr-test-mode-notice {
    margin-top: 12px;
    font-size: 13px;
    color: #92400e;
    background-color: #fffbeb;
    border: 1px solid #fde68a;
    padding: 8px 12px;
    border-radius: 6px;
}

/* ==========================================================================
   LOADING STATE
   ========================================================================== */

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

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

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

.card-brand-icon {
    height: 24px;
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 3;
}

/* ==========================================================================
   FALLBACK FORM
   ========================================================================== */

.rvr-fallback-wrapper {
    background-color: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 16px;
}

/* ==========================================================================
   POINTER EVENTS - Ensure interactivity
   ========================================================================== */

#rvr-card-element,
#rvr-card-element *,
.rvr-form-control,
.rvr-form-control * {
    pointer-events: auto;
}

/* ==========================================================================
   WOOCOMMERCE COMPATIBILITY
   ========================================================================== */

#payment .payment_methods li .payment_box {
    padding: 16px;
    background-color: #f9fafb;
}

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

.form-row {
    margin-bottom: 16px;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media (max-width: 768px) {
    .form-row-first,
    .form-row-last {
        width: 100%;
        float: none;
    }
    
    #rvr-card-element {
        padding: 10px 12px;
    }
}

/* ==========================================================================
   SCROLL BEHAVIOR
   ========================================================================== */

#rvr-card-element,
#rvr-card-element * {
    scroll-margin-top: 50px;
}

/* ==========================================================================
   BLOCKS CHECKOUT SUPPORT
   ========================================================================== */

#rvr-card-blocks {
    display: block;
    visibility: visible;
    opacity: 1;
    min-height: 56px;
    height: auto;
    cursor: text;
    position: relative;
    z-index: 2;
    background-color: #fff;
    padding: 12px 16px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    margin: 8px 0 16px 0;
    width: 100%;
    max-width: 100%;
    overflow: visible;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    box-sizing: border-box;
}

#rvr-card-blocks:hover {
    border-color: #9ca3af;
}

#rvr-card-blocks:focus-within {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    outline: none;
}

#rvr-card-blocks iframe {
    display: block;
    visibility: visible;
    opacity: 1;
    position: relative;
    z-index: 2;
    height: auto;
    min-height: 32px;
    width: 100%;
    border: none;
    background-color: transparent;
    pointer-events: auto;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ==========================================================================
   RESET OVERRIDES - Prevent theme interference
   Only use !important as last resort for theme conflicts
   ========================================================================== */

body .rvr-card-container,
body .rvr-card-container * {
    max-height: none;
    transform: none;
    clip: auto;
    clip-path: none;
    filter: none;
}
