/* ─── Admin Panel ─────────────────────────────────────────────────── */

.admin {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg-primary);
  overflow: hidden;
}

.admin__header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.admin__title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.admin__badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #fff;
  background: var(--accent);
}
.admin__badge--root { background: #ef4444; }
.admin__badge--l1   { background: #7c3aed; }
.admin__badge--l2   { background: #2563eb; }
.admin__badge--l3   { background: #059669; }

.admin__body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ─── Timer bar ───────────────────────────────────────────────────── */

.admin-timer {
  position: relative;
  height: 28px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.admin-timer__fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: var(--accent);
  opacity: 0.15;
  transition: width 1s linear, background 0.5s;
}

.admin-timer__text {
  position: relative;
  z-index: 1;
  font-size: 11px;
  color: var(--text-secondary);
  padding: 0 12px;
  font-variant-numeric: tabular-nums;
}

/* ─── Tabs ────────────────────────────────────────────────────────── */

.admin-tabs {
  display: flex;
  gap: 2px;
  padding: 10px 12px 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-primary);
  flex-wrap: wrap;
}

.admin-tab {
  font-size: 13px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: 8px 8px 0 0;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.admin-tab:hover { background: var(--bg-hover); color: var(--text-primary); }
.admin-tab--active {
  background: var(--bg-secondary);
  color: var(--accent);
  border-bottom: 2px solid var(--accent);
}

.admin-tab-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ─── Section ─────────────────────────────────────────────────────── */

.admin-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.admin-section__title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ─── Stats ───────────────────────────────────────────────────────── */

.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}

.admin-stat-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.admin-stat-card__label {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
}

.admin-stat-card__value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

.admin-stat-card__value--online { color: #22c55e; }

/* ─── Permissions card ────────────────────────────────────────────── */

.admin-perms-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.admin-perm {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-primary);
}

.admin-perm__icon {
  width: 18px;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.admin-perm--yes .admin-perm__icon { color: #22c55e; }
.admin-perm--no  { opacity: 0.4; }
.admin-perm--no .admin-perm__icon { color: #ef4444; }

/* ─── Users toolbar ───────────────────────────────────────────────── */

.admin-users-toolbar {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-search {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}

.admin-search:focus { border-color: var(--accent); }

.admin-sort-btns {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.admin-sort-btn {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.admin-sort-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.admin-sort-btn--active { border-color: var(--accent); color: var(--accent); background: rgba(var(--accent-rgb, 139, 92, 246), 0.08); }

.admin-users-count {
  font-size: 12px;
  color: var(--text-secondary);
  padding: 0 2px;
}

/* ─── User rows ───────────────────────────────────────────────────── */

.admin-users {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.admin-user-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  transition: border-color 0.15s;
}

.admin-user-row:hover { border-color: var(--accent); }

.admin-user-row__avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  background-size: cover;
  background-position: center;
}

.admin-user-row__info {
  flex: 1;
  min-width: 0;
}

.admin-user-row__name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-user-row__meta {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-user-row__tags {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

/* Tags */
.admin-tag {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 20px;
  letter-spacing: 0.03em;
}

.admin-tag--hardcoded  { background: rgba(239,68,68,0.15); color: #ef4444; }
.admin-tag--l1         { background: rgba(124,58,237,0.15); color: #7c3aed; }
.admin-tag--l2         { background: rgba(37,99,235,0.15); color: #2563eb; }
.admin-tag--l3         { background: rgba(5,150,105,0.15); color: #059669; }
.admin-tag--online     { background: rgba(34,197,94,0.15); color: #22c55e; }
.admin-tag--protected  { background: rgba(245,158,11,0.15); color: #f59e0b; }

/* Actions */
.admin-user-row__actions {
  display: flex;
  gap: 5px;
  flex-shrink: 0;
}

/* ─── Buttons ─────────────────────────────────────────────────────── */

.admin-btn {
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.admin-btn:hover    { background: var(--bg-hover); }
.admin-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.admin-btn--promote {
  border-color: var(--accent);
  color: var(--accent);
}
.admin-btn--promote:hover { background: rgba(var(--accent-rgb, 139, 92, 246), 0.12); }

.admin-btn--demote {
  border-color: #f59e0b;
  color: #f59e0b;
}
.admin-btn--demote:hover { background: rgba(245,158,11,0.1); }

.admin-btn--delete {
  border-color: #ef4444;
  color: #ef4444;
}
.admin-btn--delete:hover { background: rgba(239,68,68,0.1); }

.admin-btn--edit {
  border-color: #3b82f6;
  color: #3b82f6;
}
.admin-btn--edit:hover { background: rgba(59,130,246,0.1); }

.admin-btn--passwd {
  border-color: #8b5cf6;
  color: #8b5cf6;
}
.admin-btn--passwd:hover { background: rgba(139,92,246,0.1); }

.admin-btn--confirming {
  border-color: #ef4444 !important;
  color: #ef4444 !important;
  animation: confirmPulse 0.8s ease infinite;
}

@keyframes confirmPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.6; }
}

/* ─── Password gate ───────────────────────────────────────────────── */

.admin-gate {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 32px 20px;
  max-width: 360px;
  margin: 0 auto;
}

.admin-gate__icon { font-size: 48px; }

.admin-gate__title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  text-align: center;
}

.admin-gate__hint {
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
  margin: 0;
}

.admin-gate__fields {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.admin-gate__field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.admin-gate__field label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.admin-gate__field input {
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
  box-sizing: border-box;
}

.admin-gate__field input:focus { border-color: var(--accent); }

.admin-gate__btn {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.admin-gate__btn:hover   { opacity: 0.88; }
.admin-gate__btn:disabled { opacity: 0.5; cursor: not-allowed; }

.admin-gate__error {
  font-size: 13px;
  color: #ef4444;
  text-align: center;
  min-height: 18px;
}

/* ─── Password form (own password tab) ───────────────────────────── */

.admin-pass-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 380px;
}

.admin-pass-form__field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.admin-pass-form__field label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.admin-pass-form__field input {
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

.admin-pass-form__field input:focus { border-color: var(--accent); }

.admin-pass-form__error {
  font-size: 13px;
  color: #ef4444;
  min-height: 18px;
}

/* ─── Modal ───────────────────────────────────────────────────────── */

.admin-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.admin-modal {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.admin-modal__title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.admin-modal__hint {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
}

.admin-modal__field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.admin-modal__field label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.admin-modal__field input,
.admin-modal__field textarea {
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  resize: vertical;
  font-family: inherit;
  transition: border-color 0.15s;
}

.admin-modal__field input:focus,
.admin-modal__field textarea:focus { border-color: var(--accent); }

.admin-modal__actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.admin-modal__error {
  font-size: 13px;
  color: #ef4444;
  min-height: 18px;
}

/* ─── Stub ────────────────────────────────────────────────────────── */

.admin-stub {
  background: var(--bg-secondary);
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 32px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
}

.admin-stub__icon { font-size: 32px; margin-bottom: 10px; }

.admin-stub__title {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

/* ─── Loading ─────────────────────────────────────────────────────── */

.admin-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-secondary);
  gap: 10px;
}
