/* ========================================
   通用样式文件
   ======================================== */

:root {
  /* 主题色 */
  --primary-color: #1890ff;
  --success-color: #52c41a;
  --warning-color: #faad14;
  --danger-color: #ff4d4f;
  --info-color: #13c2c2;
  
  /* 中性色 */
  --text-primary: #262626;
  --text-secondary: #595959;
  --text-disabled: #bfbfbf;
  --border-color: #d9d9d9;
  --bg-color: #f0f2f5;
  --bg-white: #ffffff;
  
  /* 阴影 */
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  
  /* 圆角 */
  --border-radius-sm: 4px;
  --border-radius-md: 8px;
  --border-radius-lg: 12px;
  
  /* 间距 */
  --spacing-xs: 8px;
  --spacing-sm: 12px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
    'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background-color: var(--bg-color);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ========================================
   布局
   ======================================== */

.layout {
  display: flex;
  min-height: 100vh;
}

/* 侧边栏 */
.sidebar {
  width: 200px;
  background: #001529;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-logo {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
}

.sidebar-logo h1 {
  color: white;
  font-size: 18px;
  font-weight: bold;
  margin: 0;
}

/* 菜单 */
.menu {
  list-style: none;
  padding: 0;
  margin: 0;
}

.menu-item {
  position: relative;
}

.menu-item a {
  display: flex;
  align-items: center;
  padding: 14px 24px;
  color: rgba(255, 255, 255, 0.65);
  text-decoration: none;
  transition: all 0.3s;
}

.menu-item a:hover {
  color: white;
  background: rgba(255, 255, 255, 0.08);
}

.menu-item.active a {
  color: white;
  background: var(--primary-color);
}

.menu-item a > i {
  margin-right: 10px;
  font-size: 16px;
  width: 16px;
  text-align: center;
  display: inline-block;
}

.menu-submenu-title > div > i {
  margin-right: 10px;
  font-size: 16px;
  width: 16px;
  text-align: center;
  display: inline-block;
}

.menu-submenu-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  color: rgba(255, 255, 255, 0.65);
  cursor: pointer;
  transition: all 0.3s;
}

.menu-submenu-title:hover {
  color: white;
  background: rgba(255, 255, 255, 0.08);
}

.menu-submenu-content {
  background: rgba(0, 0, 0, 0.3);
  display: none;
}

.menu-submenu.open .menu-submenu-content {
  display: block;
}

.menu-submenu-content .menu-item a {
  padding-left: 48px;
}

/* 主内容区 */
.main-content {
  flex: 1;
  margin-left: 200px;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
}

/* 顶部栏 */
.header {
  height: 64px;
  background: white;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--spacing-lg);
  position: sticky;
  top: 0;
  z-index: 99;
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--spacing-lg);
}

.user-info {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  cursor: pointer;
  padding: 8px 12px;
  border-radius: var(--border-radius-sm);
  transition: background 0.3s;
}

.user-info:hover {
  background: var(--bg-color);
}

/* 通知中心 */
.notification-center {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.notification-bell {
  font-size: 18px;
  line-height: 1;
  color: var(--text-secondary);
}

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

.notification-badge {
  position: absolute;
  top: -4px;
  right: -6px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--danger-color);
  color: white;
  font-size: 10px;
  line-height: 16px;
  text-align: center;
}

.notification-panel {
  position: absolute;
  top: 28px;
  right: 0;
  width: 320px;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-md);
  display: none;
  z-index: 1000;
}

.notification-panel.open {
  display: block;
}

.notification-panel-header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
  font-size: 13px;
}

.notification-panel-body {
  max-height: 320px;
  overflow-y: auto;
}

.notification-item {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color);
}

.notification-item:last-child {
  border-bottom: none;
}

.notification-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
}

.notification-message {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.notification-time {
  font-size: 11px;
  color: var(--text-disabled);
}

.notification-empty {
  padding: 24px 12px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 12px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-color);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: bold;
}

/* 内容区域 */
.content {
  flex: 1;
  padding: var(--spacing-lg);
  min-height: calc(100vh - 64px);
}

/* 面包屑 */
.breadcrumb {
  margin-bottom: var(--spacing-lg);
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 14px;
}

.breadcrumb-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.breadcrumb-separator {
  color: var(--text-disabled);
}

/* ========================================
   卡片
   ======================================== */

.card {
  background: white;
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--spacing-lg);
  overflow: hidden;
}

