/**
 * 修狗支付 - Stripe风格自制表单样式
 * 模仿Stripe官方设计，但使用自制表单字段
 */

/* 主容器 */
#xiugou-pay-form-container {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
}

/* 支付表单 */
.xiugou-pay-payment-form {
    background: #fff;
    border-radius: 8px;
    position: relative;
}

/* 表单行 */
.xiugou-pay-form-row {
    margin-bottom: 20px;
}

.xiugou-pay-form-row:last-child {
    margin-bottom: 0;
}

/* 分割行 */
.xiugou-pay-form-row-split {
    display: flex;
    gap: 12px;
}

.xiugou-pay-form-column {
    flex: 1;
}

/* 标签样式 - 完全模仿Stripe */
.xiugou-pay-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #30313d;
    margin-bottom: 6px;
    line-height: 1.2;
    letter-spacing: 0.025em;
}

/* 输入容器 */
.xiugou-pay-input-container {
    position: relative;
    display: flex;
    align-items: center;
}

/* 输入框样式 - 完全模仿Stripe Elements */
.xiugou-pay-input {
    width: 100%;
    background: #fff;
    border: 1px solid #e1e5e9;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 16px;
    line-height: 1.2;
    color: #30313d;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    box-sizing: border-box;
    min-height: 44px;
    font-family: inherit;
    letter-spacing: 0.025em;
    appearance: none;
    outline: none;
}

.xiugou-pay-input::placeholder {
    color: #8b959e;
}

/* 悬停效果 */
.xiugou-pay-input:hover {
    border-color: #c7c9d1;
}

/* 焦点效果 - 模仿Stripe的蓝色焦点 */
.xiugou-pay-input:focus {
    outline: 0;
    border-color: #0570de;
    box-shadow: 0px 1px 1px rgba(0, 0, 0, 0.03), 0px 3px 6px rgba(0, 0, 0, 0.02), 0 0 0 3px hsla(210, 96%, 45%, 25%), 0 1px 1px 0 rgba(0, 0, 0, 0.08);
}

/* 有效状态 */
.xiugou-pay-input.valid {
    border-color: #10b981;
}

/* 错误状态 */
.xiugou-pay-input.invalid {
    border-color: #df1b41;
    box-shadow: 0 0 0 1px #df1b41;
}

/* 信用卡号特殊样式 */
.xiugou-pay-card-number {
    font-family: 'SFMono-Regular', Monaco, 'Inconsolata', 'Fira Code', 'Droid Sans Mono', 'Courier New', monospace;
    padding-right: 50px; /* 为卡片品牌图标留空间 */
}

/* 卡片品牌显示容器 */
.xiugou-pay-card-brands {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 4px;
    height: 20px;
    width: 144px; /* 默认多图标宽度: 4个图标 * 32px + 3个间隙 * 4px */
    overflow: hidden;
    transition: width 0.3s ease;
}

/* 单个卡片品牌图标 */
.xiugou-pay-card-brand {
    width: 32px;
    height: 21px;
    border-radius: 2px;
    background: transparent;
    border: none;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    opacity: 1;
    transform: translateX(0);
    transition: all 0.3s ease;
    flex-shrink: 0;
}

/* 激活状态的图标 */
.xiugou-pay-card-brand.active {
    opacity: 1;
}

/* 检测到品牌时的单图标显示 - 收缩动画 */
.xiugou-pay-card-brands.single-brand {
    width: 32px; /* 收缩为单图标宽度 */
}

.xiugou-pay-card-brands.single-brand .xiugou-pay-card-brand {
    opacity: 0;
    transform: translateX(32px); /* 向左收缩消失 */
}

.xiugou-pay-card-brands.single-brand .xiugou-pay-card-brand.active {
    opacity: 1;
    transform: translateX(0); /* 检测到的图标保持在原位 */
}

/* 卡片品牌SVG图标 - 通过JavaScript动态设置background-image */
.xiugou-pay-card-brand.visa {
    /* background-image 由 JavaScript 动态设置 */
}

.xiugou-pay-card-brand.mastercard {
    /* background-image 由 JavaScript 动态设置 */
}

.xiugou-pay-card-brand.amex {
    /* background-image 由 JavaScript 动态设置 */
}

.xiugou-pay-card-brand.discover {
    /* background-image 由 JavaScript 动态设置 */
}

.xiugou-pay-card-brand.jcb {
    /* background-image 由 JavaScript 动态设置 */
}

.xiugou-pay-card-brand.diners {
    /* background-image 由 JavaScript 动态设置 */
}

/* CVV图标样式 */
.xiugou-pay-cvv-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    height: 20px;
    pointer-events: none;
}

