/* 管理后台主题样式 - 现代化设计 */

:root {
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 70px;
  --topbar-height: 60px;
  --primary-color: #6366f1;
  --primary-hover: #4f46e5;
  --sidebar-bg: #1e1b4b;
  --sidebar-hover: rgba(255,255,255,0.1);
  --sidebar-active: rgba(99,102,241,0.3);
  --card-shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
  --transition-speed: 0.3s;
  /* 深色主题配色：与 base.html 的 data-bs-theme="dark" 保持一致 */
  --app-bg: #0f172a;
  --surface-bg: #1e293b;
  --surface-2: #172033;
  --surface-border: #334155;
  --text-primary: #e2e8f0;
  --text-muted: #94a3b8;
}

body {
  background-color: var(--app-bg);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* 侧边栏 */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: var(--sidebar-width);
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, #0f0a2e 100%);
  z-index: 1000;
  transition: all var(--transition-speed) ease;
  box-shadow: 4px 0 15px rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

.sidebar-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.sidebar-logo {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary-color), #a855f7);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: white;
  flex-shrink: 0;
}

.sidebar-logo i {
  font-size: 1.15rem;
  line-height: 1;
}

.sidebar-title {
  color: white;
  font-size: 1.1rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar.collapsed .sidebar-title,
.sidebar.collapsed .nav-text,
.sidebar.collapsed .nav-section-title {
  display: none;
}

.sidebar-nav {
  padding: 1rem 0;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
}

/* 折叠后窄条内居中图标，避免图标被挤出边界 */
.sidebar.collapsed .sidebar-header {
  padding: 1.25rem 0.5rem;
  justify-content: center;
}

.sidebar.collapsed .nav-item {
  margin: 0.25rem 0.5rem;
}

.sidebar.collapsed .nav-link {
  justify-content: center;
  padding: 0.75rem 0.5rem;
}

.sidebar-nav::-webkit-scrollbar {
  width: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.2);
  border-radius: 2px;
}

.nav-section-title {
  padding: 0.75rem 1.5rem 0.5rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.4);
  font-weight: 600;
}

.nav-item {
  margin: 0.25rem 0.75rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  color: rgba(255,255,255,0.7);
  border-radius: 8px;
  text-decoration: none;
  transition: all 0.2s ease;
}

.nav-link:hover {
  background: var(--sidebar-hover);
  color: white;
}

.nav-link.active {
  background: var(--sidebar-active);
  color: white;
}

.nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.8;
}

.nav-link.active .nav-icon,
.nav-link:hover .nav-icon {
  opacity: 1;
}

/* 主内容区 */
.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  transition: margin-left var(--transition-speed) ease;
}

.sidebar.collapsed ~ .main-content {
  margin-left: var(--sidebar-collapsed-width);
}

/* 顶部栏 */
.topbar {
  height: var(--topbar-height);
  background: var(--surface-bg);
  border-bottom: 1px solid var(--surface-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.toggle-sidebar {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 6px;
  color: var(--text-muted);
  transition: all 0.2s;
}

.toggle-sidebar:hover {
  background: rgba(255,255,255,0.08);
  color: var(--primary-color);
}

.page-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  text-decoration: none;
  color: #cbd5e1;
  transition: all 0.2s;
}

.user-menu:hover {
  background: rgba(255,255,255,0.08);
  color: var(--primary-color);
}

.user-avatar {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--primary-color), #a855f7);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 0.875rem;
}

/* 内容容器 */
.content-wrapper {
  padding: 2rem;
}

/* 卡片增强 */
.card {
  background-color: var(--surface-bg);
  border: none;
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px -5px rgba(0,0,0,0.1);
}

.card-header {
  background: transparent;
  border-bottom: 1px solid var(--surface-border);
  padding: 1.25rem 1.5rem;
  font-weight: 600;
}

/* 深色模式下的浅色信息面板（替代亮色的 bg-light） */
.surface-muted {
  background-color: var(--surface-2) !important;
  color: #cbd5e1 !important;
  border-color: var(--surface-border) !important;
}

