/**
 * Whop Payment Gateway Styles
 */

/* Base Styles */
.whop-payment-gateway {
    position: relative;
}

/* Test Mode Notice */
.whop-test-mode-notice {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 4px;
    color: #856404;
    padding: 12px 15px;
    margin-bottom: 20px;
    font-size: 14px;
}

.whop-test-mode-notice strong {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
}

/* Card Input Field */
.whop-card-field {
    margin-bottom: 15px;
}

.whop-card-field label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.whop-card-element {
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    font-size: 16px;
    transition: border-color 0.3s ease;
}

.whop-card-element:focus,
.whop-card-element:focus-within {
    border-color: #0073aa;
    outline: none;
    box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.2);
}

/* Card Errors */
.whop-card-errors {
    color: #dc3232;
    font-size: 14px;
    margin-top: 5px;
    padding: 5px 0;
}

/* Payment Status */
.whop-payment-status {
    padding: 10px 15px;
    border-radius: 4px;
    font-weight: 600;
    display: inline-block;
}

.whop-payment-status.success {
    background: #28a745;
    color: #fff;
}

.whop-payment-status.pending {
    background: #ffc107;
    color: #000;
}

.whop-payment-status.failed {
    background: #dc3545;
    color: #fff;
}

/* Modal Styles */
#whop-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.whop-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
}

.whop-modal-container {
    position: relative;
    width: 90%;
    max-width: 800px;
    height: 90vh;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    z-index: 999999;
}

.whop-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #ddd;
}

.whop-modal-header h3 {
    margin: 0;
    font-size: 18px;
    color: #333;
}

.whop-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #666;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.whop-modal-close:hover {
    background: #e9ecef;
    color: #000;
}

.whop-modal-content {
    flex: 1;
    overflow: hidden;
}

.whop-modal-content iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Iframe Container */
#whop-payment-container {
    margin: 20px 0;
    min-height: 600px;
}

#whop-payment-frame {
    width: 100%;
    min-height: 600px;
    border: 1px solid #ddd;
    border-radius: 8px;
}

/* Loading Styles */
.whop-loading {
    text-align: center;
    color: #333;
}

.whop-loading .spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #0073aa;
    border-radius: 50%;
    animation: whop-spin 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes whop-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.whop-loading p {
    margin: 0;
    font-size: 16px;
}

/* Processing State */
body.whop-processing #place_order,
body.whop-processing button[name="woocommerce_checkout_place_order"] {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

body.whop-processing #place_order::after,
body.whop-processing button[name="woocommerce_checkout_place_order"]::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid transparent;
    border-top-color: #fff;
    border-radius: 50%;
    animation: whop-spin 0.8s linear infinite;
}

/* Payment Method Icon */
.payment_method_whop_payment_gateway .whop-payment-icon {
    display: inline-block;
    width: 40px;
    height: 24px;
    margin-right: 10px;
    vertical-align: middle;
    background: url('../images/whop-icon.png') no-repeat center center;
    background-size: contain;
}

/* Form Validation */
.whop-payment-gateway .form-row.woocommerce-validated {
    position: relative;
}

.whop-payment-gateway .form-row.woocommerce-invalid-required-field input,
.whop-payment-gateway .form-row.woocommerce-invalid input {
    border-color: #dc3232;
}

/* Checkout Page Styles */
.woocommerce-checkout .payment_method_whop_payment_gateway {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 15px;
}

.woocommerce-checkout .payment_method_whop_payment_gateway label {
    cursor: pointer;
    font-weight: 600;
}

/* Mobile Responsiveness */
@media screen and (max-width: 768px) {
    .whop-modal-container {
        width: 95%;
        height: 95vh;
    }

    .whop-modal-header {
        padding: 12px 15px;
    }

    .whop-modal-header h3 {
        font-size: 16px;
    }

    .whop-modal-close {
        font-size: 20px;
        width: 25px;
        height: 25px;
    }

    #whop-payment-frame {
        min-height: 400px;
    }
}

@media screen and (max-width: 480px) {
    .whop-modal-container {
        width: 100%;
        height: 100vh;
        border-radius: 0;
    }

    .whop-modal-header {
        padding: 10px;
    }

    .whop-modal-header h3 {
        font-size: 14px;
    }

    .whop-card-element {
        padding: 10px;
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .whop-card-element {
        border-width: 2px;
    }

    .whop-modal-container {
        border: 2px solid #000;
    }

    .whop-modal-header {
        border-bottom-width: 2px;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .whop-modal-container {
        background: #1e1e1e;
        color: #fff;
    }

    .whop-modal-header {
        background: #2d2d2d;
        border-bottom-color: #444;
    }

    .whop-modal-header h3 {
        color: #fff;
    }

    .whop-modal-close {
        color: #ccc;
    }

    .whop-modal-close:hover {
        background: #3d3d3d;
        color: #fff;
    }
}

/* Print Styles */
@media print {
    #whop-modal,
    .whop-loading {
        display: none !important;
    }

    body.whop-processing #place_order,
    body.whop-processing button[name="woocommerce_checkout_place_order"] {
        opacity: 1;
        pointer-events: auto;
    }
}

/* Accessibility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus Styles */
.whop-payment-gateway *:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

.whop-payment-gateway *:focus:not(:focus-visible) {
    outline: none;
}

.whop-payment-gateway *:focus-visible {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Animation Transitions */
.whop-payment-gateway * {
    transition: color 0.3s ease, background-color 0.3s ease, border-color 0.3s ease;
}