/* ============================================================
   公共 CSS 变量 & 组件样式
   所有页面共用，消除4个模板中的重复定义
   ============================================================ */

:root {
  --bg-main: #000000;
  --bg-panel: #1e1e1e;
  --bg-panel-soft: #242424;
  --bg-elevated: #2a2a2a;
  --border-soft: rgba(255, 255, 255, 0.06);
  --text-main: #ffffff;
  --text-dim: #a1a1a1;
  --text-soft: #666666;
  --accent-gold: #ffb11a;
  --accent-blue: #0052ff;
  --accent-green: #3fb950;
  --accent-red: #f85149;
  --shadow-main: 0 4px 12px rgba(0, 0, 0, 0.5);
}

body {
  background: var(--bg-main);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

a { color: inherit; text-decoration: none; }

/* ── 左侧导航栏 ─────────────────────────────────────────── */
.dashboard-body {
  display: flex;
  min-height: 100vh;
}

.dashboard-sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 200px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  z-index: 1030;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text-main);
  font-size: 0.98rem;
  font-weight: 600;
}

.sidebar-brand img {
  width: 28px;
  height: 28px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  display: flex;
  flex-direction: column;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: var(--text-dim);
  font-size: 0.88rem;
  font-weight: 500;
  transition: all 0.2s ease;
  border-left: 3px solid transparent;
}

.sidebar-nav-item i {
  font-size: 1.1rem;
}

.sidebar-nav-item:hover {
  color: var(--text-main);
  background: var(--bg-panel-soft);
}

.sidebar-nav-item.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
  border-left-color: var(--accent-blue);
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sidebar-footer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sidebar-admin {
  color: var(--accent-gold);
  font-size: 0.75rem;
  padding: 4px 10px;
  background: rgba(255, 177, 26, 0.1);
  border-radius: 4px;
  border: 1px solid rgba(255, 177, 26, 0.2);
}

.sidebar-logout {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #f0b7b7;
  font-size: 0.82rem;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 107, 107, 0.24);
  transition: all 0.2s ease;
}

.sidebar-logout:hover {
  background: rgba(255, 107, 107, 0.12);
  border-color: rgba(255, 107, 107, 0.34);
  color: #ffd8d8;
}

.sidebar-status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-dim);
  font-size: 0.78rem;
  padding: 8px 12px;
  background: var(--bg-panel-soft);
  border-radius: 6px;
}

.sidebar-status .status-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--accent-green);
}

.sidebar-account-selector {
  margin-bottom: 12px;
  max-height: 300px;
  overflow-y: auto;
}

.sidebar-account-selector .acc-tab {
  display: flex;
  flex-direction: column;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 0.78rem;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 4px;
  border: 1px solid transparent;
  position: relative;
}

.sidebar-account-selector .acc-tab:hover {
  background: var(--bg-panel-soft);
  color: var(--text-main);
}

.sidebar-account-selector .acc-tab.active {
  background: rgba(255,255,255,0.08);
  color: var(--text-main);
  border-color: var(--border-soft);
}

.sidebar-account-selector .acc-tab .status-dot-tab {
  margin-right: 6px;
}

.sidebar-account-selector .acc-tab .acc-tab-line1 {
  font-weight: 500;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  flex: 1;
}

.sidebar-account-selector .acc-tab .acc-tab-right {
  margin-left: auto;
  font-weight: 600;
  font-size: 0.78rem;
}

