/* main.css - 棋牌室 PC 后台 · 紫渐变主题 */
*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  font-size: 14px; color: #1f2937;
  background: #f3f4f6;
  height: 100%;
}
a { color: #6b5fff; text-decoration: none; }
code { background: #f3f4f6; padding: 2px 6px; border-radius: 4px; font-size: 12px; color: #be185d; }
button { font-family: inherit; font-size: 14px; cursor: pointer; }
input, select, textarea {
  font-family: inherit; font-size: 14px;
  border: 1px solid #d1d5db; border-radius: 6px; padding: 8px 10px;
  background: #fff; color: #1f2937; outline: none;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: #6b5fff; }

/* ========== 整体布局 ========== */
.layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

/* ========== 左侧栏 ========== */
.sidebar {
  background: linear-gradient(180deg, #1f1d4d 0%, #2a2772 100%);
  color: #e5e7eb;
  padding: 18px 0;
  position: sticky; top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar .brand {
  padding: 4px 20px 20px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  margin-bottom: 12px;
}
.sidebar .brand-logo {
  font-size: 24px;
}
.sidebar .brand-name {
  font-size: 16px; font-weight: 700;
  letter-spacing: 1px;
}
.sidebar .brand-sub {
  font-size: 11px; color: rgba(229,231,235,.6);
  margin-top: 2px;
}
.nav { display: flex; flex-direction: column; gap: 2px; padding: 0 8px; }
.nav-group-title {
  font-size: 11px; color: rgba(229,231,235,.4);
  padding: 16px 12px 6px; letter-spacing: 1px; text-transform: uppercase;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 6px;
  color: rgba(229,231,235,.85);
  font-size: 14px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active {
  background: linear-gradient(90deg, rgba(107,95,255,.25), rgba(107,95,255,.05));
  color: #fff; font-weight: 600;
  box-shadow: inset 3px 0 0 #6b5fff;
}
.nav-icon { font-size: 18px; width: 22px; text-align: center; }
.nav-super {
  margin-left: auto;
  font-size: 9px; padding: 1px 6px; border-radius: 8px;
  background: linear-gradient(135deg,#f59e0b,#ef4444);
  color: #fff; font-weight: 700; letter-spacing: 0.5px;
}

/* ========== 主体 ========== */
.main {
  display: flex; flex-direction: column;
  min-width: 0;
}
.topbar {
  background: #fff;
  padding: 0 24px;
  height: 56px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid #e5e7eb;
  position: sticky; top: 0; z-index: 10;
}
.topbar-title { font-size: 15px; font-weight: 600; color: #1f2937; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-chip-wrap { position: relative; }
.user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 12px 4px 4px; border-radius: 20px;
  background: #f3f4f6;
  cursor: pointer;
  user-select: none;
  transition: background .15s;
}
.user-chip:hover { background: #e5e7eb; }
.user-chip.open { background: #e5e7eb; }
.user-caret { font-size: 10px; color: #6b7280; margin-left: 2px; }
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, #6b5fff, #ec4899);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.user-name { font-size: 13px; font-weight: 500; }
.user-role {
  font-size: 10px; padding: 1px 6px; border-radius: 8px;
  background: #dbeafe; color: #1d4ed8;
}
.user-role.super {
  background: linear-gradient(135deg,#f59e0b,#ef4444);
  color: #fff;
}

/* 用户胶囊下拉菜单 */
.user-menu {
  position: absolute; top: calc(100% + 8px); right: 0;
  min-width: 180px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  padding: 4px;
  z-index: 100;
}
.user-menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  color: #1f2937;
  cursor: pointer;
  transition: background .12s;
}
.user-menu-item:hover { background: #f3f4f6; }
.user-menu-item.danger { color: #dc2626; }
.user-menu-item.danger:hover { background: #fef2f2; }
.user-menu-icon { width: 18px; text-align: center; font-size: 14px; }
.user-menu-divider { height: 1px; background: #e5e7eb; margin: 4px 6px; }

/* 修改密码表单 */
.form-row { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.form-row .label {
  width: 88px; flex-shrink: 0;
  font-size: 13px; color: #6b7280; padding-top: 8px;
}
.form-row .field { flex: 1; }
.form-row input {
  width: 100%; padding: 8px 12px;
  border: 1px solid #d1d5db; border-radius: 6px;
  font-size: 14px;
  box-sizing: border-box;
}
.form-row input:focus { outline: none; border-color: #6b5fff; box-shadow: 0 0 0 3px rgba(107,95,255,.12); }
.form-hint { font-size: 12px; color: #9ca3af; padding-left: 100px; margin-top: -4px; margin-bottom: 8px; }

.content {
  padding: 24px;
  flex: 1;
  min-width: 0;
}
.page-loading {
  text-align: center; padding: 60px 0; color: #6b7280;
}
.empty-state {
  text-align: center; padding: 80px 0;
}
.empty-icon { font-size: 56px; opacity: .5; }
.empty-text { color: #6b7280; margin-top: 12px; }

/* ========== 通用控件 ========== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 16px; border-radius: 6px;
  font-size: 13px; font-weight: 500;
  border: 1px solid transparent;
  transition: all .15s;
  background: #f3f4f6; color: #374151;
  cursor: pointer;
}
.btn:hover { background: #e5e7eb; }
.btn.primary { background: linear-gradient(135deg, #6b5fff, #8b5cf6); color: #fff; border: none; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger { background: #ef4444; color: #fff; border: none; }
.btn.danger:hover { background: #dc2626; }
.btn.ghost { background: transparent; color: #6b5fff; border-color: #6b5fff; }
.btn.ghost:hover { background: #eef2ff; }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn.lg { padding: 10px 24px; font-size: 14px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.link { color: #6b5fff; cursor: pointer; }
.link:hover { text-decoration: underline; }
.link.danger { color: #ef4444; }

/* ========== 页面通用 ========== */
.page-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.page-title { font-size: 20px; font-weight: 700; color: #1f2937; margin: 0; }
.page-sub { color: #6b7280; font-size: 13px; margin-top: 4px; }
.page-tools { display: flex; align-items: center; gap: 8px; }

.card {
  background: #fff; border-radius: 10px;
  padding: 18px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
  margin-bottom: 16px;
}
.card-title {
  font-size: 14px; font-weight: 600; color: #1f2937;
  margin: 0 0 12px;
  display: flex; align-items: center; justify-content: space-between;
}
.card-title .more { color: #6b5fff; font-size: 12px; cursor: pointer; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1200px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 800px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* ========== 指标卡 ========== */
.metric-card {
  background: #fff;
  border-radius: 10px;
  padding: 18px 20px;
  display: flex; align-items: center; gap: 16px;
  position: relative; overflow: hidden;
}
.metric-card.primary { background: linear-gradient(135deg, #4a3aef, #3a2bd0); color: #fff; }
.metric-card.primary .metric-label { color: rgba(255,255,255,.8); }
.metric-card.primary .metric-icon { background: rgba(255,255,255,.18); color: #fff; }
.metric-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  background: #eef2ff; color: #6b5fff;
}
.metric-body { flex: 1; min-width: 0; }
.metric-value { font-size: 24px; font-weight: 700; line-height: 1.1; }
.metric-label { font-size: 12px; color: #6b7280; margin-top: 4px; }

/* ========== 表格 ========== */
.table-wrap { background: #fff; border-radius: 10px; overflow: hidden; }
.table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.table th {
  background: #f9fafb; text-align: left;
  padding: 10px 14px; font-weight: 600; color: #4b5563;
  border-bottom: 1px solid #e5e7eb;
}
.table td {
  padding: 12px 14px;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #f9fafb; }
.table .num { font-variant-numeric: tabular-nums; }

/* ========== 状态 chip ========== */
.chip {
  display: inline-flex; align-items: center;
  padding: 2px 9px; border-radius: 12px;
  font-size: 11px; font-weight: 500;
  background: #f3f4f6; color: #4b5563;
}
.chip.success { background: #dcfce7; color: #166534; }
.chip.warn { background: #fef3c7; color: #92400e; }
.chip.danger { background: #fee2e2; color: #991b1b; }
.chip.info { background: #dbeafe; color: #1e40af; }
.chip.muted { background: #f3f4f6; color: #6b7280; }

/* ========== Tab ========== */
.tabs {
  display: flex; align-items: center; gap: 4px;
  background: #fff; padding: 6px; border-radius: 10px;
  margin-bottom: 16px;
  width: fit-content;
}
.tab {
  padding: 7px 16px; border-radius: 6px;
  font-size: 13px; color: #4b5563;
  cursor: pointer; transition: all .15s;
}
.tab:hover { background: #f3f4f6; }
.tab.active {
  background: linear-gradient(135deg, #6b5fff, #8b5cf6);
  color: #fff; font-weight: 500;
}
.tab .badge {
  display: inline-block;
  margin-left: 4px; padding: 0 6px; border-radius: 8px;
  font-size: 11px; background: #e5e7eb; color: #4b5563;
}
.tab.active .badge { background: rgba(255,255,255,.25); color: #fff; }

/* ========== 搜索栏 ========== */
.toolbar {
  background: #fff; border-radius: 10px;
  padding: 14px 16px; margin-bottom: 16px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.toolbar .field {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: #4b5563;
}
.toolbar .field input, .toolbar .field select {
  padding: 6px 10px; min-width: 140px;
}

/* ========== Modal ========== */
.modal-wrap, .drawer-wrap {
  position: fixed; inset: 0; z-index: 9000;
  display: flex; align-items: center; justify-content: center;
  animation: fadein .15s ease;
}
.modal-mask, .drawer-mask {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.45);
}
.modal-box {
  position: relative;
  background: #fff; border-radius: 10px;
  min-width: 480px; max-width: 90vw; max-height: 90vh;
  display: flex; flex-direction: column;
  box-shadow: 0 20px 50px rgba(0,0,0,.2);
  animation: modal-in .2s ease;
}
.modal-head, .drawer-head {
  padding: 14px 20px; border-bottom: 1px solid #e5e7eb;
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 600;
}
.modal-close, .drawer-close {
  font-size: 24px; color: #9ca3af; cursor: pointer; line-height: 1;
}
.modal-close:hover, .drawer-close:hover { color: #1f2937; }
.modal-body, .drawer-body {
  padding: 18px 20px;
  overflow-y: auto;
  flex: 1;
}
.modal-foot {
  padding: 12px 20px; border-top: 1px solid #e5e7eb;
  display: flex; justify-content: flex-end; gap: 8px;
}

/* ========== Drawer ========== */
.drawer-wrap { justify-content: flex-end; }
.drawer-box {
  position: relative; height: 100%;
  background: #fff;
  display: flex; flex-direction: column;
  animation: drawer-in .2s ease;
}

/* ========== Form ========== */
.form { display: grid; gap: 14px; }
.form-row { display: grid; grid-template-columns: 110px 1fr; align-items: center; gap: 12px; }
.form-row .label { font-size: 13px; color: #4b5563; text-align: right; }
.form-row .field { display: flex; gap: 6px; align-items: center; }
.form-row input, .form-row select, .form-row textarea { width: 100%; }
.form-row textarea { min-height: 72px; resize: vertical; }
.form-hint { font-size: 12px; color: #9ca3af; margin-top: 4px; }

/* ========== Loading ========== */
.loading-wrap {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
}
.loading-mask { position: absolute; inset: 0; background: rgba(255,255,255,.6); }
.loading-box {
  position: relative;
  background: #fff; border-radius: 10px;
  padding: 24px 32px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.1);
}
.loading-spinner {
  width: 32px; height: 32px;
  border: 3px solid #e5e7eb; border-top-color: #6b5fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.loading-text { font-size: 13px; color: #4b5563; }

/* ========== 动画 ========== */
@keyframes fadein { from { opacity: 0 } to { opacity: 1 } }
@keyframes modal-in {
  from { transform: translateY(-12px) scale(.96); opacity: 0 }
  to { transform: none; opacity: 1 }
}
@keyframes drawer-in { from { transform: translateX(40px) } to { transform: none } }
@keyframes spin { to { transform: rotate(360deg) } }
@keyframes toast-in { from { transform: translateY(-12px); opacity: 0 } to { transform: none; opacity: 1 } }

/* ========== 趋势柱状图 ========== */
.trend-chart { display: flex; align-items: flex-end; gap: 12px; height: 160px; padding: 16px 0; }
.trend-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.trend-bar {
  width: 100%; max-width: 32px;
  background: linear-gradient(180deg, #8b5cf6, #6b5fff);
  border-radius: 4px 4px 0 0;
  min-height: 4px;
  transition: all .2s;
}
.trend-bar:hover { filter: brightness(1.1); }
.trend-val { font-size: 11px; color: #4b5563; }
.trend-date { font-size: 11px; color: #9ca3af; }

/* ========== 房间状态格子 ========== */
.room-grid {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}
.room-cell {
  background: #f9fafb;
  border-radius: 8px;
  padding: 12px;
  border-left: 4px solid #9ca3af;
}
.room-cell.idle { border-left-color: #16a34a; }
.room-cell.booked { border-left-color: #2563eb; }
.room-cell.in_use { border-left-color: #ea580c; }
.room-cell.offline { border-left-color: #9ca3af; opacity: .7; }
.room-cell.fault { border-left-color: #dc2626; }
.room-cell .name { font-weight: 600; font-size: 14px; color: #1f2937; }
.room-cell .status { font-size: 11px; color: #6b7280; margin-top: 4px; }

/* ========== Login 页 ========== */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #6b5fff 0%, #ec4899 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-box {
  background: #fff; border-radius: 16px;
  padding: 40px;
  width: 100%; max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.login-logo {
  text-align: center; font-size: 48px; margin-bottom: 8px;
}
.login-title {
  text-align: center;
  font-size: 22px; font-weight: 700;
  background: linear-gradient(135deg, #6b5fff, #ec4899);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.login-sub {
  text-align: center; color: #6b7280; font-size: 13px;
  margin-top: 6px; margin-bottom: 28px;
}
.login-form .form-row { grid-template-columns: 1fr; }
.login-form .btn { width: 100%; padding: 12px; font-size: 14px; }
