/* ============== 基础重置 ============== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --bg: #f5f5f7;
    --card-bg: #fff;
    --text: #1a1a2e;
    --text-secondary: #6b7280;
    --border: #e5e7eb;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-lg: 0 10px 25px rgba(0,0,0,.08);
}

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

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

a { color: var(--primary); text-decoration: none; }

/* ============== 导航栏 ============== */
.navbar {
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 14px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}
.nav-content { display: flex; justify-content: space-between; align-items: center; }
.nav-brand { font-size: 18px; font-weight: 700; color: var(--text); }
.nav-links a { margin-left: 24px; color: var(--text-secondary); font-size: 14px; }
.nav-links a:hover { color: var(--primary); }

/* ============== Hero ============== */
.hero {
    text-align: center;
    padding: 48px 0 32px;
}
.hero h1 { font-size: 32px; font-weight: 800; margin-bottom: 8px; }
.hero p { color: var(--text-secondary); font-size: 16px; }

/* ============== 商品卡片 ============== */
.category-section { margin-bottom: 40px; }
.category-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--primary);
    display: inline-block;
}

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

.product-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    transition: transform .2s, box-shadow .2s;
}
.product-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.product-name { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.product-desc { font-size: 13px; color: var(--text-secondary); margin-bottom: 12px; min-height: 36px; }
.product-footer { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.product-price { font-size: 18px; font-weight: 700; color: var(--primary); }
.product-stock { font-size: 13px; color: var(--text-secondary); }
.product-stock.stock-in,
strong.stock-in { color: var(--success); font-weight: 600; }
.product-stock.stock-out,
strong.stock-out { color: var(--danger); font-weight: 600; }

/* ============== 按钮 ============== */
.btn {
    display: inline-block;
    padding: 8px 18px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    background: #fff;
    color: var(--text);
    transition: all .15s;
    text-align: center;
}
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-block { display: block; width: 100%; }
.btn-lg { padding: 12px 24px; font-size: 16px; font-weight: 600; }
.btn-sm { padding: 4px 12px; font-size: 12px; }

/* ============== 卡片容器 ============== */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

/* ============== 表单 ============== */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 6px; }
.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color .15s;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.1); }
.form-sm { width: 100px; }

.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 160px; }

.inline-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .form-control { width: auto; }

textarea.form-control { resize: vertical; font-family: inherit; }
select.form-control { appearance: auto; }

/* ============== 购买页 ============== */
.buy-card { max-width: 520px; margin: 32px auto; }
.buy-card h2 { margin-bottom: 8px; }
.product-desc-detail { color: var(--text-secondary); margin-bottom: 20px; }
.product-info-row { display: flex; justify-content: space-between; padding: 12px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.buy-tip { text-align: center; margin-top: 12px; font-size: 13px; color: var(--text-secondary); }

/* ============== 订单页 ============== */
.order-card { max-width: 560px; margin: 32px auto; }
.order-info { margin: 20px 0; }
.info-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); }
.info-row .label { color: var(--text-secondary); }
.info-row .value { font-weight: 500; }
.info-row .price { color: var(--primary); font-weight: 700; }

.card-content-box { margin-top: 20px; padding: 16px; background: #f0fdf4; border-radius: 8px; border: 1px solid #bbf7d0; }
.card-content-box h3 { font-size: 15px; margin-bottom: 10px; color: var(--success); }
.card-actions { display: flex; gap: 8px; margin-bottom: 10px; }
.card-textarea {
    width: 100%;
    min-height: 80px;
    padding: 12px;
    border: 1px solid #bbf7d0;
    border-radius: 6px;
    font-family: monospace;
    font-size: 14px;
    resize: vertical;
    background: #fff;
}

.pay-action { margin-top: 20px; text-align: center; }
.tip { text-align: center; margin-top: 8px; font-size: 13px; color: var(--text-secondary); }

/* ============== 查询页 ============== */
.query-card { max-width: 440px; margin: 60px auto; }
.query-card h2 { text-align: center; margin-bottom: 24px; }

/* ============== 查询结果卡片 ============== */
.result-order-card {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 12px;
}
.result-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.result-product { font-weight: 600; font-size: 15px; }
.result-meta { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--text-secondary); }
.result-meta code { background: var(--bg); padding: 1px 5px; border-radius: 4px; font-size: 12px; }

/* ============== 分隔符 ============== */
.form-divider {
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
    margin: 12px 0;
    position: relative;
}
.form-divider::before, .form-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 40%;
    height: 1px;
    background: var(--border);
}
.form-divider::before { left: 0; }
.form-divider::after { right: 0; }

