/* ===== CSS Variables ===== */
:root {
    --primary: #818cf8;
    --primary-dark: #6366f1;
    --success: #34d399;
    --warning: #fbbf24;
    --danger: #f87171;
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --bg-card-hover: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --border-color: #334155;
    --shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

/* ===== Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, var(--bg-dark) 0%, #1a1a2e 100%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

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

/* ===== Header ===== */
.header {
    text-align: center;
    margin-bottom: 3rem;
    padding: 2rem 0;
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(90deg, var(--primary), #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.back-link {
    color: var(--primary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.3s;
}

.back-link:hover {
    color: var(--primary-dark);
}

/* ===== Products Grid ===== */
.products {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

.product-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    cursor: pointer;
}

.product-card:hover {
    background: var(--bg-card-hover);
    transform: translateY(-4px);
    box-shadow: var(--shadow);
}

.product-name {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.product-desc {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    min-height: 3rem;
}

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

.product-price {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--success);
}

.product-price::before {
    content: '¥';
    font-size: 1rem;
}

.product-stock {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.btn-buy {
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-buy:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 30px rgba(99, 102, 241, 0.4);
}

.btn-buy:disabled {
    background: var(--border-color);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ===== Modal ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 2rem;
    width: 90%;
    max-width: 450px;
    position: relative;
    border: 1px solid var(--border-color);
    animation: slideUp 0.3s ease;
}

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

.close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.3s;
}

.close:hover {
    color: var(--text-primary);
}

.modal-content h2 {
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

.product-info {
    background: var(--bg-dark);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.product-info p {
    margin-bottom: 0.5rem;
}

.product-info p:last-child {
    margin-bottom: 0;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.btn-pay {
    width: 100%;
    background: linear-gradient(135deg, var(--success), #059669);
    color: white;
    border: none;
    padding: 1rem;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 0.5rem;
}

.btn-pay:hover {
    transform: scale(1.02);
    box-shadow: 0 10px 30px rgba(16, 185, 129, 0.4);
}

/* ===== Order Page ===== */
.order-page {
    max-width: 600px;
    margin: 0 auto;
}

.search-box {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    align-items: stretch;
}

.search-box input {
    flex: 1;
    padding: 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
}

.btn-search {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0 2rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-search:hover {
    background: var(--primary-dark);
}

.btn-back {
    background: var(--bg-card);
    color: var(--text-primary);
    text-decoration: none;
    padding: 0 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s;
    white-space: nowrap;
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-back:hover {
    background: var(--bg-card-hover);
    border-color: var(--primary);
}

.order-card {
    background: var(--bg-card);
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.order-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--bg-dark);
    border-bottom: 1px solid var(--border-color);
}

.order-no {
    font-family: monospace;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.order-status {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.status-paid {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.status-pending {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning);
}

.status-failed {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.order-body {
    padding: 1.5rem;
}

.order-body p {
    margin-bottom: 0.75rem;
    color: var(--text-secondary);
}

.order-body span {
    color: var(--text-primary);
}

.order-error {
    text-align: center;
    padding: 2rem;
    background: var(--bg-card);
    border-radius: 16px;
    border: 1px solid var(--border-color);
}

.order-error p {
    color: var(--danger);
    font-size: 1.1rem;
}

/* ===== Redeem Code Section ===== */
.redeem-code-section {
    padding: 1.5rem;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(168, 85, 247, 0.1));
    border-top: 1px solid var(--border-color);
}

.redeem-code-label {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 0.75rem;
}

.redeem-code-box {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.redeem-code-box code {
    flex: 1;
    padding: 1rem;
    background: var(--bg-dark);
    border-radius: 8px;
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 0.95rem;
    color: var(--success);
    word-break: break-all;
    border: 1px solid var(--border-color);
}

.btn-copy {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
}

.btn-copy:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

.btn-activate {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    text-decoration: none;
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s;
    white-space: nowrap;
    display: inline-block;
}

.btn-activate:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

/* ===== Footer ===== */
.footer {
    text-align: center;
    margin-top: 3rem;
    padding: 2rem 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.footer a {
    color: var(--primary);
    text-decoration: none;
    margin-left: 1rem;
}

.footer a:hover {
    text-decoration: underline;
}

/* ===== Loading ===== */
.loading {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    .header h1 {
        font-size: 1.8rem;
    }

    .products {
        grid-template-columns: 1fr;
    }

    .search-box {
        flex-direction: column;
    }
    
    .floating-qr {
        display: none; /* 移动端隐藏悬浮二维码 */
    }
}

/* ===== New UI Elements ===== */
.tips-box {
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 2rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.tips-box a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.tips-box a:hover {
    text-decoration: underline;
}

.redeem-code-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.redeem-code-label {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 0;
}

.warning-text {
    color: var(--danger);
    font-weight: 600;
    font-size: 0.85rem;
    background: rgba(239, 68, 68, 0.1);
    padding: 0.25rem 0.75rem;
    border-radius: 6px;
    margin-bottom: 0;
}

.promo-link {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px dashed rgba(255, 255, 255, 0.1);
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.promo-link a {
    color: var(--success);
    text-decoration: none;
    font-weight: 600;
    word-break: break-all;
}

.promo-link a:hover {
    text-decoration: underline;
}

@media (max-width: 768px) {
    .search-box {
        flex-direction: column;
    }
    
    .btn-search, .btn-back {
        padding: 1rem;
        width: 100%;
    }
}

/* ===== Floating QR Codes ===== */
.floating-qr {
    position: fixed;
    right: 2rem;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    z-index: 100;
}

.qr-item {
    background: white;
    padding: 0.5rem;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    text-align: center;
    width: 120px;
}

.qr-label {
    color: #333;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.qr-item img {
    width: 100%;
    height: auto;
    display: block;
}
