/**
 * Google Pay Server-to-Server Styles
 * Styling for Google Pay buttons and messages
 */

/* Main Google Pay container */
.spgw-googlepay-container {
    margin: 20px 0;
    text-align: center;
    clear: both;
}

/* Google Pay button container */
.spgw-googlepay-button {
    display: inline-block;
    min-height: 48px;
    width: 100%;
    max-width: 300px;
    position: relative;
    margin: 10px 0;
}

/* Button loading state */
.spgw-googlepay-button.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Loading indicator */
.spgw-googlepay-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    color: #666;
    font-size: 14px;
}

/* Generic loading overlay used across payment methods */
.spgw-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.9);
    padding: 10px 15px;
    border-radius: 4px;
    font-size: 14px;
    color: #666;
    z-index: 9999;
    border: 1px solid #ddd;
}

.spgw-loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #4285f4;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 8px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Separator between Google Pay and other payment methods */
.spgw-googlepay-separator {
    margin: 20px 0;
    position: relative;
    text-align: center;
}

.spgw-googlepay-separator:before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: #ddd;
    z-index: 1;
}

.spgw-googlepay-separator span {
    background: #fff;
    padding: 0 15px;
    color: #666;
    font-size: 14px;
    position: relative;
    z-index: 2;
}

/* Message styles */
.spgw-googlepay-message {
    padding: 12px 15px;
    margin: 10px 0;
    border-radius: 4px;
    font-size: 14px;
    text-align: center;
}

.spgw-googlepay-message.spgw-loading {
    background: #e3f2fd;
    color: #1976d2;
    border: 1px solid #bbdefb;
}

.spgw-googlepay-message.spgw-success {
    background: #e8f5e8;
    color: #2e7d32;
    border: 1px solid #c8e6c9;
}

.spgw-googlepay-message.spgw-error {
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ffcdd2;
}

/* Responsive styles */
@media (max-width: 768px) {
    .spgw-googlepay-button {
        max-width: 100%;
    }
    
    .spgw-googlepay-container {
        margin: 15px 0;
    }
}

/* Additional info styling */
.spgw-googlepay-info {
    margin-top: 10px;
}

.spgw-googlepay-info small {
    color: #666;
    font-size: 11px;
}

/* Product page specific styles */
.single-product .spgw-googlepay-container {
    margin: 20px 0 30px 0;
}

/* Cart page specific styles */
.woocommerce-cart .spgw-googlepay-container {
    margin: 20px 0;
    padding: 20px;
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* Checkout page specific styles */
.woocommerce-checkout .spgw-googlepay-container {
    margin: 20px 0;
    padding: 15px;
    background: #f8f8f8;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
}

/* Responsive design */
@media (max-width: 768px) {
    .spgw-googlepay-button {
        max-width: 100%;
    }
    
    .spgw-googlepay-container {
        margin: 15px 0;
    }
    
    .spgw-googlepay-header h3 {
        font-size: 14px;
    }
}

/* Dark theme support */
@media (prefers-color-scheme: dark) {
    .spgw-googlepay-header h3 {
        color: #ccc;
    }
    
    .spgw-googlepay-placeholder {
        background: #3a3a3a;
        border-color: #555;
        color: #ccc;
    }
    
    .spgw-googlepay-separator::before {
        background: #555;
    }
    
    .spgw-googlepay-separator span {
        background: #333;
        color: #ccc;
    }
    
    .spgw-googlepay-info small {
        color: #aaa;
    }
    
    .woocommerce-cart .spgw-googlepay-container,
    .woocommerce-checkout .spgw-googlepay-container {
        background: #2a2a2a;
        border-color: #444;
    }

    .spgw-loading {
        background: rgba(51, 51, 51, 0.9);
        color: #ccc;
        border-color: #555;
    }
}

/* Animation for loading state */
@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

.spgw-googlepay-button.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.7);
    animation: pulse 1.5s infinite;
    border-radius: 4px;
}

/* Hide container if Google Pay is not available */
.spgw-googlepay-container.hidden {
    display: none !important;
}

/* Hide Google Pay for non-logged-in users */
body:not(.logged-in) .spgw-googlepay-container,
body:not(.logged-in) .google-pay-button-container,
body:not(.logged-in) [id*="google-pay"],
body:not(.logged-in) [class*="google-pay"],
body.spgw-googlepay-hidden-not-logged-in .spgw-googlepay-container,
body.spgw-googlepay-hidden-not-logged-in .google-pay-button-container {
    display: none !important;
    visibility: hidden !important;
}

/* Error message styles */
.spgw-googlepay-error {
    background: #f8d7da;
    color: #721c24;
    padding: 10px 15px;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    margin: 10px 0;
    font-size: 14px;
}

/* Success message styles */
.spgw-googlepay-success {
    background: #d4edda;
    color: #155724;
    padding: 10px 15px;
    border: 1px solid #c3e6cb;
    border-radius: 4px;
    margin: 10px 0;
    font-size: 14px;
}

/* Processing state styles */
.spgw-googlepay-message.spgw-processing {
    background: #e7f3ff;
    color: #0073aa;
    padding: 10px 15px;
    border: 1px solid #c3e6cb;
    border-radius: 4px;
    margin: 10px 0;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Spinner for processing state */
.spgw-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #0073aa;
    border-radius: 50%;
    animation: spgw-spin 1s linear infinite;
    flex-shrink: 0;
}

@keyframes spgw-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* WooCommerce Blocks specific styles */
.wp-block-woocommerce-cart .spgw-googlepay-container,
.wp-block-woocommerce-checkout .spgw-googlepay-container {
    margin: 20px 0;
    padding: 20px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.wp-block-woocommerce-cart .spgw-googlepay-button,
.wp-block-woocommerce-checkout .spgw-googlepay-button {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
}

/* Express payment methods area in blocks */
.wc-block-components-express-payment-methods .spgw-googlepay-container {
    margin: 0;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
}

.wc-block-components-express-payment-methods .spgw-googlepay-separator {
    display: none; /* Hide separator in express payment area */
}

/* Blocks integration specific */
.spgw-googlepay-container.blocks-integration {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.spgw-googlepay-container.blocks-integration .spgw-googlepay-button {
    width: 100%;
    max-width: 300px;
}

/* Editor preview styles */
.spgw-googlepay-container.editor-preview {
    background: #f8f9fa;
    border: 2px dashed #dee2e6;
    padding: 20px;
    text-align: center;
    border-radius: 8px;
}

.spgw-googlepay-button.editor-button {
    background: #4285f4;
    color: white;
    padding: 12px 24px;
    border-radius: 4px;
    border: none;
    font-size: 14px;
    font-weight: 500;
    cursor: default;
    display: inline-block;
}

/* Mobile responsiveness for blocks */
@media (max-width: 768px) {
    .wp-block-woocommerce-cart .spgw-googlepay-container,
    .wp-block-woocommerce-checkout .spgw-googlepay-container {
        margin: 15px 0;
        padding: 15px;
    }
    
    .spgw-googlepay-container.blocks-integration .spgw-googlepay-button {
        max-width: 280px;
    }
}
