/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f0f2f5;
  --white: #fff;
  --text: #1a1a2e;
  --text2: #5a5f6e;
  --text3: #9ca0ab;
  --nav-bg: #0f1d3d;
  --nav-text: #fff;
  --sidebar-bg: #fff;
  --sidebar-hover: #f5f6f8;
  --sidebar-active: #eef1f7;
  --accent: #3b5998;
  --accent2: #4A90D9;
  --border: #e8eaed;
  --danger: #d94a5a;
  --success: #3c9a5f;
  --warning: #e8a020;
  --shadow: 0 2px 8px rgba(0,0,0,0.06);
  --radius: 8px;
}

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

a { text-decoration: none; color: var(--accent); }

/* ===== Login Page ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f1d3d 0%, #1a3a6a 100%);
}

.login-container { width: 100%; max-width: 420px; padding: 20px; }

.login-box {
  background: var(--white);
  border-radius: 16px;
  padding: 48px 36px 36px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.2);
  text-align: center;
}

.login-logo { font-size: 42px; font-weight: 700; color: #0f1d3d; margin-bottom: 4px; }
.login-sub { font-size: 14px; color: var(--text3); margin-bottom: 32px; }

.login-form { text-align: left; }

.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text2); margin-bottom: 6px; }

.form-group input,
.form-group select,
.form-input {
  width: 100%;
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text);
  background: var(--white);
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-input:focus { border-color: var(--accent2); }

.login-error { color: var(--danger); font-size: 13px; margin-bottom: 12px; min-height: 20px; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
}

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

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

.btn-primary:hover { background: #2f4a82; }

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

.btn-block { width: 100%; height: 46px; font-size: 15px; }

.btn-sm { height: 32px; padding: 0 12px; font-size: 12px; }

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

/* ===== Top Nav ===== */
.top-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 52px;
  background: var(--nav-bg);
  color: var(--nav-text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

.top-nav-left { display: flex; align-items: center; gap: 12px; }

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--nav-text);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
}

.sidebar-toggle:hover { background: rgba(255,255,255,0.1); }

.top-nav-brand { font-size: 20px; font-weight: 700; }
.top-nav-desc { font-size: 12px; opacity: 0.7; margin-right: 4px; }

.top-nav-right { display: flex; align-items: center; gap: 14px; }

.top-nav-user { font-size: 13px; opacity: 0.9; }

.top-nav-logout {
  color: var(--nav-text);
  font-size: 12px;
  opacity: 0.7;
  padding: 4px 10px;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 4px;
  transition: all 0.15s;
}

.top-nav-logout:hover { opacity: 1; background: rgba(255,255,255,0.1); }

/* ===== Dashboard Layout ===== */
.dashboard-wrap {
  display: flex;
  margin-top: 52px;
  min-height: calc(100vh - 52px);
}

/* ===== Sidebar ===== */
.sidebar {
  width: 220px;
  min-width: 220px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  padding: 16px 0;
  overflow-y: auto;
  transition: margin-right 0.25s, width 0.25s;
}

.sidebar.collapsed {
  width: 0;
  min-width: 0;
  overflow: hidden;
  padding: 0;
  border: none;
}

.sidebar-nav { display: flex; flex-direction: column; gap: 4px; padding: 0 10px; }

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
}

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

.sidebar-item.active { background: var(--sidebar-active); color: var(--accent); font-weight: 600; }

.sidebar-icon { font-size: 18px; }

/* ===== Main Content ===== */
.main-content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

.page-section { display: none; }
.page-section.active { display: block; }

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

.page-title { font-size: 22px; font-weight: 700; }
.page-subtitle { font-size: 18px; font-weight: 600; color: var(--text2); }

.page-stats { display: flex; gap: 10px; }

.stat-badge {
  padding: 5px 14px;
  background: var(--white);
  border-radius: 20px;
  font-size: 13px;
  color: var(--text2);
  border: 1px solid var(--border);
}

.stat-active { color: var(--success); border-color: var(--success); }

/* ===== Toolbar ===== */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar-left { display: flex; align-items: center; gap: 8px; }
.toolbar-right { display: flex; align-items: center; gap: 8px; }

.search-input {
  height: 32px;
  width: 220px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  outline: none;
}

.search-input:focus { border-color: var(--accent2); }

