/* app.css - 用户管理 UI 样式(阶段 2.5)
   设计:干净、紧凑、无外部依赖。
   跟 css/styles.css(附件 demo)互不影响 */

/* ============== Reset & Base ============== */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
               'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: #0f172a;
  background: #f8fafc;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--color-primary-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font-family: inherit; font-size: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: inherit; }

code {
  font-family: 'SF Mono', Consolas, 'Liberation Mono', monospace;
  font-size: 0.9em;
  background: #f1f5f9;
  padding: 0.1em 0.4em;
  border-radius: 3px;
}

/* ============== Top Bar ============== */

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.topbar-brand {
  font-weight: 600;
  font-size: 16px;
  color: #0f172a;
}

.topbar-nav {
  display: flex;
  gap: 4px;
  margin-left: 12px;
}

.topbar-nav a {
  padding: 6px 12px;
  border-radius: 4px;
  color: #475569;
  font-weight: 500;
}
.topbar-nav a:hover { background: #f1f5f9; text-decoration: none; }
.topbar-nav a.active { background: var(--color-primary-soft); color: var(--color-primary-dark); }

.topbar-spacer { flex: 1; }

.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #475569;
  font-size: 13px;
}
.topbar-user-name { font-weight: 500; color: #0f172a; }
.topbar-user-role { color: #64748b; font-size: 12px; }

/* ============== Container ============== */

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

.page-title {
  margin: 0 0 4px 0;
  font-size: 20px;
  font-weight: 600;
}
.page-subtitle {
  margin: 0 0 20px 0;
  color: #64748b;
  font-size: 13px;
}

/* ============== Card ============== */

.card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
}
.card-title { font-weight: 600; font-size: 14px; }
.card-body { padding: 20px; }

/* ============== Login Page ============== */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
}

.login-card {
  width: 100%;
  max-width: 380px;
  margin: 20px;
  padding: 32px;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
}

.login-card h1 {
  margin: 0 0 4px 0;
  font-size: 20px;
  font-weight: 600;
  text-align: center;
}
.login-card .subtitle {
  margin: 0 0 24px 0;
  text-align: center;
  color: #64748b;
  font-size: 13px;
}

.login-card form { display: flex; flex-direction: column; gap: 14px; }
.login-card .field { display: flex; flex-direction: column; gap: 4px; }
.login-card .field label { font-size: 12px; color: #475569; font-weight: 500; }

.login-error {
  padding: 8px 12px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  border-radius: 4px;
  font-size: 13px;
}

/* ============== Buttons ============== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  background: #ffffff;
  color: #334155;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  transition: background-color 0.1s, border-color 0.1s;
}
.btn:hover { background: #f8fafc; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
  color: #ffffff;
}
.btn-primary:hover { background: var(--color-primary-dark); }

.btn-danger {
  background: #ffffff;
  border-color: #fca5a5;
  color: #b91c1c;
}
.btn-danger:hover { background: #fef2f2; }

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--color-primary-dark);
}
.btn-ghost:hover { background: var(--color-primary-soft); }

.btn-sm { padding: 4px 8px; font-size: 12px; }

.btn-block { width: 100%; }

/* ============== Forms ============== */

.form-group { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.form-group label { font-size: 12px; color: #475569; font-weight: 500; }
.form-group .hint { font-size: 11px; color: #94a3b8; }

.input, .select {
  padding: 7px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  background: #ffffff;
  font-size: 14px;
  color: #0f172a;
  transition: border-color 0.1s, box-shadow 0.1s;
}
.input:focus, .select:focus {
  outline: none;
  border-color: var(--color-primary-dark);
  box-shadow: 0 0 0 3px rgba(6, 71, 41, 0.1);
}
.input:disabled { background: #f1f5f9; color: #64748b; }

.form-row { display: flex; gap: 12px; }
.form-row > * { flex: 1; }

/* ============== Table ============== */

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table th, .table td {
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid #e2e8f0;
}

.table th {
  font-weight: 600;
  color: #475569;
  background: #f8fafc;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.table tbody tr:hover { background: #f8fafc; }
.table tbody tr.inactive { opacity: 0.55; }

.table .col-actions { text-align: right; white-space: nowrap; }
.table .col-actions .btn { margin-left: 4px; }

.table-empty {
  padding: 40px 20px;
  text-align: center;
  color: #94a3b8;
}

/* ============== Badges ============== */

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.6;
}

.badge-admin { background: #fef3c7; color: #92400e; }
.badge-collaborator { background: var(--color-primary-light); color: var(--color-primary-dark); }
.badge-viewer { background: #f1f5f9; color: #475569; }

.badge-active { background: #d1fae5; color: #065f46; }
.badge-inactive { background: #fee2e2; color: #991b1b; }

.badge-wildcard { background: #ede9fe; color: #5b21b6; }
.badge-view { background: #f1f5f9; color: #475569; }
.badge-edit { background: var(--color-primary-light); color: var(--color-primary-dark); }

/* ============== Toolbar ============== */

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}
.toolbar .search { flex: 1; max-width: 280px; }
.toolbar .spacer { flex: 1; }

/* ============== Modal ============== */

.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 100;
  align-items: flex-start;
  justify-content: center;
  padding-top: 60px;
}
.modal.active { display: flex; }
.modal-box {
  width: 100%;
  max-width: 480px;
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  overflow: hidden;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid #e2e8f0;
  font-weight: 600;
}
.modal-close {
  background: transparent;
  border: 0;
  font-size: 20px;
  color: #64748b;
  padding: 0 4px;
  cursor: pointer;
}
.modal-body { padding: 20px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
}

/* ============== Toasts ============== */

.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 10px 16px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  font-size: 13px;
  min-width: 200px;
  pointer-events: auto;
  animation: toast-in 0.2s ease-out;
}
.toast-success { border-left: 3px solid #10b981; }
.toast-error { border-left: 3px solid #ef4444; }
.toast-info { border-left: 3px solid var(--color-primary); }

@keyframes toast-in {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ============== Empty / Notice ============== */

.notice {
  padding: 12px 16px;
  background: var(--color-primary-soft);
  border: 1px solid var(--color-primary-soft);
  color: var(--color-primary-dark);
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 16px;
}

.notice-warning {
  background: #fef3c7;
  border-color: #fde68a;
  color: #92400e;
}

/* ============== Helpers ============== */

.muted { color: #94a3b8; }
.text-right { text-align: right; }
.flex-row { display: flex; align-items: center; gap: 8px; }
.flex-col { display: flex; flex-direction: column; gap: 8px; }
.flex-spacer { flex: 1; }
.no-wrap { white-space: nowrap; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }

/* ============== Loading ============== */

.loading {
  padding: 40px;
  text-align: center;
  color: #94a3b8;
}
.loading::before {
  content: '';
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid #cbd5e1;
  border-top-color: var(--color-primary-dark);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============== Login Brand (4 个登录页标题旁的 logo + v2.0 标签) ============== */

.login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--color-border-soft);
}

.login-brand img {
  height: 28px;
  width: auto;
}

.login-brand-text {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text-strong);
  letter-spacing: 0.2px;
}
