/* ========== 基础重置 & 变量 ========== */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #eff6ff;
    --accent: #f59e0b;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --success: #10b981;
    --danger: #ef4444;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-hover: 0 4px 6px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

/* ========== Header ========== */
header {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    padding: 40px 0 32px;
    text-align: center;
}
header h1 { font-size: 28px; font-weight: 700; }
header .subtitle { margin-top: 6px; opacity: 0.85; font-size: 15px; }

/* ========== 商品列表 ========== */
#products-section { padding: 32px 0; }
#products-section h2 { font-size: 22px; margin-bottom: 20px; }

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.product-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}
.product-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
}

.product-card img {
    width: 100%;
    height: 220px;
    object-fit: cover;
    background: #f1f5f9;
}

.product-info { padding: 16px; }

.product-info h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 6px;
    line-height: 1.4;
}

.product-desc {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 10px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.product-price {
    font-size: 20px;
    font-weight: 700;
    color: var(--danger);
}
.product-price .unit { font-size: 14px; }

.product-stock {
    font-size: 13px;
    color: var(--text-light);
}
.product-stock .in-stock { color: var(--success); font-weight: 600; }
.product-stock .out-of-stock { color: var(--danger); font-weight: 600; }

/* ========== 下单页 ========== */
.hidden { display: none !important; }

#order-section { padding: 24px 0; }

.order-container {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px;
    max-width: 700px;
    margin: 0 auto;
}

.back-btn {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font-size: 14px;
    padding: 0;
    margin-bottom: 20px;
    display: inline-block;
}
.back-btn:hover { text-decoration: underline; }

/* ========== 商品详情页 ========== */
#order-product-info {
    padding-bottom: 16px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
#order-product-info .info h3 { font-size: 20px; margin-bottom: 6px; }
#order-product-info .info .price { font-size: 26px; font-weight: 700; color: var(--danger); }
#order-product-info .info .desc {
    font-size: 14px;
    color: var(--text-light);
    margin-top: 8px;
    line-height: 1.7;
    white-space: pre-wrap;
}

/* 商品多图画廊 */
.product-gallery {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 16px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
    scroll-snap-type: x mandatory;
}
.product-gallery img {
    width: 240px;
    height: 240px;
    object-fit: cover;
    border-radius: 10px;
    flex-shrink: 0;
    scroll-snap-align: start;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: transform 0.2s;
}
.product-gallery img:hover { transform: scale(1.02); }
.product-gallery::-webkit-scrollbar { height: 6px; }
.product-gallery::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* 规格选择器 */
.spec-selector {
    padding-bottom: 16px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
.spec-selector h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text-light);
}
.spec-options { display: flex; flex-wrap: wrap; gap: 10px; }
.spec-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 20px;
    border: 2px solid var(--border);
    border-radius: 10px;
    background: var(--card-bg);
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}
.spec-btn:hover { border-color: var(--primary); }
.spec-btn.active {
    border-color: var(--primary);
    background: var(--primary-light);
}
.spec-btn .spec-name { font-size: 14px; font-weight: 600; color: var(--text); }
.spec-btn .spec-price { font-size: 16px; font-weight: 700; color: var(--danger); }

/* 商品特点列表 */
.product-features {
    padding: 0 0 16px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
.product-features h4 { font-size: 14px; font-weight: 600; margin-bottom: 8px; color: var(--text-light); }
.product-features ul {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.product-features li {
    font-size: 13px;
    background: var(--primary-light);
    color: var(--primary);
    padding: 4px 12px;
    border-radius: 20px;
    white-space: nowrap;
}

/* ========== 表单 ========== */
.order-form h3 { font-size: 18px; margin-bottom: 16px; }

.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text);
}
.form-group .required { color: var(--danger); }

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    transition: border-color 0.2s;
    font-family: inherit;
}
.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.order-total {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 600;
    margin: 20px 0 16px;
}
.total-price { font-size: 24px; color: var(--danger); }