/* ============== 状态标签 ============== */
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}
.badge-pending { background: #fef3c7; color: #b45309; }
.badge-paid { background: #d1fae5; color: #065f46; }
.badge-expired { background: #fee2e2; color: #991b1b; }

/* ============== Flash 消息 ============== */
.flash-messages { margin: 16px 0; }
.flash {
    padding: 10px 16px;
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 14px;
}
.flash-success { background: #d1fae5; color: #065f46; }
.flash-error { background: #fee2e2; color: #991b1b; }

/* ============== 表格 ============== */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; padding: 10px 8px; border-bottom: 2px solid var(--border); font-weight: 600; font-size: 13px; color: var(--text-secondary); }
.table td { padding: 10px 8px; border-bottom: 1px solid var(--border); }
.table code { background: var(--bg); padding: 2px 6px; border-radius: 4px; font-size: 12px; }

.filter-bar { display: inline-flex; gap: 6px; margin-left: 12px; vertical-align: middle; }

.pagination { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 16px; }
.page-info { font-size: 13px; color: var(--text-secondary); }

/* ============== 空状态 ============== */
.empty-state { text-align: center; padding: 60px; color: var(--text-secondary); }

/* ============== 页脚 ============== */
.footer { text-align: center; padding: 32px 0; color: var(--text-secondary); font-size: 13px; margin-top: 40px; }

/* ============== 登录页 ============== */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { background: #fff; padding: 40px; border-radius: var(--radius); box-shadow: var(--shadow-lg); width: 380px; }
.login-card h2 { text-align: center; margin-bottom: 24px; }

/* ============== 后台布局 ============== */
.admin-body { background: var(--bg); }
.admin-layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 220px;
    background: #1a1a2e;
    color: #fff;
    flex-shrink: 0;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
}
.sidebar-brand { padding: 20px; font-size: 18px; font-weight: 700; border-bottom: 1px solid rgba(255,255,255,.1); }
.sidebar-nav { padding: 12px 0; }
.sidebar-nav a {
    display: block;
    padding: 10px 20px;
    color: rgba(255,255,255,.7);
    font-size: 14px;
    transition: all .15s;
}
.sidebar-nav a:hover, .sidebar-nav a.active { background: rgba(255,255,255,.1); color: #fff; }
.sidebar-link-btn {
    display: block; width: 100%; padding: 10px 20px; border: none; background: none; cursor: pointer;
    color: rgba(255,255,255,.7); font-size: 14px; text-align: left; transition: all .15s; font-family: inherit;
}
.sidebar-link-btn:hover { background: rgba(255,255,255,.1); color: #fff; }
.sidebar-divider { border-top: 1px solid rgba(255,255,255,.1); margin: 8px 0; }

.admin-main { margin-left: 220px; flex: 1; padding: 24px 32px; }
.admin-header { margin-bottom: 24px; }
.admin-header h1 { font-size: 24px; font-weight: 700; }

/* ============== 统计卡片 ============== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: #fff; border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); text-align: center; }
.stat-number { font-size: 28px; font-weight: 800; color: var(--primary); }
.stat-label { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }

/* ============== 支付页 ============== */
.pay-page { max-width: 480px; margin: 32px auto; text-align: center; }
.pay-header { margin-bottom: 20px; }
.pay-header h2 { margin-bottom: 4px; }
.pay-hint { color: var(--text-secondary); font-size: 14px; }

.pay-amount-box {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    border-radius: 12px;
    padding: 20px 24px;
    margin-bottom: 24px;
    color: #fff;
}
.pay-amount-label { font-size: 13px; opacity: .8; margin-bottom: 4px; }
.pay-amount { font-size: 40px; font-weight: 800; letter-spacing: -1px; }
.pay-amount small { font-size: 16px; font-weight: 400; opacity: .7; }
.pay-network { font-size: 12px; opacity: .7; margin-top: 4px; }

.pay-qr-section { margin-bottom: 20px; }
.pay-qr-img {
    width: 200px; height: 200px;
    border: 6px solid #fff;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,.1);
}
.qr-tip { font-size: 13px; color: var(--text-secondary); margin-top: 8px; }

.pay-address { margin-bottom: 16px; text-align: left; }
.pay-address label { font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; display: block; }
.address-row { display: flex; gap: 8px; }
.address-input {
    flex: 1;
    background: var(--bg);
    padding: 10px 12px;
    border-radius: 8px;
    font-family: monospace;
    font-size: 12px;
    border: 1px solid var(--border);
    outline: none;
    color: var(--text);
}
.btn-copy { flex-shrink: 0; padding: 10px 16px; font-size: 13px; }
.copy-toast {
    margin-top: 6px;
    font-size: 12px;
    color: var(--success);
    font-weight: 500;
}

.pay-warning {
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    color: #92400e;
    text-align: left;
    margin-bottom: 20px;
}

.pay-detail { text-align: left; margin-bottom: 24px; }

.pay-confirm-btn {
    font-size: 18px !important;
    padding: 16px !important;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
    border-color: #10b981 !important;
    border-radius: 12px !important;
}
.pay-confirm-btn:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%) !important;
}

.pay-status-box {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 10px;
    font-size: 14px;
    color: #1e40af;
    margin-bottom: 16px;
}
.pay-spinner {
    width: 18px; height: 18px;
    border: 3px solid #bfdbfe;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.pay-status-success { background: #d1fae5; border-color: #6ee7b7; color: #065f46; }
.pay-status-fail { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }
.pay-status-ok { font-weight: 600; font-size: 16px; }
.pay-status-expired { font-weight: 600; font-size: 15px; }

.pay-countdown {
    padding: 10px;
    font-size: 14px;
    color: var(--text-secondary);
    background: var(--bg);
    border-radius: 8px;
}
.pay-countdown span { font-weight: 700; color: var(--warning); }
.countdown-icon { margin-right: 4px; }

/* ============== 响应式 ============== */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .admin-main { margin-left: 0; padding: 16px; }
    .product-grid { grid-template-columns: 1fr; }
    .form-row { flex-direction: column; }
    .inline-form { flex-direction: column; }
    .table { font-size: 12px; }
}
