/* ===== 用户管理模块 - WB Brand Design System ===== */
/* 与 iot-dashboard.css 统一设计语言 */

:root {
  --wb-primary: #2563EB;
  --wb-primary-light: #3B82F6;
  --wb-accent: #06B6D4;
  --wb-success: #10B981;
  --wb-warning: #F59E0B;
  --wb-danger: #EF4444;
  --wb-purple: #8B5CF6;
  --wb-text: #1E293B;
  --wb-text-muted: #64748B;
  --wb-text-light: #94A3B8;
  --wb-bg: #F1F5F9;
  --wb-surface: #FFFFFF;
  --wb-border: #E2E8F0;
  --wb-r: 10px;
  --wb-r-lg: 14px;
  --wb-r-sm: 6px;
  --wb-shadow-sm: 0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.03);
  --wb-shadow-md: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --wb-shadow-lg: 0 12px 32px rgba(0,0,0,0.1);
}

/* ===== 布局 ===== */
.layout {
  display: flex;
  min-height: 100vh;
  background: var(--wb-bg);
}

/* ===== 侧边栏（与 IoT 统一）===== */
.sidebar {
  width: 160px;
  background: var(--wb-surface);
  border-right: 1px solid var(--wb-border-light);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 10;
  box-shadow: 2px 0 12px rgba(0,0,0,.03);
}

.sidebar-header {
  padding: 22px 20px;
  border-bottom: 1px solid var(--wb-border-light);
}

.sidebar-welcome {
  font-size: 12px;
  color: var(--wb-text-secondary);
  text-align: center;
  margin-bottom: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.brand-logo {
  width: 42px;
  height: 42px;
  object-fit: contain;
  vertical-align: middle;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.08));
}

.brand-text {
  font-size: 15px;
  font-weight: 700;
  color: var(--wb-text);
  letter-spacing: -.02em;
}

.nav-menu {
  flex: 1;
  padding: 14px 12px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--wb-r-sm);
  color: var(--wb-text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 3px;
  transition: all .2s ease;
  position: relative;
}

.nav-item:hover {
  background: var(--wb-bg);
  color: var(--wb-text);
}

.nav-item.active {
  background: rgba(37,99,235,.07);
  color: var(--wb-primary);
  border: 1px solid rgba(37,99,235,.10);
  font-weight: 600;
}

.nav-item .nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}
.nav-icon svg {
  width: 19px;
  height: 19px;
  opacity: .7;
  transition: opacity .2s;
}

