/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --primary-color: #d4263c;
    --secondary-color: #ffd700;
    --success-color: #52c41a;
    --warning-color: #faad14;
    --error-color: #f5222d;
    --text-primary: #333;
    --text-secondary: #666;
    --text-hint: #999;
    --bg-primary: #f5f5f5;
    --bg-card: #fff;
    --border-color: #e8e8e8;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --radius: 8px;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--text-primary);
    background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
    min-height: 100vh;
    overflow-x: hidden;
}

/* 加载动画 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 导航栏 */
.navbar {
    position: sticky;
    top: 0;
    background: var(--primary-color);
    color: white;
    padding: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.navbar-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    max-width: 600px;
    margin: 0 auto;
}

.navbar h1 {
    font-size: 18px;
    font-weight: 500;
}

.icon-btn {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    padding: 8px;
    cursor: pointer;
    transition: opacity 0.3s;
}

.icon-btn:active {
    opacity: 0.7;
}

/* 页面容器 */
.page-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 16px;
    min-height: calc(100vh - 56px);
}

.page {
    display: none;
}

.page.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 扫码页面 */
.scan-container {
    padding: 20px 0;
}

.fortune-god-image {
    text-align: center;
    margin-bottom: 30px;
}

.fortune-god-image img {
    width: 150px;
    height: 150px;
}

.blessing-text {
    font-size: 20px;
    color: var(--primary-color);
    font-weight: bold;
    margin-top: 10px;
}

.scan-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.scan-card h2 {
    font-size: 24px;
    color: var(--text-primary);
    margin-bottom: 8px;
    text-align: center;
}

.subtitle {
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 24px;
}

/* 扫码方式 */
.scan-methods {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.primary-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 14px 24px;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s;
}

.primary-btn:active {
    transform: scale(0.98);
}

.primary-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 手动输入 */
.manual-input {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.manual-input input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 14px;
}

.manual-input button {
    padding: 10px 20px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
}

/* 测试模式 */
.test-mode {
    text-align: center;
    margin-top: 20px;
}

.link-btn {
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 14px;
    cursor: pointer;
    text-decoration: underline;
}

/* 扫码相机 */
.scanner-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #000;
    z-index: 1000;
}

.scanner-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    color: white;
    z-index: 10;
    background: linear-gradient(to bottom, rgba(0,0,0,0.7), rgba(0,0,0,0.3));
}

.scanner-back-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    color: white;
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    transition: all 0.3s;
}

.scanner-back-btn:active {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(0.95);
}

.scanner-back-btn i {
    font-size: 16px;
}

.scanner-back-btn .back-text {
    font-weight: 500;
}

.scanner-title {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 16px;
    font-weight: 500;
}

.scanner-container {
    position: relative;
    width: 100%;
    height: 100vh;
}

#scanVideo {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.scan-region {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 250px;
    height: 250px;
    border: 2px solid rgba(255, 255, 255, 0.8);
    border-radius: 8px;
}

