/* Tunnel Manager - 管理后台样式 */

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

:root {
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #06b6d4;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-500: #6b7280;
  --gray-700: #374151;
  --gray-900: #111827;
  --sidebar-width: 240px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--gray-100);
  color: var(--gray-900);
  line-height: 1.5;
}

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

.login-card {
  background: white;
  padding: 40px;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.login-card h1 {
  font-size: 28px;
  margin-bottom: 8px;
}

.login-card .subtitle {
  color: var(--gray-500);
  margin-bottom: 32px;
}

.login-error {
  color: var(--danger);
  margin-top: 16px;
  min-height: 20px;
}

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

input[type="text"],
input[type="password"],
input[type="email"],
select,
textarea {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

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

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

.btn-outline {
  background: transparent;
  border: 1px solid var(--gray-300);
  color: var(--gray-700);
}

.btn-outline:hover {
  background: var(--gray-100);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover {
  background: #16a34a;
}

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

.btn-block {
  width: 100%;
}

/* 主布局 */
.main-page {
  display: flex;
  min-height: 100vh;
}

/* 侧边栏 */
.sidebar {
  width: var(--sidebar-width);
  background: var(--gray-900);
  color: white;
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--gray-700);
}

.sidebar-header h2 {
  font-size: 18px;
}

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

.nav-item {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  color: var(--gray-300);
  text-decoration: none;
  transition: all 0.2s;
}

.nav-item:hover {
  background: var(--gray-700);
  color: white;
}

.nav-item.active {
  background: var(--primary);
  color: white;
}

.nav-item .icon {
  margin-right: 12px;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--gray-700);
}

/* 主内容 */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 24px;
}

/* 页面 */
.page {
  max-width: 1400px;
  margin: 0 auto;
}

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

.page-header h1 {
  font-size: 24px;
  font-weight: 600;
}

.page-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

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

.stat-card {
  background: white;
  padding: 24px;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--gray-900);
}

.stat-label {
  color: var(--gray-500);
  font-size: 14px;
  margin-top: 4px;
}

.stat-success .stat-value { color: var(--success); }
.stat-warning .stat-value { color: var(--warning); }
.stat-danger .stat-value { color: var(--danger); }
.stat-info .stat-value { color: var(--info); }

/* 卡片 */
.card {
  background: white;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
}

.card-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.card-body {
  padding: 20px;
}

/* 表格 */
.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--gray-200);
}

.table th {
  background: var(--gray-50);
  font-weight: 600;
  font-size: 13px;
  color: var(--gray-500);
  text-transform: uppercase;
}

.table tbody tr:hover {
  background: var(--gray-50);
}

/* 状态标签 */
.status-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.status-active {
  background: #dcfce7;
  color: #166534;
}

.status-stopped {
  background: #fef3c7;
  color: #92400e;
}

.status-expired {
  background: #fee2e2;
  color: #991b1b;
}

.status-pending {
  background: #e0e7ff;
  color: #3730a3;
}

/* 搜索和筛选 */
.search-input,
.filter-select {
  padding: 8px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 14px;
}

.search-input {
  width: 200px;
}

/* 分页 */
.pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
}

.pagination button {
  padding: 8px 14px;
  border: 1px solid var(--gray-300);
  background: white;
  border-radius: 6px;
  cursor: pointer;
}

.pagination button:hover {
  background: var(--gray-100);
}

.pagination button.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

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

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

.modal.active {
  display: flex;
}

.modal-content {
  background: white;
  border-radius: 12px;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  overflow: auto;
}

/* 弹窗大尺寸 */
.modal-lg {
  max-width: 800px;
}

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

.modal-header h3 {
  font-size: 18px;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--gray-500);
}

.modal-body {
  padding: 20px;
}

/* 表单行 */
.form-row {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
}

.form-row .form-group {
  flex: 1;
  margin-bottom: 0;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  color: var(--gray-700);
}

.form-group small {
  display: block;
  margin-top: 4px;
  color: var(--gray-500);
  font-size: 12px;
}

.form-group .required {
  color: var(--danger);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--gray-200);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: auto;
}

input[type="number"],
input[type="date"] {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  font-size: 14px;
}

/* 标签 */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}

.badge-primary {
  background: var(--primary);
  color: white;
}

/* 来源标签 */
.source-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 500;
  margin-left: 8px;
  vertical-align: middle;
}

.source-db {
  background: var(--success);
  color: white;
}

.source-env {
  background: var(--info);
  color: white;
}

/* 部署指南页面样式 */
.script-section {
  margin-bottom: 20px;
}

.script-section h4 {
  margin-bottom: 10px;
  color: var(--text);
  font-size: 14px;
}

.code-block-wrapper {
  position: relative;
}

