/* ═══════════════════════════════════════════════
   工业机械风格 · ExpoCtrl 设备管理系统
═══════════════════════════════════════════════ */

:root {
  --bg-deep:     #0d0e14;
  --bg-panel:    #13151f;
  --bg-card:     #1a1d2e;
  --bg-hover:    #21253a;
  --border:      #2a2f4a;
  --border-glow: #3a4070;
  --accent:      #4f7cff;
  --accent-dim:  #2a4499;
  --gold:        #c8a84b;
  --green:       #22c55e;
  --red:         #ef4444;
  --orange:      #f97316;
  --text-pri:    #e2e4f0;
  --text-sec:    #7a8099;
  --text-dim:    #4a5070;
  --font-mono:   'Courier New', 'Consolas', monospace;
  --font-sans:   'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --radius:      4px;
  --shadow:      0 4px 24px rgba(0,0,0,0.5);
}

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

html, body {
  height: 100%;
  background: var(--bg-deep);
  color: var(--text-pri);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
}

/* ── 滚动条 ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb { background: var(--border-glow); border-radius: 3px; }

/* ── 顶部导航栏 ── */
.navbar {
  display: flex;
  align-items: center;
  height: 56px;
  padding: 0 24px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 12px rgba(0,0,0,0.4);
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 2px;
  text-decoration: none;
}

.navbar-brand .logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.navbar-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 32px;
  list-style: none;
}

.navbar-nav a {
  display: block;
  padding: 6px 14px;
  color: var(--text-sec);
  text-decoration: none;
  border-radius: var(--radius);
  font-size: 13px;
  transition: all 0.15s;
  border: 1px solid transparent;
}

.navbar-nav a:hover,
.navbar-nav a.active {
  color: var(--text-pri);
  background: var(--bg-hover);
  border-color: var(--border);
}

.navbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  animation: pulse 2s infinite;
}

.status-dot.offline { background: var(--red); box-shadow: 0 0 6px var(--red); animation: none; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

.user-info {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-sec);
}

/* ── 侧边栏 ── */
.layout {
  display: flex;
  height: calc(100vh - 56px);
}

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px 0;
}

.sidebar-section {
  padding: 0 12px 8px;
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-dim);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-top: 8px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  cursor: pointer;
  color: var(--text-sec);
  text-decoration: none;
  font-size: 13px;
  border-left: 3px solid transparent;
  transition: all 0.15s;
}

.sidebar-item:hover {
  color: var(--text-pri);
  background: var(--bg-hover);
  border-left-color: var(--border-glow);
}

.sidebar-item.active {
  color: var(--accent);
  background: rgba(79,124,255,0.08);
  border-left-color: var(--accent);
}

/* ── 主内容区 ── */
.main {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background: var(--bg-deep);
}

/* ── 面包屑 / 页头 ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.page-title {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-pri);
  letter-spacing: 1px;
}

.page-title span {
  color: var(--text-dim);
  font-size: 12px;
  margin-left: 12px;
  font-weight: 400;
}

/* ── 卡片 ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
}

.card-title {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--gold);
  letter-spacing: 1px;
}

.card-body { padding: 18px; }

/* ── 按钮 ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-hover);
  color: var(--text-pri);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font-sans);
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--border-glow);
  background: var(--bg-panel);
}

.btn-primary {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent); }

.btn-danger  { border-color: #7a2a2a; color: var(--red); }
.btn-danger:hover { background: rgba(239,68,68,0.1); border-color: var(--red); }

.btn-success { border-color: #1a6a3a; color: var(--green); }
.btn-success:hover { background: rgba(34,197,94,0.1); border-color: var(--green); }

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

/* ── 开关按钮 ── */
.power-btn {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 3px solid var(--border);
  background: var(--bg-panel);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: var(--text-dim);
  transition: all 0.2s;
  position: relative;
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.5);
}

.power-btn:hover { border-color: var(--border-glow); }

.power-btn.on {
  border-color: var(--green);
  color: var(--green);
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.5), 0 0 16px rgba(34,197,94,0.3);
}

.power-btn.off {
  border-color: var(--red);
  color: var(--red);
}

/* ── LED 状态灯 ── */
.led {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.led-green {
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  animation: pulse 2s infinite;
}

.led-red    { background: var(--red);  box-shadow: 0 0 4px var(--red); }
.led-gray   { background: #444; }
.led-yellow { background: var(--orange); box-shadow: 0 0 6px var(--orange); }

/* ── 表格 ── */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table th {
  padding: 10px 14px;
  text-align: left;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 1px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
  white-space: nowrap;
}

.table td {
  padding: 11px 14px;
  border-bottom: 1px solid rgba(42,47,74,0.5);
  color: var(--text-sec);
  vertical-align: middle;
}

.table tr:hover td { background: var(--bg-hover); }
.table tr:last-child td { border-bottom: none; }

.table td.mono {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-pri);
}

/* ── 表单 ── */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 12px;
  color: var(--text-sec);
  margin-bottom: 6px;
  font-family: var(--font-mono);
  letter-spacing: 0.5px;
}

.form-control {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-pri);
  font-size: 13px;
  font-family: var(--font-sans);
  transition: border-color 0.15s;
  outline: none;
}

.form-control:focus { border-color: var(--accent); }
.form-control option { background: var(--bg-panel); }

/* ── 模态框 ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(2px);
}

.modal-overlay.hidden { display: none; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius);
  width: 480px;
  max-width: 96vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.7);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
}

.modal-title {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--gold);
  letter-spacing: 1px;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-sec);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.modal-close:hover { color: var(--text-pri); }

.modal-body { padding: 20px; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-panel);
}

/* ── 通知 toast ── */
.toast-container {
  position: fixed;
  top: 70px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text-pri);
  box-shadow: var(--shadow);
  animation: slideIn 0.2s ease;
  max-width: 300px;
}

.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }
.toast.info    { border-left: 3px solid var(--accent); }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── 徽章 ── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-family: var(--font-mono);
  border: 1px solid;
}

.badge-green  { color: var(--green);  border-color: #1a6a3a; background: rgba(34,197,94,0.08); }
.badge-red    { color: var(--red);    border-color: #7a2a2a; background: rgba(239,68,68,0.08); }
.badge-gray   { color: var(--text-dim); border-color: var(--border); }
.badge-blue   { color: var(--accent); border-color: var(--accent-dim); background: rgba(79,124,255,0.08); }
.badge-gold   { color: var(--gold);   border-color: #6a5a2a; background: rgba(200,168,75,0.08); }

/* ── 设备卡片网格 ── */
.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.device-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.device-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--border), var(--border-glow), var(--border));
}

.device-card:hover { border-color: var(--border-glow); }

.device-card.online::before {
  background: linear-gradient(90deg, transparent, var(--green), transparent);
}

.device-card.offline { opacity: 0.5; }

.device-name {
  font-size: 13px;
  color: var(--text-pri);
  text-align: center;
  font-weight: 500;
}

.device-type-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 1px;
}

.device-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  width: 100%;
}

.action-btn {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-panel);
  color: var(--text-sec);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font-sans);
}

.action-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(79,124,255,0.08);
}

/* ── 分隔线 ── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

/* ── 空状态 ── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

.empty-state .icon { font-size: 40px; margin-bottom: 12px; opacity: 0.4; }

/* ── 加载动画 ── */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── 响应式 ── */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main { padding: 16px; }
  .device-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}