.card-header {
  padding: var(--spacing-md) var(--spacing-lg);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.card-body {
  padding: var(--spacing-md);
}

.card-body.compact {
  padding: var(--spacing-sm);
}

/* ========================================
   表格
   ======================================== */

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--spacing-md);
  gap: var(--spacing-md);
  flex-wrap: wrap;
}

.table-toolbar-left,
.table-toolbar-right {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.table-container {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: white;
}

thead {
  background: var(--bg-color);
}

th {
  padding: 8px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  border-bottom: 2px solid var(--border-color);
  font-size: 13px;
}

td {
  padding: 8px 12px;
  border-bottom: 1px solid #f0f0f0;
  color: var(--text-secondary);
  font-size: 13px;
}

tr:hover td {
  background: #fafafa;
}

.table-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
}

.table-actions .btn {
  min-width: 80px;
  justify-content: center;
}

/* ========================================
   表单
   ======================================== */

.form {
  max-width: 800px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-md);
}

.form-group {
  margin-bottom: var(--spacing-md);
}

.form-label {
  display: block;
  margin-bottom: 8px;
  color: var(--text-primary);
  font-weight: 500;
}

.form-label.required::after {
  content: '*';
  color: var(--danger-color);
  margin-left: 4px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  font-size: 14px;
  transition: all 0.3s;
  outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.1);
}

.form-input:disabled,
.form-select:disabled,
.form-textarea:disabled {
  background: #f5f5f5;
  cursor: not-allowed;
}

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

.form-help {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-secondary);
}

.form-error {
  margin-top: 4px;
  font-size: 12px;
  color: var(--danger-color);
}

/* ========================================
   按钮
   ======================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 14px;
  border: 1px solid transparent;
  border-radius: var(--border-radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s;
  text-decoration: none;
  outline: none;
  white-space: nowrap;
}

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

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

.btn-primary:hover:not(:disabled) {
  background: #40a9ff;
}

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

.btn-success:hover:not(:disabled) {
  background: #73d13d;
}

.btn-warning {
  background: var(--warning-color);
  color: white;
}

.btn-warning:hover:not(:disabled) {
  background: #ffc53d;
}

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

.btn-danger:hover:not(:disabled) {
  background: #ff7875;
}

.btn-default {
  background: white;
  color: var(--text-primary);
  border-color: var(--border-color);
}

.btn-default:hover:not(:disabled) {
  color: var(--primary-color);
  border-color: var(--primary-color);
}

.btn-link {
  background: transparent;
  color: var(--primary-color);
  border: none;
  padding: 0;
}

.btn-link:hover:not(:disabled) {
  color: #40a9ff;
}

.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
}

.btn-lg {
  padding: 12px 24px;
  font-size: 16px;
}

/* ========================================
   徽章
   ======================================== */

.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 12px;
  border-radius: 10px;
  font-weight: 500;
  white-space: nowrap;
}

.badge-primary {
  background: #e6f7ff;
  color: var(--primary-color);
}

.badge-success {
  background: #f6ffed;
  color: var(--success-color);
}

.badge-warning {
  background: #fffbe6;
  color: var(--warning-color);
}

.badge-danger {
  background: #fff2f0;
  color: var(--danger-color);
}

.badge-info {
  background: #e6fffb;
  color: var(--info-color);
}

.badge-default {
  background: #fafafa;
  color: var(--text-secondary);
}

/* ========================================
   统计卡片
   ======================================== */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-md);
}

.stat-card {
  background: white;
  border-radius: var(--border-radius-md);
  padding: var(--spacing-md);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  transition: all 0.3s;
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--border-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

    .stat-icon.primary {
      background: linear-gradient(135deg, #1890ff 0%, #096dd9 100%);
      color: white;
    }

.stat-icon.success {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  color: white;
}

.stat-icon.warning {
  background: linear-gradient(135deg, #ffa751 0%, #ffe259 100%);
  color: white;
}

.stat-icon.info {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  color: white;
}

.stat-content {
  flex: 1;
}

.stat-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.stat-value {
  font-size: 20px;
  font-weight: bold;
  color: var(--text-primary);
  margin-bottom: 2px;
  line-height: 1.2;
}

.stat-trend {
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.stat-trend.up {
  color: var(--success-color);
}

.stat-trend.down {
  color: var(--danger-color);
}

/* ========================================
   分页
   ======================================== */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: var(--spacing-lg);
  padding: var(--spacing-md) 0;
}

.pagination-item {
  min-width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  background: white;
  cursor: pointer;
  transition: all 0.3s;
  text-decoration: none;
  color: var(--text-primary);
  padding: 0 8px;
}

.pagination-item:hover {
  color: var(--primary-color);
  border-color: var(--primary-color);
}

.pagination-item.active {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

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

/* ========================================
   模态框
   ======================================== */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.3s;
}

.modal {
  background: white;
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-lg);
  max-width: 90%;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: slideDown 0.3s;
}

.modal-header {
  padding: var(--spacing-md) var(--spacing-lg);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 20px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--border-radius-sm);
  transition: all 0.3s;
}

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

.modal-body {
  padding: var(--spacing-lg);
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: var(--spacing-md) var(--spacing-lg);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--spacing-sm);
}