.xiugou-pay-cvv-icon-img {
    width: 20px;
    height: 20px;
    object-fit: contain;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

/* CVV输入框需要右边距来避免与图标重叠 */
.xiugou-pay-card-cvc {
    padding-right: 40px !important;
}

/* 支付方式标题图标样式 */
.xiugou-pay-method-icons {
    margin-left: 10px;
    display: inline-flex;
    gap: 4px;
    align-items: center;
}

.xiugou-pay-method-icons img,
.xiugou-pay-method-icon {
    width: 32px;
    height: 22px;
    object-fit: contain;
    border-radius: 2px;
    vertical-align: middle;
}

/* 移动端优化支付方式图标 */
@media (max-width: 480px) {
    .xiugou-pay-method-icons {
        margin-left: 6px;
        gap: 2px;
    }
    
    .xiugou-pay-method-icons img,
    .xiugou-pay-method-icon {
        width: 28px;
        height: 18px;
    }
    
    /* 移动端CVV图标优化 */
    .xiugou-pay-cvv-icon {
        right: 8px;
    }
    
    .xiugou-pay-cvv-icon-img {
        width: 18px;
        height: 18px;
    }
    
    .xiugou-pay-card-cvc {
        padding-right: 35px !important;
    }
}

/* 移动端优化 - 只显示一个轮换图标 */
@media (max-width: 768px) {
    .xiugou-pay-card-brands {
        width: 32px !important; /* 强制单图标宽度 */
        gap: 0;
    }
    
    .xiugou-pay-card-brands.mobile-mode .xiugou-pay-card-brand {
        display: none; /* 隐藏所有图标 */
    }
    
    .xiugou-pay-card-brands.mobile-mode .xiugou-pay-card-brand.mobile-rotating {
        display: block; /* 只显示移动端轮换图标 */
        opacity: 1;
        transform: translateX(0);
    }
    
    /* 移动端下即使检测到卡片也保持单图标模式 */
    .xiugou-pay-card-brands.mobile-mode.single-brand {
        width: 32px !important;
    }
    
    .xiugou-pay-card-brands.mobile-mode.single-brand .xiugou-pay-card-brand {
        display: none;
    }
    
    .xiugou-pay-card-brands.mobile-mode.single-brand .xiugou-pay-card-brand.mobile-rotating {
        display: block;
        opacity: 1;
        transform: translateX(0);
    }
}

/* 错误消息样式 - 模仿Stripe */
.xiugou-pay-error-message {
    color: #df1b41;
    font-size: 12px;
    margin-top: 4px;
    line-height: 1.4;
    display: none;
    letter-spacing: 0.025em;
}

.xiugou-pay-error-message.visible {
    display: block;
}

/* 测试模式横幅 */
.xiugou-pay-test-mode-banner {
    margin-top: 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 6px;
    padding: 12px 16px;
    color: white;
    font-size: 13px;
    line-height: 1.4;
}

.xiugou-pay-test-mode-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.xiugou-pay-test-mode-content strong {
    font-weight: 600;
}

/* 加载状态 */
.xiugou-pay-processing {
    position: relative;
    pointer-events: none;
}

.xiugou-pay-processing::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 6px;
    z-index: 1;
}

.xiugou-pay-processing::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #0570de;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: xiugou-spin 1s linear infinite;
    z-index: 2;
}

@keyframes xiugou-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 动画效果 */
.xiugou-pay-input,
.xiugou-pay-card-brand,
.xiugou-pay-error-message {
    transition: all 0.15s ease;
}

/* 聚焦动画 */
.xiugou-pay-input:focus {
    animation: xiugou-focus-in 0.15s ease;
}

@keyframes xiugou-focus-in {
    0% {
        border-color: #e1e5e9;
        box-shadow: none;
    }
    100% {
        border-color: #0570de;
        box-shadow: 0px 1px 1px rgba(0, 0, 0, 0.03), 0px 3px 6px rgba(0, 0, 0, 0.02), 0 0 0 3px hsla(210, 96%, 45%, 25%), 0 1px 1px 0 rgba(0, 0, 0, 0.08);
    }
}

/* 响应式设计 */
@media (max-width: 480px) {
    #xiugou-pay-form-container {
        max-width: 100%;
    }
    
    .xiugou-pay-form-row-split {
        flex-direction: column;
        gap: 16px;
    }
    
    .xiugou-pay-input {
        font-size: 16px; /* 防止iOS缩放 */
    }
}

/* 暗色主题适配 */
@media (prefers-color-scheme: dark) {
    .xiugou-pay-payment-form {
        background: #1e1e1e;
    }
    
    .xiugou-pay-label {
        color: #e0e0e0;
    }
    
    .xiugou-pay-input {
        background: #2d2d2d;
        border-color: #404040;
        color: #e0e0e0;
    }
    
    .xiugou-pay-input::placeholder {
        color: #999;
    }
    
    .xiugou-pay-security-notice {
        background: #2d2d2d;
        border-color: #404040;
        color: #ccc;
    }
    
    .xiugou-pay-card-brand {
        background: #404040;
        border-color: #555;
        color: #ccc;
    }
}

/* 高对比度模式 */
@media (prefers-contrast: high) {
    .xiugou-pay-input {
        border-width: 2px;
    }
    
    .xiugou-pay-input:focus {
        outline: 0;
        border-color: #0570de;
        box-shadow: 0px 1px 1px rgba(0, 0, 0, 0.03), 0px 3px 6px rgba(0, 0, 0, 0.02), 0 0 0 3px hsla(210, 96%, 45%, 40%), 0 1px 1px 0 rgba(0, 0, 0, 0.08);
    }
}

/* 减少动画模式 */
@media (prefers-reduced-motion: reduce) {
    .xiugou-pay-input,
    .xiugou-pay-card-brand,
    .xiugou-pay-error-message {
        transition: none;
    }
    
    .xiugou-pay-processing::after {
        animation: none;
    }
}

/* 打印样式 */
@media print {
    .xiugou-pay-test-mode-banner,
    .xiugou-pay-security-info {
        display: none;
    }
    
    .xiugou-pay-input {
        border: 1px solid #000;
        background: white;
    }
} 