.scan-line {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(to right, transparent, #4CAF50, transparent);
    animation: scan 2s linear infinite;
}

@keyframes scan {
    to { transform: translateY(248px); }
}

.scanner-tip {
    position: absolute;
    bottom: 100px;
    left: 0;
    right: 0;
    text-align: center;
    color: white;
    font-size: 14px;
}

/* 领取页面 */
.claim-container {
    padding: 20px 0;
}

.device-info {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.success-icon {
    color: var(--success-color);
    font-size: 48px;
    margin-bottom: 12px;
}

.device-info h3 {
    margin-bottom: 8px;
}

.device-info p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* 选项卡片 */
.option-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.option-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.option-icon {
    font-size: 24px;
}

.option-header h4 {
    margin: 0;
}

/* 免费条件 */
.option-conditions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.condition-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px;
    background: var(--bg-primary);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.3s;
}

.condition-item:hover {
    background: #e8e8e8;
}

.condition-info {
    display: flex;
    flex-direction: column;
}

.condition-title {
    font-weight: 500;
    margin-bottom: 2px;
}

.condition-desc {
    font-size: 12px;
    color: var(--text-secondary);
}

.condition-action {
    padding: 6px 12px;
    background: var(--primary-color);
    color: white;
    border-radius: 4px;
    font-size: 12px;
}

.condition-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 支付金额 */
.payment-amounts {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

.amount-btn {
    padding: 12px;
    border: 2px solid var(--border-color);
    background: white;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.3s;
}

.amount-btn:hover {
    border-color: var(--primary-color);
}

.amount-btn.selected {
    border-color: var(--primary-color);
    background: rgba(212, 38, 60, 0.05);
}

.amount {
    display: block;
    font-size: 18px;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 4px;
}

.desc {
    font-size: 12px;
    color: var(--text-secondary);
}

/* 支付方式 */
.payment-methods {
    display: flex;
    gap: 12px;
}

.payment-method {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.3s;
    background: white;
}

.payment-method:hover {
    border-color: var(--primary-color);
    background: rgba(212, 38, 60, 0.05);
}

.payment-method:active {
    transform: scale(0.98);
}

.payment-method input {
    display: none;
}

.payment-method:has(input:checked) {
    border-color: var(--primary-color);
    background: rgba(212, 38, 60, 0.05);
}

/* 支付图标 */
.pay-icon {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
    color: white;
}

.pay-icon.alipay {
    background: #1677FF;
}

.pay-icon.wechat {
    background: #07C160;
}

/* 成功页面 */
.success-container {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 40px 24px;
    text-align: center;
    box-shadow: var(--shadow);
    margin-top: 40px;
}

.success-animation {
    font-size: 64px;
    color: var(--success-color);
    margin-bottom: 20px;
    animation: scaleIn 0.5s ease;
}

@keyframes scaleIn {
    from { transform: scale(0); }
    to { transform: scale(1); }
}

.success-message {
    color: var(--text-secondary);
    margin: 12px 0 24px;
}

.success-details {
    background: var(--bg-primary);
    border-radius: var(--radius);
    padding: 16px;
    margin: 24px 0;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.detail-item:last-child {
    margin-bottom: 0;
}

.success-actions {
    display: flex;
    gap: 12px;
}

.secondary-btn {
    flex: 1;
    padding: 12px;
    border: 1px solid var(--primary-color);
    background: white;
    color: var(--primary-color);
    border-radius: var(--radius);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
}

/* 记录页面 */
.records-container {
    padding: 20px 0;
}

.records-container h2 {
    margin-bottom: 20px;
}

.records-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.record-item {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}

.record-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.record-type {
    font-weight: 500;
}

.record-amount {
    color: var(--primary-color);
    font-weight: bold;
}

.record-details {
    font-size: 14px;
    color: var(--text-secondary);
}

/* 返回按钮 */
.back-btn {
    width: 100%;
    padding: 12px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 14px;
    cursor: pointer;
    margin-top: 20px;
}

/* Toast提示 */
.toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 12px 24px;
    border-radius: 4px;
    font-size: 14px;
    z-index: 2000;
    display: none;
}

.toast.show {
    display: block;
    animation: toastFade 2s ease;
}

@keyframes toastFade {
    0%, 80% { opacity: 1; }
    100% { opacity: 0; }
}

/* 模态框 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1500;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: var(--radius);
    width: 90%;
    max-width: 400px;
    max-height: 80vh;
    overflow: auto;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
}

.modal-body {
    padding: 16px;
}

.modal-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
    text-align: right;
}

.modal-btn {
    padding: 8px 20px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

/* 简化的领取选项 */
.simplified-claim {
    margin-top: 20px;
}

/* 支付确认按钮 */
.pay-submit-btn {
    width: 100%;
    padding: 12px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 500;
    margin-top: 20px;
    cursor: pointer;
    transition: background 0.3s;
}

.pay-submit-btn:hover {
    background: #c92a47;
}

.pay-submit-btn:active {
    transform: scale(0.98);
}

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

/* 免费领取（框外居中） */
.free-claim-outer {
    width: 100%;
    margin: 20px 0;
    padding: 10px;
    text-align: center;
    cursor: pointer;
    transition: opacity 0.3s;
}

.free-claim-outer:hover {
    opacity: 0.8;
}

.free-claim-outer.disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

.free-claim-text {
    color: white;
    font-size: 14px;
    text-align: center;
    display: block;
}

.free-claim-text #freeClaimCount {
    color: white;
    font-weight: bold;
}

/* 响应式适配 */
@media (max-width: 375px) {
    .payment-amounts {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 768px) {
    .page-container {
        padding: 24px;
    }

    .scan-card {
        padding: 32px;
    }
}