/* 发卡网站样式 */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
}

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

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

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

/* 导航 */
.navbar {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    padding: 0;
    box-shadow: 0 2px 10px rgba(99,102,241,0.3);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 64px;
}

.navbar .logo {
    color: #fff;
    font-size: 1.4rem;
    font-weight: 700;
    text-decoration: none;
    letter-spacing: 1px;
}

.navbar .nav-links {
    display: flex;
    gap: 8px;
}

.navbar .nav-links a {
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.navbar .nav-links a:hover,
.navbar .nav-links a.active {
    background: rgba(255,255,255,0.15);
    color: #fff;
}

/* 公告 */
.notice {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    border-left: 4px solid var(--warning);
    padding: 14px 20px;
    margin: 24px 0;
    border-radius: 8px;
    font-size: 0.9rem;
    color: #92400e;
}

/* 商品网格 */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
    margin: 24px 0 40px;
}

.product-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 28px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    border: 1px solid var(--border);
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
}

.product-card:hover {
    box-shadow: 0 10px 25px rgba(0,0,0,0.08);
    transform: translateY(-2px);
}

.product-card h3 {
    font-size: 1.15rem;
    margin-bottom: 10px;
    color: var(--text);
}

.product-card .desc {
    color: var(--text-light);
    font-size: 0.88rem;
    margin-bottom: 16px;
    flex: 1;
}

.product-card .meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

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

.product-card .price small {
    font-size: 0.85rem;
    font-weight: 400;
}

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

.product-card .stock.low {
    color: var(--danger);
}

/* 按钮 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 24px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    gap: 6px;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

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

.btn-success {
    background: var(--success);
    color: #fff;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.82rem;
}

.btn-block {
    width: 100%;
}

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

/* 表单 */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: 10px;
    font-size: 0.9rem;
    transition: border-color 0.2s;
    outline: none;
    background: #fff;
}

.form-control:focus {
    border-color: var(--primary);
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

/* 页面标题 */
.page-header {
    padding: 32px 0 8px;
}

.page-header h1 {
    font-size: 1.6rem;
    font-weight: 700;
}

.page-header p {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-top: 4px;
}

/* 卡片容器 */
.card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 28px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    border: 1px solid var(--border);
    margin-bottom: 24px;
}

.card h2 {
    font-size: 1.2rem;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border);
}

/* 支付页面 */
.pay-container {
    text-align: center;
    max-width: 480px;
    margin: 40px auto;
}

.qr-code {
    display: inline-block;
    padding: 20px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    margin: 20px 0;
}

.qr-code img {
    width: 220px;
    height: 220px;
}

.order-info {
    text-align: left;
    background: #f1f5f9;
    border-radius: 12px;
    padding: 20px;
    margin: 20px 0;
}

.order-info .row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px dashed #cbd5e1;
}

.order-info .row:last-child {
    border-bottom: none;
}

.order-info .label {
    color: var(--text-light);
}

.order-info .value {
    font-weight: 600;
}

.order-info .value.price {
    color: var(--danger);
    font-size: 1.1rem;
}

/* 状态标签 */
.status {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.status-pending { background: #fef3c7; color: #92400e; }
.status-paid { background: #dcfce7; color: #166534; }
.status-expired { background: #fee2e2; color: #991b1b; }

/* 卡密展示 */
.card-result {
    background: #f0fdf4;
    border: 2px solid #86efac;
    border-radius: 12px;
    padding: 20px;
    margin: 20px 0;
}

.card-result h3 {
    color: #166534;
    margin-bottom: 12px;
}

.card-item {
    background: #fff;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 8px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    word-break: break-all;
    border: 1px solid #bbf7d0;
}

/* 页脚 */
.footer {
    text-align: center;
    padding: 30px 0;
    color: var(--text-light);
    font-size: 0.82rem;
    border-top: 1px solid var(--border);
    margin-top: 40px;
}

/* 提示框 */
.alert {
    padding: 14px 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.alert-success { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.alert-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }

/* ======== 后台样式 ======== */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: 240px;
    background: linear-gradient(180deg, #1e293b, #0f172a);
    color: #fff;
    padding: 0;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
}

.admin-sidebar .brand {
    padding: 24px 20px;
    font-size: 1.1rem;
    font-weight: 700;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.admin-sidebar .menu {
    list-style: none;
    padding: 12px 0;
}

.admin-sidebar .menu a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 24px;
    color: rgba(255,255,255,0.65);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.admin-sidebar .menu a:hover,
.admin-sidebar .menu a.active {
    color: #fff;
    background: rgba(255,255,255,0.08);
}

.admin-main {
    margin-left: 240px;
    flex: 1;
    padding: 28px 36px;
    background: var(--bg);
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
}

.admin-header h1 {
    font-size: 1.5rem;
}

/* 统计卡片 */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background: #fff;
    padding: 24px;
    border-radius: 14px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    border: 1px solid var(--border);
}

.stat-card .number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-card .label {
    color: var(--text-light);
    font-size: 0.85rem;
    margin-top: 4px;
}

/* 表格 */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

table th {
    background: #f1f5f9;
    text-align: left;
    padding: 12px 16px;
    font-weight: 600;
    white-space: nowrap;
}

table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

table tr:hover td {
    background: #f8fafc;
}

/* 分页 */
.pagination {
    display: flex;
    gap: 6px;
    margin-top: 20px;
    justify-content: center;
}

.pagination a, .pagination span {
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    text-decoration: none;
    border: 1px solid var(--border);
    color: var(--text);
}

.pagination span.current {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.pagination a:hover {
    background: #f1f5f9;
}

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

.modal-overlay.show {
    display: flex;
}

.modal {
    background: #fff;
    border-radius: 16px;
    padding: 32px;
    width: 480px;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.modal h2 {
    margin-bottom: 20px;
    border: none;
    padding: 0;
}

@media (max-width: 768px) {
    .products-grid {
        grid-template-columns: 1fr;
    }
    .admin-sidebar {
        width: 200px;
    }
    .admin-main {
        margin-left: 200px;
        padding: 20px;
    }
    .navbar .container {
        flex-direction: column;
        height: auto;
        padding: 12px 20px;
        gap: 8px;
    }
}