/* 统计卡片 */
.stat-card {
  background: linear-gradient(135deg, var(--primary-color), #8b5cf6);
  color: white;
  border: none;
}

.stat-card.success {
  background: linear-gradient(135deg, #10b981, #059669);
}

.stat-card.dark {
  background: linear-gradient(135deg, #475569, #1e293b);
}

.stat-card.warning {
  background: linear-gradient(135deg, #f59e0b, #d97706);
}

.stat-card.info {
  background: linear-gradient(135deg, #06b6d4, #0891b2);
}

.stat-card .card-body {
  padding: 1.5rem;
}

.stat-card .card-title {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.stat-card .card-text {
  opacity: 0.9;
  font-size: 0.875rem;
  margin: 0;
}

/* 表格增强 */
.table {
  background: transparent;
  --bs-table-bg: transparent;
  --bs-table-color: var(--text-primary);
  border-radius: 12px;
  overflow: hidden;
}

.table thead th {
  background: var(--surface-2);
  border-bottom: 2px solid var(--surface-border);
  font-weight: 600;
  color: #cbd5e1;
  padding: 1rem 1.25rem;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.table tbody td {
  padding: 1rem 1.25rem;
  vertical-align: middle;
  border-bottom: 1px solid rgba(51,65,85,0.6);
}

.table tbody tr:hover {
  background: rgba(99,102,241,0.08);
}

/* 按钮增强 */
.btn {
  border-radius: 8px;
  padding: 0.5rem 1rem;
  font-weight: 500;
  transition: all 0.2s;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-color), #8b5cf6);
  border: none;
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-hover), #7c3aed);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99,102,241,0.3);
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
}

/* 统一按钮文字为白色：warning / info 默认是黑字，这里连底色一并压深以保证对比度 */
.btn-warning,
.btn-info {
  --bs-btn-color: #fff;
  --bs-btn-hover-color: #fff;
  --bs-btn-active-color: #fff;
  --bs-btn-disabled-color: #fff;
}

.btn-warning {
  --bs-btn-bg: #b45309;
  --bs-btn-border-color: #b45309;
  --bs-btn-hover-bg: #92400e;
  --bs-btn-hover-border-color: #92400e;
  --bs-btn-active-bg: #92400e;
  --bs-btn-active-border-color: #92400e;
  --bs-btn-disabled-bg: #92400e;
  --bs-btn-disabled-border-color: #92400e;
}

.btn-info {
  --bs-btn-bg: #0e7490;
  --bs-btn-border-color: #0e7490;
  --bs-btn-hover-bg: #155e75;
  --bs-btn-hover-border-color: #155e75;
  --bs-btn-active-bg: #155e75;
  --bs-btn-active-border-color: #155e75;
  --bs-btn-disabled-bg: #155e75;
  --bs-btn-disabled-border-color: #155e75;
}

/* 徽章增强 */
.badge {
  padding: 0.375rem 0.75rem;
  border-radius: 20px;
  font-weight: 500;
}

/* 日志框 */
.log-box {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 12px;
  color: #e2e8f0;
  font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
  font-size: 13px;
  min-height: 360px;
  max-height: 640px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  padding: 1rem;
}

/* 表单增强 */
.form-control, .form-select {
  border-radius: 8px;
  border: 1px solid var(--surface-border);
  padding: 0.625rem 0.875rem;
  transition: all 0.2s;
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}

.form-label {
  font-weight: 500;
  color: #cbd5e1;
  margin-bottom: 0.5rem;
}

/* 警告和通知 */
.alert {
  border: none;
  border-radius: 10px;
  padding: 1rem 1.25rem;
}

/* 响应式 */
@media (max-width: 992px) {
  .sidebar {
    transform: translateX(-100%);
  }
  
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  
  .main-content {
    margin-left: 0;
  }
  
  .content-wrapper {
    padding: 1rem;
  }
  
  .topbar {
    padding: 0 1rem;
  }

  .topbar-left {
    min-width: 0;
  }

  .page-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .table-responsive {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  .table {
    min-width: 680px;
  }

  .table th,
  .table td {
    white-space: nowrap;
  }
}

/* 移动端菜单按钮 */
.mobile-menu-btn {
  display: none;
}

@media (max-width: 992px) {
  .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

@media (max-width: 576px) {
  :root {
    --topbar-height: 54px;
  }

  .content-wrapper {
    padding: 0.75rem;
  }

  .topbar {
    padding: 0 0.5rem;
    gap: 0.25rem;
  }

  .topbar-left,
  .topbar-right {
    gap: 0.25rem;
  }

  .toggle-sidebar {
    display: none;
  }

  .mobile-menu-btn {
    padding: 0.35rem 0.5rem;
  }

  .page-title {
    font-size: 1rem;
  }

  .user-menu {
    padding: 0.25rem;
  }

  .user-avatar {
    width: 28px;
    height: 28px;
    font-size: 0.75rem;
  }

  .card {
    border-radius: 8px;
  }

  .card-header,
  .card-body {
    padding: 0.75rem;
  }

  .card-body.p-0 {
    padding: 0;
  }

  .btn {
    min-height: 38px;
    padding: 0.5rem 0.75rem;
  }

  .btn-sm {
    min-height: 34px;
    padding: 0.35rem 0.6rem;
  }

  .row.g-4 {
    --bs-gutter-y: 1rem;
  }

  .form-control,
  .form-select {
    font-size: 16px;
  }

  .table {
    min-width: 620px;
    font-size: 0.875rem;
  }

  .table thead th,
  .table tbody td {
    padding: 0.65rem 0.75rem;
  }

  .table-responsive {
    border-radius: 8px;
  }

  .alert {
    padding: 0.75rem;
  }

  .log-box {
    min-height: 260px;
    max-height: 55vh;
    font-size: 12px;
    padding: 0.75rem;
  }
}

/* 滚动条美化 */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--app-bg);
}

::-webkit-scrollbar-thumb {
  background: var(--surface-border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #475569;
}
