/**
 * MCP Payment Gateway - Form Styles
 * 信用卡表单样式，支持卡品牌图标和验证状态
 * Version: 3.3.1
 */

/* CSS Variables */
:root {
    --mcp-primary-color: #4f46e5;
    --mcp-text-primary: #1f2937;
    --mcp-text-secondary: #6b7280;
    --mcp-border-color: #e5e7eb;
    --mcp-bg-primary: #ffffff;
    --mcp-bg-secondary: #f9fafb;
    --mcp-success-color: #10b981;
    --mcp-error-color: #ef4444;
    --mcp-warning-color: #f59e0b;
    --mcp-radius-md: 10px;
    --mcp-radius-lg: 14px;
    --mcp-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --mcp-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --mcp-transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --mcp-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Description */
.mcp-description {
    margin: 0 0 20px 0;
    color: var(--mcp-text-secondary);
    font-size: 14px;
    line-height: 1.5;
}

/* Card Form Container */
.mcp-card-form {
    padding: 24px;
    border: 1px solid var(--mcp-border-color);
    background: var(--mcp-bg-primary);
    border-radius: var(--mcp-radius-lg);
    box-shadow: var(--mcp-shadow-sm);
    margin: 0;
    font-family: var(--mcp-font-family);
}

/* ===== Card Brands Section - 已优化 ===== */
.mcp-card-brands {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding: 12px 16px;
    background: var(--mcp-bg-secondary);
    border-radius: var(--mcp-radius-md);
    border: 1px solid var(--mcp-border-color);
}

.mcp-card-brands-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--mcp-text-secondary);
    margin-right: 8px;
    white-space: nowrap;
}

/* 图标容器 - 统一排列 */
.mcp-card-brands-icons {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* 单个图标样式 - 默认彩色显示 */
.mcp-card-brand-icon {
    width: 48px;
    height: 32px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    border-radius: 6px;
    background-color: #fff;
    border: 1px solid #e5e7eb;
    padding: 4px;
    box-sizing: border-box;
    transition: all var(--mcp-transition);
    /* 默认彩色显示，不再灰度 */
    opacity: 0.85;
    filter: none;
}

/* 鼠标悬停效果 */
.mcp-card-brand-icon:hover {
    opacity: 1;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* 激活状态 - 当前输入的卡类型 */
.mcp-card-brand-icon.active {
    opacity: 1;
    transform: scale(1.1);
    border-color: var(--mcp-primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

/* 非激活状态（当有其他卡被选中时）*/
.mcp-card-brands.has-active .mcp-card-brand-icon:not(.active) {
    opacity: 0.4;
    filter: grayscale(80%);
}

/* Card Brand Icons - 图片路径 */
.mcp-card-brand-visa {
    background-image: url("../images/visa.svg");
}

.mcp-card-brand-mastercard {
    background-image: url("../images/mastercard.svg");
}

.mcp-card-brand-amex {
    background-image: url("../images/ae.svg");
}

.mcp-card-brand-discover {
    background-image: url("../images/ds.svg");
}

.mcp-card-brand-jcb {
    background-image: url("../images/jcb.svg");
}

.mcp-card-brand-unionpay {
    background-image: url("../images/unionpay.svg");
}



/* ===== Form Rows ===== */
.mcp-form-row {
    margin-bottom: 18px;
    position: relative;
}

.mcp-form-row:last-child {
    margin-bottom: 0;
}

.mcp-form-row-wide {
    width: 100%;
}

.mcp-form-row-half-container {
    display: flex;
    gap: 16px;
    margin-bottom: 18px;
}

.mcp-form-row-half {
    flex: 1;
    margin-bottom: 0;
}

/* Labels */
.mcp-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 13px;
    color: var(--mcp-text-primary);
    letter-spacing: 0.01em;
}

/* ===== Input with Icon ===== */
.mcp-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.mcp-input-icon {
    position: absolute;
    right: 14px;
    width: 36px;
    height: 24px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    pointer-events: none;
    transition: opacity var(--mcp-transition);
    z-index: 2;
}

.mcp-input-wrapper .mcp-input {
    padding-right: 58px;
}

/* ===== Inputs ===== */
.mcp-input {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--mcp-border-color);
    border-radius: var(--mcp-radius-md);
    font-size: 15px;
    font-family: var(--mcp-font-family);
    box-sizing: border-box;
    transition: border-color var(--mcp-transition), box-shadow var(--mcp-transition);
    background: var(--mcp-bg-primary);
    color: var(--mcp-text-primary);
    -webkit-appearance: none;
    appearance: none;
}

.mcp-input::placeholder {
    color: #9ca3af;
}

.mcp-input:focus {
    border-color: var(--mcp-primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
    outline: none;
}

.mcp-input:hover:not(:focus) {
    border-color: #d1d5db;
}

/* Uppercase Input */
.mcp-uppercase {
    text-transform: uppercase;
}

.mcp-uppercase::placeholder {
    text-transform: none;
}

/* Card Number Input - monospace */
.mcp-card-form input[name="mcp_card_number"],
.mcp-card-form input[name="mcp_card_expiry"],
.mcp-card-form input[name="mcp_card_cvc"] {
    font-family: "SF Mono", "Monaco", "Inconsolata", "Roboto Mono", monospace;
    letter-spacing: 0.05em;
}

/* ===== Validation States ===== */
.mcp-input.mcp-valid {
    border-color: var(--mcp-success-color);
}

.mcp-input.mcp-valid:focus {
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.12);
}

.mcp-input.mcp-invalid {
    border-color: var(--mcp-error-color);
}

.mcp-input.mcp-invalid:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}

/* Validation Icon */
.mcp-validation-icon {
    position: absolute;
    right: 14px;
    width: 20px;
    height: 20px;
    opacity: 0;
    transition: opacity var(--mcp-transition);
}

.mcp-input-wrapper .mcp-validation-icon {
    right: 58px;
}

.mcp-validation-icon.show {
    opacity: 1;
}

.mcp-validation-icon.valid {
    color: var(--mcp-success-color);
}

.mcp-validation-icon.invalid {
    color: var(--mcp-error-color);
}

/* Error Message */
.mcp-error-message {
    display: none;
    font-size: 12px;
    color: var(--mcp-error-color);
    margin-top: 6px;
    padding-left: 2px;
}

.mcp-error-message.show {
    display: block;
}

/* ===== Security Badge ===== */
.mcp-security-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--mcp-border-color);
    color: var(--mcp-text-secondary);
    font-size: 12px;
}

