:root {
  --primary-color: #1677ff;
  --bg-color: #f5f7fa;
  --sidebar-bg: #ffffff;
  --card-bg: #ffffff;
  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --border-color: #f0f0f0;
  --sidebar-width: 240px;
  --header-height: 64px;
}

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

#root {
  height: 100vh;
}

.admin-layout {
  display: flex;
  height: 100%;
}

/* Sidebar */
.admin-sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  transition: all 0.3s;
  box-shadow: 2px 0 8px rgba(0,0,0,0.05);
}

.admin-sidebar .logo {
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 24px;
  font-size: 18px;
  font-weight: bold;
  color: var(--primary-color);
  border-bottom: 1px solid var(--border-color);
}

.menu-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px 0;
}

.menu-group {
  margin-bottom: 4px;
}

.group-title {
  padding: 12px 24px;
  color: var(--text-secondary);
  font-size: 14px;
  display: flex;
  align-items: center;
  cursor: pointer;
  transition: background 0.2s;
}

.group-title:hover {
  background: #f9fafb;
}

.group-title i { margin-right: 12px; }
.group-title .arrow-icon { margin-left: auto; transition: transform 0.3s; }
.group-title .arrow-icon.expanded { transform: rotate(90deg); }

.menu-items {
  padding-left: 12px;
}

.menu-item {
  padding: 10px 24px;
  font-size: 14px;
  cursor: pointer;
  border-radius: 4px;
  margin: 2px 8px;
  transition: all 0.2s;
  color: var(--text-primary);
}

.menu-item:hover {
  background: #f0f7ff;
  color: var(--primary-color);
}

.menu-item.active {
  background: #e6f4ff;
  color: var(--primary-color);
  font-weight: 500;
}

/* Header */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.admin-header {
  height: var(--header-height);
  background: #fff;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.breadcrumb {
  font-size: 14px;
  color: var(--text-secondary);
}
.breadcrumb .sep { margin: 0 8px; }
.breadcrumb .current { color: var(--text-primary); font-weight: 500; }

/* Dashboard Cards */
.view-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.stats-card {
  background: var(--card-bg);
  padding: 24px;
  border-radius: 12px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s;
  border: 1px solid var(--border-color);
}

.stats-card:hover { transform: translateY(-4px); }

.stats-card .label { font-size: 14px; color: var(--text-secondary); margin-bottom: 8px; }
.stats-card .value { font-size: 28px; font-weight: 700; color: var(--text-primary); }
.stats-card .growth { font-size: 12px; margin-top: 8px; }
.stats-card .growth.up { color: #52c41a; }
.stats-card .growth.down { color: #ff4d4f; }

.traffic-section {
  background: #fff;
  padding: 24px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
}

.traffic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.traffic-item {
  font-size: 14px;
}

.loading {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 200px;
  color: var(--text-secondary);
}

/* User Management & Tables */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.btn {
  padding: 8px 16px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s;
}

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

.btn-primary:hover { background: #4096ff; }

.filter-bar {
  margin-bottom: 16px;
}

.filter-bar input {
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  width: 300px;
  outline: none;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.admin-table th, .admin-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  font-size: 14px;
}

.admin-table th {
  background: #fafafa;
  font-weight: 600;
  color: var(--text-primary);
}

.email-cell {
  display: flex;
  flex-direction: column;
}

.online-ip-badge {
  font-size: 11px;
  color: #1677ff;
  background: #e6f4ff;
  border: 1px solid #91caff;
  padding: 0 4px;
  border-radius: 4px;
  margin-top: 4px;
  width: fit-content;
}

.status-tag {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
}

.status-active { background: #f6ffed; border: 1px solid #b7eb8f; color: #52c41a; }
.status-disabled { background: #fff1f0; border: 1px solid #ffa39e; color: #f5222d; }
.status-pending { background: #fff7e6; border: 1px solid #ffe58f; color: #faad14; }

/* Node Management Specifics */
.node-parent {
  cursor: pointer;
  background: #fafafa;
}

.node-name-cell {
  display: flex;
  align-items: center;
}

.node-parent .arrow-icon {
  margin-right: 8px;
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 6px solid #bfbfbf;
  transition: transform 0.3s;
}

.node-parent.expanded .arrow-icon {
  transform: rotate(90deg);
}

.node-child-row td {
  background: #fcfcfc;
}

.child-indent {
  padding-left: 32px !important;
}

.child-line {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-left: 1px solid #d9d9d9;
  border-bottom: 1px solid #d9d9d9;
  margin-right: 8px;
  margin-top: -8px;
}

/* Plan Management Specifics */
.plan-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.plan-name { font-weight: 600; font-size: 16px; }
.plan-price { font-size: 24px; font-weight: bold; color: var(--primary-color); margin-bottom: 16px; }
.plan-features { list-style: none; padding: 0; margin: 0 0 16px 0; font-size: 14px; color: var(--text-secondary); }
.plan-features li { margin-bottom: 4px; border-bottom: 1px dashed var(--border-color); padding-bottom: 4px; }

.row-actions a {
  color: var(--primary-color);
  text-decoration: none;
}

.sep { margin: 0 8px; color: #d9d9d9; }

.text-danger { color: #ff4d4f !important; }

.placeholder {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 300px;
  background: #fff;
  border-radius: 12px;
  color: var(--text-secondary);
}

/* Settings View */
.settings-view {
  display: flex;
  gap: 24px;
  height: 100%;
}

.settings-sidebar {
  width: 200px;
  flex-shrink: 0;
}

.tab-item {
  padding: 12px 16px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-secondary);
  transition: all 0.2s;
  margin-bottom: 4px;
}

.tab-item:hover {
  background: rgba(0,0,0,0.03);
  color: var(--text-primary);
}

.tab-item.active {
  background: #fff;
  color: var(--primary-color);
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  font-weight: 500;
}

.settings-content {
  flex: 1;
}

.section-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
  border: 1px solid var(--border-color);
  overflow: hidden;
}

.card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.card-body {
  padding: 24px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.form-input {
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  outline: none;
  transition: border-color 0.2s;
}

.form-input:focus {
  border-color: var(--primary-color);
}

.form-help {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Switch Component */
.switch-container {
  display: flex;
  align-items: center;
}

.switch-container input {
  display: none;
}

.switch-slider {
  width: 44px;
  height: 22px;
  background-color: #e5e7eb;
  border-radius: 11px;
  position: relative;
  cursor: pointer;
  transition: .4s;
}

.switch-slider:before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

input:checked + .switch-slider {
  background-color: var(--primary-color);
}

input:checked + .switch-slider:before {
  transform: translateX(22px);
}

.animate-in {
  animation: slideIn 0.3s ease-out;
}

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

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 300px;
  color: var(--text-secondary);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(0,0,0,0.05);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 16px;
}

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