/* ========================================
   消息提示
   ======================================== */

.message {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  min-width: 300px;
  max-width: 500px;
  padding: 12px 20px;
  border-radius: var(--border-radius-sm);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slideDown 0.3s;
}

.message-success {
  background: white;
  border: 1px solid #b7eb8f;
}

.message-error {
  background: white;
  border: 1px solid #ffa39e;
}

.message-warning {
  background: white;
  border: 1px solid #ffe58f;
}

.message-info {
  background: white;
  border: 1px solid #91d5ff;
}

.message-icon {
  font-size: 18px;
}

.message-success .message-icon {
  color: var(--success-color);
}

.message-error .message-icon {
  color: var(--danger-color);
}

.message-warning .message-icon {
  color: var(--warning-color);
}

.message-info .message-icon {
  color: var(--primary-color);
}

/* ========================================
   开关
   ======================================== */

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 22px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.25);
  transition: 0.3s;
  border-radius: 22px;
}

.switch-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
}

.switch input:checked + .switch-slider {
  background-color: var(--primary-color);
}

.switch input:checked + .switch-slider:before {
  transform: translateX(22px);
}

/* ========================================
   空状态
   ======================================== */

.empty-state {
  text-align: center;
  padding: var(--spacing-xl) var(--spacing-lg);
  color: var(--text-secondary);
}

.empty-icon {
  font-size: 64px;
  color: var(--text-disabled);
  margin-bottom: var(--spacing-md);
}

.empty-text {
  font-size: 14px;
}

/* ========================================
   加载中
   ======================================== */

.loading {
  text-align: center;
  padding: var(--spacing-xl) var(--spacing-lg);
}

.spinner {
  border: 3px solid var(--border-color);
  border-top: 3px solid var(--primary-color);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 0 auto var(--spacing-md);
}

/* ========================================
   工具类
   ======================================== */

.text-primary { color: var(--primary-color) !important; }
.text-success { color: var(--success-color) !important; }
.text-warning { color: var(--warning-color) !important; }
.text-danger { color: var(--danger-color) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-disabled { color: var(--text-disabled) !important; }

.text-center { text-align: center !important; }
.text-left { text-align: left !important; }
.text-right { text-align: right !important; }

.font-bold { font-weight: bold !important; }
.font-normal { font-weight: normal !important; }

.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: var(--spacing-xs) !important; }
.mt-2 { margin-top: var(--spacing-sm) !important; }
.mt-3 { margin-top: var(--spacing-md) !important; }
.mt-4 { margin-top: var(--spacing-lg) !important; }

.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: var(--spacing-xs) !important; }
.mb-2 { margin-bottom: var(--spacing-sm) !important; }
.mb-3 { margin-bottom: var(--spacing-md) !important; }
.mb-4 { margin-bottom: var(--spacing-lg) !important; }

.p-0 { padding: 0 !important; }
.p-1 { padding: var(--spacing-xs) !important; }
.p-2 { padding: var(--spacing-sm) !important; }
.p-3 { padding: var(--spacing-md) !important; }
.p-4 { padding: var(--spacing-lg) !important; }

.d-flex { display: flex !important; }
.d-inline-flex { display: inline-flex !important; }
.d-block { display: block !important; }
.d-inline-block { display: inline-block !important; }
.d-none { display: none !important; }

.flex-1 { flex: 1 !important; }
.gap-1 { gap: var(--spacing-xs) !important; }
.gap-2 { gap: var(--spacing-sm) !important; }
.gap-3 { gap: var(--spacing-md) !important; }

.align-center { align-items: center !important; }
.justify-center { justify-content: center !important; }
.justify-between { justify-content: space-between !important; }

/* ========================================
   动画
   ======================================== */

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ========================================
   响应式
   ======================================== */

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s;
  }
  
  .sidebar.open {
    transform: translateX(0);
  }
  
  .main-content {
    margin-left: 0;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  .form-row {
    grid-template-columns: 1fr;
  }
  
  .table-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
}
