/* ========== 全局重置 ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, "Microsoft YaHei", "Segoe UI", Tahoma, sans-serif;
    background: #f5f5f5;
    color: #333;
    font-size: 14px;
    line-height: 1.6;
}

a {
    color: #2563eb;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ========== 布局 ========== */
.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 15px;
}

.container-narrow {
    max-width: 480px;
    margin: 0 auto;
    padding: 0 15px;
}

/* ========== 导航栏 ========== */
.navbar {
    background: #1e293b;
    padding: 0 20px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.navbar-brand {
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    text-decoration: none;
}

.navbar-brand:hover {
    text-decoration: none;
}

.navbar-nav {
    display: flex;
    gap: 18px;
    align-items: center;
    list-style: none;
}

.navbar-nav a {
    color: #cbd5e1;
    font-size: 14px;
    text-decoration: none;
}

.navbar-nav a:hover {
    color: #fff;
    text-decoration: none;
}

.navbar-nav .nav-balance {
    color: #fbbf24;
    font-weight: 600;
}

/* ========== 卡片 ========== */
.card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    margin-bottom: 20px;
}

.card-header {
    padding: 12px 16px;
    border-bottom: 1px solid #e2e8f0;
    font-weight: 600;
    font-size: 15px;
    background: #f8fafc;
    border-radius: 6px 6px 0 0;
}

.card-body {
    padding: 16px;
}

/* ========== 表单 ========== */
.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #475569;
    font-size: 13px;
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    color: #333;
    transition: border-color 0.15s;
}

.form-control:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

textarea.form-control {
    resize: vertical;
    min-height: 70px;
}

select.form-control {
    cursor: pointer;
}

/* ========== 按钮 ========== */
.btn {
    display: inline-block;
    padding: 8px 20px;
    border: 1px solid transparent;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: background 0.15s, border-color 0.15s;
    line-height: 1.4;
}

.btn:hover {
    text-decoration: none;
}

.btn-primary {
    background: #2563eb;
    color: #fff;
}

.btn-primary:hover {
    background: #1d4ed8;
}

.btn-success {
    background: #16a34a;
    color: #fff;
}

.btn-success:hover {
    background: #15803d;
}

.btn-danger {
    background: #dc2626;
    color: #fff;
}

.btn-danger:hover {
    background: #b91c1c;
}

.btn-warning {
    background: #d97706;
    color: #fff;
}

.btn-warning:hover {
    background: #b45309;
}

.btn-secondary {
    background: #e2e8f0;
    color: #475569;
    border-color: #cbd5e1;
}

.btn-secondary:hover {
    background: #cbd5e1;
}

.btn-sm {
    padding: 4px 12px;
    font-size: 13px;
}

.btn-block {
    display: block;
    width: 100%;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ========== 表格 ========== */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.table th {
    text-align: left;
    padding: 10px 12px;
    background: #f1f5f9;
    border-bottom: 2px solid #e2e8f0;
    color: #475569;
    font-weight: 600;
    white-space: nowrap;
}

.table td {
    padding: 10px 12px;
    border-bottom: 1px solid #e2e8f0;
    color: #334155;
}

.table tr:hover td {
    background: #f8fafc;
}

.table-wrap {
    overflow-x: auto;
}

/* ========== 徽章 ========== */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 12px;
    font-weight: 500;
}