.sidebar-footer {
  padding: 10px 12px;
  border-top: 1px solid var(--wb-border-light);
}
.sidebar-footer .nav-item {
  margin-bottom: 2px;
}
.sidebar-footer .nav-item:last-child {
  margin-bottom: 0;
}
.sidebar-footer .nav-item-danger:hover {
  background: rgba(239,68,68,0.08);
  color: #EF4444;
}
.sidebar-footer .nav-item-danger:hover .nav-icon svg {
  color: #EF4444;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar-sm {
  width: 36px; height: 36px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.avatar-super-admin {
  background: linear-gradient(135deg, #D97706, #B45309);
  box-shadow: 0 2px 8px rgba(217,119,6,.25);
}
.avatar-admin {
  background: linear-gradient(135deg, #7C3AED, #5B21B6);
  box-shadow: 0 2px 8px rgba(124,58,237,.25);
}
.avatar-operator {
  background: linear-gradient(135deg, #2563EB, #1D4ED8);
  box-shadow: 0 2px 8px rgba(37,99,235,.25);
}

.user-details h4 {
  color: var(--wb-text);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 1px;
}
.user-details p {
  color: var(--wb-text-light);
  font-size: 11.5px;
}

/* ===== 主内容区 ===== */
.main-content {
  margin-left: 160px;
  flex: 1;
  padding: 28px 32px;
  background: var(--wb-bg);
  min-height: 100vh;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.page-title {
  color: var(--wb-text);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -.02em;
}

/* ===== 按钮（与 IoT 统一）===== */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 20px;
  background: linear-gradient(135deg, var(--wb-primary), var(--wb-primary-light));
  color: white;
  border: none;
  border-radius: var(--wb-r);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all .22s ease;
  box-shadow: 0 2px 8px rgba(37,99,235,.2);
}
.btn-primary:hover {
  box-shadow: 0 4px 16px rgba(37,99,235,.3);
  transform: translateY(-1px);
}

.btn-secondary {
  padding: 9px 20px;
  background: var(--wb-surface);
  color: var(--wb-text-muted);
  border: 1.5px solid var(--wb-border);
  border-radius: var(--wb-r);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s ease;
}
.btn-secondary:hover {
  border-color: var(--wb-primary-light);
  color: var(--wb-primary);
  background: rgba(37,99,235,.02);
}

/* ===== 用户卡片列表 ===== */
.user-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.user-card {
  background: var(--wb-surface);
  border: 1px solid var(--wb-border);
  border-radius: var(--wb-r-lg);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  transition: all .2s ease;
  box-shadow: var(--wb-shadow-sm);
  position: relative;
  overflow: hidden;
}
.user-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  border-radius: 2px 0 0 2px;
  background: var(--wb-primary-light);
  opacity: 0;
  transition: opacity .2s;
}
.user-card:hover {
  border-color: rgba(37,99,235,.18);
  box-shadow: var(--wb-shadow-md);
  transform: translateX(2px);
}
.user-card:hover::before { opacity: 1; }

.user-card-left {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-width: 0;
}

.avatar-lg {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
  position: relative;
}
/* 角色图标装饰 */
.avatar-lg::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 14px;
  border: 1px dashed transparent;
  transition: border-color .2s;
}
.user-card:hover .avatar-lg::after {
  border-color: currentColor;
  opacity: .25;
}

.user-name {
  font-size: 15px;
  font-weight: 650;
  color: var(--wb-text);
  margin-bottom: 3px;
}

.user-info-row {
  color: var(--wb-text-muted);
  font-size: 12.5px;
  margin-top: 2px;
  line-height: 1.5;
}

/* ===== 操作按钮 ===== */
.user-actions {
  display: flex;
  gap: 7px;
  flex-shrink: 0;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 7px 13px;
  background: var(--wb-bg);
  border: 1px solid var(--wb-border);
  border-radius: var(--wb-r-sm);
  color: var(--wb-text-muted);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s ease;
  white-space: nowrap;
}
.btn-icon:hover {
  background: rgba(37,99,235,.05);
  color: var(--wb-primary);
  border-color: rgba(37,99,235,.15);
}

.btn-assign {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 7px 13px;
  background: rgba(37,99,235,.05);
  border: 1px solid rgba(37,99,235,.12);
  border-radius: var(--wb-r-sm);
  color: var(--wb-primary);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s ease;
  white-space: nowrap;
}
.btn-assign:hover {
  background: rgba(37,99,235,.1);
  border-color: rgba(37,99,235,.22);
}

.btn-danger {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 7px 13px;
  background: rgba(239,68,68,.04);
  border: 1px solid rgba(239,68,68,.12);
  border-radius: var(--wb-r-sm);
  color: #DC2626;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s ease;
  white-space: nowrap;
}
.btn-danger:hover {
  background: rgba(239,68,68,.08);
  border-color: rgba(239,68,68,.22);
}

/* ===== 空状态 ===== */
.empty-state {
  text-align: center;
  padding: 56px 20px;
  color: var(--wb-text-muted);
}
.empty-state-icon {
  width: 72px; height: 72px;
  margin: 0 auto 16px;
  background: var(--wb-bg);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.empty-state-icon svg {
  width: 32px; height: 32px;
  color: var(--wb-text-light);
}
.empty-state h3 {
  color: var(--wb-text);
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 6px;
}
.empty-state p {
  font-size: 13.5px;
  color: var(--wb-text-light);
}

/* ===== 模态框（与 IoT 统一）===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.45);
  backdrop-filter: blur(8px);
  z-index: 100;
  justify-content: center;
  align-items: center;
  padding: 20px;
  overflow-y: auto;
}
.modal-box {
  background: var(--wb-surface);
  border: 1px solid var(--wb-border);
  border-radius: var(--wb-r-lg);
  width: 440px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--wb-shadow-lg), 0 0 0 1px rgba(255,255,255,.5) inset;
  display: flex;
  flex-direction: column;
  animation: modalIn .2s ease;
  position: relative;
}
.modal-box::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--wb-primary), var(--wb-accent));
  border-radius: var(--wb-r-lg) var(--wb-r-lg) 0 0;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid rgba(226,232,240,.6);
  flex-shrink: 0;
}
.modal-header h3 {
  color: var(--wb-text);
  font-size: 16px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--wb-text-light);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--wb-r-sm);
  line-height: 1;
  transition: all .2s;
}
.modal-close:hover {
  color: var(--wb-text);
  background: var(--wb-bg);
}

.modal-body {
  padding: 20px 22px;
  overflow-y: auto;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 22px;
  border-top: 1px solid rgba(226,232,240,.6);
  flex-shrink: 0;
}

/* ===== 表单（与 IoT 统一）===== */
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  color: var(--wb-text);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}
.form-group input,
.form-group select {
  width: 100%;
  padding: 10px 13px;
  background: var(--wb-surface);
  border: 1.5px solid var(--wb-border);
  border-radius: var(--wb-r);
  color: var(--wb-text);
  font-size: 14px;
  outline: none;
  transition: all .2s ease;
  box-sizing: border-box;
}
.form-group input:focus,
.form-group select:focus {
  border-color: var(--wb-primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.08);
}
.form-group select option { background: var(--wb-surface); }
.form-hint {
  font-size: 11.5px;
  color: var(--wb-text-light);
  margin-top: 4px;
}

/* ===== 设备分配弹窗 ===== */
.device-list {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--wb-border);
  border-radius: 0 0 var(--wb-r) var(--wb-r);
}
.device-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(226,232,240,.6);
  font-size: 13px;
  transition: background .15s;
}
.device-item:last-child { border-bottom: none; }
.device-item:hover { background: var(--wb-bg); }
.device-item input[type=checkbox] {
  width: 16px; height: 16px;
  accent-color: var(--wb-primary);
  cursor: pointer;
}

