/* 重置样式 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: #333;
  background-color: #f5f5f5;
}

/* 全局样式 */
a {
  color: #007bff;
  text-decoration: none;
  transition: color 0.3s;
}

a:hover {
  color: #0056b3;
}

ul {
  list-style: none;
}

/* 布局样式 */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* 头部样式 */
.header {
  background-color: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  padding: 15px 0;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-size: 24px;
  font-weight: bold;
  color: #007bff;
}

/* 导航样式 */
.nav {
  display: flex;
  gap: 20px;
}

.nav a {
  font-weight: 500;
}

/* 移动端导航按钮 */
.mobile-nav-btn {
  display: none;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
}

/* 主体样式 */
.main {
  padding: 40px 0;
  min-height: calc(100vh - 200px);
}

/* 页脚样式 */
.footer {
  background-color: #333;
  color: #fff;
  padding: 40px 0;
  margin-top: 40px;
}

.footer .container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
}

.footer h3 {
  margin-bottom: 20px;
  color: #007bff;
}

/* 组件样式 */
/* 按钮样式 */
.btn {
  display: inline-block;
  padding: 10px 20px;
  font-size: 16px;
  font-weight: 500;
  text-align: center;
  cursor: pointer;
  border: none;
  border-radius: 4px;
  transition: all 0.3s;
}

.btn-primary {
  background-color: #007bff;
  color: #fff;
}

.btn-primary:hover {
  background-color: #0056b3;
  color: #fff;
}

.btn-secondary {
  background-color: #6c757d;
  color: #fff;
}

.btn-secondary:hover {
  background-color: #545b62;
  color: #fff;
}

/* 筛选按钮样式 */
.filter .btn {
  background-color: #6c757d;
  color: #fff;
  border: none;
}

.filter .btn:hover {
  background-color: #545b62;
  color: #fff;
}

/* 筛选按钮高亮样式 */
.filter .btn.active {
  background-color: #007bff;
  color: #fff;
  border-color: #007bff;
}

/* 确保primary按钮在非active状态下显示与secondary按钮相同的样式 */
.filter .btn-primary:not(.active) {
  background-color: #6c757d;
  color: #fff;
}

.filter .btn-primary:not(.active):hover {
  background-color: #545b62;
  color: #fff;
}

/* 确保primary按钮的active样式也正常 */
.filter .btn-primary.active {
  background-color: #007bff;
  color: #fff;
}

/* 确保secondary按钮的active样式也正常 */
.filter .btn-secondary.active {
  background-color: #007bff;
  color: #fff;
  border-color: #007bff;
}

/* 卡片样式 */
.card {
  background-color: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  padding: 20px;
  transition: transform 0.3s, box-shadow 0.3s;
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.card img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  border-radius: 4px;
  margin-bottom: 15px;
}

.card-title {
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 10px;
}

.card-price {
  font-size: 20px;
  font-weight: bold;
  color: #ff6b6b;
  margin-bottom: 15px;
}

/* 表单样式 */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  margin-bottom: 5px;
  font-weight: 500;
}

/* 为必填项的*符号添加红色 */
.form-label {
  position: relative;
}

/* 使用CSS选择器选中所有包含*的label文本 */
.form-label::after {
  content: '';
}

/* 为必填项的*符号添加红色 */
.form-label {
  color: #333;
}

/* 直接选中标签中的*符号 */
.form-label:contains('*') {
  color: #333;
}

/* 为所有标签中的*符号添加红色 */
.form-label {
  color: #333;
}

/* 最终解决方案：使用JavaScript将*替换为红色span标签 */
.form-label {
  color: #333;
}

.form-control {
  width: 100%;
  padding: 10px;
  font-size: 16px;
  border: 1px solid #ddd;
  border-radius: 4px;
  transition: border-color 0.3s;
}

.form-control:focus {
  outline: none;
  border-color: #007bff;
  box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* 商品列表样式 */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

/* 分类导航样式 */
.category-nav {
  background-color: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  padding: 15px 0;
  margin-bottom: 30px;
}

.category-nav .container {
  display: flex;
  gap: 20px;
  overflow-x: auto;
  white-space: nowrap;
}

.category-nav a {
  padding: 8px 15px;
  border-radius: 20px;
  background-color: #f0f0f0;
  font-weight: 500;
  transition: all 0.3s;
}

.category-nav a:hover,
.category-nav a.active {
  background-color: #007bff;
  color: #fff;
}

/* 页头样式 */
.page-header {
  background-color: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  padding: 30px 0;
  margin-bottom: 30px;
  text-align: center;
}

.page-header h1 {
  font-size: 36px;
  margin-bottom: 10px;
}

.page-header p {
  color: #666;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .mobile-nav-btn {
    display: block;
  }
  
  .nav {
    position: fixed;
    top: 60px;
    left: 0;
    width: 100%;
    background-color: #fff;
    flex-direction: column;
    padding: 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    transform: translateY(-100%);
    opacity: 0;
    transition: all 0.3s;
  }
  
  .nav.active {
    transform: translateY(0);
    opacity: 1;
  }
  
  .product-grid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  }
  
  .footer .container {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 576px) {
  .page-header h1 {
    font-size: 28px;
  }
  
  .product-grid {
    grid-template-columns: 1fr;
  }
  
  .card img {
    height: 150px;
  }
}

/* 后台管理样式 */
.admin-container {
  display: flex;
  min-height: 100vh;
}

.admin-sidebar {
  width: 250px;
  background-color: #343a40;
  color: #fff;
  padding: 20px;
}

.admin-sidebar h3 {
  margin-bottom: 20px;
  color: #007bff;
}

.admin-sidebar ul {
  list-style: none;
}

.admin-sidebar li {
  margin-bottom: 10px;
}

.admin-sidebar a {
  color: #fff;
  display: block;
  padding: 10px;
  border-radius: 4px;
  transition: background-color 0.3s;
}

.admin-sidebar a:hover,
.admin-sidebar a.active {
  background-color: #495057;
}

.admin-main {
  flex: 1;
  padding: 20px;
  background-color: #f5f5f5;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
}

.admin-title {
  font-size: 24px;
  color: #333;
}

/* 表格样式 */
.table {
  width: 100%;
  border-collapse: collapse;
  background-color: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.table th,
.table td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid #ddd;
}

.table th {
  background-color: #f8f9fa;
  font-weight: 600;
}

.table tr:hover {
  background-color: #f8f9fa;
}

/* 操作按钮组 */
.action-buttons {
  display: flex;
  gap: 10px;
}

.action-btn {
  padding: 5px 10px;
  font-size: 14px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.3s;
}

.edit-btn {
  background-color: #28a745;
  color: #fff;
}

.edit-btn:hover {
  background-color: #218838;
}

.delete-btn {
  background-color: #dc3545;
  color: #fff;
}

.delete-btn:hover {
  background-color: #c82333;
}

/* 表单容器 */
.form-container {
  background-color: #fff;
  padding: 30px;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  max-width: 600px;
  margin: 0 auto;
}

.form-container h2 {
  margin-bottom: 20px;
  color: #333;
  text-align: center;
}

/* 成功/错误提示 */
.alert {
  padding: 15px;
  margin-bottom: 20px;
  border: 1px solid transparent;
  border-radius: 4px;
}

.alert-success {
  color: #155724;
  background-color: #d4edda;
  border-color: #c3e6cb;
}

.alert-error {
  color: #721c24;
  background-color: #f8d7da;
  border-color: #f5c6cb;
}

/* 加载状态 */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid #007bff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* 隐藏元素 */
.hidden {
  display: none;
}