.code-block {
  background: #1e1e1e;
  color: #d4d4d4;
  padding: 15px;
  border-radius: 6px;
  overflow-x: auto;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 13px;
  line-height: 1.5;
  margin: 0;
}

.code-block code {
  background: none;
  padding: 0;
  color: inherit;
}

.code-block-wrapper .btn-copy {
  position: absolute;
  top: 8px;
  right: 8px;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.code-block-wrapper:hover .btn-copy {
  opacity: 1;
}

.btn-copy {
  background: rgba(255,255,255,0.1);
  color: white;
  border: 1px solid rgba(255,255,255,0.2);
}

.btn-copy:hover {
  background: rgba(255,255,255,0.2);
}

.commands-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 15px;
}

.command-item {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

.command-title {
  font-weight: 500;
  margin-bottom: 8px;
  font-size: 13px;
}

.command-item .code-block {
  padding: 10px;
  font-size: 12px;
}

.command-item .code-block-wrapper .btn-copy {
  top: 4px;
  right: 4px;
  padding: 2px 6px;
  font-size: 11px;
}

.page-desc {
  color: var(--text-secondary);
  margin-top: 5px;
  font-size: 14px;
}

/* 提示框 */
.tips-box {
  background: var(--gray-50);
  padding: 16px;
  border-radius: 8px;
}

.tips-box h4 {
  margin-bottom: 8px;
  color: var(--gray-900);
}

.tips-box ul {
  margin-left: 20px;
  color: var(--gray-700);
}

.tips-box ul li {
  margin-bottom: 4px;
}

.card-desc {
  color: var(--gray-500);
  font-size: 13px;
  margin-top: 4px;
}

/* 结果信息 */
.result-info {
  line-height: 1.8;
}

.result-info h4 {
  margin-top: 20px;
  margin-bottom: 10px;
  color: var(--gray-900);
}

.result-info h5 {
  margin-top: 16px;
  margin-bottom: 8px;
  color: var(--gray-700);
}

.code-block {
  background: var(--gray-900);
  color: #e5e7eb;
  padding: 12px 16px;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 13px;
  margin: 8px 0;
}

.code-block code {
  font-family: 'Monaco', 'Menlo', monospace;
}

/* 文档页面 */
.docs-container {
  display: flex;
  gap: 24px;
}

.docs-nav {
  width: 200px;
  flex-shrink: 0;
}

.docs-nav-item {
  display: block;
  padding: 10px 16px;
  color: var(--gray-700);
  text-decoration: none;
  border-radius: 6px;
  margin-bottom: 4px;
}

.docs-nav-item:hover {
  background: var(--gray-200);
}

.docs-nav-item.active {
  background: var(--primary);
  color: white;
}

.docs-content {
  flex: 1;
  background: white;
  padding: 24px;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.docs-content h2 {
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--primary);
}

.docs-content h3 {
  margin-top: 24px;
  margin-bottom: 12px;
}

.docs-content p {
  margin-bottom: 12px;
  color: var(--gray-700);
}

.docs-content pre {
  background: var(--gray-900);
  color: #e5e7eb;
  padding: 16px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 16px 0;
  font-size: 13px;
}

.docs-content code {
  font-family: 'Monaco', 'Menlo', monospace;
}

.docs-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
}

.docs-content table th,
.docs-content table td {
  padding: 10px 12px;
  border: 1px solid var(--gray-200);
  text-align: left;
}

.docs-content table th {
  background: var(--gray-50);
}

/* 详情列表 */
.detail-list {
  list-style: none;
}

.detail-list li {
  padding: 12px 0;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
}

.detail-list li:last-child {
  border-bottom: none;
}

.detail-label {
  width: 120px;
  color: var(--gray-500);
  flex-shrink: 0;
}

.detail-value {
  flex: 1;
  word-break: break-all;
}

/* 下载按钮组 */
.download-buttons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 16px;
}

/* 响应式 */
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
  }
  
  .main-content {
    margin-left: 0;
  }
  
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }
  
  .page-actions {
    flex-wrap: wrap;
  }
  
  .docs-container {
    flex-direction: column;
  }
  
  .docs-nav {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
}

/* 按钮组 */
.btn-group {
  display: flex;
  gap: 4px;
}

.btn-group .btn {
  padding: 4px 8px;
  font-size: 12px;
}

/* 日期输入框 */
.date-input {
  padding: 8px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 14px;
}

/* 单选框组 */
.radio-group {
  display: flex;
  gap: 20px;
  padding: 8px 0;
}

.radio-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.radio-group input[type="radio"] {
  width: auto;
  margin: 0;
}

/* 警告按钮 */
.btn-warning {
  background: var(--warning);
  color: white;
}

.btn-warning:hover {
  background: #d97706;
}
