* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: Arial, sans-serif;
  background-color: #f5f5f5;
  color: #333;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

h1 {
  text-align: center;
  margin-bottom: 20px;
  color: #2c3e50;
}

/* 登录区域 */
.login-area {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  padding: 15px;
  background-color: white;
  border-radius: 5px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

#userID {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 16px;
  flex: 1;
  max-width: 300px;
}

#userID:disabled {
  background-color: #f0f0f0;
  cursor: not-allowed;
}

button {
  padding: 8px 16px;
  background-color: #3498db;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 16px;
  cursor: pointer;
  transition: background-color 0.3s;
}

button:hover:not(:disabled) {
  background-color: #2980b9;
}

button:disabled {
  background-color: #bdc3c7;
  cursor: not-allowed;
}

/* 头部数据展示 */
.header-stats {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
  padding: 15px;
  background-color: white;
  border-radius: 5px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  flex-wrap: wrap;
  align-items: center;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.stat-label {
  font-weight: bold;
  color: #555;
}

.stat-value {
  font-size: 18px;
  color: #2c3e50;
  font-weight: bold;
}

/* 刷新区域样式 */
.refresh-area {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-left: auto;
}

.refresh-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 8px 16px;
  background-color: #95a5a6;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 16px;
  cursor: pointer;
  transition: background-color 0.3s;
}

.refresh-btn:hover:not(:disabled) {
  background-color: #7f8c8d;
}

.refresh-btn:disabled {
  background-color: #bdc3c7;
  cursor: not-allowed;
}

/* 刷新动画 */
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.refresh-icon.spinning {
  animation: spin 1s linear infinite;
}

/* 倒计时区域样式 */
.countdown-area {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 14px;
  color: #555;
}

.countdown-label {
  font-weight: bold;
}

.countdown-value {
  font-size: 16px;
  font-weight: bold;
  color: #3498db;
}

.countdown-unit {
  font-size: 14px;
  color: #7f8c8d;
}

/* 标签页样式 */
.tabs {
  margin-bottom: 20px;
  background-color: white;
  border-radius: 5px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.tab-buttons {
  display: flex;
  background-color: #f5f5f5;
  border-bottom: 1px solid #ddd;
}

.tab-btn {
  padding: 12px 20px;
  background-color: transparent;
  border: none;
  color: #555;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.3s;
  border-bottom: 2px solid transparent;
}

.tab-btn:hover {
  background-color: #e0e0e0;
}

.tab-btn.active {
  background-color: white;
  color: #3498db;
  border-bottom-color: #3498db;
  font-weight: bold;
}

.tab-content {
  padding: 20px;
  display: none;
}

.tab-content.active {
  display: block;
}

/* 表格容器 */
.table-container {
  background-color: white;
  border-radius: 5px;
  overflow: hidden;
}

/* 表格样式 */
table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th, td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid #ddd;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal; /* 允许换行 */
  word-wrap: break-word;
}

th {
  background-color: #f2f2f2;
  font-weight: bold;
  position: sticky;
  top: 0;
  z-index: 10;
  white-space: nowrap;
}

th:nth-child(1) {
  width: 22%; /* 商品名称宽度 */
}

th:nth-child(2) {
  width: 8%; /* 图片宽度 */
  text-align: center;
}

th:nth-child(3) {
  width: 8%; /* 库存宽度 */
  text-align: center;
}

th:nth-child(4),
th:nth-child(5),
th:nth-child(6) {
  width: 11%; /* 价格和涨幅宽度 */
}

th:nth-child(7) {
  width: 15%; /* 更新时间宽度 */
  text-align: center;
}

th:nth-child(8) {
  width: 10%; /* 操作宽度 */
  text-align: center;
}

td:nth-child(2),
td:nth-child(3),
td:nth-child(7) {
  text-align: center;
}

td:nth-child(8) {
  text-align: center;
}

td img {
  max-width: 50px;
  max-height: 50px;
  object-fit: contain;
  vertical-align: middle;
  margin: 0 auto;
  display: block;
}

/* 库存展示样式 */
.inventory-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 15px;
  padding: 10px;
}

