/* 全局样式 - 管理后台 */

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

:root {
  --primary: #1a73e8;
  --primary-dark: #1557b0;
  --primary-light: #e8f0fe;
  --success: #0f9d58;
  --warning: #f4b400;
  --danger: #db4437;
  --bg: #f5f6fa;
  --sidebar-bg: #1e293b;
  --sidebar-text: #cbd5e1;
  --sidebar-active: #fff;
  --card-bg: #fff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-secondary: #64748b;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* Layout */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-logo {
  padding: 20px;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

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

.sidebar-nav a {
  display: flex; align-items: center;
  padding: 10px 20px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 14px;
  transition: all 0.2s;
  gap: 10px;
}

.sidebar-nav a:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar-nav a.active { background: var(--primary); color: #fff; font-weight: 500; }

.sidebar-nav a .nav-icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer {
  padding: 12px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 13px;
}

.main-content {
  margin-left: 220px;
  flex: 1;
  padding: 24px;
}

.top-bar {
  background: var(--card-bg);
  padding: 14px 24px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.top-bar h2 { font-size: 18px; font-weight: 600; }

.top-bar-actions { display: flex; gap: 10px; align-items: center; }

/* Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card-bg);
  padding: 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.stat-icon.blue { background: #e8f0fe; color: var(--primary); }
.stat-icon.green { background: #e6f4ea; color: var(--success); }
.stat-icon.orange { background: #fef7e0; color: var(--warning); }
.stat-icon.purple { background: #f3e8fd; color: #9334e6; }

.stat-info h4 { font-size: 24px; font-weight: 700; color: var(--text); }
.stat-info p { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  font-size: 15px;
}

.card-body { padding: 20px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border: none; border-radius: 6px;
  font-size: 14px; font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

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

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #0b8043; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c53929; }

.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #d69e00; }

.btn-outline {
  background: transparent; color: var(--primary);
  border: 1px solid var(--primary);
}
.btn-outline:hover { background: var(--primary-light); }

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

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Forms */
.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  transition: border-color 0.2s;
  background: #fff;
  color: var(--text);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,115,232,0.15);
}

textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { cursor: pointer; }

/* Tables */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

table th, table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

table th {
  background: #f8fafc;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

table tr:hover { background: #f8fafc; }

/* Modal */
.modal-overlay {
  display: none;
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  justify-content: center; align-items: center;
}

.modal-overlay.active { display: flex; }

.modal {
  background: #fff;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
}

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

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

.modal-body { padding: 20px; }

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

/* Tags / Badges */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}

.tag-blue { background: #e8f0fe; color: var(--primary); }
.tag-green { background: #e6f4ea; color: var(--success); }
.tag-red { background: #fce8e6; color: var(--danger); }
.tag-yellow { background: #fef7e0; color: #e37400; }

/* Map container */
.map-container {
  width: 100%; height: calc(100vh - 140px);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.split-layout {
  display: flex;
  gap: 16px;
  height: calc(100vh - 140px);
}

.split-left {
  width: 340px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.split-right {
  flex: 1;
}

/* List */
.list-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.list-item:hover { background: #f8fafc; }
.list-item.active { background: var(--primary-light); border-left: 3px solid var(--primary); }

.list-item-info h5 { font-size: 14px; font-weight: 500; }
.list-item-info p { font-size: 12px; color: var(--text-secondary); }

.list-scroll {
  flex: 1;
  overflow-y: auto;
}

/* Login */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 40px;
  width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.login-card h1 {
  text-align: center;
  margin-bottom: 8px;
  font-size: 24px;
  color: var(--text);
}

.login-card .subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 32px;
}

/* Utility */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-2 { gap: 10px; }
.w-full { width: 100%; }

.alert {
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 16px;
}

.alert-error { background: #fce8e6; color: var(--danger); }
.alert-success { background: #e6f4ea; color: var(--success); }
.alert-info { background: var(--primary-light); color: var(--primary); }

/* Auth guard */
body.no-auth { overflow: hidden; }

/* Nested list for route nodes */
.node-list { list-style: none; }

.node-list li {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  margin-bottom: 6px;
  background: #f8fafc;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 13px;
  cursor: move;
}

.node-list li .node-index {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}

.node-list li .node-name { flex: 1; }

.node-list li .node-remove {
  cursor: pointer;
  color: var(--danger);
  font-size: 16px;
  line-height: 1;
}

.node-list li.dragging { opacity: 0.5; }

/* Schedule panel */
.schedule-panel {
  padding: 20px;
}

.schedule-panel h4 {
  margin-bottom: 16px;
  font-size: 16px;
}

.panda-check-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0;
  font-size: 14px;
}

.panda-check-item input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; }

/* Search box */
.search-box {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  margin-bottom: 12px;
}

.search-box:focus { outline: none; border-color: var(--primary); }

/* Pagination */
.pagination {
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: center;
  margin-top: 16px;
}

.pagination button {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
}

.pagination button:hover { background: var(--primary-light); }
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Toasts */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  padding: 12px 20px;
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease;
  max-width: 400px;
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-warning { background: var(--warning); }

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

/* Loading */
.loading { text-align: center; padding: 40px; color: var(--text-secondary); }
.loading::after { content: '...'; animation: dots 1.5s infinite; }

@keyframes dots {
  0%,20% { content: '.'; }
  40% { content: '..'; }
  60%,100% { content: '...'; }
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar-logo { font-size: 0; padding: 16px; }
  .sidebar-nav a span { display: none; }
  .main-content { margin-left: 60px; }
  .split-layout { flex-direction: column; height: auto; }
  .split-left { width: 100%; }
  .map-container { height: 400px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* Inline form row */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 480px) {
  .form-row { grid-template-columns: 1fr; }
}