/* ===== Table ===== */
.table-wrap {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  background: #f8f9fb;
  padding: 12px 14px;
  text-align: left;
  font-weight: 600;
  color: var(--text2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #fafbfc; }

.th-check { width: 40px; text-align: center !important; }

.td-loading { text-align: center !important; color: var(--text3); padding: 40px 0 !important; }

.avatar-cell { width: 44px; }

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--border);
}

.user-avatar-placeholder {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--sidebar-active);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--text);
}

.user-avatar-default {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: #fff;
}

.status-tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.status-active { background: #e8f5ec; color: var(--success); }
.status-blocked { background: #fde8ec; color: var(--danger); }

.action-btns { display: flex; gap: 6px; }

.action-btn {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--white);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
}

.action-btn:hover { background: var(--sidebar-hover); }
.action-btn.danger:hover { color: var(--danger); border-color: var(--danger); }

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

.page-btn {
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--white);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.page-btn:hover { background: var(--sidebar-hover); }
.page-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  visibility: hidden;
  opacity: 0;
  transition: visibility 0s 0.25s, opacity 0.25s;
}

.modal-overlay.active {
  visibility: visible;
  opacity: 1;
  transition: visibility 0s, opacity 0.25s;
}

.modal-mask {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.45);
}

.modal-card {
  position: relative;
  width: 460px;
  max-width: 90vw;
  background: var(--white);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  z-index: 1;
}

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

.modal-title { font-size: 17px; font-weight: 600; }

.modal-close {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--text3);
  cursor: pointer;
  padding: 4px;
}

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

.modal-body { padding: 20px; max-height: 60vh; overflow-y: auto; }

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

/* ===== Stats Cards ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px;
  text-align: center;
}

.stat-num {
  display: block;
  font-size: 36px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 6px;
}

.stat-label {
  font-size: 13px;
  color: var(--text2);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .sidebar { width: 0; min-width: 0; overflow: hidden; padding: 0; border: none; }
  .sidebar.open { width: 200px; min-width: 200px; overflow: visible; padding: 16px 0; border-right: 1px solid var(--border); }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .page-header { flex-direction: column; align-items: flex-start; }
}

/* ===== Pay Settings ===== */
.pay-form-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 560px;
}

.cert-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--success);
  padding-top: 4px;
}

/* ===== Vocabulary Form Panel (inline, not modal) ===== */
.vocab-form-panel {
  margin-bottom: 20px;
}

.vocab-form-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.vocab-form-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: #f8f9fb;
  border-bottom: 1px solid var(--border);
}

.vocab-form-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.vocab-form-body {
  padding: 20px;
}

.vocab-form-body label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 4px;
}

/* Examples row */
.vocab-examples-row {
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
}

.vocab-examples-col {
  flex: 1;
  min-width: 0;
}

.example-hint {
  font-weight: 400;
  font-size: 11px;
  color: var(--text3);
  margin-left: 6px;
}

/* Example textarea */
.example-textarea {
  height: auto;
  resize: vertical;
  font-size: 13px;
  font-family: 'Segoe UI', system-ui, sans-serif;
  line-height: 1.8;
  white-space: pre-wrap;
}

/* Example translation textarea — Uyghur: RTL, Arabic-script font */
.example-trans-textarea {
  height: auto;
  resize: vertical;
  font-size: 15px;
  font-family: 'UKIJ Tuz', 'Scheherazade New', 'Noto Naskh Arabic', 'Arabic Typesetting', 'Traditional Arabic', serif;
  line-height: 2;
  direction: rtl;
  text-align: right;
  white-space: pre-wrap;
}

.vocab-form-footer {
  display: flex;
  align-items: center;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: #fafbfc;
  gap: 10px;
}

/* ===== File Drop Zone ===== */
.file-drop-zone {
  position: relative;
}

.file-drop-area {
  transition: border-color 0.2s, background-color 0.2s;
}

.file-drop-area:hover,
.file-drop-area.drag-over {
  border-color: var(--accent) !important;
  background: #f0f4ff;
}

/* ===== Import Result ===== */
.import-result-success {
  background: #e8f5ec;
  border: 1px solid #c3e6cb;
  color: #1a5c2a;
}

.import-result-partial {
  background: #fef3e0;
  border: 1px solid #fce4b8;
  color: #8a5d10;
}

.import-result-error {
  background: #fde8ec;
  border: 1px solid #f5c6cb;
  color: #8a1f2d;
}