.sidebar-account-selector .acc-tab .acc-tab-line2 {
  font-size: 0.72rem;
  opacity: 0.85;
  padding-left: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.sidebar-account-selector .acc-tab .acc-tab-line2-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sidebar-account-selector .acc-tab .acc-tab-line2-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.sidebar-account-selector .acc-tab .acc-days-tag {
  display: inline-flex;
  align-items: center;
  gap: 0;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 1px 6px;
  font-size: 0.75rem;
  background: rgba(255,255,255,0.03);
  color: var(--text-dim);
}

/* ── 主内容区 ───────────────────────────────────────────── */
.dashboard-main {
  margin-left: 200px;
  flex: 1;
  min-height: 100vh;
  padding: 20px;
}

/* ── 顶部按钮 ───────────────────────────────────────────── */
.btn-topbar {
  border-radius: 8px; min-height: 32px;
  padding: 0.3rem 0.85rem; font-size: 0.8rem;
  background: transparent; transition: all 0.2s ease;
}
.btn-topbar.btn-outline-danger {
  color: #f0b7b7; border: 1px solid rgba(255,107,107,0.24);
}
.btn-topbar.btn-outline-danger:hover {
  background: rgba(255,107,107,0.12);
  border-color: rgba(255,107,107,0.34); color: #ffd8d8;
}
.btn-topbar.btn-outline-light {
  color: #e9dfca; border: 1px solid rgba(214,171,83,0.24);
}
.btn-topbar.btn-outline-light:hover {
  background: rgba(214,171,83,0.12);
  border-color: rgba(214,171,83,0.36); color: #fff3d7;
}

/* ── 表单控件 ───────────────────────────────────────────── */
.form-control, .form-select {
  background-color: rgba(12,15,21,0.98) !important;
  border-color: rgba(255,255,255,0.08) !important;
  color: var(--text-main) !important; border-radius: 10px;
}
.form-control:focus, .form-select:focus {
  border-color: rgba(214,171,83,0.45) !important;
  box-shadow: 0 0 0 0.2rem rgba(214,171,83,0.12) !important;
}
.form-label { color: var(--text-soft); font-size: 0.82rem; }

/* ── 按钮 ───────────────────────────────────────────────── */
.btn-primary {
  background: linear-gradient(180deg, #3d8bff, #2a6bcc);
  border-color: #2a6bcc; color: #fff;
}
.btn-primary:hover, .btn-primary:focus {
  background: linear-gradient(180deg, #5c9eff, #3d8bff);
  border-color: #3d8bff; color: #fff;
}

/* ── 卡片 ───────────────────────────────────────────────── */
.card {
  background: var(--bg-panel); border: 1px solid var(--border-soft);
  border-radius: 12px; box-shadow: var(--shadow-main);
  margin-bottom: 15px; overflow: hidden;
}
.card-header {
  background: var(--bg-panel-soft); border-bottom: 1px solid var(--border-soft);
  color: var(--text-main); font-weight: 500;
  padding: 12px 16px; font-size: 0.95rem;
}
.flat-section-card {
  background: var(--bg-panel); border: 1px solid var(--border-soft);
  border-radius: 8px;
}
.flat-section-header {
  background: var(--bg-panel-soft); border-bottom: 1px solid var(--border-soft);
  padding: 12px 14px;
  border-top-left-radius: 8px; border-top-right-radius: 8px;
}
.flat-section-title {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--text-main); font-weight: 500; font-size: 0.94rem;
}
.flat-section-title-muted { color: var(--text-dim); font-size: 0.78rem; font-weight: 500; }
.flat-count-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 28px; padding: 0 10px; border-radius: 4px;
  background: var(--bg-panel); border: 1px solid var(--border-soft);
  color: var(--text-dim); font-size: 0.78rem; font-weight: 500;
}

/* ── 表格 ───────────────────────────────────────────────── */
.table-dark {
  --bs-table-bg: transparent;
  --bs-table-border-color: var(--border-soft);
  background-color: transparent; color: var(--text-main);
}
.table-dark th {
  background-color: var(--bg-panel);
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--text-dim); font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.04em;
  font-size: 0.72rem; padding: 10px 8px;
}
.table-dark td {
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--text-main); padding: 8px;
}
.table-hover > tbody > tr:hover > * {
  --bs-table-bg-state: rgba(255,255,255,0.015);
  color: var(--text-main);
}

/* ── 颜色工具类 ─────────────────────────────────────────── */
.text-up   { color: var(--accent-green) !important; }
.text-down { color: var(--accent-red) !important; }
.text-muted { color: var(--text-dim) !important; }

/* ── 状态点动画 ─────────────────────────────────────────── */
@keyframes breathing-green {
  0%   { box-shadow: 0 0 0 0 rgba(16,185,129,0.4); }
  70%  { box-shadow: 0 0 0 4px rgba(16,185,129,0); }
  100% { box-shadow: 0 0 0 0 rgba(16,185,129,0); }
}
@keyframes breathing-red {
  0%   { box-shadow: 0 0 0 0 rgba(239,68,68,0.4); }
  70%  { box-shadow: 0 0 0 4px rgba(239,68,68,0); }
  100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); }
}
.status-dot-tab {
  width: 7px; height: 7px; border-radius: 999px;
  display: inline-block; margin-right: 6px; vertical-align: middle;
}
.status-dot-tab.status-normal        { background: var(--accent-green); }
.status-dot-tab.status-paused        { background: var(--accent-gold); }
.status-dot-tab.status-breathing-green { background: var(--accent-green); animation: breathing-green 2s infinite; }
.status-dot-tab.status-breathing-red  { background: var(--accent-red);   animation: breathing-red 2s infinite; }
.status-dot-tab.status-error          { background: var(--accent-red); }

/* ── Modal ──────────────────────────────────────────────── */
.modal-content {
  background: linear-gradient(180deg, rgba(13,17,23,0.98), rgba(8,10,15,0.98));
  border: 1px solid var(--border-soft);
}
.modal-header, .modal-footer { border-color: rgba(255,255,255,0.06); }

/* ── Toast ──────────────────────────────────────────────── */
#custom-toast-container {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  z-index: 9999; display: flex; flex-direction: column; gap: 10px;
  pointer-events: none;
}
.custom-toast {
  background-color: rgba(12,15,21,0.96); color: var(--text-main);
  border: 1px solid rgba(214,171,83,0.18); border-radius: 6px;
  padding: 12px 20px; box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  display: flex; align-items: center; gap: 10px;
  pointer-events: auto; backdrop-filter: blur(10px);
  animation: slideDown 0.3s ease forwards;
}
.custom-toast.success { border-left: 4px solid var(--accent-green); }
.custom-toast.error   { border-left: 4px solid var(--accent-red); }
.custom-toast.info    { border-left: 4px solid var(--accent-blue); }
@keyframes slideDown {
  from { transform: translateY(-20px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

/* ── 滚动条 ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }

/* ── 响应式 ─────────────────────────────────────────────── */
@media (max-width: 991.98px) {
  .dashboard-sidebar {
    width: 60px;
  }
  .sidebar-brand a,
  .sidebar-nav-item span,
  .sidebar-username,
  .sidebar-admin,
  .sidebar-logout span,
  .sidebar-status,
  .sidebar-account-selector {
    display: none;
  }
  .sidebar-brand {
    justify-content: center;
    padding: 16px;
  }
  .sidebar-nav-item {
    justify-content: center;
    padding: 12px;
  }
  .sidebar-logout {
    justify-content: center;
    padding: 8px;
  }
  .dashboard-main {
    margin-left: 60px;
  }
}