.inventory-item {
  position: relative;
  background-color: #f5f5f5;
  border-radius: 5px;
  overflow: hidden;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  aspect-ratio: 3/4;
  display: flex;
  align-items: center;
  justify-content: center;
}

.inventory-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 10px;
  background-color: rgba(255, 255, 255, 0.8);
}

.inventory-item .price {
  position: absolute;
  top: 5px;
  right: 5px;
  background-color: rgba(255, 255, 255, 0.9);
  padding: 3px 6px;
  border-radius: 3px;
  font-size: 12px;
  font-weight: bold;
  color: #e74c3c;
}

.inventory-item .exterior {
  position: absolute;
  top: 5px;
  left: 5px;
  background-color: rgba(255, 255, 255, 0.9);
  padding: 3px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: bold;
  color: #3498db;
  text-align: center;
  min-width: 60px;
  word-break: break-all;
}

.delete-btn {
  background-color: #e74c3c;
  padding: 5px 10px;
  font-size: 14px;
}

.delete-btn:hover {
  background-color: #c0392b;
}

/* 弹窗样式 */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  overflow: auto;
}

.modal-content {
  background-color: white;
  margin: 15% auto;
  padding: 20px;
  border-radius: 5px;
  width: 90%;
  max-width: 500px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
  animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-50px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.close {
  color: #aaa;
  float: right;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
}

.close:hover {
  color: black;
}

.modal h2 {
  margin-bottom: 20px;
  color: #2c3e50;
}

/* 商品选择区域样式 */
.goods-selection {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 5px;
  flex-wrap: wrap;
}

.selected-info {
  flex: 1;
  padding: 8px 12px;
  background-color: #f5f5f5;
  border: 1px solid #ddd;
  border-radius: 4px;
  min-height: 38px;
  display: flex;
  align-items: center;
  font-size: 14px;
  color: #555;
}

.select-btn {
  padding: 8px 16px;
  background-color: #3498db;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}

.select-btn:hover {
  background-color: #2980b9;
}

/* 搜索区域样式 */
.search-area {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
  flex-wrap: wrap;
  align-items: center;
}

.search-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 16px;
  min-width: 200px;
}

.search-btn {
  padding: 8px 16px;
  background-color: #3498db;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}

.search-btn:hover {
  background-color: #2980b9;
}

.reset-btn {
  padding: 8px 16px;
  background-color: #95a5a6;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}

.reset-btn:hover {
  background-color: #7f8c8d;
}

/* 商品选择弹窗样式 */
.goods-modal-content {
  max-width: 800px;
  width: 95%;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.goods-table-container {
  flex: 1;
  overflow-y: auto;
  max-height: 500px;
  margin-top: 10px;
}

#goodsTable {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

#goodsTable th,
#goodsTable td {
  padding: 10px;
  text-align: left;
  border-bottom: 1px solid #ddd;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#goodsTable th {
  background-color: #f2f2f2;
  font-weight: bold;
  position: sticky;
  top: 0;
  z-index: 10;
  min-width: 100px;
}

#goodsTable th:nth-child(2) {
  width: 40%;
}

#goodsTable th:nth-child(3),
#goodsTable th:nth-child(4) {
  width: 15%;
}

#goodsTable th:nth-child(5) {
  width: 10%;
  text-align: center;
}

#goodsTable td:nth-child(5) {
  text-align: center;
}

.select-goods-btn {
  padding: 5px 10px;
  background-color: #2ecc71;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}

.select-goods-btn:hover {
  background-color: #27ae60;
}

/* 表单样式 */
.form-group {
  margin-bottom: 15px;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  font-weight: bold;
  color: #555;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 16px;
}

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .header-stats {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .login-area {
    flex-direction: column;
  }
  
  #userID {
    max-width: none;
  }
  
  .table-container {
    overflow-x: auto;
  }
  
  table {
    width: auto;
    min-width: 100%;
  }
}

/* 涨幅样式 */
.profit-up {
  color: #e74c3c; /* 红色 */
  font-weight: bold;
}

.profit-down {
  color: #2ecc71; /* 绿色 */
  font-weight: bold;
}

/* 表格性能优化 */
tr {
  transition: background-color 0.2s;
}

tr:hover {
  background-color: #f5f5f5;
}