.btn-primary {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled {
    background: #94a3b8;
    cursor: not-allowed;
}

/* ========== 弹窗 ========== */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.2s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-content {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 32px;
    max-width: 480px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: slideUp 0.3s;
}
@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 20px;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-light);
    line-height: 1;
}
.modal-close:hover { color: var(--text); }

.modal-content h2 {
    text-align: center;
    font-size: 22px;
    margin-bottom: 12px;
}

.payment-amount {
    text-align: center;
    font-size: 16px;
    margin-bottom: 20px;
    color: var(--text-light);
}
.payment-amount strong {
    font-size: 28px;
    color: var(--danger);
}

.qrcode-container {
    display: flex;
    justify-content: center;
    margin-bottom: 12px;
}
.qrcode-container img {
    width: 260px;
    height: 260px;
    border: 2px solid var(--border);
    border-radius: 8px;
}

.payment-hint {
    text-align: center;
    font-size: 14px;
    color: var(--text-light);
    margin-bottom: 4px;
}
.payment-hint.small { font-size: 12px; margin-bottom: 20px; }

.payment-form { margin-top: 16px; }

/* ========== 成功弹窗 ========== */
.success-content { text-align: center; }
.success-icon { font-size: 64px; margin-bottom: 12px; }
.success-content h2 { color: var(--success); }
.success-content p { color: var(--text-light); margin-bottom: 24px; }

/* ========== Footer ========== */
footer {
    text-align: center;
    padding: 24px 0;
    color: var(--text-light);
    font-size: 13px;
}

/* ========== 响应式 ========== */
@media (max-width: 640px) {
    header { padding: 28px 0 24px; }
    header h1 { font-size: 22px; }
    .product-grid { grid-template-columns: 1fr; }
    .order-container { padding: 20px; }
    .modal-content { padding: 24px; }
    .qrcode-container img { width: 220px; height: 220px; }
}


/* ========== 支付区 ========== */
.payment-section {
    padding: 20px 0;
    margin-bottom: 16px;
    border-top: 1px solid var(--border);
}
.payment-section h3 {
    font-size: 18px;
    margin-bottom: 16px;
}
.payment-qr-area {
    text-align: center;
    margin-bottom: 20px;
}
.payment-amount-label {
    font-size: 16px;
    color: var(--text-light);
    margin-bottom: 12px;
}
.payment-amount-label strong {
    font-size: 28px;
    color: var(--danger);
}
.payment-qrcode {
    display: flex;
    justify-content: center;
    margin-bottom: 8px;
}
.payment-qrcode img {
    width: 220px;
    height: 220px;
    border: 2px solid var(--border);
    border-radius: 8px;
}
.payment-tip {
    font-size: 13px;
    color: var(--text-light);
}

/* ========== 文件上传 ========== */
.file-upload-area {
    position: relative;
}
.file-upload-area input[type="file"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
.file-upload-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px;
    border: 2px dashed var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-light);
    font-size: 15px;
}
.file-upload-label:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}
.file-upload-label .upload-icon {
    font-size: 24px;
}
.voucher-preview {
    margin-top: 12px;
    position: relative;
    display: inline-block;
}
.voucher-preview img {
    max-width: 100%;
    max-height: 240px;
    border-radius: 8px;
    border: 1px solid var(--border);
    display: block;
}
.remove-voucher {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: var(--danger);
    color: white;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* ========== 提交区域 ========== */
.order-submit-area {
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* ========== 成功弹窗 - 订单号 ========== */
.success-order-info {
    margin: 20px 0;
    padding: 16px;
    background: #f0fdf4;
    border-radius: 8px;
    border: 1px solid #bbf7d0;
}
.success-order-info p {
    color: var(--text-light);
    font-size: 14px;
    margin-bottom: 4px;
}
.success-order-info .order-id-display {
    font-size: 22px;
    font-weight: 700;
    color: var(--primary);
    text-align: center;
    letter-spacing: 1px;
    padding: 8px 0;
    user-select: all;
}
.success-order-info .success-tip {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 0;
}
