/* 简约风格的后台管理样式 */

:root {
  --primary: #0071e3;
  --success: #34c759;
  --danger: #ef4444;
  --warning: #ff9500;
  --bg: #f5f5f7;
  --card: #ffffff;
  --text: #1d1d1f;
  --text-secondary: #86868b;
  --border: rgba(0, 0, 0, 0.1);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.12);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* 认证页面 */
.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 1rem;
}

.auth-box {
  background: var(--card);
  border-radius: 16px;
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-hover);
  animation: fadeInUp 0.4s ease-out;
}

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

.auth-header {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-logo {
  width: 64px;
  height: 64px;
  margin: 0 auto 1rem;
  color: var(--primary);
}

.auth-header h1 {
  font-size: 1.75rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.auth-header p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.auth-form {
  margin-top: 1.5rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text);
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  transition: all 0.2s;
  background: var(--card);
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.1);
}

.form-group small {
  display: block;
  margin-top: 0.25rem;
  color: var(--text-secondary);
  font-size: 0.8rem;
}

.password-strength {
  margin-top: 0.5rem;
  height: 3px;
  background: #e0e0e0;
  border-radius: 2px;
  overflow: hidden;
  transition: all 0.3s;
}

.password-strength::after {
  content: '';
  display: block;
  height: 100%;
  width: 0%;
  background: var(--danger);
  transition: width 0.3s, background 0.3s;
}

.password-strength.weak::after {
  width: 33%;
  background: var(--danger);
}

.password-strength.medium::after {
  width: 66%;
  background: var(--warning);
}

.password-strength.strong::after {
  width: 100%;
  background: var(--success);
}

.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: white;
  width: 100%;
  justify-content: center;
}

.btn-primary:hover {
  background: #0051a5;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 113, 227, 0.3);
}

.btn-secondary {
  background: #e0e0e0;
  color: var(--text);
}

.btn-secondary:hover {
  background: #d0d0d0;
}

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

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

.btn-icon {
  padding: 0.5rem;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: var(--bg);
  color: var(--text);
}

.error-message {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: #fee;
  color: var(--danger);
  border-radius: 8px;
  display: none;
  animation: fadeIn 0.3s;
}