.badge-success { background: #dcfce7; color: #15803d; }
.badge-danger  { background: #fee2e2; color: #b91c1c; }
.badge-warning { background: #fef3c7; color: #b45309; }
.badge-info    { background: #dbeafe; color: #1d4ed8; }
.badge-secondary { background: #e2e8f0; color: #475569; }

/* ========== 提示框 ========== */
.alert {
    padding: 12px 16px;
    border-radius: 4px;
    margin-bottom: 16px;
    font-size: 13px;
    border: 1px solid transparent;
}

.alert-success { background: #dcfce7; border-color: #86efac; color: #15803d; }
.alert-danger  { background: #fee2e2; border-color: #fca5a5; color: #b91c1c; }
.alert-warning { background: #fef3c7; border-color: #fcd34d; color: #b45309; }
.alert-info    { background: #dbeafe; border-color: #93c5fd; color: #1d4ed8; }

/* ========== 余额显示 ========== */
.balance-display {
    text-align: center;
    padding: 24px 16px;
    background: #1e293b;
    color: #fff;
    border-radius: 6px;
    margin-bottom: 20px;
}

.balance-display .balance-label {
    font-size: 13px;
    color: #94a3b8;
    margin-bottom: 6px;
}

.balance-display .balance-amount {
    font-size: 32px;
    font-weight: 700;
    color: #fbbf24;
}

.balance-display .balance-actions {
    margin-top: 16px;
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* ========== 商品卡片 ========== */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.product-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 16px;
    display: flex;
    flex-direction: column;
}

.product-card h3 {
    font-size: 15px;
    margin-bottom: 8px;
    color: #1e293b;
}

.product-card .product-desc {
    color: #64748b;
    font-size: 13px;
    flex-grow: 1;
    margin-bottom: 12px;
}

.product-card .product-type {
    color: #2563eb;
    font-size: 12px;
    margin-bottom: 8px;
}

.product-card .product-price {
    font-size: 20px;
    font-weight: 700;
    color: #dc2626;
    margin-bottom: 12px;
}

.product-card .product-stock {
    font-size: 12px;
    color: #94a3b8;
    margin-bottom: 10px;
}

/* ========== 分页 ========== */
.pagination {
    display: flex;
    gap: 4px;
    justify-content: center;
    margin-top: 20px;
    list-style: none;
}

.pagination a, .pagination span {
    padding: 6px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 3px;
    font-size: 13px;
    color: #475569;
    text-decoration: none;
}

.pagination a:hover {
    background: #e2e8f0;
    text-decoration: none;
}

.pagination .active {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}

/* ========== 工具类 ========== */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-danger { color: #dc2626; }
.text-success { color: #16a34a; }
.text-warning { color: #d97706; }
.text-muted  { color: #94a3b8; }
.text-bold   { font-weight: 700; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.d-flex { display: flex; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.flex-wrap { flex-wrap: wrap; }

/* ========== 管理后台侧边栏 ========== */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: 200px;
    background: #1e293b;
    color: #cbd5e1;
    padding: 0;
    flex-shrink: 0;
}

.admin-sidebar .sidebar-header {
    padding: 16px 20px;
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid #334155;
}

.admin-sidebar ul {
    list-style: none;
    padding: 0;
}

.admin-sidebar li a {
    display: block;
    padding: 12px 20px;
    color: #94a3b8;
    font-size: 13px;
    text-decoration: none;
    border-left: 3px solid transparent;
}

.admin-sidebar li a:hover {
    background: #334155;
    color: #fff;
    text-decoration: none;
}

.admin-sidebar li a.active {
    background: #334155;
    color: #fff;
    border-left-color: #2563eb;
}

.admin-content {
    flex-grow: 1;
    padding: 20px;
    overflow-x: auto;
}

.admin-content h1 {
    font-size: 20px;
    margin-bottom: 20px;
    color: #1e293b;
}

/* ========== 统计卡片 ========== */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 16px;
}

.stat-card .stat-label {
    font-size: 13px;
    color: #64748b;
    margin-bottom: 6px;
}

.stat-card .stat-value {
    font-size: 24px;
    font-weight: 700;
    color: #1e293b;
}

/* ========== 支付页面 ========== */
.pay-box {
    text-align: center;
    padding: 30px 20px;
}

.pay-box .pay-amount {
    font-size: 28px;
    font-weight: 700;
    color: #dc2626;
    margin: 10px 0;
}

.pay-box .pay-qrcode {
    margin: 16px auto;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    max-width: 250px;
}

.pay-box .pay-tip {
    color: #64748b;
    font-size: 13px;
}

/* ========== 响应式 ========== */
@media (max-width: 768px) {
    .admin-layout {
        flex-direction: column;
    }
    .admin-sidebar {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
    }
    .admin-sidebar .sidebar-header {
        width: 100%;
    }
    .admin-sidebar ul {
        display: flex;
        flex-wrap: wrap;
    }
    .admin-sidebar li a {
        padding: 8px 14px;
        border-left: none;
        border-bottom: 3px solid transparent;
    }
    .admin-sidebar li a.active {
        border-left: none;
        border-bottom-color: #2563eb;
    }
    .product-grid {
        grid-template-columns: 1fr;
    }
    .navbar {
        padding: 0 12px;
    }
    .navbar-nav {
        gap: 12px;
    }
}

@media (max-width: 480px) {
    .container, .container-narrow {
        padding: 0 10px;
    }
    .balance-display .balance-amount {
        font-size: 26px;
    }
    .table {
        font-size: 12px;
    }
    .table th, .table td {
        padding: 8px;
    }
}