.mcp-security-badge svg {
    width: 16px;
    height: 16px;
    color: var(--mcp-success-color);
}

/* ===== WooCommerce Override ===== */
.woocommerce-checkout .mcp-card-form .mcp-input,
.woocommerce-checkout .mcp-card-form input[type="text"] {
    height: auto;
    padding: 12px 14px;
    font-size: 15px;
    line-height: 1.5;
}

.woocommerce-checkout .mcp-card-form .mcp-label {
    font-size: 13px;
    font-weight: 600;
}

/* Block Checkout Overrides */
.wc-block-checkout .mcp-card-form {
    margin-top: 0;
}

.wc-block-checkout .mcp-card-form .mcp-input {
    border-radius: var(--mcp-radius-md);
}

/* Clear floats (legacy themes) */
.mcp-card-form::after {
    content: "";
    display: table;
    clear: both;
}

/* ===== Responsive Design ===== */
@media (max-width: 600px) {
    .mcp-card-form {
        padding: 16px;
        border-radius: 12px;
    }
    
    /* 银行卡图标区域 - 手机端优化 */
    .mcp-card-brands {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 12px;
    }
    
    .mcp-card-brands-label {
        margin-right: 0;
        margin-bottom: 4px;
    }
    
    .mcp-card-brands-icons {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
        width: 100%;
    }
    
    .mcp-card-brand-icon {
        width: 100%;
        height: 32px;
        margin: 0;
    }
    
    /* 表单行 - 手机端堆叠 */
    .mcp-form-row-half-container {
        flex-direction: column;
        gap: 0;
    }
    
    .mcp-form-row-half {
        margin-bottom: 16px;
    }
    
    .mcp-form-row-half:last-child {
        margin-bottom: 0;
    }
    
    .mcp-form-row {
        margin-bottom: 16px;
    }
    
    /* 输入框 - 防止iOS缩放 */
    .mcp-input {
        padding: 12px 14px;
        font-size: 16px;
        border-radius: 8px;
    }
    
    .mcp-label {
        font-size: 13px;
        margin-bottom: 6px;
    }
    
    .mcp-description {
        font-size: 13px;
        margin-bottom: 16px;
    }
    
    /* 安全徽章 */
    .mcp-security-badge {
        margin-top: 16px;
        padding-top: 14px;
        font-size: 11px;
    }
}

/* 更小屏幕的优化 */
@media (max-width: 380px) {
    .mcp-card-form {
        padding: 14px;
    }
    
    .mcp-card-brands-icons {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }
    
    .mcp-card-brand-icon {
        height: 28px;
        padding: 3px;
        border-radius: 4px;
    }
    
    .mcp-input {
        padding: 10px 12px;
    }
    
    .mcp-input-wrapper .mcp-input {
        padding-right: 50px;
    }
    
    .mcp-input-icon {
        right: 10px;
        width: 32px;
        height: 20px;
    }
}

/* ===== Print Styles ===== */
@media print {
    .mcp-card-form {
        display: none;
    }
}

/* ===== High Contrast Mode ===== */
@media (prefers-contrast: high) {
    .mcp-card-form {
        border-width: 2px;
    }
    
    .mcp-input {
        border-width: 2px;
    }
    
    .mcp-input:focus {
        box-shadow: none;
        outline: 3px solid var(--mcp-primary-color);
        outline-offset: 1px;
    }
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
    .mcp-input,
    .mcp-card-brand-icon,
    .mcp-validation-icon {
        transition: none;
    }
}

/* ===== RTL Support ===== */
[dir="rtl"] .mcp-card-form {
    text-align: right;
}

[dir="rtl"] .mcp-form-row-half-container {
    flex-direction: row-reverse;
}

[dir="rtl"] .mcp-input-icon {
    right: auto;
    left: 14px;
}

[dir="rtl"] .mcp-input-wrapper .mcp-input {
    padding-right: 14px;
    padding-left: 58px;
}

[dir="rtl"] .mcp-validation-icon {
    right: auto;
    left: 14px;
}

[dir="rtl"] .mcp-input-wrapper .mcp-validation-icon {
    left: 58px;
}