.error-message.show {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.auth-footer {
  margin-top: 1.5rem;
  text-align: center;
}

.auth-link {
  color: var(--primary);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.2s;
}

.auth-link:hover {
  color: #0051a5;
  text-decoration: underline;
}

/* 管理界面 */
.admin-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.admin-header {
  background: var(--card);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.back-link {
  display: flex;
  align-items: center;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 0.5rem;
  border-radius: 6px;
  transition: all 0.2s;
}

.back-link:hover {
  background: var(--bg);
  color: var(--text);
}

.admin-header h1 {
  font-size: 1.5rem;
  font-weight: 600;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

#current-user {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.admin-layout {
  display: flex;
  flex: 1;
}

.admin-sidebar {
  width: 260px;
  background: var(--card);
  border-right: 1px solid var(--border);
  padding: 1rem 0;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.5rem;
  color: var(--text);
  text-decoration: none;
  transition: all 0.2s;
  border-left: 3px solid transparent;
}

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

.nav-item.active {
  background: rgba(0, 113, 227, 0.08);
  color: var(--primary);
  border-left-color: var(--primary);
  font-weight: 500;
}

.admin-content {
  flex: 1;
  padding: 2rem;
  overflow-y: auto;
}

.page {
  display: none;
  animation: fadeIn 0.3s;
}

.page.active {
  display: block;
}

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

.page-header h2 {
  font-size: 1.75rem;
  font-weight: 600;
}

.button-group {
  display: flex;
  gap: 0.75rem;
}

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

.stat-card {
  background: var(--card);
  border-radius: 12px;
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow);
  transition: all 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.stat-icon {
  font-size: 2.5rem;
}

.stat-info {
  flex: 1;
}

.stat-value {
  font-size: 2rem;
  font-weight: 600;
  color: var(--primary);
  line-height: 1.2;
}

.stat-label {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

/* 表格 */
.table-container {
  background: var(--card);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table thead {
  background: var(--bg);
}

.data-table th {
  padding: 1rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.data-table td {
  padding: 1rem;
  border-top: 1px solid var(--border);
}

.data-table tbody tr {
  transition: background 0.2s;
}

.data-table tbody tr:hover {
  background: var(--bg);
}

.badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 500;
  background: var(--bg);
  color: var(--text);
}

.empty-state {
  padding: 2rem;
  text-align: center;
  color: var(--text-secondary);
}

/* 模态框 */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s;
}

.modal.show {
  display: flex;
}

.modal-content {
  background: var(--card);
  border-radius: 12px;
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-hover);
  animation: fadeInUp 0.3s;
}

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

.modal-header h3 {
  font-size: 1.25rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.2s;
}

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

.modal-body {
  padding: 1.5rem;
}

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

/* 文件浏览器 */
.file-browser {
  background: var(--card);
  border-radius: 12px;
  padding: 1rem;
  box-shadow: var(--shadow);
}

.file-item {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.2s;
}

.file-item:last-child {
  border-bottom: none;
}

.file-item:hover {
  background: var(--bg);
}

/* 编辑器 */
.editor-container {
  background: var(--card);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.code-editor {
  width: 100%;
  min-height: 500px;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
  resize: vertical;
  background: var(--card);
  color: var(--text);
}

.code-editor:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.1);
}

.config-controls {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  align-items: center;
}

.config-controls select {
  flex: 1;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
}

/* 日志 */
.logs-container {
  background: var(--card);
  border-radius: 12px;
  padding: 1rem;
  max-height: 600px;
  overflow-y: auto;
  box-shadow: var(--shadow);
}

.logs-content {
  font-family: 'Courier New', monospace;
  font-size: 0.85rem;
}

.log-entry {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 1rem;
  transition: background 0.2s;
}

.log-entry:last-child {
  border-bottom: none;
}

.log-entry:hover {
  background: var(--bg);
}

.log-time {
  color: var(--text-secondary);
  min-width: 150px;
}

.log-level {
  font-weight: 600;
  min-width: 60px;
}

.log-level.INFO {
  color: var(--success);
}

.log-level.WARN {
  color: var(--warning);
}

.log-level.ERROR {
  color: var(--danger);
}

.log-message {
  flex: 1;
}

/* 设置页面 */
.settings-container {
  max-width: 1000px;
}

.settings-section {
  margin-bottom: 2rem;
}

.section-header {
  margin-bottom: 1rem;
}

.section-header h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.section-description {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.settings-card {
  background: var(--card);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.database-info,
.system-stats,
.os-info {
  display: grid;
  gap: 1rem;
}

.info-item,
.stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.info-item:last-child,
.stat-item:last-child {
  border-bottom: none;
}

.info-label,
.stat-label {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.info-value,
.stat-value {
  font-weight: 500;
  color: var(--text);
}

.status-badge {
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 500;
}

.status-connected {
  background: rgba(52, 199, 89, 0.1);
  color: var(--success);
}

.database-password,
.database-convert {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.password-warning,
.convert-warning {
  background: #fff3cd;
  border: 1px solid var(--warning);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
  color: #856404;
  font-size: 0.9rem;
}

.password-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.password-form .form-group {
  margin-bottom: 0;
}

#password-result,
#convert-result {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 8px;
  display: none;
}

#password-result.success,
#convert-result.success {
  background: rgba(52, 199, 89, 0.1);
  border: 1px solid var(--success);
  color: var(--success);
  display: block;
}

#password-result.error,
#convert-result.error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid var(--danger);
  color: var(--danger);
  display: block;
}

.convert-form {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.convert-form select {
  flex: 1;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
}

/* 响应式 */
@media (max-width: 768px) {
  .admin-layout {
    flex-direction: column;
  }

  .admin-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .sidebar-nav {
    flex-direction: row;
    overflow-x: auto;
  }

  .nav-item {
    white-space: nowrap;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
}
