/* 基本樣式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    line-height: 1.6;
}

.container {
    max-width: 500px;
    margin: 0 auto;
}

/* 標題區塊 */
header {
    text-align: center;
    margin-bottom: 30px;
    color: white;
}

header h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

header .subtitle {
    font-size: 16px;
    opacity: 0.9;
}

/* 區塊共用樣式 */
section {
    background: white;
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

section h2 {
    font-size: 18px;
    color: #333;
    margin-bottom: 16px;
    font-weight: 600;
}

section h3 {
    font-size: 16px;
    color: #333;
    margin-bottom: 12px;
    font-weight: 600;
}

/* 訂單資訊 */
.order-details {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 16px;
}

.order-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    color: #666;
}

.order-total {
    display: flex;
    justify-content: space-between;
    padding-top: 12px;
    margin-top: 12px;
    border-top: 1px dashed #ddd;
    font-weight: 600;
    color: #333;
}

.total-price {
    color: #667eea;
    font-size: 20px;
}

/* 付款方式選擇 */
.method-tabs {
    display: flex;
    gap: 12px;
}

.tab-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 20px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    background: white;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    color: #666;
    transition: all 0.3s ease;
}

.tab-btn:hover {
    border-color: #667eea;
    color: #667eea;
}

.tab-btn.active {
    border-color: #667eea;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.tab-btn .icon {
    width: 20px;
    height: 20px;
}

/* 付款區塊 */
.payment-section {
    display: none;
}

.payment-section.active {
    display: block;
}

/* 信用卡表單 */
.card-form {
    margin-bottom: 20px;
}

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

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    margin-bottom: 8px;
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-row .form-group {
    flex: 1;
}

/* TapPay 欄位容器 */
.tpfield {
    height: 44px;
    padding: 0 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: white;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.tpfield:hover {
    border-color: #667eea;
}

.tpfield.tpfield-focused {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.tpfield.tpfield-error {
    border-color: #e74c3c;
}

/* 信用卡圖示 */
.card-icons {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 8px;
}

.card-icon {
    width: 42px;
    height: 28px;
    opacity: 0.5;
    transition: opacity 0.3s ease;
}

.card-icon.active {
    opacity: 1;
}

/* 提交按鈕 */
.submit-btn {
    width: 100%;
    padding: 16px 24px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.submit-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.submit-btn.loading {
    pointer-events: none;
}

.submit-btn .btn-text {
    display: inline;
}

.submit-btn .btn-loading {
    display: none;
}

.submit-btn.loading .btn-text {
    display: none;
}

.submit-btn.loading .btn-loading {
    display: inline;
}

/* Apple Pay 區塊 */
.apple-pay-container {
    text-align: center;
}

#apple-pay-button-container {
    min-height: 50px;
}

/* Apple Pay 按鈕樣式 */
.apple-pay-button {
    width: 100%;
    height: 50px;
    border-radius: 12px;
    -webkit-appearance: -apple-pay-button;
    -apple-pay-button-type: buy;
    -apple-pay-button-style: black;
    cursor: pointer;
}

.not-available {
    color: #999;
    font-size: 14px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 12px;
}

/* 付款結果 */
.result-section {
    text-align: center;
}

.result-content {
    padding: 20px 0;
}

.result-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
}

.result-icon.success {
    background: #d4edda;
    color: #28a745;
}

.result-icon.error {
    background: #f8d7da;
    color: #dc3545;
}

.result-icon::before {
    content: '';
}

.result-icon.success::before {
    content: '✓';
}

.result-icon.error::before {
    content: '✗';
}

#result-title {
    font-size: 24px;
    margin-bottom: 12px;
    color: #333;
}

#result-message {
    color: #666;
    margin-bottom: 20px;
}

.result-details {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 16px;
    text-align: left;
    margin-bottom: 20px;
    font-size: 14px;
}

.result-details p {
    padding: 6px 0;
    border-bottom: 1px solid #eee;
}

.result-details p:last-child {
    border-bottom: none;
}

.result-details strong {
    color: #333;
}

.retry-btn {
    padding: 12px 32px;
    border: 2px solid #667eea;
    border-radius: 8px;
    background: white;
    color: #667eea;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.retry-btn:hover {
    background: #667eea;
    color: white;
}

/* 測試卡號區塊 */
.info-section {
    background: rgba(255, 255, 255, 0.95);
}

.test-cards {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.test-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: #f8f9fa;
    border-radius: 8px;
}

.card-type {
    font-weight: 500;
    color: #333;
    font-size: 14px;
}

.test-card code {
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 14px;
    color: #667eea;
    background: white;
    padding: 4px 8px;
    border-radius: 4px;
}

.note {
    font-size: 13px;
    color: #888;
    text-align: center;
}

/* RWD 響應式設計 */
@media (max-width: 480px) {
    body {
        padding: 12px;
    }

    header h1 {
        font-size: 24px;
    }

    section {
        padding: 20px;
        border-radius: 12px;
    }

    .method-tabs {
        flex-direction: column;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .test-card {
        flex-direction: column;
        gap: 6px;
        text-align: center;
    }
}

/* 動畫效果 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

section {
    animation: fadeIn 0.5s ease-out;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.submit-btn.loading .btn-loading {
    animation: pulse 1.5s ease-in-out infinite;
}