.select-all-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--wb-border);
  background: var(--wb-bg);
  border-radius: var(--wb-r) var(--wb-r) 0 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--wb-text);
  cursor: pointer;
  user-select: none;
  transition: background .15s;
}
.select-all-bar:hover { background: #e2e8f0; }
.select-all-bar input[type=checkbox] {
  width: 16px; height: 16px;
  accent-color: var(--wb-primary);
}
.select-all-count {
  margin-left: auto;
  color: var(--wb-text-light);
  font-size: 12px;
  font-weight: 400;
}
.device-name {
  color: var(--wb-text);
  font-weight: 550;
  flex: 1;
}
.device-type {
  color: var(--wb-text-light);
  font-size: 12px;
}

.search-input {
  width: 100%;
  padding: 9px 13px;
  background: var(--wb-surface);
  border: 1.5px solid var(--wb-border);
  border-radius: var(--wb-r);
  color: var(--wb-text);
  font-size: 13.5px;
  outline: none;
  margin-bottom: 12px;
  transition: all .2s ease;
  box-sizing: border-box;
}
.search-input:focus {
  border-color: var(--wb-primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.08);
}

/* ===== Toast（与 IoT 统一）===== */
.toast-container {
  position: fixed;
  top: 20px; right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 20px;
  border-radius: var(--wb-r);
  font-size: 13px;
  font-weight: 600;
  animation: toastSlideIn .3s ease;
  max-width: 360px;
  backdrop-filter: blur(10px);
}
.toast.success {
  background: rgba(16,185,129,.92);
  color: white;
  border: 1px solid rgba(16,185,129,.4);
}
.toast.error {
  background: rgba(239,68,68,.92);
  color: white;
  border: 1px solid rgba(239,68,68,.4);
}
@keyframes toastSlideIn {
  from { transform: translateX(120%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ===== 响应式 ===== */
@media (max-width: 900px) {
  .sidebar { width: 72px; }
  .brand-text, .sidebar-welcome, .user-details, .nav-item span:not(.nav-icon) { display: none; }
  .nav-item { justify-content: center; padding: 12px; }

  .main-content { margin-left: 70px; padding: 20px; }
  .user-card { flex-wrap: wrap; }
  .user-actions { width: 100%; margin-top: 10px; justify-content: flex-end; }
}
@media (max-width: 640px) {
  .main-content { padding: 16px; }
  .page-header { flex-direction: column; gap: 12px; align-items: flex-start; }
  .user-card-left { flex-wrap: wrap; }
  .modal-box { width: 95vw; }
}
